extension: Add more logging when building extensions (#16794)
This helps debug what steps are taken and where the compiled extension ended up. Also remove duplicate "compiling Rust extension" / "compiling rust extension" text - it's confusing. Release Notes: - N/A --------- Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
This commit is contained in:
parent
093f131712
commit
d67d44f600
1 changed files with 31 additions and 2 deletions
|
@ -93,12 +93,21 @@ impl ExtensionBuilder {
|
||||||
self.compile_rust_extension(extension_dir, extension_manifest, options)
|
self.compile_rust_extension(extension_dir, extension_manifest, options)
|
||||||
.await
|
.await
|
||||||
.context("failed to compile Rust extension")?;
|
.context("failed to compile Rust extension")?;
|
||||||
|
log::info!("compiled Rust extension {}", extension_dir.display());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (grammar_name, grammar_metadata) in &extension_manifest.grammars {
|
for (grammar_name, grammar_metadata) in &extension_manifest.grammars {
|
||||||
|
log::info!(
|
||||||
|
"compiling grammar {grammar_name} for extension {}",
|
||||||
|
extension_dir.display()
|
||||||
|
);
|
||||||
self.compile_grammar(extension_dir, grammar_name.as_ref(), grammar_metadata)
|
self.compile_grammar(extension_dir, grammar_name.as_ref(), grammar_metadata)
|
||||||
.await
|
.await
|
||||||
.with_context(|| format!("failed to compile grammar '{grammar_name}'"))?;
|
.with_context(|| format!("failed to compile grammar '{grammar_name}'"))?;
|
||||||
|
log::info!(
|
||||||
|
"compiled grammar {grammar_name} for extension {}",
|
||||||
|
extension_dir.display()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!("finished compiling extension {}", extension_dir.display());
|
log::info!("finished compiling extension {}", extension_dir.display());
|
||||||
|
@ -117,7 +126,10 @@ impl ExtensionBuilder {
|
||||||
let cargo_toml_content = fs::read_to_string(&extension_dir.join("Cargo.toml"))?;
|
let cargo_toml_content = fs::read_to_string(&extension_dir.join("Cargo.toml"))?;
|
||||||
let cargo_toml: CargoToml = toml::from_str(&cargo_toml_content)?;
|
let cargo_toml: CargoToml = toml::from_str(&cargo_toml_content)?;
|
||||||
|
|
||||||
log::info!("compiling rust extension {}", extension_dir.display());
|
log::info!(
|
||||||
|
"compiling Rust crate for extension {}",
|
||||||
|
extension_dir.display()
|
||||||
|
);
|
||||||
let output = Command::new("cargo")
|
let output = Command::new("cargo")
|
||||||
.args(["build", "--target", RUST_TARGET])
|
.args(["build", "--target", RUST_TARGET])
|
||||||
.args(options.release.then_some("--release"))
|
.args(options.release.then_some("--release"))
|
||||||
|
@ -133,6 +145,11 @@ impl ExtensionBuilder {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log::info!(
|
||||||
|
"compiled Rust crate for extension {}",
|
||||||
|
extension_dir.display()
|
||||||
|
);
|
||||||
|
|
||||||
let mut wasm_path = PathBuf::from(extension_dir);
|
let mut wasm_path = PathBuf::from(extension_dir);
|
||||||
wasm_path.extend([
|
wasm_path.extend([
|
||||||
"target",
|
"target",
|
||||||
|
@ -155,6 +172,11 @@ impl ExtensionBuilder {
|
||||||
.context("failed to load adapter module")?
|
.context("failed to load adapter module")?
|
||||||
.validate(true);
|
.validate(true);
|
||||||
|
|
||||||
|
log::info!(
|
||||||
|
"encoding wasm component for extension {}",
|
||||||
|
extension_dir.display()
|
||||||
|
);
|
||||||
|
|
||||||
let component_bytes = encoder
|
let component_bytes = encoder
|
||||||
.encode()
|
.encode()
|
||||||
.context("failed to encode wasm component")?;
|
.context("failed to encode wasm component")?;
|
||||||
|
@ -168,9 +190,16 @@ impl ExtensionBuilder {
|
||||||
.context("compiled wasm did not contain a valid zed extension api version")?;
|
.context("compiled wasm did not contain a valid zed extension api version")?;
|
||||||
manifest.lib.version = Some(wasm_extension_api_version);
|
manifest.lib.version = Some(wasm_extension_api_version);
|
||||||
|
|
||||||
fs::write(extension_dir.join("extension.wasm"), &component_bytes)
|
let extension_file = extension_dir.join("extension.wasm");
|
||||||
|
fs::write(extension_file.clone(), &component_bytes)
|
||||||
.context("failed to write extension.wasm")?;
|
.context("failed to write extension.wasm")?;
|
||||||
|
|
||||||
|
log::info!(
|
||||||
|
"extension {} written to {}",
|
||||||
|
extension_dir.display(),
|
||||||
|
extension_file.display()
|
||||||
|
);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue