Skip to content

Commit

Permalink
include wabt.lib in cargo build
Browse files Browse the repository at this point in the history
  • Loading branch information
xmclark committed Dec 16, 2018
1 parent 16603d0 commit 63dc072
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
20 changes: 20 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
os: Visual Studio 2017

environment:
matrix:
- channel: stable
target: x86_64-pc-windows-msvc

install:
- appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
- rustup-init -yv --default-toolchain %channel% --default-host %target%
- set PATH=%PATH%;%USERPROFILE%\.cargo\bin
- rustc -vV
- cargo -vV
- git submodule update --init --recursive

build: false

test_script: |
cargo build --verbose --all
cargo test --verbose --all
3 changes: 3 additions & 0 deletions wabt-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ keywords = ["tools", "webassembly", "wasm"]
[build-dependencies]
cmake = "0.1.32"
cc = "1.0.4"

[target.'cfg(windows)'.build-dependencies]
glob = "0.2.11"
27 changes: 23 additions & 4 deletions wabt-sys/build.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,46 @@
extern crate cmake;
extern crate cc;
extern crate cmake;
#[cfg(windows)]
extern crate glob;

use std::env;

fn main() {
let dst = cmake::Config::new("wabt")
// Turn off building tests and tools. This not only speeds up the build but
// also prevents building executables that for some reason are put
// also prevents building executables that for some reason are put
// into the `wabt` directory which now is deemed as an error.
//
// Since that is all targets available, also don't specify target
// Since that is all targets available, also don't specify target
// (by default it is set to `--target install`).
// Otherwise, there will be an error message "No rule to make target `install'".
.define("BUILD_TESTS", "OFF")
.define("BUILD_TOOLS", "OFF")
.no_build_target(true)
.build();

let mut out_build_dir = dst;
out_build_dir.push("build");

println!("cargo:rustc-link-search=native={}", out_build_dir.display());

// help cargo find wabt.lib when targeting windows
#[cfg(windows)] {
let pattern = format!("{}/*/wabt.lib", out_build_dir.display());
for entry in glob::glob(&pattern).unwrap() {
if let Ok(path) = entry {
let out_lib_dir = path.parent().unwrap().to_path_buf();
println!(
"cargo:rustc-link-search=native={}",
out_lib_dir.display(),
);
break;
}
}
}

println!("cargo:rustc-link-lib=static=wabt");

// We need to link against C++ std lib
if let Some(cpp_stdlib) = get_cpp_stdlib() {
println!("cargo:rustc-link-lib={}", cpp_stdlib);
Expand Down

0 comments on commit 63dc072

Please sign in to comment.