-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce wasm binary size with
cargo-xbuild
& removing rlib
crate-t…
…ype (#33) * WIP: building wasm with xargo * Fix compilation errors * Fmt * Run commands with `rustup run nightly` * Pass separate link-args in rustflags for xargo compat * Warn user if 'rlib' crate type * Colourise printed error * Ignore Xargo.toml in template * Refactor Xargo file generation, only remove if generated. * WIP: Add rlib crate-type when generating metadata * Add rlib when building metadata, remove when building wasm * Fmt * Make error bright red * Fix generating without modified Cargo.toml * Don't need to check nightly installed, the command will fail * Only load toml when ready to modify: allow for multi usage * Fmt * Show error context * Debug crate metadata * Disable rlib by default for template * Use correct working dir, not workspace root * Use `cargo-xbuild` as lib * Check for nightly channel * Check for correct xbuild configuration * Add xbuild config to template * Fix xbuild config check and use latest xbuild version * Fmt * Restore tempfile dev dependency * Move xbuild config to the end of the file * Enable rlib by default in template * Don't need nightly for generating the metadata * Actually do need nightly, and just run plain cargo * Not verbose: need to pass that flag through properly * Fmt * Fix tests * Error when xbuild config not present, and update README * Fix tests * Remove references to xargo and update readmes * Fmt * Add error context to cargo invocation * Fix tests compilation * Fmt * Nightly toolchain for CI * Add docs for nightly toolchain requirement * Link to nightly docs * Disable backtrace on CI * Make tests pass * Install rust-src * Disable backtrace to make tests pass * Move args closer to invocation * Create temporary Cargo.toml * Rework temp manifest api * Target dir is already absolute * temp dir prefix * xbuild config with sysroot path and explicit args * Use custom xbuild branch * Remove check for xbuild config * Rewrite relatives paths when using temp file * Fix dependency path rewrite * Update cargo-xbuild * workspaces: parse workspace member manifests * WIP workspaces * Implement temp workspace copy * Fmt * Rewrite bin relative path * Handle package rename for contracts * Fmt * Pass rustflags by setting env var * Fmt * Use abs path for lib default * Add 1 decimal place to file size * Make generate-metadata work, introduces ManifestPath * Fmt * cargo update * Rename manifest to workspace * Fix test compilation and fmt * Fix link * Add prerequisites section to readme * Remove rust-src component (added to image) * Fix deploy build * Use builder like method for amending root manifest * List installed components * Show active-toolchain and whether rust-src installed * Install nightly rust-src (temporary) * Fix metadata test * Fmt * Remove manual install of rust-src and diagnostics * More doc comments * Add verbosity flags * Add verbosity flags to metadata command * Fix working dir for generate-metadata * Add verbosity to tests * Add verbosity to tests * Make url optional and cargo update * Remove bk file from gitignore * Bump version * Fix comment and formatting * Add CHANGELOG.md
- Loading branch information
Showing
17 changed files
with
1,200 additions
and
530 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Version 0.4.0 (2020-02-26) | ||
|
||
- Minimize contract wasm binary size: | ||
- Uses [`cargo-xbuild`](https://github.com/rust-osdev/cargo-xbuild) to build custom sysroot crates without panic string | ||
bloat. | ||
- Automatically removes the `rlib` crate type from `Cargo.toml`, removing redundant metadata. | ||
- Removes requirement for linker args specified in `.cargo/config`. | ||
- Added `--verbose` and `--quiet` flags for `build` and `generate-metadata` commands. |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "cargo-contract" | ||
version = "0.3.0" | ||
version = "0.4.0" | ||
authors = ["Parity Technologies <[email protected]>"] | ||
build = "build.rs" | ||
edition = "2018" | ||
|
@@ -27,14 +27,19 @@ cargo_metadata = "0.9.1" | |
codec = { package = "parity-scale-codec", version = "1.1" } | ||
which = "3.1.0" | ||
colored = "1.9" | ||
toml = "0.5.4" | ||
cargo-xbuild = "0.5.26" | ||
rustc_version = "0.2.3" | ||
serde_json = "1.0" | ||
tempfile = "3.1.0" | ||
|
||
# dependencies for optional extrinsics feature | ||
async-std = { version = "1.5.0", optional = true } | ||
sp-core = { git = "https://github.com/paritytech/substrate/", package = "sp-core", optional = true } | ||
subxt = { git = "https://github.com/paritytech/substrate-subxt/", rev = "b7565ff435b9499ca1ff4dad519009e94a13111c", package = "substrate-subxt", optional = true } | ||
futures = { version = "0.3.2", optional = true } | ||
url = { version = "2.1.1", optional = true } | ||
hex = { version = "0.4.0", optional = true } | ||
url = { version = "2.1.1", optional = true } | ||
|
||
[build-dependencies] | ||
anyhow = "1.0.26" | ||
|
@@ -43,10 +48,9 @@ walkdir = "2.3.1" | |
|
||
[dev-dependencies] | ||
assert_matches = "1.3.0" | ||
tempfile = "3.1.0" | ||
wabt = "0.9.2" | ||
|
||
[features] | ||
default = [] | ||
extrinsics = ["sp-core", "subxt", "async-std", "futures", "url", "hex"] | ||
extrinsics = ["sp-core", "subxt", "async-std", "futures", "hex", "url"] | ||
test-ci-only = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.