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

force using system clang unless overridden #54

Merged
merged 1 commit into from
Aug 6, 2023
Merged
Changes from all 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
35 changes: 18 additions & 17 deletions src-rs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,24 +246,23 @@ impl SwiftLinker {
let sdk_path = String::from_utf8_lossy(&sdk_path_output.stdout);

let mut command = Command::new("swift");

command
.args(["build"])
.args(["--sdk", sdk_path.trim()])
.args(["-c", configuration])
.current_dir(&package.path)
.args(["--build-path", &out_path.display().to_string()]);

command.args([
"-Xswiftc",
"-sdk",
"-Xswiftc",
sdk_path.trim(),
"-Xswiftc",
"-target",
"-Xswiftc",
&rust_target
.swift_target_triple(&self.macos_min_version, self.ios_min_version.as_deref()),
]);
.args(["--build-path", &out_path.display().to_string()])
.args(["-Xswiftc", "-sdk"])
.args(["-Xswiftc", sdk_path.trim()])
.args(["-Xswiftc", "-target"])
.args([
"-Xswiftc",
&rust_target.swift_target_triple(
&self.macos_min_version,
self.ios_min_version.as_deref(),
),
]);

if !command.status().unwrap().success() {
panic!("Failed to compile swift package {}", package.name);
Expand Down Expand Up @@ -296,10 +295,12 @@ fn link_clang_rt(rust_target: &RustTarget) {
}

fn clang_link_search_path() -> String {
let output = std::process::Command::new("clang")
.arg("--print-search-dirs")
.output()
.unwrap();
let output = std::process::Command::new(
std::env::var("SWIFT_RS_CLANG").unwrap_or_else(|_| "/usr/bin/clang".to_string()),
)
.arg("--print-search-dirs")
.output()
.unwrap();
if !output.status.success() {
panic!("Can't get search paths from clang");
}
Expand Down
Loading