mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-22 14:55:41 +00:00
Only use substrate-wasm-builder when std feature is enabled. (#12790)
Co-authored-by: parity-processbot <>
This commit is contained in:
@@ -51,7 +51,7 @@ frame-system-benchmarking = { version = "4.0.0-dev", default-features = false, p
|
|||||||
pallet-template = { version = "4.0.0-dev", default-features = false, path = "../pallets/template" }
|
pallet-template = { version = "4.0.0-dev", default-features = false, path = "../pallets/template" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
substrate-wasm-builder = { version = "5.0.0-dev", path = "../../../utils/wasm-builder" }
|
substrate-wasm-builder = { version = "5.0.0-dev", path = "../../../utils/wasm-builder", optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
@@ -86,6 +86,7 @@ std = [
|
|||||||
"sp-std/std",
|
"sp-std/std",
|
||||||
"sp-transaction-pool/std",
|
"sp-transaction-pool/std",
|
||||||
"sp-version/std",
|
"sp-version/std",
|
||||||
|
"substrate-wasm-builder",
|
||||||
]
|
]
|
||||||
runtime-benchmarks = [
|
runtime-benchmarks = [
|
||||||
"frame-benchmarking/runtime-benchmarks",
|
"frame-benchmarking/runtime-benchmarks",
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
use substrate_wasm_builder::WasmBuilder;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
WasmBuilder::new()
|
#[cfg(feature = "std")]
|
||||||
.with_current_project()
|
{
|
||||||
.export_heap_base()
|
substrate_wasm_builder::WasmBuilder::new()
|
||||||
.import_memory()
|
.with_current_project()
|
||||||
.build()
|
.export_heap_base()
|
||||||
|
.import_memory()
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ pallet-vesting = { version = "4.0.0-dev", default-features = false, path = "../.
|
|||||||
pallet-whitelist = { version = "4.0.0-dev", default-features = false, path = "../../../frame/whitelist" }
|
pallet-whitelist = { version = "4.0.0-dev", default-features = false, path = "../../../frame/whitelist" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
substrate-wasm-builder = { version = "5.0.0-dev", path = "../../../utils/wasm-builder" }
|
substrate-wasm-builder = { version = "5.0.0-dev", path = "../../../utils/wasm-builder", optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
@@ -205,6 +205,7 @@ std = [
|
|||||||
"sp-io/std",
|
"sp-io/std",
|
||||||
"pallet-child-bounties/std",
|
"pallet-child-bounties/std",
|
||||||
"pallet-alliance/std",
|
"pallet-alliance/std",
|
||||||
|
"substrate-wasm-builder",
|
||||||
]
|
]
|
||||||
runtime-benchmarks = [
|
runtime-benchmarks = [
|
||||||
"frame-benchmarking/runtime-benchmarks",
|
"frame-benchmarking/runtime-benchmarks",
|
||||||
|
|||||||
@@ -15,12 +15,13 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use substrate_wasm_builder::WasmBuilder;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
WasmBuilder::new()
|
#[cfg(feature = "std")]
|
||||||
.with_current_project()
|
{
|
||||||
.export_heap_base()
|
substrate_wasm_builder::WasmBuilder::new()
|
||||||
.import_memory()
|
.with_current_project()
|
||||||
.build()
|
.export_heap_base()
|
||||||
|
.import_memory()
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ sp-runtime = { version = "7.0.0", default-features = false, path = "../../../pri
|
|||||||
sp-std = { version = "5.0.0", default-features = false, path = "../../../primitives/std" }
|
sp-std = { version = "5.0.0", default-features = false, path = "../../../primitives/std" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
substrate-wasm-builder = { version = "5.0.0-dev", path = "../../../utils/wasm-builder" }
|
substrate-wasm-builder = { version = "5.0.0-dev", path = "../../../utils/wasm-builder", optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
@@ -28,4 +28,5 @@ std = [
|
|||||||
"sp-io/std",
|
"sp-io/std",
|
||||||
"sp-runtime/std",
|
"sp-runtime/std",
|
||||||
"sp-std/std",
|
"sp-std/std",
|
||||||
|
"substrate-wasm-builder",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -16,22 +16,26 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use substrate_wasm_builder::WasmBuilder;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// regular build
|
// regular build
|
||||||
WasmBuilder::new()
|
#[cfg(feature = "std")]
|
||||||
.with_current_project()
|
{
|
||||||
.export_heap_base()
|
substrate_wasm_builder::WasmBuilder::new()
|
||||||
.import_memory()
|
.with_current_project()
|
||||||
.build();
|
.export_heap_base()
|
||||||
|
.import_memory()
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
// and building with tracing activated
|
// and building with tracing activated
|
||||||
WasmBuilder::new()
|
#[cfg(feature = "std")]
|
||||||
.with_current_project()
|
{
|
||||||
.export_heap_base()
|
substrate_wasm_builder::WasmBuilder::new()
|
||||||
.import_memory()
|
.with_current_project()
|
||||||
.set_file_name("wasm_binary_with_tracing.rs")
|
.export_heap_base()
|
||||||
.append_to_rust_flags(r#"--cfg feature="with-tracing""#)
|
.import_memory()
|
||||||
.build();
|
.set_file_name("wasm_binary_with_tracing.rs")
|
||||||
|
.append_to_rust_flags(r#"--cfg feature="with-tracing""#)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,14 @@ sp-runtime-interface = { version = "7.0.0", default-features = false, path = "..
|
|||||||
sp-std = { version = "5.0.0", default-features = false, path = "../../std" }
|
sp-std = { version = "5.0.0", default-features = false, path = "../../std" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
substrate-wasm-builder = { version = "5.0.0-dev", path = "../../../utils/wasm-builder" }
|
substrate-wasm-builder = { version = "5.0.0-dev", path = "../../../utils/wasm-builder", optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = [ "std" ]
|
default = [ "std" ]
|
||||||
std = [ "sp-core/std", "sp-io/std", "sp-runtime-interface/std", "sp-std/std" ]
|
std = [
|
||||||
|
"sp-core/std",
|
||||||
|
"sp-io/std",
|
||||||
|
"sp-runtime-interface/std",
|
||||||
|
"sp-std/std",
|
||||||
|
"substrate-wasm-builder",
|
||||||
|
]
|
||||||
|
|||||||
@@ -15,12 +15,13 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use substrate_wasm_builder::WasmBuilder;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
WasmBuilder::new()
|
#[cfg(feature = "std")]
|
||||||
.with_current_project()
|
{
|
||||||
.export_heap_base()
|
substrate_wasm_builder::WasmBuilder::new()
|
||||||
.import_memory()
|
.with_current_project()
|
||||||
.build()
|
.export_heap_base()
|
||||||
|
.import_memory()
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,14 @@ sp-runtime-interface = { version = "7.0.0", default-features = false, path = "..
|
|||||||
sp-std = { version = "5.0.0", default-features = false, path = "../../std" }
|
sp-std = { version = "5.0.0", default-features = false, path = "../../std" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
substrate-wasm-builder = { version = "5.0.0-dev", path = "../../../utils/wasm-builder" }
|
substrate-wasm-builder = { version = "5.0.0-dev", path = "../../../utils/wasm-builder", optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = [ "std" ]
|
default = [ "std" ]
|
||||||
std = [ "sp-core/std", "sp-io/std", "sp-runtime-interface/std", "sp-std/std" ]
|
std = [
|
||||||
|
"sp-core/std",
|
||||||
|
"sp-io/std",
|
||||||
|
"sp-runtime-interface/std",
|
||||||
|
"sp-std/std",
|
||||||
|
"substrate-wasm-builder",
|
||||||
|
]
|
||||||
|
|||||||
@@ -15,12 +15,13 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use substrate_wasm_builder::WasmBuilder;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
WasmBuilder::new()
|
#[cfg(feature = "std")]
|
||||||
.with_current_project()
|
{
|
||||||
.export_heap_base()
|
substrate_wasm_builder::WasmBuilder::new()
|
||||||
.import_memory()
|
.with_current_project()
|
||||||
.build()
|
.export_heap_base()
|
||||||
|
.import_memory()
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ substrate-test-runtime-client = { version = "2.0.0", path = "./client" }
|
|||||||
futures = "0.3.21"
|
futures = "0.3.21"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
substrate-wasm-builder = { version = "5.0.0-dev", path = "../../utils/wasm-builder" }
|
substrate-wasm-builder = { version = "5.0.0-dev", path = "../../utils/wasm-builder", optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = [
|
default = [
|
||||||
@@ -101,6 +101,7 @@ std = [
|
|||||||
"sp-trie/std",
|
"sp-trie/std",
|
||||||
"sp-transaction-pool/std",
|
"sp-transaction-pool/std",
|
||||||
"trie-db/std",
|
"trie-db/std",
|
||||||
|
"substrate-wasm-builder",
|
||||||
]
|
]
|
||||||
# Special feature to disable logging
|
# Special feature to disable logging
|
||||||
disable-logging = [ "sp-api/disable-logging" ]
|
disable-logging = [ "sp-api/disable-logging" ]
|
||||||
|
|||||||
@@ -15,24 +15,28 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use substrate_wasm_builder::WasmBuilder;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
WasmBuilder::new()
|
#[cfg(feature = "std")]
|
||||||
.with_current_project()
|
{
|
||||||
.export_heap_base()
|
substrate_wasm_builder::WasmBuilder::new()
|
||||||
// Note that we set the stack-size to 1MB explicitly even though it is set
|
.with_current_project()
|
||||||
// to this value by default. This is because some of our tests (`restoration_of_globals`)
|
.export_heap_base()
|
||||||
// depend on the stack-size.
|
// Note that we set the stack-size to 1MB explicitly even though it is set
|
||||||
.append_to_rust_flags("-Clink-arg=-zstack-size=1048576")
|
// to this value by default. This is because some of our tests
|
||||||
.import_memory()
|
// (`restoration_of_globals`) depend on the stack-size.
|
||||||
.build();
|
.append_to_rust_flags("-Clink-arg=-zstack-size=1048576")
|
||||||
|
.import_memory()
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
WasmBuilder::new()
|
#[cfg(feature = "std")]
|
||||||
.with_current_project()
|
{
|
||||||
.export_heap_base()
|
substrate_wasm_builder::WasmBuilder::new()
|
||||||
.import_memory()
|
.with_current_project()
|
||||||
.set_file_name("wasm_binary_logging_disabled.rs")
|
.export_heap_base()
|
||||||
.enable_feature("disable-logging")
|
.import_memory()
|
||||||
.build();
|
.set_file_name("wasm_binary_logging_disabled.rs")
|
||||||
|
.enable_feature("disable-logging")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,23 +8,24 @@ The Wasm builder is a tool that integrates the process of building the WASM bina
|
|||||||
A project that should be compiled as a Wasm binary needs to:
|
A project that should be compiled as a Wasm binary needs to:
|
||||||
|
|
||||||
1. Add a `build.rs` file.
|
1. Add a `build.rs` file.
|
||||||
2. Add `wasm-builder` as dependency into `build-dependencies`.
|
2. Add `wasm-builder` as dependency into `build-dependencies` (can be made optional and only enabled when `std` feature is used).
|
||||||
|
|
||||||
The `build.rs` file needs to contain the following code:
|
The `build.rs` file needs to contain the following code:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use substrate_wasm_builder::WasmBuilder;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
WasmBuilder::new()
|
#[cfg(feature = "std")]
|
||||||
// Tell the builder to build the project (crate) this `build.rs` is part of.
|
{
|
||||||
.with_current_project()
|
substrate_wasm_builder::WasmBuilder::new()
|
||||||
// Make sure to export the `heap_base` global, this is required by Substrate
|
// Tell the builder to build the project (crate) this `build.rs` is part of.
|
||||||
.export_heap_base()
|
.with_current_project()
|
||||||
// Build the Wasm file so that it imports the memory (need to be provided by at instantiation)
|
// Make sure to export the `heap_base` global, this is required by Substrate
|
||||||
.import_memory()
|
.export_heap_base()
|
||||||
// Build it.
|
// Build the Wasm file so that it imports the memory (need to be provided by at instantiation)
|
||||||
.build()
|
.import_memory()
|
||||||
|
// Build it.
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user