-
Notifications
You must be signed in to change notification settings - Fork 11
/
build.rs
120 lines (104 loc) · 4.3 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
use std::collections::HashMap;
use std::env;
fn main() {
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
cbindgen::Builder::new()
.with_config({
let mut config = cbindgen::Config::default();
config.language = cbindgen::Language::C;
config.braces = cbindgen::Braces::SameLine;
config.cpp_compat = true;
config.style = cbindgen::Style::Both;
config.layout = cbindgen::LayoutConfig { ..Default::default() };
config.enumeration = cbindgen::EnumConfig {
derive_helper_methods: true,
// prefix_with_name: true,
..Default::default()
};
config.export = cbindgen::ExportConfig {
mangle: cbindgen::MangleConfig { remove_underscores: true, ..Default::default() },
..Default::default()
};
config.defines = HashMap::new();
// config.defines.insert("target_arch = wasm32".to_string(),
// "TARGET_WASM32".to_string());
config.defines.insert(
"target_pointer_width = 32".to_string(),
"TARGET_POINTER_WIDTH_32".to_string(),
);
config
})
.with_crate(crate_dir.clone())
.generate()
.expect("Unable to generate bindings")
.write_to_file("dojo.h");
cbindgen::Builder::new()
.with_config({
let mut config = cbindgen::Config::default();
config.language = cbindgen::Language::Cxx;
config.braces = cbindgen::Braces::SameLine;
config.style = cbindgen::Style::Both;
config.layout = cbindgen::LayoutConfig { ..Default::default() };
config.enumeration = cbindgen::EnumConfig {
derive_helper_methods: true,
// prefix_with_name: true,
..Default::default()
};
config.export = cbindgen::ExportConfig {
mangle: cbindgen::MangleConfig { remove_underscores: true, ..Default::default() },
..Default::default()
};
// config.structure.derive_constructor = true;
// config.structure.derive_eq = true;
config.namespace = Some("dojo_bindings".to_string());
config.defines = HashMap::new();
config.defines.insert(
"target_pointer_width = 32".to_string(),
"TARGET_POINTER_WIDTH_32".to_string(),
);
config
})
.with_crate(crate_dir.clone())
.generate()
.expect("Unable to generate bindings")
.write_to_file("dojo.hpp");
cbindgen::Builder::new()
.with_config({
let mut config = cbindgen::Config::default();
config.language = cbindgen::Language::Cython;
config.braces = cbindgen::Braces::SameLine;
config.style = cbindgen::Style::Both;
config.layout = cbindgen::LayoutConfig { ..Default::default() };
config.enumeration = cbindgen::EnumConfig {
derive_helper_methods: true,
// prefix_with_name: true,
..Default::default()
};
config.export = cbindgen::ExportConfig {
mangle: cbindgen::MangleConfig { remove_underscores: true, ..Default::default() },
..Default::default()
};
// config.structure.derive_constructor = true;
// config.structure.derive_eq = true;
config.namespace = Some("dojo_bindings".to_string());
config.defines = HashMap::new();
config.defines.insert(
"target_pointer_width = 32".to_string(),
"TARGET_POINTER_WIDTH_32".to_string(),
);
config
})
.with_crate(crate_dir.clone())
.generate()
.expect("Unable to generate bindings")
.write_to_file("dojo.pyx");
// NOTE: disable for now. use c2cs to generate csharp bindings
// generics not supported
// csbindgen::Builder::default()
// .input_extern_file("src/lib.rs")
// .input_extern_file("src/types.rs")
// .csharp_dll_name("libtorii_c.dylib")
// .csharp_namespace("Dojo")
// .generate_csharp_file("./Dojo.g.cs")
// .unwrap();
}