-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.onyx
48 lines (38 loc) · 960 Bytes
/
build.onyx
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
#load "./module"
use core {package, *}
use cbindgen {*}
use opengles
main :: () {
path := module_path(#file);
c_file_path := string.concat(path, "opengles.c");
result := generate_c_binding(.{
output_file = c_file_path,
foreign_block = opengles.foreign_block,
cast_map = .[],
name_map = ((name) => aprintf("glad_{}", name)),
preamble = .[
"""
#define GLAD_GLES2_IMPLEMENTATION
#include "glad.h"
"""
],
custom_implementations = .[
.{ "glInit",
"""
ONYX_DEF(glInit, (LONG), ()) {
GLADloadfunc load_sym = (GLADloadfunc) params->data[0].of.i64;
gladLoadGLES2(load_sym);
return NULL;
}
"""}
],
});
if !result {
os.exit(1);
}
result = compile_c_file(c_file_path, string.concat(path, "onyx_opengles"), flags="-Wno-int-conversion");
if !result {
os.exit(1);
}
os.remove_file(c_file_path);
}