about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/lib.rs
diff options
context:
space:
mode:
authorMichael Baikov <manpacket@gmail.com>2024-04-06 11:22:21 -0400
committerMichael Baikov <manpacket@gmail.com>2024-04-19 08:31:41 -0400
commitc8390cdbfaccc55aa374222e39cdf9092a1e5ff6 (patch)
tree577135d1f960834ad4bc2b8b53278096ba6aa106 /compiler/rustc_codegen_ssa/src/lib.rs
parent43a0686f8d18fa068e2689d5bd889bd2670dbf50 (diff)
downloadrust-c8390cdbfaccc55aa374222e39cdf9092a1e5ff6.tar.gz
rust-c8390cdbfaccc55aa374222e39cdf9092a1e5ff6.zip
Show files produced by --emit foo in json artifact notifications
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/lib.rs')
-rw-r--r--compiler/rustc_codegen_ssa/src/lib.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_ssa/src/lib.rs b/compiler/rustc_codegen_ssa/src/lib.rs
index 80fe7e0bb78..7e0e5a9e632 100644
--- a/compiler/rustc_codegen_ssa/src/lib.rs
+++ b/compiler/rustc_codegen_ssa/src/lib.rs
@@ -113,6 +113,24 @@ pub struct CompiledModule {
     pub llvm_ir: Option<PathBuf>,  // --emit=llvm-ir, llvm-bc is in bytecode
 }
 
+impl CompiledModule {
+    /// Call `emit` function with every artifact type currently compiled
+    pub fn for_each_output(&self, mut emit: impl FnMut(&Path, OutputType)) {
+        if let Some(path) = self.object.as_deref() {
+            emit(path, OutputType::Object);
+        }
+        if let Some(path) = self.bytecode.as_deref() {
+            emit(path, OutputType::Bitcode);
+        }
+        if let Some(path) = self.llvm_ir.as_deref() {
+            emit(path, OutputType::LlvmAssembly);
+        }
+        if let Some(path) = self.assembly.as_deref() {
+            emit(path, OutputType::Assembly);
+        }
+    }
+}
+
 pub struct CachedModuleCodegen {
     pub name: String,
     pub source: WorkProduct,