mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 13:17:56 +00:00
Make RUSTFLAGS configurable in wasm-builder (#3057)
* Make `RUSTFLAGS` configurable in `wasm-builder` * Version ups * Update `Cargo.lock`
This commit is contained in:
committed by
Gavin Wood
parent
3a002a9100
commit
29311e98b4
@@ -30,6 +30,9 @@ use std::{env, process::{Command, self}, fs, path::{PathBuf, Path}};
|
||||
/// Environment variable that tells us to skip building the WASM binary.
|
||||
const SKIP_BUILD_ENV: &str = "SKIP_WASM_BUILD";
|
||||
|
||||
/// Environment variable to extend the `RUSTFLAGS` variable given to the WASM build.
|
||||
const WASM_BUILD_RUSTFLAGS_ENV: &str = "WASM_BUILD_RUSTFLAGS";
|
||||
|
||||
/// Environment variable that tells us to create a dummy WASM binary.
|
||||
///
|
||||
/// This is useful for `cargo check` to speed-up the compilation.
|
||||
@@ -93,6 +96,20 @@ impl WasmBuilderSource {
|
||||
}
|
||||
}
|
||||
|
||||
/// Build the currently built project as WASM binary and extend `RUSTFLAGS` with the given rustflags.
|
||||
///
|
||||
/// For more information, see [`build_current_project`].
|
||||
pub fn build_current_project_with_rustflags(
|
||||
file_name: &str,
|
||||
wasm_builder_source: WasmBuilderSource,
|
||||
rustflags: &str,
|
||||
) {
|
||||
let given_rustflags = env::var(WASM_BUILD_RUSTFLAGS_ENV).unwrap_or_default();
|
||||
env::set_var(WASM_BUILD_RUSTFLAGS_ENV, format!("{} {}", given_rustflags, rustflags));
|
||||
|
||||
build_current_project(file_name, wasm_builder_source)
|
||||
}
|
||||
|
||||
/// Build the currently built project as WASM binary.
|
||||
///
|
||||
/// The current project is determined using the `CARGO_MANIFEST_DIR` environment variable.
|
||||
|
||||
Reference in New Issue
Block a user