Skip to content

Commit

Permalink
Refactor Cargo.toml and build.rs to enable/disable hardware bound che…
Browse files Browse the repository at this point in the history
…ck feature (#70)
  • Loading branch information
lum1n0us authored Sep 24, 2024
1 parent 9e6d207 commit bf7cf01
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ component_dirs = ["./crates/wamr-sys/wasm-micro-runtime/build-scripts/esp-idf"]
[features]
custom-section = ["wamr-sys/custom-section"]
dump-call-stack = ["wamr-sys/dump-call-stack"]
esp-idf = ["esp-idf-sys", "wamr-sys/esp-idf"]
hw-bound-check = ["wamr-sys/hw-bound-check"]
llvmjit = ["wamr-sys/llvmjit"]
multi-module = ["wamr-sys/multi-module"]
name-section = ["wamr-sys/name-section"]
esp-idf = ["esp-idf-sys", "wamr-sys/esp-idf"]
3 changes: 2 additions & 1 deletion crates/wamr-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ cmake = "0.1"
[features]
custom-section = []
dump-call-stack = []
esp-idf = []
hw-bound-check = []
llvmjit = []
multi-module = []
name-section = [ "custom-section" ]
std = []
esp-idf = []
13 changes: 10 additions & 3 deletions crates/wamr-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn check_is_espidf() -> bool {
is_espidf
}

fn get_feature_flags() -> (String, String, String, String, String) {
fn get_feature_flags() -> (String, String, String, String, String, String) {
let enable_custom_section = if cfg!(feature = "custom-section") {
"1"
} else {
Expand All @@ -69,13 +69,19 @@ fn get_feature_flags() -> (String, String, String, String, String) {
} else {
"0"
};
let disable_hw_bound_check = if cfg!(feature = "hw-bound-check") {
"0"
} else {
"1"
};

(
enable_custom_section.to_string(),
enable_dump_call_stack.to_string(),
enable_llvm_jit.to_string(),
enable_multi_module.to_string(),
enable_name_section.to_string(),
disable_hw_bound_check.to_string(),
)
}

Expand Down Expand Up @@ -105,14 +111,15 @@ fn link_llvm_libraries(llvm_cfg_path: &String, enable_llvm_jit: &String) {

fn setup_config(
wamr_root: &PathBuf,
feature_flags: (String, String, String, String, String),
feature_flags: (String, String, String, String, String, String),
) -> Config {
let (
enable_custom_section,
enable_dump_call_stack,
enable_llvm_jit,
enable_multi_module,
enable_name_section,
disalbe_hw_bound_check,
) = feature_flags;

let mut cfg = Config::new(wamr_root);
Expand All @@ -125,7 +132,7 @@ fn setup_config(
.define("WAMR_BUILD_SIMD", "1")
.define("WAMR_BUILD_LIBC_WASI", "1")
.define("WAMR_BUILD_LIBC_BUILTIN", "0")
.define("WAMR_DISABLE_HW_BOUND_CHECK", "1")
.define("WAMR_DISABLE_HW_BOUND_CHECK", &disalbe_hw_bound_check)
.define("WAMR_BUILD_MULTI_MODULE", &enable_multi_module)
.define("WAMR_BUILD_DUMP_CALL_STACK", &enable_dump_call_stack)
.define("WAMR_BUILD_CUSTOM_NAME_SECTION", &enable_name_section)
Expand Down

0 comments on commit bf7cf01

Please sign in to comment.