Add the code for compiling node-cli for WASM-browser (#3974)

* Extract CLI to separate module in node/cli

* Make node/cli compile for WASM

* More work on node/cli browser

* More work on browser node

* More work

* More work

* Purge a bit the CI script

* More clean up

* Remove substrate-finality-grandpa from the CI

Its tests use tokio, which fails to compile.

* Address review

* Add rocksdb feature to the service

* Fix substrate-service WASM CI

* Apply suggestions from code review

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Don't WASM-compile substrate-service altogether
This commit is contained in:
Pierre Krieger
2019-10-31 16:34:12 +01:00
committed by Gavin Wood
parent c0a1926704
commit 4264613a96
18 changed files with 687 additions and 224 deletions
+48 -8
View File
@@ -16,14 +16,15 @@ is-it-maintained-open-issues = { repository = "paritytech/substrate" }
[[bin]]
name = "substrate"
path = "bin/main.rs"
required-features = ["cli"]
[lib]
crate-type = ["cdylib", "rlib"]
[dependencies]
log = "0.4.8"
tokio = "0.1.22"
futures = "0.1.29"
exit-future = "0.1.4"
jsonrpc-core = "13.2.0"
cli = { package = "substrate-cli", path = "../../core/cli" }
codec = { package = "parity-scale-codec", version = "1.0.0" }
sr-io = { path = "../../core/sr-io" }
client = { package = "substrate-client", path = "../../core/client" }
@@ -35,7 +36,7 @@ node-primitives = { path = "../primitives" }
hex-literal = "0.2.1"
substrate-rpc = { package = "substrate-rpc", path = "../../core/rpc" }
substrate-basic-authorship = { path = "../../core/basic-authorship" }
substrate-service = { path = "../../core/service" }
substrate-service = { path = "../../core/service", default-features = false }
chain-spec = { package = "substrate-chain-spec", path = "../../core/chain-spec" }
transaction_pool = { package = "substrate-transaction-pool", path = "../../core/transaction-pool" }
network = { package = "substrate-network", path = "../../core/network" }
@@ -47,7 +48,6 @@ sr-primitives = { path = "../../core/sr-primitives" }
node-executor = { path = "../executor" }
substrate-telemetry = { package = "substrate-telemetry", path = "../../core/telemetry" }
structopt = "0.3.3"
transaction-factory = { path = "../../test-utils/transaction-factory" }
keyring = { package = "substrate-keyring", path = "../../core/keyring" }
indices = { package = "srml-indices", path = "../../srml/indices" }
timestamp = { package = "srml-timestamp", path = "../../srml/timestamp", default-features = false }
@@ -60,9 +60,26 @@ transaction-payment = { package = "srml-transaction-payment", path = "../../srml
support = { package = "srml-support", path = "../../srml/support", default-features = false }
im_online = { package = "srml-im-online", path = "../../srml/im-online", default-features = false }
serde = { version = "1.0.101", features = [ "derive" ] }
client_db = { package = "substrate-client-db", path = "../../core/client/db", features = ["kvdb-rocksdb"] }
client_db = { package = "substrate-client-db", path = "../../core/client/db", default-features = false }
offchain = { package = "substrate-offchain", path = "../../core/offchain" }
ctrlc = { version = "3.1.3", features = ["termination"] }
# CLI-specific dependencies
tokio = { version = "0.1.22", optional = true }
exit-future = { version = "0.1.4", optional = true }
substrate-cli = { path = "../../core/cli", optional = true }
transaction-factory = { path = "../../test-utils/transaction-factory", optional = true }
ctrlc = { version = "3.1.3", features = ["termination"], optional = true }
# WASM-specific dependencies
libp2p = { version = "0.12.0", default-features = false, optional = true }
clear_on_drop = { version = "0.2.3", features = ["no_cc"], optional = true } # Imported just for the `no_cc` feature
console_error_panic_hook = { version = "0.1.1", optional = true }
console_log = { version = "0.1.2", optional = true }
js-sys = { version = "0.3.22", optional = true }
wasm-bindgen = { version = "0.2.45", optional = true }
wasm-bindgen-futures = { version = "0.3.22", optional = true }
kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d", optional = true }
rand6 = { package = "rand", version = "0.6", features = ["wasm-bindgen"], optional = true } # Imported just for the `wasm-bindgen` feature
[dev-dependencies]
keystore = { package = "substrate-keystore", path = "../../core/keystore" }
@@ -73,6 +90,29 @@ futures03 = { package = "futures-preview", version = "0.3.0-alpha.19" }
tempfile = "3.1.0"
[build-dependencies]
cli = { package = "substrate-cli", path = "../../core/cli" }
substrate-cli = { package = "substrate-cli", path = "../../core/cli" }
structopt = "0.3.3"
vergen = "3.0.4"
[features]
default = ["cli"]
browser = [
"clear_on_drop",
"console_error_panic_hook",
"console_log",
"js-sys",
"libp2p",
"wasm-bindgen",
"wasm-bindgen-futures",
"kvdb-memorydb",
"rand/wasm-bindgen",
"rand6"
]
cli = [
"substrate-cli",
"transaction-factory",
"tokio",
"exit-future",
"ctrlc",
"substrate-service/rocksdb"
]