Skip to content

Commit e2eeef0

Browse files
committed
Checking in bindgen generated file; do not run bindgen if file exists
1 parent 102ef81 commit e2eeef0

File tree

3 files changed

+1849
-42
lines changed

3 files changed

+1849
-42
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ MMTK_MOVING ?= 1
33
MMTK_PLAN ?= Immix
44
CURR_PATH := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
55

6+
# Disable some variables set inside Julia
7+
# that may interfere with building the binding
8+
PKG_CONFIG_LIBDIR=
9+
PKG_CONFIG_PATH=
10+
611
# If the Julia directory doesn't exist throw an error
712
# since we need it to generate the bindgen bindings
813
ifeq (${JULIA_PATH},)
@@ -50,7 +55,6 @@ julia-debug:
5055
# Clean up the build artifacts
5156
clean:
5257
@echo "Cleaning up build artifacts in $(JULIA_PATH) and $(MMTK_JULIA_DIR)";
53-
@cd $(JULIA_PATH) && make clean
5458
@cd $(MMTK_JULIA_DIR)mmtk && cargo clean
5559

5660
.PHONY: release debug julia julia-debug clean

mmtk/build.rs

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)