-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbuild.rs
121 lines (110 loc) · 4.19 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
121
use std::env;
fn main() {
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
cbindgen::Builder::new()
.with_config({
let mut config = cbindgen::Config {
language: cbindgen::Language::C,
braces: cbindgen::Braces::SameLine,
cpp_compat: true,
style: cbindgen::Style::Both,
layout: cbindgen::LayoutConfig { ..Default::default() },
enumeration: cbindgen::EnumConfig {
derive_helper_methods: true,
// prefix_with_name: true,
..Default::default()
},
export: cbindgen::ExportConfig {
mangle: cbindgen::MangleConfig {
remove_underscores: true,
..Default::default()
},
..Default::default()
},
namespace: Some("dojo_bindings".to_string()),
..Default::default()
};
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 {
language: cbindgen::Language::Cxx,
braces: cbindgen::Braces::SameLine,
style: cbindgen::Style::Both,
layout: cbindgen::LayoutConfig { ..Default::default() },
enumeration: cbindgen::EnumConfig {
derive_helper_methods: true,
// prefix_with_name: true,
..Default::default()
},
export: cbindgen::ExportConfig {
mangle: cbindgen::MangleConfig {
remove_underscores: true,
..Default::default()
},
..Default::default()
},
namespace: Some("dojo_bindings".to_string()),
..Default::default()
};
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 {
language: cbindgen::Language::Cython,
braces: cbindgen::Braces::SameLine,
style: cbindgen::Style::Both,
layout: cbindgen::LayoutConfig { ..Default::default() },
enumeration: cbindgen::EnumConfig {
derive_helper_methods: true,
// prefix_with_name: true,
..Default::default()
},
export: cbindgen::ExportConfig {
mangle: cbindgen::MangleConfig {
remove_underscores: true,
..Default::default()
},
..Default::default()
},
namespace: Some("dojo_bindings".to_string()),
..Default::default()
};
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();
}