Skip to content

Commit

Permalink
build: don't attempt static linking on mac
Browse files Browse the repository at this point in the history
  • Loading branch information
Dav1dde committed Feb 11, 2024
1 parent 18dad7a commit 39bc58f
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,21 @@ fn compile_sitter(sitter @ Sitter { lang, .. }: &Sitter) -> bool {
}

if scanner_cc.exists() {
cc::Build::new()
.cpp(true)
.flag_if_supported("-w")
let mut cc = cc::Build::new();

cc.flag_if_supported("-w")
.include(&src)
.file(&scanner_cc)
.static_flag(true)
.cpp_link_stdlib(None)
.compile(&format!("{lang}-scanner_cc"));
.file(&scanner_cc);

println!("cargo:rerun-if-changed={}", scanner_cc.display());
// Static linking does not work on Mac.
if !cfg!(target_os = "macos") {
cc.static_flag(true).cpp_link_stdlib(None);
needs_cpp = true;
}

needs_cpp = true;
cc.compile(&format!("{lang}-scanner_cc"));

println!("cargo:rerun-if-changed={}", scanner_cc.display());
}

needs_cpp
Expand Down

0 comments on commit 39bc58f

Please sign in to comment.