Skip to content

Commit 51b8fd7

Browse files
Brooooooklynanonrig
authored andcommitted
fix: windows build
1 parent eebe76c commit 51b8fd7

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ada-url"
3-
authors = ["Yagiz Nizipli <[email protected]>", "Daniel Lemire <[email protected]>"]
3+
authors = ["Yagiz Nizipli <[email protected]>", "Daniel Lemire <[email protected]>", "LongYinan <[email protected]>"]
44
version = "0.1.0"
55
edition = "2021"
66
description = "Fast WHATWG Compliant URL parser"
@@ -13,6 +13,10 @@ exclude = [".github"]
1313
name = "parse"
1414
path = "bench/parse.rs"
1515

16+
[features]
17+
# pass `cpp_set_stdlib("c++")` to `cc`
18+
libcpp = []
19+
1620
[dependencies]
1721
thiserror = "1"
1822

@@ -21,3 +25,10 @@ url = "2" # Used by benchmarks
2125

2226
[build-dependencies]
2327
cc = { version = "1.0", features = ["parallel"] }
28+
link_args = "0.6"
29+
30+
[profile.bench]
31+
opt-level = 3
32+
lto = true
33+
codegen-units = 1
34+
overflow-checks = false

build.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,21 @@ fn main() {
1717
let compile_target_env = env::var("CARGO_CFG_TARGET_ENV").expect("CARGO_CFG_TARGET_ENV");
1818
if !(compile_target_os == "windows" && compile_target_env == "msvc") {
1919
build.compiler("clang++");
20-
build.cpp_set_stdlib("c++").flag("-std=c++17");
21-
println!("cargo:rustc-link-lib=c++");
20+
build.flag("-std=c++17");
21+
#[cfg(feature = "libcpp")]
22+
{
23+
build.cpp_set_stdlib("c++");
24+
println!("cargo:rustc-link-lib=c++");
25+
}
2226
} else {
2327
build.flag("/std:c++17").static_crt(true);
28+
link_args::windows! {
29+
unsafe {
30+
no_default_lib(
31+
"libcmt.lib",
32+
);
33+
}
34+
};
2435
}
2536

2637
build.compile("ada");

0 commit comments

Comments
 (0)