Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an environment variable EMSCRIPTEN_ROOT for emscripten installed with brew and add supports for other wasm targets. #276

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
163f80c
Add basic support for vcpkg.
TheVeryDarkness Oct 13, 2023
0df54a2
Improve support for wasm32.
TheVeryDarkness Oct 13, 2023
0b30251
Fix a warning.
TheVeryDarkness Oct 13, 2023
651f28c
Make clippy happy
TheVeryDarkness Oct 13, 2023
c284d15
Merge remote-tracking branch 'upstream/master' into add-vcpkg
TheVeryDarkness Oct 18, 2023
2d8d63f
Refactor the process.
TheVeryDarkness Oct 18, 2023
02de1e7
Added a ci test for vcpkg-installed z3
TheVeryDarkness Oct 18, 2023
7716650
Fix mistakes in ci
TheVeryDarkness Oct 18, 2023
e4bcbdc
Merge remote-tracking branch 'upstream' into add-vcpkg
TheVeryDarkness Oct 18, 2023
ed6b65b
Rename build_z3 to build_bundled_z3
TheVeryDarkness Oct 18, 2023
728b962
Revert "Improve support for wasm32."
TheVeryDarkness Oct 18, 2023
8eedfa7
Merge branch 'add-vcpkg' of https://github.com/TheVeryDarkness/z3.rs …
TheVeryDarkness Oct 18, 2023
d10c623
Merge branch 'add-vcpkg' of https://github.com/TheVeryDarkness/z3.rs …
TheVeryDarkness Oct 18, 2023
d4d3164
Fix an error in build script.
TheVeryDarkness Oct 18, 2023
a31eb7f
Fix an error in ci
TheVeryDarkness Oct 18, 2023
9f0bd1d
Fixing ci errors.
TheVeryDarkness Oct 18, 2023
a5b44da
Force to set VCPKG_ROOT in CI
TheVeryDarkness Oct 18, 2023
ecb607b
Remove macos and a redundant step from workflows
TheVeryDarkness Oct 18, 2023
63aa222
No fail fast
TheVeryDarkness Oct 18, 2023
6c0f856
Test on windows only.
TheVeryDarkness Oct 18, 2023
25a913e
Clean build trees after build.
TheVeryDarkness Oct 18, 2023
e5244a6
Test only on Windows indeed.
TheVeryDarkness Oct 18, 2023
bfb6a46
Show default toolchain of rust.
TheVeryDarkness Oct 18, 2023
af5bd2e
Merge pull request #1 from TheVeryDarkness/master
TheVeryDarkness Oct 18, 2023
6c95b82
Support env var EMSCRIPTEN_ROOT
TheVeryDarkness Oct 26, 2023
b15dbbd
Merge remote-tracking branch 'upstream/master' into emscripten-root
TheVeryDarkness Nov 23, 2023
813080f
Fix duplicate feature `vcpkg`
TheVeryDarkness Nov 23, 2023
e648ca1
Fix a typo in comment.
TheVeryDarkness Nov 23, 2023
f181557
Add description for $EMSDK and $EMSCRIPTEN_ROOT
TheVeryDarkness Nov 23, 2023
ff187c9
Force env var only for *-emscripten targets
TheVeryDarkness Nov 23, 2023
e4eb0fc
Fix some warnings that have been fixed.
TheVeryDarkness Nov 23, 2023
3d3e2f2
Add more descriptions for $EMSCRIPTEN_ROOT
TheVeryDarkness Nov 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions z3-sys/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ There are 3 ways for this crate to currently find Z3:
by that version to be used. In this case, there is no override
via the environment variable.

### Finding emscripten

For wasm32 targets, we may need an existed emscripten installation for a `sysroot`.
One may specify the root of emsdk by environment variable `EMSDK`,
or the root of emscripten by environment variable `EMSCRIPTEN_ROOT`.
Then we'll use `$EMSDK/upstream/emscripten/cache/sysroot` or `$EMSCRIPTEN_ROOT/cache/sysroot`.

For example, if you're using brew, you can assign `$HOMEBREW_CELLAR/emscripten/<emscripten version>/libexec` to `EMSCRIPTEN_ROOT`.

## Support and Maintenance

I am developing this library largely on my own so far. I am able
Expand Down
21 changes: 16 additions & 5 deletions z3-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,22 @@ fn generate_binding(header: &str) {
.generate_comments(false)
.rustified_enum(format!("Z3_{x}"))
.allowlist_type(format!("Z3_{x}"));
if env::var("TARGET").unwrap() == "wasm32-unknown-emscripten" {
enum_bindings = enum_bindings.clang_arg(format!(
"--sysroot={}/upstream/emscripten/cache/sysroot",
env::var("EMSDK").expect("$EMSDK env var missing. Is emscripten installed?")
));
let target = env::var("TARGET").unwrap();
let wasm = target.starts_with("wasm");
let emscripten = target.ends_with("emscripten");
if wasm {
// It seems that sometimes the cache may be missing.
let sysroot = env::var("EMSDK")
.map(|emsdk| format!("{}/upstream/emscripten/cache/sysroot", emsdk))
.or_else(|_err| {
env::var("EMSCRIPTEN_ROOT")
.map(|emscripten_root| format!("{}/cache/sysroot", emscripten_root))
});
if let Ok(sysroot) = sysroot {
enum_bindings = enum_bindings.clang_arg(format!("--sysroot={}", sysroot));
} else if emscripten {
panic!("$EMSDK and $EMSCRIPTEN_ROOT env var missing. Is emscripten installed?");
}
}
enum_bindings
.generate()
Expand Down