Skip to content

Commit e767f24

Browse files
Firestar99eddyb
authored andcommitted
remove example build scripts forwarding PROFILE env var
no longer necessary since d416b65
1 parent 2aa4d4f commit e767f24

File tree

5 files changed

+7
-40
lines changed

5 files changed

+7
-40
lines changed

examples/runners/ash/build.rs

Lines changed: 0 additions & 8 deletions
This file was deleted.

examples/runners/ash/src/main.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,6 @@ pub struct Options {
124124
}
125125

126126
pub fn main() {
127-
// Hack: spirv_builder builds into a custom directory if running under cargo, to not
128-
// deadlock, and the default target directory if not. However, packages like `proc-macro2`
129-
// have different configurations when being built here vs. when building
130-
// rustc_codegen_spirv normally, so we *want* to build into a separate target directory, to
131-
// not have to rebuild half the crate graph every time we run. So, pretend we're running
132-
// under cargo by setting these environment variables.
133-
unsafe {
134-
std::env::set_var("OUT_DIR", env!("OUT_DIR"));
135-
std::env::set_var("PROFILE", env!("PROFILE"));
136-
}
137-
138127
let options = Options::parse();
139128
let (vert_data, frag_data) = compile_shaders(&options.shader);
140129

examples/runners/wgpu/build.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,16 @@ use std::error::Error;
33
use std::path::PathBuf;
44

55
fn main() -> Result<(), Box<dyn Error>> {
6-
let target_os = std::env::var("CARGO_CFG_TARGET_OS")?;
7-
let target_arch = std::env::var("CARGO_CFG_TARGET_ARCH")?;
6+
let target_os = env::var("CARGO_CFG_TARGET_OS")?;
7+
let target_arch = env::var("CARGO_CFG_TARGET_ARCH")?;
88
println!("cargo:rerun-if-changed=build.rs");
99
println!("cargo:rerun-if-env-changed=CARGO_CFG_TARGET_OS");
1010
println!("cargo:rerun-if-env-changed=CARGO_CFG_TARGET_ARCH");
11-
// While OUT_DIR is set for both build.rs and compiling the crate, PROFILE is only set in
12-
// build.rs. So, export it to crate compilation as well.
13-
let profile = env::var("PROFILE").unwrap();
14-
println!("cargo:rustc-env=PROFILE={profile}");
11+
1512
if target_os != "android" && target_arch != "wasm32" {
1613
return Ok(());
1714
}
15+
let profile = env::var("PROFILE").unwrap();
1816
let mut dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
1917
// Strip `$profile/build/*/out`.
2018
let ok = dir.ends_with("out")
@@ -25,10 +23,6 @@ fn main() -> Result<(), Box<dyn Error>> {
2523
&& dir.ends_with(profile)
2624
&& dir.pop();
2725
assert!(ok);
28-
// NOTE(eddyb) this needs to be distinct from the `--target-dir` value that
29-
// `spirv-builder` generates in a similar way from `$OUT_DIR` and `$PROFILE`,
30-
// otherwise repeated `cargo build`s will cause build script reruns and the
31-
// rebuilding of `rustc_codegen_spirv` (likely due to common proc macro deps).
3226
let dir = dir.join("example-runner-wgpu-builder");
3327
let status = std::process::Command::new("cargo")
3428
.args([

examples/runners/wgpu/builder/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ fn build_shader(path_to_crate: &str, codegen_names: bool) -> Result<(), Box<dyn
99
let path_to_crate = builder_dir.join(path_to_crate);
1010
let result = SpirvBuilder::new(path_to_crate, "spirv-unknown-vulkan1.1")
1111
.print_metadata(MetadataPrintout::Full)
12+
// Give this spirv-builder a unique target dir, so that rebuilding android and the main wgpu app's target dir
13+
// don't clash and break each other's incremental
14+
.target_dir_path("example-runner-wgpu-builder")
1215
.build()?;
1316
if codegen_names {
1417
let out_dir = env::var_os("OUT_DIR").unwrap();

examples/runners/wgpu/src/lib.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -236,17 +236,6 @@ pub fn main(
236236

237237
#[cfg(not(any(target_os = "android", target_arch = "wasm32")))]
238238
{
239-
// Hack: spirv_builder builds into a custom directory if running under cargo, to not
240-
// deadlock, and the default target directory if not. However, packages like `proc-macro2`
241-
// have different configurations when being built here vs. when building
242-
// rustc_codegen_spirv normally, so we *want* to build into a separate target directory, to
243-
// not have to rebuild half the crate graph every time we run. So, pretend we're running
244-
// under cargo by setting these environment variables.
245-
unsafe {
246-
std::env::set_var("OUT_DIR", env!("OUT_DIR"));
247-
std::env::set_var("PROFILE", env!("PROFILE"));
248-
}
249-
250239
if options.shader == RustGPUShader::Compute {
251240
return compute::start(&options);
252241
}

0 commit comments

Comments
 (0)