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

Explicitly reference current directory in rustflags #60

Merged
merged 1 commit into from
Nov 30, 2024
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
23 changes: 16 additions & 7 deletions bin/build_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub fn cargo_build_env() -> String {
pub fn ilasm_check() {
match std::process::Command::new(&*ILASM_PATH).output(){
Ok(_)=>println!("An CIL assembler has been detected."),
Err(err)=>panic!("Could not find the CIL assembler at name/path {:?}, due to {err:?}.
Err(err)=>panic!("Could not find the CIL assembler at name/path {:?}, due to {err:?}.
Please instal the CIL assembler, and/or set the ILASM_PATH enviroment variable to point to your CIL assembler.",*ILASM_PATH)
}
}
Expand All @@ -97,7 +97,9 @@ pub fn absolute_backend_path() -> PathBuf {
} else if cfg!(target_os = "windows") {
std::fs::canonicalize("../target/debug/rustc_codegen_clr.dll").unwrap()
} else if cfg!(target_os = "macos") {
std::fs::canonicalize("../target/debug/librustc_codegen_clr.dylib").unwrap()
let current_dir = std::env::current_dir().unwrap();
let dylib_path = current_dir.join("target/debug/librustc_codegen_clr.dylib");
std::fs::canonicalize(dylib_path).expect("Could not find the backend dylib")
} else {
panic!("Unsupported target OS");
}
Expand All @@ -106,7 +108,9 @@ pub fn absolute_backend_path() -> PathBuf {
} else if cfg!(target_os = "windows") {
std::fs::canonicalize("../target/release/rustc_codegen_clr.dll").unwrap()
} else if cfg!(target_os = "macos") {
std::fs::canonicalize("../target/release/librustc_codegen_clr.dylib").unwrap()
let current_dir = std::env::current_dir().unwrap();
let dylib_path = current_dir.join("target/release/librustc_codegen_clr.dylib");
std::fs::canonicalize(dylib_path).expect("Could not find the backend dylib")
} else {
panic!("Unsupported target OS");
}
Expand Down Expand Up @@ -156,7 +160,9 @@ static RUSTC_CODEGEN_CLR_LINKER: std::sync::LazyLock<PathBuf> = std::sync::LazyL
.unwrap();
//TODO: Fix this for other platforms
if cfg!(target_os = "linux") || cfg!(target_os = "macos") {
std::fs::canonicalize("../target/debug/linker").unwrap()
let current_dir = std::env::current_dir().unwrap();
let linker_path = current_dir.join("target/debug/linker");
std::fs::canonicalize(linker_path).unwrap()
} else if cfg!(target_os = "windows") {
std::fs::canonicalize("../target/debug/linker.exe").unwrap()
} else {
Expand All @@ -169,7 +175,9 @@ static RUSTC_CODEGEN_CLR_LINKER: std::sync::LazyLock<PathBuf> = std::sync::LazyL
.unwrap();
//TODO: Fix this for other platforms
if cfg!(target_os = "linux") || cfg!(target_os = "macos") {
std::fs::canonicalize("../target/release/linker").unwrap()
let current_dir = std::env::current_dir().unwrap();
let linker_path = current_dir.join("target/release/linker");
std::fs::canonicalize(linker_path).unwrap()
} else if cfg!(target_os = "windows") {
std::fs::canonicalize("../target/release/linker.exe").unwrap()
} else {
Expand All @@ -187,13 +195,14 @@ fn build_backend() -> Result<(), String> {
.args(["build", "--lib", "--release"])
.output()
.map_err(|err| err.to_string())?;
let current_dir = std::env::current_dir().unwrap();
let _out = std::process::Command::new("cargo")
.current_dir("../cilly")
.current_dir(current_dir.join("cilly"))
.args(["build", "--bin", "linker"])
.output()
.expect("could not build the backend");
let _out = std::process::Command::new("cargo")
.current_dir("../cilly")
.current_dir(current_dir.join("cilly"))
.args(["build", "--bin", "linker", "--release"])
.output()
.expect("could not build the backend");
Expand Down
Loading