Skip to content

Commit cfe3dd6

Browse files
Rename static-link-z3 to bundled.
This renames the `static-link-z3` build feature to `bundled` but leaves a bit around for now to maintain compatibility. It also improves the README's discussion a little bit to mention `vcpkg`.
1 parent 849330e commit cfe3dd6

File tree

6 files changed

+66
-35
lines changed

6 files changed

+66
-35
lines changed

.github/workflows/rust.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
# XXX: Ubuntu's Z3 package seems to be missing some symbols, like
3838
# `Z3_mk_pbeq`, leading to linker errors. Just ignore this, I guess, until
3939
# we figure out how to work around it. At least we have the
40-
# statically-linked Z3 tests below...
40+
# build using a bundled Z3 below...
4141
if: ${{ success() || failure() }}
4242

4343
build_on_wasm:
@@ -57,12 +57,12 @@ jobs:
5757
source ./emsdk_env.sh
5858
- name: Install wasm32-unknown-emscripten target
5959
run: rustup target add wasm32-unknown-emscripten
60-
- name: Build z3-sys and z3 with statically linked Z3
60+
- name: Build z3-sys and z3 with bundled Z3
6161
run: |
6262
source ~/emsdk/emsdk_env.sh
63-
cargo build --target=wasm32-unknown-emscripten --features static-link-z3
63+
cargo build --target=wasm32-unknown-emscripten --features bundled
6464
65-
build_z3_statically:
65+
build_with_bundled_z3:
6666
strategy:
6767
matrix:
6868
build: [linux, macos, windows]
@@ -87,8 +87,8 @@ jobs:
8787
- name: Set LIBCLANG_PATH
8888
run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV
8989
if: matrix.os == 'windows-latest'
90-
- name: Test `z3-sys` and `z3` with statically linked Z3
91-
run: cargo test --workspace --features static-link-z3
90+
- name: Test `z3-sys` and `z3` with bundled linked Z3
91+
run: cargo test --workspace --features bundled
9292

9393
build_with_vcpkg_installed_z3:
9494
strategy:

z3-sys/Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ cmake = { version = "0.1.49", optional = true }
2121
vcpkg = { version = "0.2.15", optional = true }
2222

2323
[features]
24-
# Enable this feature to statically link our own build of Z3, rather than
25-
# dynamically linking to the system's `libz3.so`.
26-
static-link-z3 = ["cmake"]
27-
vcpkg = ["dep:vcpkg"]
24+
bundled = ["dep:cmake"] # Build Z3 via our bundled submodule.
25+
vcpkg = ["dep:vcpkg"] # Build Z3 via vcpkg.
26+
27+
# Legacy feature for short term compatibility
28+
static-link-z3 = ["bundled"]

