-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use std::env; | ||
use std::fs; | ||
use std::path::{Path, PathBuf}; | ||
use std::process::Command; | ||
|
||
static PIXI_TRAMPOLINE: &str = "pixi_trampoline"; | ||
static TRAMPOLINES_FOLDER: &str = "trampolines"; | ||
|
||
fn main() { | ||
// Construct trampoline crate path | ||
let manifest_dir = env!("CARGO_MANIFEST_DIR"); | ||
let trampoline_crate_path = format!("{}/crates/{}", manifest_dir, PIXI_TRAMPOLINE); | ||
let trampoline_crate = Path::new(&trampoline_crate_path); | ||
let trampolines_dir = trampoline_crate.join(TRAMPOLINES_FOLDER); | ||
|
||
// Get the target triplet, which will be used to name the trampoline binary | ||
let target_triplet = env::var("TARGET").expect("TARGET env variable should be set by cargo"); | ||
|
||
// Build the trampoline binary | ||
// we always use --release profile for this | ||
Command::new("cargo") | ||
.current_dir(&trampoline_crate) | ||
.args(&["build", "--release", "--target", target_triplet.as_str()]) | ||
.status() | ||
.expect("Failed to build trampoline crate"); | ||
|
||
// Create trampolines directory if it doesn't exist | ||
fs::create_dir_all(&trampolines_dir).expect("Failed to create trampolines directory"); | ||
|
||
let cargo_target_dir = | ||
env::var("CARGO_TARGET_DIR").expect("CARGO_TARGET_DIR should be set by cargo"); | ||
// Construct the path to the built binary | ||
let target_path = PathBuf::from_iter([ | ||
cargo_target_dir.as_str(), | ||
target_triplet.as_str(), | ||
"release", | ||
PIXI_TRAMPOLINE, | ||
]); | ||
|
||
let built_binary_path = trampoline_crate.join(target_path); | ||
let dest_path = trampolines_dir.join(format!("pixi_trampoline-{}", target_triplet)); | ||
|
||
// Copy the built binary to the trampolines directory | ||
fs::copy(&built_binary_path, &dest_path).expect("Failed to copy second crate binary"); | ||
|
||
// Tell cargo to re-run this build script if the trampoline binary code changes | ||
println!("cargo:rerun-if-changed=crates/pixi_trampoline/src"); | ||
} |
Binary file added
BIN
+582 KB
crates/pixi_trampoline/trampolines/pixi_trampoline-aarch64-apple-darwin
Binary file not shown.