Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cranelift: rework isle-in-source-tree functionality. #9633

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions cranelift/codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,6 @@ souper-harvest = ["souper-ir", "souper-ir/stringify"]
# Report any ISLE errors in pretty-printed style.
isle-errors = ["cranelift-isle/fancy-errors"]

# Put ISLE generated files in isle_generated_code/, for easier
# inspection, rather than inside of target/.
isle-in-source-tree = []

# Enable tracking how long passes take in Cranelift.
#
# Enabled by default.
Expand Down
37 changes: 12 additions & 25 deletions cranelift/codegen/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,37 +63,24 @@ fn main() {

println!("cargo:rerun-if-changed=build.rs");

let explicit_isle_dir = &crate_dir.join("isle_generated_code");
#[cfg(feature = "isle-in-source-tree")]
let isle_dir = explicit_isle_dir;
#[cfg(not(feature = "isle-in-source-tree"))]
let isle_dir = &out_dir;

#[cfg(feature = "isle-in-source-tree")]
{
std::fs::create_dir_all(isle_dir).expect("Could not create ISLE source directory");
}
#[cfg(not(feature = "isle-in-source-tree"))]
{
if explicit_isle_dir.is_dir() {
eprintln!(concat!(
"Error: directory isle_generated_code/ exists but is only used when\n",
"`--feature isle-in-source-tree` is specified. To prevent confusion,\n",
"this build script requires the directory to be removed when reverting\n",
"to the usual generated code in target/. Please delete the directory and\n",
"re-run this build.\n",
));
std::process::exit(1);
}
}
let isle_dir = if let Ok(path) = std::env::var("ISLE_SOURCE_DIR") {
// This will canonicalize any relative path in terms of the
// crate root, and will take any absolute path as overriding the
// `crate_dir`.
crate_dir.join(&path)
} else {
out_dir.into()
};

std::fs::create_dir_all(&isle_dir).expect("Could not create ISLE source directory");

if let Err(err) = meta::generate(&isas, &out_dir, isle_dir) {
if let Err(err) = meta::generate(&isas, &out_dir, &isle_dir) {
eprintln!("Error: {err}");
process::exit(1);
}

if &std::env::var("SKIP_ISLE").unwrap_or("0".to_string()) != "1" {
if let Err(err) = build_isle(crate_dir, isle_dir) {
if let Err(err) = build_isle(crate_dir, &isle_dir) {
eprintln!("Error: {err}");
process::exit(1);
}
Expand Down