Skip to content

Commit

Permalink
ci: generate a list of generated files (#10267)
Browse files Browse the repository at this point in the history
* ci: generate a list of generated files

This fix is necessary for Windows users who may be using absolute-path
target directories: the previous solution, separating the paths by `:`,
runs into issues with Windows absolute paths (e.g., `C:\...`). This
change is similar to #10266 but should avoid any further OS
compatibility issues during a hypothetical cross-compilation.

prtest:full

* fix: debug string
  • Loading branch information
abrown authored Feb 21, 2025
1 parent 253579a commit 0c84696
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
18 changes: 10 additions & 8 deletions cranelift/assembler-x64/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use cranelift_assembler_x64_meta as meta;
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::Path;

fn main() {
Expand All @@ -13,12 +15,12 @@ fn main() {
meta::generate_isle_definitions(out_dir.join("assembler-definitions.isle")),
];

println!(
"cargo:rustc-env=ASSEMBLER_BUILT_FILES={}",
built_files
.iter()
.map(|p| p.to_string_lossy().to_string())
.collect::<Vec<_>>()
.join(":")
);
// Generating this additional bit of Rust is necessary for listing the
// generated files.
let mut vec_of_built_files = File::create(out_dir.join("generated-files.rs")).unwrap();
writeln!(vec_of_built_files, "vec![").unwrap();
for file in &built_files {
writeln!(vec_of_built_files, " {:?}.into(),", file.display()).unwrap();
}
writeln!(vec_of_built_files, "]").unwrap();
}
5 changes: 1 addition & 4 deletions cranelift/assembler-x64/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,5 @@ pub use rex::RexFlags;

/// List the files generated to create this assembler.
pub fn generated_files() -> Vec<std::path::PathBuf> {
env!("ASSEMBLER_BUILT_FILES")
.split(':')
.map(std::path::PathBuf::from)
.collect()
include!(concat!(env!("OUT_DIR"), "/generated-files.rs"))
}

0 comments on commit 0c84696

Please sign in to comment.