z3-sys/README.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,32 @@ Add it to your `Cargo.toml` like so:
2424
z3-sys = "0.8"
2525
```
2626

27-
**Note:** This crate requires a `z3.h` during build time.
27+
### Finding Z3 Libraries
2828

29-
* By default, the crate will look for a `z3.h` in standard/system include paths.
30-
* If the feature `static-link-z3` is enabled, the `z3.h` of the built Z3 will be used.
31-
* Alternatively, the path to the desired `z3.h` can be specified via the environment variable
32-
`Z3_SYS_Z3_HEADER`. I.e., running:
29+
**Note:** This library has a dependency on Z3.
3330

34-
```console
35-
$ Z3_SYS_Z3_HEADER="/path/to/my/z3.h" cargo build
36-
```
31+
There are 3 ways for this crate to currently find Z3:
32+
33+
* By default, it will look for a system-installed copy of Z3.
34+
On Linux, this would be via the package manager. On macOS, this
35+
might be via Homebrew (`brew install z3`).
36+
* Enabling the `bundled` feature will use `cmake` to build a
37+
locally bundled copy of Z3. This copy is provided via a git
38+
submodule within the repository.
39+
* Enabling the `vcpkg` feature will use `vcpkg` to build and
40+
install a copy of Z3 which is then used.
41+
42+
**Note:** This crate requires a `z3.h` during build time.
3743

38-
in your project will use `/path/to/my/z3.h` instead.
44+
* By default, the crate will look for a `z3.h` in standard/system
45+
include paths. The `Z3_SYS_Z3_HEADER` environment variable can
46+
also be used to customize this.
47+
* Enabling the`bundled` feature will cause the bundled copy of `z3.h`
48+
to be used. The `Z3_SYS_Z3_HEADER` environment variable can also
49+
be used to customize this.
50+
* Enabling the `vcpkg` feature will cause the copy of `z3.h` provided
51+
by that version to be used. In this case, there is no override
52+
via the environment variable.
3953

4054
## Support and Maintenance
4155

z3-sys/build.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
use std::env;
22

33
fn main() {
4-
// Feature `vcpkg` is prior to `static-link-z3` as vcpkg-installed z3 is also statically linked.
5-
6-
#[cfg(not(feature = "vcpkg"))]
7-
#[cfg(feature = "static-link-z3")]
4+
#[cfg(feature = "bundled")]
85
build_bundled_z3();
96

107
println!("cargo:rerun-if-changed=build.rs");
118

129
#[cfg(not(feature = "vcpkg"))]
1310
let header = find_header_by_env();
11+
1412
#[cfg(feature = "vcpkg")]
1513
let header = find_library_header_by_vcpkg();
1614

@@ -69,7 +67,7 @@ fn find_library_header_by_vcpkg() -> String {
6967
#[cfg(not(feature = "vcpkg"))]
7068
fn find_header_by_env() -> String {
7169
const Z3_HEADER_VAR: &str = "Z3_SYS_Z3_HEADER";
72-
let header = if cfg!(feature = "static-link-z3") {
70+
let header = if cfg!(feature = "bundled") {
7371
"z3/src/api/z3.h".to_string()
7472
} else if let Ok(header_path) = env::var(Z3_HEADER_VAR) {
7573
header_path
@@ -116,8 +114,7 @@ fn generate_binding(header: &str) {
116114
}
117115

118116
/// Build z3 with bundled source codes.
119-
#[cfg(not(feature = "vcpkg"))]
120-
#[cfg(feature = "static-link-z3")]
117+
#[cfg(feature = "bundled")]
121118
fn build_bundled_z3() {
122119
let mut cfg = cmake::Config::new("z3");
123120
cfg

z3/Cargo.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@ edition = "2018"
1616

1717
[features]
1818
default = []
19-
20-
# Enable this feature to statically link our own build of Z3, rather than
21-
# dynamically linking to the system's `libz3.so`.
22-
static-link-z3 = ["z3-sys/static-link-z3"]
23-
19+
bundled = ["z3-sys/bundled"]
2420
vcpkg = ["z3-sys/vcpkg"]
2521

22+
# This is a legacy feature here for short term compatibility.
23+
static-link-z3 = ["z3-sys/bundled"]
24+
2625
[dependencies]
2726
log = "0.4"
2827

z3/README.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,33 @@ Add it to your `Cargo.toml` like so:
2424
z3 = "0.12"
2525
```
2626

27-
**Note:** This library has a dependency on Z3. You will either need to
28-
have the Z3 dependency already installed, or you can statically link
29-
to our build of Z3 like so:
27+
### Finding Z3 Libraries
28+
29+
**Note:** This library has a dependency on Z3.
30+
31+
There are 3 ways for this crate to currently find Z3:
32+
33+
* By default, it will look for a system-installed copy of Z3.
34+
On Linux, this would be via the package manager. On macOS, this
35+
might be via Homebrew (`brew install z3`).
36+
* Enabling the `bundled` feature will use `cmake` to build a
37+
locally bundled copy of Z3. This copy is provided via a git
38+
submodule within the repository.
39+
* Enabling the `vcpkg` feature will use `vcpkg` to build and
40+
install a copy of Z3 which is then used.
41+
42+
This might look like:
43+
44+
```toml
45+
[dependencies]
46+
z3 = {version="0.12", features = ["bundled"]}
47+
```
48+
49+
or:
3050

3151
```toml
3252
[dependencies]
33-
z3 = {version="0.12", features = ["static-link-z3"]}
53+
z3 = {version="0.12", features = ["vcpkg"]}
3454
```
3555

3656
## Support and Maintenance

0 commit comments

Comments
 (0)