Skip to content

Commit 044297a

Browse files
chore: handling the case where --generate-only flag is passed
1 parent 644e34e commit 044297a

File tree

2 files changed

+32
-22
lines changed

2 files changed

+32
-22
lines changed

crates/intrinsic-test/src/arm/mod.rs

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl SupportedArchitectureTest for ArmArchitectureTest {
6969

7070
let (chunk_size, chunk_count) = chunk_info(self.intrinsics.len());
7171

72-
let cpp_compiler = compile::build_cpp_compilation(&self.cli_options).unwrap();
72+
let cpp_compiler_wrapped = compile::build_cpp_compilation(&self.cli_options);
7373

7474
let notice = &build_notices("// ");
7575
self.intrinsics
@@ -81,9 +81,11 @@ impl SupportedArchitectureTest for ArmArchitectureTest {
8181
write_mod_cpp(&mut file, notice, c_target, platform_headers, chunk).unwrap();
8282

8383
// compile this cpp file into a .o file
84-
let output = cpp_compiler
85-
.compile_object_file(&format!("mod_{i}.cpp"), &format!("mod_{i}.o"))?;
86-
assert!(output.status.success(), "{output:?}");
84+
if let Some(cpp_compiler) = cpp_compiler_wrapped.as_ref() {
85+
let output = cpp_compiler
86+
.compile_object_file(&format!("mod_{i}.cpp"), &format!("mod_{i}.o"))?;
87+
assert!(output.status.success(), "{output:?}");
88+
}
8789

8890
Ok(())
8991
})
@@ -99,21 +101,25 @@ impl SupportedArchitectureTest for ArmArchitectureTest {
99101
)
100102
.unwrap();
101103

104+
// This is done because `cpp_compiler_wrapped` is None when
105+
// the --generate-only flag is passed
106+
if let Some(cpp_compiler) = cpp_compiler_wrapped.as_ref() {
102107
// compile this cpp file into a .o file
103-
info!("compiling main.cpp");
104-
let output = cpp_compiler
105-
.compile_object_file("main.cpp", "intrinsic-test-programs.o")
106-
.unwrap();
107-
assert!(output.status.success(), "{output:?}");
108-
109-
let object_files = (0..chunk_count)
110-
.map(|i| format!("mod_{i}.o"))
111-
.chain(["intrinsic-test-programs.o".to_owned()]);
112-
113-
let output = cpp_compiler
114-
.link_executable(object_files, "intrinsic-test-programs")
115-
.unwrap();
116-
assert!(output.status.success(), "{output:?}");
108+
info!("compiling main.cpp");
109+
let output = cpp_compiler
110+
.compile_object_file("main.cpp", "intrinsic-test-programs.o")
111+
.unwrap();
112+
assert!(output.status.success(), "{output:?}");
113+
114+
let object_files = (0..chunk_count)
115+
.map(|i| format!("mod_{i}.o"))
116+
.chain(["intrinsic-test-programs.o".to_owned()]);
117+
118+
let output = cpp_compiler
119+
.link_executable(object_files, "intrinsic-test-programs")
120+
.unwrap();
121+
assert!(output.status.success(), "{output:?}");
122+
}
117123

118124
true
119125
}

crates/intrinsic-test/src/common/gen_rust.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ pub fn compile_rust_programs(toolchain: Option<&str>, target: &str, linker: Opti
130130
/* If there has been a linker explicitly set from the command line then
131131
* we want to set it via setting it in the RUSTFLAGS*/
132132

133+
// This is done because `toolchain` is None when
134+
// the --generate-only flag is passed
135+
if toolchain.is_none() {
136+
return true;
137+
}
138+
133139
trace!("Building cargo command");
134140

135141
let mut cargo_command = Command::new("cargo");
@@ -138,10 +144,8 @@ pub fn compile_rust_programs(toolchain: Option<&str>, target: &str, linker: Opti
138144
// Do not use the target directory of the workspace please.
139145
cargo_command.env("CARGO_TARGET_DIR", "target");
140146

141-
if let Some(toolchain) = toolchain
142-
&& !toolchain.is_empty()
143-
{
144-
cargo_command.arg(toolchain);
147+
if toolchain.is_some_and(|val| !val.is_empty()) {
148+
cargo_command.arg(toolchain.unwrap());
145149
}
146150
cargo_command.args(["build", "--target", target, "--release"]);
147151

0 commit comments

Comments
 (0)