Skip to content

Commit d4e0ff6

Browse files
committed
target-spec: remove target spec handling and show targets
1 parent 74534c8 commit d4e0ff6

File tree

4 files changed

+1
-191
lines changed

4 files changed

+1
-191
lines changed

crates/cargo-gpu/src/install.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use crate::spirv_source::{
44
get_channel_from_rustc_codegen_spirv_build_script, query_metadata, FindPackage as _,
55
};
6-
use crate::target_specs::update_target_specs_files;
76
use crate::{cache_dir, spirv_source::SpirvSource};
87
use anyhow::Context as _;
98
use spirv_builder::SpirvBuilder;
@@ -17,8 +16,6 @@ pub struct InstalledBackend {
1716
pub rustc_codegen_spirv_location: PathBuf,
1817
/// toolchain channel name
1918
pub toolchain_channel: String,
20-
/// directory with target-specs json files
21-
pub target_spec_dir: PathBuf,
2219
}
2320

2421
impl InstalledBackend {
@@ -48,10 +45,6 @@ impl InstalledBackend {
4845
pub fn configure_spirv_builder(&self, builder: &mut SpirvBuilder) -> anyhow::Result<()> {
4946
builder.rustc_codegen_spirv_location = Some(self.rustc_codegen_spirv_location.clone());
5047
builder.toolchain_overwrite = Some(self.toolchain_channel.clone());
51-
builder.path_to_target_spec = Some(self.target_spec_dir.join(format!(
52-
"{}.json",
53-
builder.target.as_ref().context("expect target to be set")?
54-
)));
5548
Ok(())
5649
}
5750
}
@@ -270,10 +263,6 @@ package = "rustc_codegen_spirv"
270263
)?;
271264
log::info!("selected toolchain channel `{toolchain_channel:?}`");
272265

273-
log::debug!("update_spec_files");
274-
let target_spec_dir = update_target_specs_files(&source, &dummy_metadata, !skip_rebuild)
275-
.context("writing target spec files")?;
276-
277266
log::debug!("ensure_toolchain_and_components_exist");
278267
crate::install_toolchain::ensure_toolchain_and_components_exist(
279268
&toolchain_channel,
@@ -336,7 +325,6 @@ package = "rustc_codegen_spirv"
336325
Ok(InstalledBackend {
337326
rustc_codegen_spirv_location: dest_dylib_path,
338327
toolchain_channel,
339-
target_spec_dir,
340328
})
341329
}
342330
}

crates/cargo-gpu/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ mod lockfile;
6464
mod metadata;
6565
mod show;
6666
mod spirv_source;
67-
mod target_specs;
6867
mod test;
6968

7069
pub use install::*;

crates/cargo-gpu/src/show.rs

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
//! Display various information about `cargo gpu`, eg its cache directory.
22
33
use crate::cache_dir;
4-
use crate::spirv_source::{query_metadata, SpirvSource};
5-
use crate::target_specs::update_target_specs_files;
6-
use anyhow::bail;
7-
use std::fs;
8-
use std::path::Path;
4+
use crate::spirv_source::SpirvSource;
95

106
/// Show the computed source of the spirv-std dependency.
117
#[derive(Clone, Debug, clap::Parser)]
@@ -26,9 +22,6 @@ pub enum Info {
2622
Commitsh,
2723
/// All the available SPIR-V capabilities that can be set with `--capabilities`
2824
Capabilities,
29-
30-
/// All available SPIR-V targets
31-
Targets(SpirvSourceDep),
3225
}
3326

3427
/// `cargo gpu show`
@@ -70,13 +63,6 @@ impl Show {
7063
println!(" {capability:?}");
7164
}
7265
}
73-
Info::Targets(SpirvSourceDep { shader_crate }) => {
74-
let (source, targets) = Self::available_spirv_targets_iter(shader_crate)?;
75-
println!("All available targets for rust-gpu version '{source}':");
76-
for target in targets {
77-
println!("{target}");
78-
}
79-
}
8066
}
8167

8268
Ok(())
@@ -90,32 +76,4 @@ impl Show {
9076
let last_capability = spirv_builder::Capability::CacheControlsINTEL as u32;
9177
(0..=last_capability).filter_map(spirv_builder::Capability::from_u32)
9278
}
93-
94-
/// List all available spirv targets, note: the targets from compile time of cargo-gpu and those
95-
/// in the cache-directory will be picked up.
96-
fn available_spirv_targets_iter(
97-
shader_crate: &Path,
98-
) -> anyhow::Result<(SpirvSource, impl Iterator<Item = String>)> {
99-
let source = SpirvSource::new(shader_crate, None, None)?;
100-
let install_dir = source.install_dir()?;
101-
if !install_dir.is_dir() {
102-
bail!("rust-gpu version {} is not installed", source);
103-
}
104-
let dummy_metadata = query_metadata(&install_dir)?;
105-
let target_specs_dir = update_target_specs_files(&source, &dummy_metadata, false)?;
106-
107-
let mut targets = fs::read_dir(target_specs_dir)?
108-
.filter_map(|entry| {
109-
let file = entry.ok()?;
110-
if file.path().is_file() {
111-
if let Some(target) = file.file_name().to_string_lossy().strip_suffix(".json") {
112-
return Some(target.to_owned());
113-
}
114-
}
115-
None
116-
})
117-
.collect::<Vec<_>>();
118-
targets.sort();
119-
Ok((source, targets.into_iter()))
120-
}
12179
}

crates/cargo-gpu/src/target_specs.rs

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

0 commit comments

Comments
 (0)