mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 11:38:01 +00:00
Make wasm-builder work with cargo install (#3043)
* Make `wasm-builder` work with `cargo install` * Update `Cargo.lock`
This commit is contained in:
@@ -97,14 +97,26 @@ pub fn create_and_compile(cargo_manifest: &Path) -> (WasmBinary, WasmBinaryBloat
|
||||
///
|
||||
/// If the `Cargo.lock` cannot be found, we emit a warning and return `None`.
|
||||
fn find_cargo_lock(cargo_manifest: &Path) -> Option<PathBuf> {
|
||||
let mut path = build_helper::out_dir();
|
||||
fn find_impl(mut path: PathBuf) -> Option<PathBuf> {
|
||||
loop {
|
||||
if path.join("Cargo.lock").exists() {
|
||||
return Some(path.join("Cargo.lock"))
|
||||
}
|
||||
|
||||
while path.pop() {
|
||||
if path.join("Cargo.lock").exists() {
|
||||
return Some(path.join("Cargo.lock"))
|
||||
if !path.pop() {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(path) = find_impl(build_helper::out_dir()) {
|
||||
return Some(path);
|
||||
}
|
||||
|
||||
if let Some(path) = find_impl(cargo_manifest.to_path_buf()) {
|
||||
return Some(path);
|
||||
}
|
||||
|
||||
build_helper::warning!(
|
||||
"Could not find `Cargo.lock` for `{}`, while searching from `{}`.",
|
||||
cargo_manifest.display(),
|
||||
@@ -136,12 +148,13 @@ fn get_wasm_binary_name(cargo_manifest: &Path) -> String {
|
||||
fn get_wasm_workspace_root() -> PathBuf {
|
||||
let mut out_dir = build_helper::out_dir();
|
||||
|
||||
while out_dir.parent().is_some() {
|
||||
if out_dir.parent().map(|p| p.ends_with("target")).unwrap_or(false) {
|
||||
return out_dir;
|
||||
loop {
|
||||
match out_dir.parent() {
|
||||
Some(parent) if out_dir.ends_with("build") => return parent.to_path_buf(),
|
||||
_ => if !out_dir.pop() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
out_dir.pop();
|
||||
}
|
||||
|
||||
panic!("Could not find target dir in: {}", build_helper::out_dir().display())
|
||||
|
||||
Reference in New Issue
Block a user