Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 0 additions & 8 deletions examples/runners/ash/build.rs

This file was deleted.

11 changes: 0 additions & 11 deletions examples/runners/ash/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,6 @@ pub struct Options {
}

pub fn main() {
// Hack: spirv_builder builds into a custom directory if running under cargo, to not
// deadlock, and the default target directory if not. However, packages like `proc-macro2`
// have different configurations when being built here vs. when building
// rustc_codegen_spirv normally, so we *want* to build into a separate target directory, to
// not have to rebuild half the crate graph every time we run. So, pretend we're running
// under cargo by setting these environment variables.
unsafe {
std::env::set_var("OUT_DIR", env!("OUT_DIR"));
std::env::set_var("PROFILE", env!("PROFILE"));
}

let options = Options::parse();
let (vert_data, frag_data) = compile_shaders(&options.shader);

Expand Down
14 changes: 4 additions & 10 deletions examples/runners/wgpu/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@ use std::error::Error;
use std::path::PathBuf;

fn main() -> Result<(), Box<dyn Error>> {
let target_os = std::env::var("CARGO_CFG_TARGET_OS")?;
let target_arch = std::env::var("CARGO_CFG_TARGET_ARCH")?;
let target_os = env::var("CARGO_CFG_TARGET_OS")?;
let target_arch = env::var("CARGO_CFG_TARGET_ARCH")?;
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-env-changed=CARGO_CFG_TARGET_OS");
println!("cargo:rerun-if-env-changed=CARGO_CFG_TARGET_ARCH");
// While OUT_DIR is set for both build.rs and compiling the crate, PROFILE is only set in
// build.rs. So, export it to crate compilation as well.
let profile = env::var("PROFILE").unwrap();
println!("cargo:rustc-env=PROFILE={profile}");

if target_os != "android" && target_arch != "wasm32" {
return Ok(());
}
let profile = env::var("PROFILE").unwrap();
let mut dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
// Strip `$profile/build/*/out`.
let ok = dir.ends_with("out")
Expand All @@ -25,10 +23,6 @@ fn main() -> Result<(), Box<dyn Error>> {
&& dir.ends_with(profile)
&& dir.pop();
assert!(ok);
// NOTE(eddyb) this needs to be distinct from the `--target-dir` value that
// `spirv-builder` generates in a similar way from `$OUT_DIR` and `$PROFILE`,
// otherwise repeated `cargo build`s will cause build script reruns and the
// rebuilding of `rustc_codegen_spirv` (likely due to common proc macro deps).
let dir = dir.join("example-runner-wgpu-builder");
let status = std::process::Command::new("cargo")
.args([
Expand Down
3 changes: 3 additions & 0 deletions examples/runners/wgpu/builder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ fn build_shader(path_to_crate: &str, codegen_names: bool) -> Result<(), Box<dyn
let path_to_crate = builder_dir.join(path_to_crate);
let result = SpirvBuilder::new(path_to_crate, "spirv-unknown-vulkan1.1")
.print_metadata(MetadataPrintout::Full)
// Give this spirv-builder a unique target dir, so that rebuilding android and the main wgpu app's target dir
// don't clash and break each other's incremental
.target_dir_path("example-runner-wgpu-builder")
.build()?;
if codegen_names {
let out_dir = env::var_os("OUT_DIR").unwrap();
Expand Down
11 changes: 0 additions & 11 deletions examples/runners/wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,17 +236,6 @@ pub fn main(

#[cfg(not(any(target_os = "android", target_arch = "wasm32")))]
{
// Hack: spirv_builder builds into a custom directory if running under cargo, to not
// deadlock, and the default target directory if not. However, packages like `proc-macro2`
// have different configurations when being built here vs. when building
// rustc_codegen_spirv normally, so we *want* to build into a separate target directory, to
// not have to rebuild half the crate graph every time we run. So, pretend we're running
// under cargo by setting these environment variables.
unsafe {
std::env::set_var("OUT_DIR", env!("OUT_DIR"));
std::env::set_var("PROFILE", env!("PROFILE"));
}

if options.shader == RustGPUShader::Compute {
return compute::start(&options);
}
Expand Down