Skip to content

Commit

Permalink
Fix sysroot flag not passed to C build (#21)
Browse files Browse the repository at this point in the history
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
  • Loading branch information
jiayihu and Veykril authored Oct 19, 2020
1 parent c8355b8 commit f064cbb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
3 changes: 2 additions & 1 deletion wasm3-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ cty = "0.2"

[build-dependencies]
cc = "1"
shlex = "0.1.1"

[build-dependencies.bindgen]
version = "0.54"
optional = true

[package.metadata.docs.rs]
all-features = true
all-features = true
23 changes: 19 additions & 4 deletions wasm3-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,24 +125,39 @@ fn gen_bindings() {

fn main() {
gen_bindings();
// build

let mut cfg = cc::Build::new();

cfg.files(
fs::read_dir(WASM3_SOURCE)
.unwrap_or_else(|_| panic!("failed to read {} directory", WASM3_SOURCE))
.filter_map(Result::ok)
.map(|entry| entry.path())
.filter(|p| p.extension().and_then(OsStr::to_str) == Some("c")),
);
let cfg = cfg
.warnings(false)
.cpp(false)

cfg.cpp(false)
.define("d_m3LogOutput", Some("0"))
.warnings(false)
.extra_warnings(false)
.include(WASM3_SOURCE);

// Add any extra arguments from the environment to the CC command line.
if let Ok(extra_clang_args) = std::env::var("BINDGEN_EXTRA_CLANG_ARGS") {
// Try to parse it with shell quoting. If we fail, make it one single big argument.
if let Some(strings) = shlex::split(&extra_clang_args) {
strings.iter().for_each(|string| {
cfg.flag(string);
})
} else {
cfg.flag(&extra_clang_args);
};
}

if cfg!(feature = "wasi") {
cfg.define("d_m3HasWASI", None);
}

cfg.define(
"d_m3Use32BitSlots",
if cfg!(feature = "use-32bit-slots") {
Expand Down

0 comments on commit f064cbb

Please sign in to comment.