diff --git a/Cargo.toml b/Cargo.toml index bb7f1e4d123be9258d26f9497bf1fc530dcfedff..0630212907de09047af4ff1cb5de702b8dc2be56 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -73,6 +73,7 @@ walkdir = "2.3.2" substrate-build-script-utils = "3.0.0" platforms = "2.0.0" which = "4.2.5" +regex = "1.5.5" [dev-dependencies] assert_cmd = "2.0.4" diff --git a/build.rs b/build.rs index 7b5618ed2eaf0b71b78be38456691ae31fa10628..5c7f9f110453be93f14f5f8f457b4c1ee65e93cb 100644 --- a/build.rs +++ b/build.rs @@ -314,13 +314,17 @@ fn zip_dylint_driver(src_dir: &Path, dst_file: &Path, method: CompressionMethod) let walkdir = WalkDir::new(src_dir); let it = walkdir.into_iter().filter_map(|e| e.ok()); + let regex = regex::Regex::new(r#"(lib)?ink_linting@.+\.(dll|so|dylib)"#) + .expect("Regex is correct; qed"); + let mut lib_found = false; for entry in it { let path = entry.path(); let name = path.strip_prefix(&src_dir)?.to_path_buf(); let file_path = name.as_os_str().to_string_lossy(); - if path.is_file() && path.display().to_string().contains("libink_linting@") { + println!("path: {:?}", path.display().to_string()); + if path.is_file() && regex.is_match(&path.display().to_string()) { zip.start_file(file_path, options)?; let mut f = File::open(path)?; @@ -329,9 +333,18 @@ fn zip_dylint_driver(src_dir: &Path, dst_file: &Path, method: CompressionMethod) buffer.clear(); zip.finish()?; + lib_found = true; break; } } + + if !lib_found { + anyhow::bail!( + "Couldn't find compiled lint. Is your architecture ({}) defined in ./ink_linting/.cargo/config.toml?", + std::env::var("TARGET").unwrap(), + ); + } + Ok(()) } diff --git a/ink_linting/.cargo/config.toml b/ink_linting/.cargo/config.toml index e8488c83f6768657d8c0f545c389ac3d18346642..55e905489c47d4749e5f21a7bdc49a7aff591ba3 100644 --- a/ink_linting/.cargo/config.toml +++ b/ink_linting/.cargo/config.toml @@ -1,11 +1,38 @@ # This file corresponds to the `.cargo/config.toml` file used for the `dylint` examples here: # https://github.com/trailofbits/dylint/tree/master/examples. +[target.aarch64-apple-darwin] +linker = "dylint-link" + [target.x86_64-apple-darwin] linker = "dylint-link" +[target.aarch64-unknown-linux-gnu] +linker = "dylint-link" + +[target.aarch64-unknown-linux-musl] +linker = "dylint-link" + [target.x86_64-unknown-linux-gnu] linker = "dylint-link" +[target.x86_64-unknown-linux-musl] +linker = "dylint-link" + +[target.x86_64-unknown-linux-gnux32] +linker = "dylint-link" + +[target.aarch64-pc-windows-msvc] +linker = "dylint-link" + +[target.i586-pc-windows-msvc] +linker = "dylint-link" + +[target.i586-pc-windows-gnu] +linker = "dylint-link" + [target.x86_64-pc-windows-msvc] linker = "dylint-link" + +[target.x86_64-pc-windows-gnu] +linker = "dylint-link"