-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Build Wasmtime engine using a `build.rs` script The current mechanism for building engines using Docker has several issues: it is slow (Cargo must re-download all required crates), it is too Linux-specific, and it does not play well with workflows that attempt to build Sightglass in Docker (i.e., docker-in-docker is tricky). This change provides a `build.rs` script to build both the engine shared library and a `.build-info` metadata file: the engine shared library is built using the same steps the `Dockerfile` used and the `.build-info` file attempts to capture some of the environmental information that Docker fixed but is now system-dependent (e.g., tool versions for reproducing the build). * Remove CLI commands--`build-engine`, `clean` If we no longer build Sightglass engines using Docker (see previous commit) and store them in a central place (the Sightglass cache directory), then it no longer makes sense to have the `build-engine` and `clean` commands available in the CLI. This change removes these commands and associated dead code. Alternately, we could remove Docker but not the cache directory; by default, the Wasmtime engine `build.rs` script could place built files there. The difficulty with this is that we previously used the `dirs` crate to reliably find the `data_dir()` within the user's home directory. It is difficult to use crates from a standalone script like `build.rs` and without a reliable way to access the user's home directory, it seemed easiest to just copy the built files to `engines/wasmtime`. * ci: use the `build.rs` script Instead of using the `build-engine` command (now removed) or manually building the engine library, use the `build.rs` script throughout the CI workflow files. * fix: check that alternate engine exists
- Loading branch information
Showing
16 changed files
with
314 additions
and
477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,15 @@ | ||
mod artifact; | ||
mod docker; | ||
mod engine; | ||
mod git; | ||
mod metadata; | ||
mod wasm; | ||
|
||
use anyhow::Context; | ||
use std::path::PathBuf; | ||
|
||
pub use artifact::Artifact; | ||
pub use docker::{DockerBuildArgs, Dockerfile}; | ||
pub use engine::*; | ||
pub use git::GitLocation; | ||
pub use metadata::{BuildInfo, BuildSystem, GitSource}; | ||
pub use wasm::WasmBenchmark; | ||
|
||
/// Get the local directory where sightglass stores cached data. | ||
pub fn sightglass_data_dir() -> anyhow::Result<PathBuf> { | ||
let mut p = dirs::data_local_dir().ok_or_else(|| { | ||
anyhow::anyhow!( | ||
"missing an application data folder for storing sightglass engines; e.g. \ | ||
/home/.../.local/share, C:\\Users\\...\\AppData\\Local" | ||
) | ||
})?; | ||
p.push("sightglass"); | ||
Ok(p) | ||
} | ||
|
||
/// Clean up and remove any cached data. | ||
pub fn clean() -> anyhow::Result<()> { | ||
let sightglass_data_dir = sightglass_data_dir()?; | ||
if !sightglass_data_dir.is_dir() { | ||
return Ok(()); | ||
} | ||
|
||
log::info!( | ||
"Recursively removing sightglass cached data in {}", | ||
sightglass_data_dir.display() | ||
); | ||
std::fs::remove_dir_all(&sightglass_data_dir).with_context(|| { | ||
format!( | ||
"failed to recursively remove {}", | ||
sightglass_data_dir.display(), | ||
) | ||
})?; | ||
|
||
Ok(()) | ||
/// Calculate the library name for a sightglass library on the target operating system: e.g. | ||
/// `engine.dll`, `libengine.so`. | ||
pub fn get_engine_filename() -> String { | ||
format!( | ||
"{}engine{}", | ||
std::env::consts::DLL_PREFIX, | ||
std::env::consts::DLL_SUFFIX | ||
) | ||
} |
Oops, something went wrong.