@@ -117,7 +117,7 @@ impl Install {
117
117
/// Create the `rustc_codegen_spirv_dummy` crate that depends on `rustc_codegen_spirv`
118
118
fn write_source_files ( source : & SpirvSource , checkout : & Path ) -> anyhow:: Result < ( ) > {
119
119
// skip writing a dummy project if we use a local rust-gpu checkout
120
- if matches ! ( source, SpirvSource :: Path { .. } ) {
120
+ if source. is_path ( ) {
121
121
return Ok ( ( ) ) ;
122
122
}
123
123
log:: debug!(
@@ -141,10 +141,12 @@ impl Install {
141
141
}
142
142
SpirvSource :: Git { url, rev } => format ! ( "git = \" {url}\" \n rev = \" {rev}\" " ) ,
143
143
SpirvSource :: Path {
144
- rust_gpu_repo_root : rust_gpu_path ,
144
+ rust_gpu_repo_root,
145
145
version,
146
146
} => {
147
- let mut new_path = rust_gpu_path. to_owned ( ) ;
147
+ // this branch is currently unreachable, as we just build `rustc_codegen_spirv` directly,
148
+ // since we don't need the `dummy` crate to make cargo download it for us
149
+ let mut new_path = rust_gpu_repo_root. to_owned ( ) ;
148
150
new_path. push ( "crates/spirv-builder" ) ;
149
151
format ! ( "path = \" {new_path}\" \n version = \" {version}\" " )
150
152
}
@@ -198,7 +200,6 @@ package = "rustc_codegen_spirv"
198
200
self . spirv_builder_source . as_deref ( ) ,
199
201
self . spirv_builder_version . as_deref ( ) ,
200
202
) ?;
201
- let source_is_path = matches ! ( source, SpirvSource :: Path { .. } ) ;
202
203
let install_dir = source. install_dir ( ) ?;
203
204
204
205
let dylib_filename = format ! (
@@ -208,7 +209,7 @@ package = "rustc_codegen_spirv"
208
209
) ;
209
210
210
211
let dest_dylib_path;
211
- if source_is_path {
212
+ if source . is_path ( ) {
212
213
dest_dylib_path = install_dir
213
214
. join ( "target" )
214
215
. join ( "release" )
@@ -223,7 +224,8 @@ package = "rustc_codegen_spirv"
223
224
}
224
225
}
225
226
226
- let skip_rebuild = !source_is_path && dest_dylib_path. is_file ( ) && !self . rebuild_codegen ;
227
+ // if `source` is a path, always rebuild
228
+ let skip_rebuild = !source. is_path ( ) && dest_dylib_path. is_file ( ) && !self . rebuild_codegen ;
227
229
if skip_rebuild {
228
230
log:: info!( "...and so we are aborting the install step." ) ;
229
231
} else {
@@ -232,9 +234,9 @@ package = "rustc_codegen_spirv"
232
234
233
235
// TODO cache toolchain channel in a file?
234
236
log:: debug!( "resolving toolchain version to use" ) ;
235
- let crate_metadata = query_metadata ( & install_dir)
237
+ let dummy_metadata = query_metadata ( & install_dir)
236
238
. context ( "resolving toolchain version: get `rustc_codegen_spirv_dummy` metadata" ) ?;
237
- let rustc_codegen_spirv = crate_metadata . find_package ( "rustc_codegen_spirv" ) . context (
239
+ let rustc_codegen_spirv = dummy_metadata . find_package ( "rustc_codegen_spirv" ) . context (
238
240
"resolving toolchain version: expected a dependency on `rustc_codegen_spirv`" ,
239
241
) ?;
240
242
let toolchain_channel =
@@ -252,7 +254,7 @@ package = "rustc_codegen_spirv"
252
254
. context ( "ensuring toolchain and components exist" ) ?;
253
255
254
256
// to prevent unsupported version errors when using older toolchains
255
- if !source_is_path {
257
+ if !source . is_path ( ) {
256
258
log:: debug!( "remove Cargo.lock" ) ;
257
259
std:: fs:: remove_file ( install_dir. join ( "Cargo.lock" ) )
258
260
. context ( "remove Cargo.lock" ) ?;
@@ -265,7 +267,7 @@ package = "rustc_codegen_spirv"
265
267
. arg ( format ! ( "+{toolchain_channel}" ) )
266
268
. args ( [ "build" , "--release" ] )
267
269
. env_remove ( "RUSTC" ) ;
268
- if source_is_path {
270
+ if source . is_path ( ) {
269
271
build_command. args ( [ "-p" , "rustc_codegen_spirv" , "--lib" ] ) ;
270
272
}
271
273
@@ -289,7 +291,7 @@ package = "rustc_codegen_spirv"
289
291
let dylib_path = target. join ( "release" ) . join ( & dylib_filename) ;
290
292
if dylib_path. is_file ( ) {
291
293
log:: info!( "successfully built {}" , dylib_path. display( ) ) ;
292
- if !source_is_path {
294
+ if !source . is_path ( ) {
293
295
std:: fs:: rename ( & dylib_path, & dest_dylib_path)
294
296
. context ( "renaming dylib path" ) ?;
295
297
0 commit comments