Skip to content

Commit

Permalink
Only needed on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Shadle committed Feb 2, 2024
1 parent b40e80d commit 1aca180
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions tools/package.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
use std::{env, fs, path, process::Command};

fn main() {
let (triple, bazel_root) = {
let (triple, bazel_cache) = {
let mut args = env::args().skip(1);
let triple = args.next().expect("expected target triple");
let bazel_root = args.next().expect("expected bazel root");

(triple, bazel_root)
let bc = if env::var_os("CI").is_some() {
Some(args.next().expect("expected bazel cache directory"))
} else {
None
};

(triple, bc)
};

let cwd = "spirv-tools-sys/spirv-tools";
Expand All @@ -27,6 +32,12 @@ fn main() {
// Build the select binaries we/rust-gpu need
{
let mut cmd = Command::new("bazel");
// We use a specific root so that CI can take advantage of the cache,
// this doesn't change the location of the outputs eg bazel-bin of the
// workspace
if let Some(bz) = bazel_cache {
cmd.arg(format!("--output_user_root={bc}"));
}
cmd.args(["build", "--compilation_mode", "opt", "--strip", "always"]);
cmd.args(BINARIES.iter().map(|b| format!(":{b}")));
cmd.current_dir(cwd);
Expand All @@ -39,7 +50,7 @@ fn main() {
let bin_files = {
let ext = if cfg!(windows) { "exe" } else { "" };

let out = path::Path::new(&bazel_root).join("bazel-bin");
let out = path::Path::new("spirv-tools-sys/spirv-tools/bazel-bin");
let pkg = path::Path::new("tools/bin");

if pkg.exists() {
Expand Down

0 comments on commit 1aca180

Please sign in to comment.