-
Notifications
You must be signed in to change notification settings - Fork 2
/
rebindgen.nu
70 lines (60 loc) · 2.78 KB
/
rebindgen.nu
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
let fmod_engine = registry query 'Software\FMOD Studio API Windows' | get value
let bindgen_ver = ^bindgen --version | str trim
def do-bindgen --wrapped [--disable-header-comment ...args] {
let header = if $disable_header_comment { [] } else { [
--raw-line $"/* automatically @generated by rust-($bindgen_ver) */"
--raw-line "/* Copyright (c), Firelight Technologies Pty, Ltd. 2004-2024. */"
]}
let flags = [
--no-layout-tests
--no-recursive-allowlist
--ctypes-prefix ::std::ffi
--no-convert-floats
--no-prepend-enum-name
--disable-header-comment
--sort-semantically
--merge-extern-blocks
]
do -c { bindgen ...$flags ...$header ...$args }
| str replace --all 'extern "C"' 'extern "system"'
| str replace --all --regex '(?s)extern "system" (fn\([^)]*\.\.\.[^)]*\))' 'extern "C" $1'
| str replace --all 'type_' 'r#type'
| str replace --all '__bindgen_anon_1' 'payload'
| str replace --all '__bindgen_ty_1' '_PAYLOAD'
}
do -c {||
cd crates/fmod-core-sys/inc
cp ($fmod_engine | path join api/core/inc/*.h) .
cp ($fmod_engine | path join '../FMOD Studio API Android/api/core/inc/fmod_android.h') .
cp ($fmod_engine | path join '../FMOD Studio API iOS/api/core/inc/fmod_iOS.h') .
cp ($fmod_engine | path join '../FMOD Studio API Universal Windows Platform/api/core/inc/fmod_uwp.h') .
do-bindgen fmod.h | save --force bindings.rs
do-bindgen --disable-header-comment fmod_android.h | save --append bindings.rs
do-bindgen --disable-header-comment fmod_ios.h | save --append bindings.rs
do-bindgen --disable-header-comment fmod_uwp.h | save --append bindings.rs
}
do -c {||
cd crates/fmod-studio-sys/inc
cp ($fmod_engine | path join api/studio/inc/*.h) .
let studio_fixup = [
# blocklist fmod-core-sys items
--allowlist-file 'fmod_studio.h'
--allowlist-file 'fmod_studio_common.h'
--allowlist-item 'FMOD_STUDIO_.*' # this shouldn't be needed but is?
# in a union, so needs to be allowlisted
--allowlist-type FMOD_BOOL
# re-add derives skipped due to blocklisting
--with-derive-custom 'FMOD_STUDIO_BANK_INFO=Debug,Copy,Clone'
--with-derive-custom 'FMOD_STUDIO_PARAMETER_DESCRIPTION=Debug,Copy,Clone'
--with-derive-custom 'FMOD_STUDIO_TIMELINE_NESTED_BEAT_PROPERTIES=Debug,Copy,Clone'
--with-derive-custom 'FMOD_STUDIO_SOUND_INFO=Debug,Copy,Clone'
]
do-bindgen fmod_studio.h ...$studio_fixup
| str replace --all --regex --multiline '^.*type FMOD_BOOL.*$\n' ''
| save --force bindings.rs
}
do -c {||
cd crates/fmod-fsbank-sys/inc
cp ($fmod_engine | path join api/fsbank/inc/*.h) .
do-bindgen fsbank.h | save --force bindings.rs
}