Skip to content

Commit c423dd0

Browse files
committed
Move target specs handling out of CLI
1 parent e50f61d commit c423dd0

File tree

9 files changed

+13
-11
lines changed

9 files changed

+13
-11
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/cargo-gpu/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ rustc_codegen_spirv-cache = { path = "../rustc_codegen_spirv-cache", default-fea
1414
cargo_metadata.workspace = true
1515
anyhow.workspace = true
1616
spirv-builder = { workspace = true, features = ["clap", "watch"] }
17-
legacy_target_specs.workspace = true
1817
clap.workspace = true
1918
env_logger.workspace = true
2019
log.workspace = true

crates/cargo-gpu/src/install.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ use rustc_codegen_spirv_cache::{
99
get_channel_from_rustc_codegen_spirv_build_script, query_metadata, FindPackage as _,
1010
SpirvSource,
1111
},
12+
target_specs::update_target_specs_files,
1213
};
1314
use spirv_builder::SpirvBuilder;
1415

15-
use crate::target_specs::update_target_specs_files;
16-
1716
/// Represents a functional backend installation, whether it was cached or just installed.
1817
#[derive(Clone, Debug, Default)]
1918
#[non_exhaustive]

crates/cargo-gpu/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ mod linkage;
6363
mod lockfile;
6464
mod metadata;
6565
mod show;
66-
mod target_specs;
6766
mod test;
6867

6968
pub use install::*;

crates/cargo-gpu/src/show.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ use anyhow::bail;
66
use rustc_codegen_spirv_cache::{
77
cache::cache_dir,
88
spirv_source::{query_metadata, SpirvSource},
9+
target_specs::update_target_specs_files,
910
};
1011

11-
use crate::target_specs::update_target_specs_files;
12-
1312
/// Show the computed source of the spirv-std dependency.
1413
#[derive(Clone, Debug, clap::Parser)]
1514
pub struct SpirvSourceDep {

crates/rustc_codegen_spirv-cache/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ keywords.workspace = true
88
license.workspace = true
99

1010
[dependencies]
11+
legacy_target_specs.workspace = true
1112
thiserror.workspace = true
1213
anyhow.workspace = true
1314
log.workspace = true

crates/rustc_codegen_spirv-cache/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,9 @@
1111
//! toolchain, but this project loosens that requirement by managing installations
1212
//! of `rustc_codegen_spirv` and their associated toolchains for you.
1313
14+
// TODO: remove this & fix documentation
15+
#![expect(clippy::missing_errors_doc, reason = "temporary allow this")]
16+
1417
pub mod cache;
1518
pub mod spirv_source;
19+
pub mod target_specs;

crates/rustc_codegen_spirv-cache/src/spirv_source.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
//! version. Then with that we `git checkout` the `rust-gpu` repo that corresponds to that version.
55
//! From there we can look at the source code to get the required Rust toolchain.
66
7-
// TODO: remove this & fix documentation
8-
#![expect(clippy::missing_errors_doc, reason = "temporary allow")]
9-
107
use std::{
118
fs,
129
path::{Path, PathBuf},

crates/cargo-gpu/src/target_specs.rs renamed to crates/rustc_codegen_spirv-cache/src/target_specs.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,15 @@ use std::path::{Path, PathBuf};
2626

2727
use anyhow::Context as _;
2828
use cargo_metadata::Metadata;
29-
use rustc_codegen_spirv_cache::{
29+
30+
use crate::{
3031
cache::cache_dir,
3132
spirv_source::{FindPackage as _, SpirvSource},
3233
};
3334

3435
/// Extract legacy target specs from our executable into some directory
36+
#[inline]
37+
#[expect(clippy::module_name_repetitions, reason = "such naming is intentional")]
3538
pub fn write_legacy_target_specs(target_spec_dir: &Path) -> anyhow::Result<()> {
3639
std::fs::create_dir_all(target_spec_dir)?;
3740
for (filename, contents) in legacy_target_specs::TARGET_SPECS {
@@ -57,6 +60,7 @@ fn copy_spec_files(src: &Path, dst: &Path) -> anyhow::Result<()> {
5760
}
5861

5962
/// Computes the `target-specs` directory to use and updates the target spec files, if enabled.
63+
#[inline]
6064
pub fn update_target_specs_files(
6165
source: &SpirvSource,
6266
dummy_metadata: &Metadata,

0 commit comments

Comments
 (0)