Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove wasm-builder-runner
  • Loading branch information
bkchr committed Nov 12, 2020
commit ed4565047d3ce069d491d8dcc78bc6710faef217
4 changes: 0 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ members = [
"client/transaction-pool",
"client/transaction-pool/graph",
"utils/prometheus",
"utils/wasm-builder-runner",
"frame/assets",
"frame/aura",
"frame/atomic-swap",
Expand Down
15 changes: 0 additions & 15 deletions utils/wasm-builder-runner/Cargo.toml

This file was deleted.

7 changes: 0 additions & 7 deletions utils/wasm-builder-runner/README.md

This file was deleted.

22 changes: 0 additions & 22 deletions utils/wasm-builder-runner/src/lib.rs

This file was deleted.

6 changes: 3 additions & 3 deletions utils/wasm-builder/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ fn generate_rerun_if_changed_instructions() {
///
/// `file_name` - The name + path of the file being generated. The file contains the
/// constant `WASM_BINARY`, which contains the built WASM binary.
/// `cargo_manifest` - The path to the `Cargo.toml` of the project that should be built.
/// `project_cargo_toml` - The path to the `Cargo.toml` of the project that should be built.
/// `default_rustflags` - Default `RUSTFLAGS` that will always be set for the build.
fn build_project(
file_name: PathBuf,
cargo_manifest: PathBuf,
project_cargo_toml: PathBuf,
default_rustflags: String,
) {
let cargo_cmd = match crate::prerequisites::check() {
Expand All @@ -214,7 +214,7 @@ fn build_project(
};

let (wasm_binary, bloaty) = crate::wasm_project::create_and_compile(
&cargo_manifest,
&project_cargo_toml,
&default_rustflags,
cargo_cmd,
);
Expand Down
42 changes: 22 additions & 20 deletions utils/wasm-builder/src/wasm_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,20 @@ fn crate_metadata(cargo_manifest: &Path) -> Metadata {
/// Creates the WASM project, compiles the WASM binary and compacts the WASM binary.
///
/// # Returns
///
/// The path to the compact WASM binary and the bloaty WASM binary.
pub(crate) fn create_and_compile(
cargo_manifest: &Path,
project_cargo_toml: &Path,
default_rustflags: &str,
cargo_cmd: CargoCommandVersioned,
) -> (Option<WasmBinary>, WasmBinaryBloaty) {
let wasm_workspace_root = get_wasm_workspace_root();
let wasm_workspace = wasm_workspace_root.join("wbuild");

let crate_metadata = crate_metadata(cargo_manifest);
let crate_metadata = crate_metadata(project_cargo_toml);

let project = create_project(
cargo_manifest,
project_cargo_toml,
&wasm_workspace,
&crate_metadata,
&crate_metadata.workspace_root,
Expand All @@ -112,14 +113,14 @@ pub(crate) fn create_and_compile(
build_project(&project, default_rustflags, cargo_cmd);
let (wasm_binary, bloaty) = compact_wasm_file(
&project,
cargo_manifest,
project_cargo_toml,
);

wasm_binary.as_ref().map(|wasm_binary|
copy_wasm_to_target_directory(cargo_manifest, wasm_binary)
copy_wasm_to_target_directory(project_cargo_toml, wasm_binary)
);

generate_rerun_if_changed_instructions(cargo_manifest, &project, &wasm_workspace);
generate_rerun_if_changed_instructions(project_cargo_toml, &project, &wasm_workspace);

(wasm_binary, bloaty)
}
Expand Down Expand Up @@ -331,29 +332,30 @@ fn has_runtime_wasm_feature_declared(
/// Create the project used to build the wasm binary.
///
/// # Returns
/// The path to the created project.
///
/// The path to the created wasm project.
fn create_project(
cargo_manifest: &Path,
project_cargo_toml: &Path,
wasm_workspace: &Path,
crate_metadata: &Metadata,
workspace_root_path: &Path,
) -> PathBuf {
let crate_name = get_crate_name(cargo_manifest);
let crate_path = cargo_manifest.parent().expect("Parent path exists; qed");
let wasm_binary = get_wasm_binary_name(cargo_manifest);
let project_folder = wasm_workspace.join(&crate_name);
let crate_name = get_crate_name(project_cargo_toml);
let crate_path = project_cargo_toml.parent().expect("Parent path exists; qed");
let wasm_binary = get_wasm_binary_name(project_cargo_toml);
let wasm_project_folder = wasm_workspace.join(&crate_name);

fs::create_dir_all(project_folder.join("src"))
fs::create_dir_all(wasm_project_folder.join("src"))
.expect("Wasm project dir create can not fail; qed");

let mut enabled_features = project_enabled_features(&cargo_manifest, &crate_metadata);
let mut enabled_features = project_enabled_features(&project_cargo_toml, &crate_metadata);

if has_runtime_wasm_feature_declared(cargo_manifest, crate_metadata) {
if has_runtime_wasm_feature_declared(project_cargo_toml, crate_metadata) {
enabled_features.push("runtime-wasm".into());
}

create_project_cargo_toml(
&project_folder,
&wasm_project_folder,
workspace_root_path,
&crate_name,
&crate_path,
Expand All @@ -362,16 +364,16 @@ fn create_project(
);

write_file_if_changed(
project_folder.join("src/lib.rs"),
wasm_project_folder.join("src/lib.rs"),
"#![no_std] pub use wasm_project::*;",
);

if let Some(crate_lock_file) = find_cargo_lock(cargo_manifest) {
if let Some(crate_lock_file) = find_cargo_lock(project_cargo_toml) {
// Use the `Cargo.lock` of the main project.
crate::copy_file_if_changed(crate_lock_file, project_folder.join("Cargo.lock"));
crate::copy_file_if_changed(crate_lock_file, wasm_project_folder.join("Cargo.lock"));
}

project_folder
wasm_project_folder
}

/// Returns if the project should be built as a release.
Expand Down