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 feature flags for static builds #4691

Merged
merged 6 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
4 changes: 4 additions & 0 deletions .github/workflows/cargo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,9 @@ jobs:
run: cargo build --all
- name: Cargo test
run: cargo test --all
- name: Cargo build with static feature
nibanks marked this conversation as resolved.
Show resolved Hide resolved
run: cargo build --all --features static
- name: Cargo test with static feature
run: cargo test --all --features static
- name: Cargo Publish (dry run)
run: cargo publish --dry-run --allow-dirty
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ include = [
"/THIRD-PARTY-NOTICES",
]

[features]
default = []
static = []

[build-dependencies]
cmake = "0.1"

Expand Down
11 changes: 10 additions & 1 deletion scripts/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@ fn main() {
}

let target = env::var("TARGET").unwrap();
let out_dir = env::var("OUT_DIR").unwrap();
// The output directory for the native MsQuic library.
let quic_output_dir = Path::new(&out_dir).join("lib");

// Builds the native MsQuic and installs it into $OUT_DIR.
let mut config = Config::new(".");
config
.define("QUIC_ENABLE_LOGGING", logging_enabled)
.define("QUIC_TLS", "openssl")
.define("QUIC_OUTPUT_DIR", "../lib");
.define("QUIC_OUTPUT_DIR", quic_output_dir.to_str().unwrap());
if cfg!(feature = "static") {
config.define("QUIC_BUILD_SHARED", "off");
}

// macos-latest's cargo automatically specify --target=${ARCH}-apple-macosx14.5
// which conflicts with -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}.
Expand All @@ -38,4 +44,7 @@ fn main() {
let dst = config.build();
let lib_path = Path::join(Path::new(&dst), Path::new(path_extra));
println!("cargo:rustc-link-search=native={}", lib_path.display());
if cfg!(feature = "static") {
println!("cargo:rustc-link-lib=static=msquic");
}
}
Loading