Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Improve build times by disabling wasm-builder in no_std (#2308)
Browse files Browse the repository at this point in the history
There is no need to compile wasm-builder in `no_std` as we skip the compilation of the crate any
way. So, we can also directly disable wasm-builder as dependency in `no_std` to improve build times.
  • Loading branch information
bkchr authored Mar 20, 2023
1 parent 7d722ec commit 5aeff50
Show file tree
Hide file tree
Showing 28 changed files with 239 additions and 75 deletions.
3 changes: 2 additions & 1 deletion parachain-template/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ edition = "2021"
targets = ["x86_64-unknown-linux-gnu"]

[build-dependencies]
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
Expand Down Expand Up @@ -121,6 +121,7 @@ std = [
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
"substrate-wasm-builder",
]

runtime-benchmarks = [
Expand Down
10 changes: 7 additions & 3 deletions parachain-template/runtime/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
use substrate_wasm_builder::WasmBuilder;

#[cfg(feature = "std")]
fn main() {
WasmBuilder::new()
substrate_wasm_builder::WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.build()
}

/// The wasm builder is deactivated when compiling
/// this crate for wasm to speed up the compilation.
#[cfg(not(feature = "std"))]
fn main() {}
3 changes: 2 additions & 1 deletion parachains/runtimes/assets/statemine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ assets-common = { path = "../common", default-features = false }
asset-test-utils = { path = "../test-utils"}

[build-dependencies]
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }

[features]
default = [ "std" ]
Expand Down Expand Up @@ -189,4 +189,5 @@ std = [
"parachain-info/std",
"parachains-common/std",
"assets-common/std",
"substrate-wasm-builder",
]
21 changes: 19 additions & 2 deletions parachains/runtimes/assets/statemine/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
use substrate_wasm_builder::WasmBuilder;
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#[cfg(feature = "std")]
fn main() {
WasmBuilder::new()
substrate_wasm_builder::WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.build()
}

#[cfg(not(feature = "std"))]
fn main() {}
3 changes: 2 additions & 1 deletion parachains/runtimes/assets/statemint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ hex-literal = "0.3.4"
asset-test-utils = { path = "../test-utils"}

[build-dependencies]
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }

[features]
default = [ "std" ]
Expand Down Expand Up @@ -179,4 +179,5 @@ std = [
"parachain-info/std",
"parachains-common/std",
"assets-common/std",
"substrate-wasm-builder",
]
21 changes: 19 additions & 2 deletions parachains/runtimes/assets/statemint/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
use substrate_wasm_builder::WasmBuilder;
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#[cfg(feature = "std")]
fn main() {
WasmBuilder::new()
substrate_wasm_builder::WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.build()
}

#[cfg(not(feature = "std"))]
fn main() {}
3 changes: 2 additions & 1 deletion parachains/runtimes/assets/westmint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ hex-literal = "0.3.4"
asset-test-utils = { path = "../test-utils"}

[build-dependencies]
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }

[features]
default = [ "std" ]
Expand Down Expand Up @@ -184,4 +184,5 @@ std = [
"parachain-info/std",
"parachains-common/std",
"assets-common/std",
"substrate-wasm-builder",
]
21 changes: 19 additions & 2 deletions parachains/runtimes/assets/westmint/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
use substrate_wasm_builder::WasmBuilder;
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#[cfg(feature = "std")]
fn main() {
WasmBuilder::new()
substrate_wasm_builder::WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.build()
}

#[cfg(not(feature = "std"))]
fn main() {}
3 changes: 2 additions & 1 deletion parachains/runtimes/bridge-hubs/bridge-hub-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
description = "Kusama's BridgeHub parachain runtime"

[build-dependencies]
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
Expand Down Expand Up @@ -126,6 +126,7 @@ std = [
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
"substrate-wasm-builder",
]

runtime-benchmarks = [
Expand Down
21 changes: 19 additions & 2 deletions parachains/runtimes/bridge-hubs/bridge-hub-kusama/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
use substrate_wasm_builder::WasmBuilder;
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#[cfg(feature = "std")]
fn main() {
WasmBuilder::new()
substrate_wasm_builder::WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.build()
}

#[cfg(not(feature = "std"))]
fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
description = "Polkadot's BridgeHub parachain runtime"

[build-dependencies]
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
Expand Down Expand Up @@ -126,6 +126,7 @@ std = [
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
"substrate-wasm-builder",
]

runtime-benchmarks = [
Expand Down
21 changes: 19 additions & 2 deletions parachains/runtimes/bridge-hubs/bridge-hub-polkadot/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
use substrate_wasm_builder::WasmBuilder;
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#[cfg(feature = "std")]
fn main() {
WasmBuilder::new()
substrate_wasm_builder::WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.build()
}

#[cfg(not(feature = "std"))]
fn main() {}
3 changes: 2 additions & 1 deletion parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
description = "Rococo's BridgeHub parachain runtime"

[build-dependencies]
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
Expand Down Expand Up @@ -126,6 +126,7 @@ std = [
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
"substrate-wasm-builder",
]

runtime-benchmarks = [
Expand Down
21 changes: 19 additions & 2 deletions parachains/runtimes/bridge-hubs/bridge-hub-rococo/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
use substrate_wasm_builder::WasmBuilder;
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#[cfg(feature = "std")]
fn main() {
WasmBuilder::new()
substrate_wasm_builder::WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.build()
}

#[cfg(not(feature = "std"))]
fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ parachains-common = { path = "../../../common", default-features = false }
hex-literal = "0.3.4"

[build-dependencies]
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }

[features]
default = [ "std" ]
Expand Down Expand Up @@ -170,4 +170,5 @@ std = [
"pallet-collator-selection/std",
"parachain-info/std",
"parachains-common/std",
"substrate-wasm-builder",
]
21 changes: 19 additions & 2 deletions parachains/runtimes/collectives/collectives-polkadot/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
use substrate_wasm_builder::WasmBuilder;
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#[cfg(feature = "std")]
fn main() {
WasmBuilder::new()
substrate_wasm_builder::WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.build()
}

#[cfg(not(feature = "std"))]
fn main() {}
3 changes: 2 additions & 1 deletion parachains/runtimes/contracts/contracts-rococo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
targets = ["x86_64-unknown-linux-gnu"]

[build-dependencies]
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
Expand Down Expand Up @@ -129,6 +129,7 @@ std = [
"cumulus-primitives-core/std",
"cumulus-primitives-timestamp/std",
"cumulus-primitives-utility/std",
"substrate-wasm-builder",
]

runtime-benchmarks = [
Expand Down
21 changes: 19 additions & 2 deletions parachains/runtimes/contracts/contracts-rococo/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
use substrate_wasm_builder::WasmBuilder;
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#[cfg(feature = "std")]
fn main() {
WasmBuilder::new()
substrate_wasm_builder::WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.build()
}

#[cfg(not(feature = "std"))]
fn main() {}
Loading

0 comments on commit 5aeff50

Please sign in to comment.