@@ -44,48 +44,50 @@ fn main() {
4444 . expect ( "failed to execute process" ) ;
4545 }
4646
47- let bindings = bindgen:: Builder :: default ( )
48- . header ( format ! ( "{}/src/julia.h" , julia_dir) )
49- . header ( format ! ( "{}/src/julia_internal.h" , julia_dir) )
50- // Including the paths to depending .h files
51- . clang_arg ( "-I" )
52- . clang_arg ( format ! ( "{}/mmtk/api" , mmtk_dir) )
53- . clang_arg ( "-I" )
54- . clang_arg ( format ! ( "{}/src" , julia_dir) )
55- . clang_arg ( "-I" )
56- . clang_arg ( format ! ( "{}/src/support" , julia_dir) )
57- . clang_arg ( "-I" )
58- . clang_arg ( format ! ( "{}/usr/include" , buildroot_dir) )
59- // all types that we generate bindings from
60- . allowlist_item ( "jl_datatype_layout_t" )
61- . allowlist_item ( "jl_ucontext_t" )
62- . allowlist_item ( "jl_small_typeof_tags" )
63- . allowlist_item ( "jl_*_tag" )
64- . allowlist_item ( "jl_svec_t" )
65- . allowlist_item ( "jl_module_t" )
66- . allowlist_item ( "jl_task_t" )
67- . allowlist_item ( "jl_datatype_t" )
68- . allowlist_item ( "jl_weakref_t" )
69- . allowlist_item ( "jl_binding_partition_t" )
70- . allowlist_item ( "jl_bt_element_t" )
71- . allowlist_item ( "jl_taggedvalue_t" )
72- . allowlist_item ( "MMTkMutatorContext" )
73- // --opaque-type MMTkMutatorContext
74- . opaque_type ( "MMTkMutatorContext" )
75- // compile using c++
76- . clang_arg ( "-x" )
77- . clang_arg ( "c++" )
78- . clang_arg ( "-std=c++14" )
79- // using MMTK types
80- . clang_arg ( "-DMMTK_GC" )
81- // Finish the builder and generate the bindings.
82- . generate ( )
83- // Unwrap the Result and panic on failure.
84- . expect ( "Unable to generate bindings" ) ;
47+ if !Path :: new ( format ! ( "{}/mmtk/src/julia_types.rs" , mmtk_dir) . as_str ( ) ) . exists ( ) {
48+ let bindings = bindgen:: Builder :: default ( )
49+ . header ( format ! ( "{}/src/julia.h" , julia_dir) )
50+ . header ( format ! ( "{}/src/julia_internal.h" , julia_dir) )
51+ // Including the paths to depending .h files
52+ . clang_arg ( "-I" )
53+ . clang_arg ( format ! ( "{}/mmtk/api" , mmtk_dir) )
54+ . clang_arg ( "-I" )
55+ . clang_arg ( format ! ( "{}/src" , julia_dir) )
56+ . clang_arg ( "-I" )
57+ . clang_arg ( format ! ( "{}/src/support" , julia_dir) )
58+ . clang_arg ( "-I" )
59+ . clang_arg ( format ! ( "{}/usr/include" , buildroot_dir) )
60+ // all types that we generate bindings from
61+ . allowlist_item ( "jl_datatype_layout_t" )
62+ . allowlist_item ( "jl_ucontext_t" )
63+ . allowlist_item ( "jl_small_typeof_tags" )
64+ . allowlist_item ( "jl_*_tag" )
65+ . allowlist_item ( "jl_svec_t" )
66+ . allowlist_item ( "jl_module_t" )
67+ . allowlist_item ( "jl_task_t" )
68+ . allowlist_item ( "jl_datatype_t" )
69+ . allowlist_item ( "jl_weakref_t" )
70+ . allowlist_item ( "jl_binding_partition_t" )
71+ . allowlist_item ( "jl_bt_element_t" )
72+ . allowlist_item ( "jl_taggedvalue_t" )
73+ . allowlist_item ( "MMTkMutatorContext" )
74+ // --opaque-type MMTkMutatorContext
75+ . opaque_type ( "MMTkMutatorContext" )
76+ // compile using c++
77+ . clang_arg ( "-x" )
78+ . clang_arg ( "c++" )
79+ . clang_arg ( "-std=c++14" )
80+ // using MMTK types
81+ . clang_arg ( "-DMMTK_GC" )
82+ // Finish the builder and generate the bindings.
83+ . generate ( )
84+ // Unwrap the Result and panic on failure.
85+ . expect ( "Unable to generate bindings" ) ;
8586
86- bindings
87- . write_to_file ( "src/julia_types.rs" )
88- . expect ( "Couldn't write bindings!" ) ;
87+ bindings
88+ . write_to_file ( "src/julia_types.rs" )
89+ . expect ( "Couldn't write bindings!" ) ;
90+ }
8991
9092 built:: write_built_file ( ) . expect ( "Failed to acquire build-time information" ) ;
9193}
0 commit comments