diff --git a/Cargo.lock b/Cargo.lock index 6804bd08c..2279393c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -181,10 +181,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "clicolors-control 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -205,10 +205,10 @@ dependencies = [ [[package]] name = "curl" -version = "0.4.18" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "curl-sys 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", + "curl-sys 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -220,7 +220,7 @@ dependencies = [ [[package]] name = "curl-sys" -version = "0.4.13" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", @@ -264,15 +264,15 @@ name = "failure_derive" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.18 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "filetime" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -389,11 +389,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "lazy_static" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "libc" @@ -493,7 +490,7 @@ dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.39 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -528,7 +525,7 @@ name = "os_type" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -572,7 +569,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -580,10 +577,10 @@ dependencies = [ [[package]] name = "quote" -version = "0.6.9" +version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -659,12 +656,12 @@ dependencies = [ [[package]] name = "regex" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -679,7 +676,7 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ucd-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -716,7 +713,7 @@ name = "schannel" version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -754,8 +751,8 @@ name = "serde_derive" version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.18 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -845,8 +842,8 @@ version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.18 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -855,8 +852,8 @@ name = "syn" version = "0.15.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -865,8 +862,8 @@ name = "synstructure" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.18 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -878,10 +875,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "tar" -version = "0.4.17" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "filetime 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "filetime 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", "xattr 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -957,7 +954,7 @@ name = "thread_local" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1047,14 +1044,14 @@ dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "cargo_metadata 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "console 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "curl 0.4.18 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", "dirs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "human-panic 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "indicatif 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "openssl 0.10.15 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1065,7 +1062,7 @@ dependencies = [ "slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog-term 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "structopt 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "tar 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)", + "tar 0.4.18 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "which 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1163,13 +1160,13 @@ dependencies = [ "checksum console 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ecd48adf136733979b49e15bc3b4c43cc0d3c85ece7bd08e6daa414c6fcb13e6" "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" "checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" -"checksum curl 0.4.18 (registry+https://github.com/rust-lang/crates.io-index)" = "a9e5285b49b44401518c947d3b808d14d99a538a6c9ffb3ec0205c11f9fc4389" -"checksum curl-sys 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)" = "08459503c415173da1ce6b41036a37b8bfdd86af46d45abb9964d4c61fe670ef" +"checksum curl 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)" = "c7c9d851c825e0c033979d4516c9173bc19a78a96eb4d6ae51d4045440eafa16" +"checksum curl-sys 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)" = "721c204978be2143fab0a84b708c49d79d1f6100b8785610f456043a90708870" "checksum dirs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "88972de891f6118092b643d85a0b28e0678e0f948d7f879aa32f2d5aafe97d2a" "checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02" "checksum failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6dd377bcc1b1b7ce911967e3ec24fa19c3224394ec05b54aa7b083d498341ac7" "checksum failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "64c2d913fe8ed3b6c6518eedf4538255b989945c14c2a7d5cbff62a5e2120596" -"checksum filetime 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "da4b9849e77b13195302c174324b5ba73eec9b236b24c221a61000daefb95c5f" +"checksum filetime 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6f57e64bf5eae62efd4efed005ae81a7115012a61f522bba54542e1a556af921" "checksum flate2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3b0c7353385f92079524de3b7116cf99d73947c08a7472774e9b3b04bff3b901" "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" "checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" @@ -1183,7 +1180,7 @@ dependencies = [ "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" -"checksum lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca488b89a5657b0a2ecd45b95609b3e848cf1755da332a0da46e2b2b1cb371a7" +"checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1" "checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d" "checksum libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "2eb5e43362e38e2bca2fd5f5134c4d4564a23a5c28e9b95411652021a8675ebe" "checksum lock_api 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "775751a3e69bde4df9b38dd00a1b5d6ac13791e4223d4a0506577f0dd27cfb7a" @@ -1205,8 +1202,8 @@ dependencies = [ "checksum parking_lot_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c" "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" "checksum podio 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "780fb4b6698bbf9cf2444ea5d22411cef2953f0824b98f33cf454ec5615645bd" -"checksum proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)" = "3d7b7eaaa90b4a90a932a9ea6666c95a389e424eff347f0f793979289429feee" -"checksum quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "63b5829244f52738cfee93b3a165c1911388675be000c888d2fae620dee8fa5b" +"checksum proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)" = "ab2fc21ba78ac73e4ff6b3818ece00be4e175ffbef4d0a717d978b48b24150c4" +"checksum quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c" "checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd" "checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c" "checksum rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1961a422c4d189dfb50ffa9320bf1f2a9bd54ecb92792fb9477f99a1045f3372" @@ -1215,9 +1212,9 @@ dependencies = [ "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum redox_users 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "214a97e49be64fd2c86f568dd0cb2c757d2cc53de95b273b6ad0a1c908482f26" "checksum regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384" -"checksum regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2069749032ea3ec200ca51e4a31df41759190a88edca0d2d86ee8bedf7073341" +"checksum regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ee84f70c8c08744ea9641a731c7fadb475bf2ecc52d7f627feb833e0b3990467" "checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7" -"checksum regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "747ba3b235651f6e2f67dfa8bcdcd073ddb7c243cb21c442fc12395dfcac212d" +"checksum regex-syntax 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fbc557aac2b708fe84121caf261346cc2eed71978024337e42eb46b8a252ac6e" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" @@ -1243,7 +1240,7 @@ dependencies = [ "checksum syn 0.15.18 (registry+https://github.com/rust-lang/crates.io-index)" = "90c39a061e2f412a9f869540471ab679e85e50c6b05604daf28bc3060f75c430" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" -"checksum tar 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)" = "83b0d14b53dbfd62681933fadd651e815f99e6084b649e049ab99296e05ab3de" +"checksum tar 0.4.18 (registry+https://github.com/rust-lang/crates.io-index)" = "89b518542272d9c12195e72885c7a4c142b89226f681bb129e4a922ba1b1ee74" "checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" "checksum tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "55c1195ef8513f3273d55ff59fe5da6940287a0d7a98331254397f464833675b" "checksum term 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5e6b677dd1e8214ea1ef4297f85dbcbed8e8cdddb561040cc998ca2551c37561" diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 69795d3bd..8471174f0 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -18,4 +18,5 @@ - [`src/utils.rs`](./tutorial/template-deep-dive/src-utils-rs.md) - [Packaging and Publishing](./tutorial/packaging-and-publishing.md) - [Using your Library](./tutorial/using-your-library.md) +- [`Cargo.toml` Configuration](./cargo-toml-configuration.md) - [Contributing](./contributing.md) diff --git a/docs/src/cargo-toml-configuration.md b/docs/src/cargo-toml-configuration.md new file mode 100644 index 000000000..48f65d172 --- /dev/null +++ b/docs/src/cargo-toml-configuration.md @@ -0,0 +1,29 @@ +# `Cargo.toml` Configuration + +`wasm-pack` can be configured via the `metadata.wasm-pack` key in +`Cargo.toml`. Every option has a default, and is not required. + +There are three profiles: `dev`, `profiling`, and `release`. These correspond to +the `--dev`, `--profiling`, and `--release` flags passed to `wasm-pack build`. + +The available configuration options and their default values are shown below: + +```toml +[metadata.wasm-pack.profile.dev.wasm-bindgen] +# Should we enable wasm-bindgen's debug assertions in its generated JS glue? +debug = true +# Should wasm-bindgen demangle the symbols in the "names" custom section? +demangle = true +# Should we keep the DWARF debug info custom sections? +keep-debug = false + +[metadata.wasm-pack.profile.profiling.wasm-bindgen] +debug = false +demangle = true +keep-debug = false + +[metadata.wasm-pack.profile.release.wasm-bindgen] +debug = false +demangle = true +keep-debug = false +``` diff --git a/docs/src/commands/build.md b/docs/src/commands/build.md index 028632bd7..884963b44 100644 --- a/docs/src/commands/build.md +++ b/docs/src/commands/build.md @@ -16,15 +16,28 @@ wasm-pack build examples/js-hello-world This path should point to a directory that contains a `Cargo.toml` file. If no path is given, the `build` command will run in the current directory. -## Debug +## Profile -The init command accepts an optional `--debug` argument. This will build the -output package using cargo's -[default non-release profile][cargo-profile-sections-documentation]. Building -this way is faster but applies few optimizations to the output, and enables -debug assertions and other runtime correctness checks. +The `build` command accepts an optional profile argument: one of `--dev`, +`--profiling`, or `--release`. If none is supplied, then `--release` is used. -The exact meaning of this flag may evolve as the platform matures. +Th controls whether debug assertions are enabled, debug info is generated, and +which (if any) optimizations are enabled. + +| Profile | Debug Assertions | Debug Info | Optimizations | Notes | +|---------------|------------------|------------|---------------|---------------------------------------| +| `--dev` | Yes | Yes | No | Useful for development and debugging. | +| `--profiling` | No | Yes | Yes | Useful when profiling and investigating performance issues. | +| `--release` | No | No | Yes | Useful for shipping to production. | + +The `--dev` profile will build the output package using cargo's [default +non-release profile][cargo-profile-sections-documentation]. Building this way is +faster but applies few optimizations to the output, and enables debug assertions +and other runtime correctness checks. The `--profiling` and `--release` profiles +use cargo's release profile, but the former enables debug info as well, which +helps when investigating performance issues in a profiler. + +The exact meaning of the profile flags may evolve as the platform matures. [cargo-profile-sections-documentation]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-profile-sections diff --git a/src/bindgen.rs b/src/bindgen.rs index 7cab450e4..ee9411bc1 100644 --- a/src/bindgen.rs +++ b/src/bindgen.rs @@ -2,6 +2,7 @@ use binaries::{Cache, Download}; use child; +use command::build::BuildProfile; use emoji; use failure::{self, ResultExt}; use manifest::CrateData; @@ -145,14 +146,17 @@ pub fn wasm_bindgen_build( out_dir: &Path, disable_dts: bool, target: &str, - debug: bool, + profile: BuildProfile, step: &Step, log: &Logger, ) -> Result<(), failure::Error> { let msg = format!("{}Running WASM-bindgen...", emoji::RUNNER); PBAR.step(step, &msg); - let release_or_debug = if debug { "debug" } else { "release" }; + let release_or_debug = match profile { + BuildProfile::Release | BuildProfile::Profiling => "release", + BuildProfile::Dev => "debug", + }; let out_dir = out_dir.to_str().unwrap(); @@ -181,9 +185,16 @@ pub fn wasm_bindgen_build( .arg(dts_arg) .arg(target_arg); - if debug { + let profile = data.configured_profile(profile); + if profile.wasm_bindgen_debug() { cmd.arg("--debug"); } + if !profile.wasm_bindgen_demangle() { + cmd.arg("--no-demangle"); + } + if profile.wasm_bindgen_keep_debug() { + cmd.arg("--keep-debug"); + } child::run(log, cmd, "wasm-bindgen").context("Running the wasm-bindgen CLI")?; Ok(()) diff --git a/src/build.rs b/src/build.rs index 327bf055c..4628d37ca 100644 --- a/src/build.rs +++ b/src/build.rs @@ -1,6 +1,7 @@ //! Building a Rust crate into a `.wasm` binary. use child; +use command::build::BuildProfile; use emoji; use failure::{Error, ResultExt}; use progressbar::Step; @@ -62,13 +63,32 @@ pub fn rustup_add_wasm_target(log: &Logger, step: &Step) -> Result<(), Error> { } /// Run `cargo build` targetting `wasm32-unknown-unknown`. -pub fn cargo_build_wasm(log: &Logger, path: &Path, debug: bool, step: &Step) -> Result<(), Error> { +pub fn cargo_build_wasm( + log: &Logger, + path: &Path, + profile: BuildProfile, + step: &Step, +) -> Result<(), Error> { let msg = format!("{}Compiling to WASM...", emoji::CYCLONE); PBAR.step(step, &msg); let mut cmd = Command::new("cargo"); cmd.current_dir(path).arg("build").arg("--lib"); - if !debug { - cmd.arg("--release"); + match profile { + BuildProfile::Profiling => { + // Once there are DWARF debug info consumers, force enable debug + // info, because builds that use the release cargo profile disables + // debug info. + // + // cmd.env("RUSTFLAGS", "-g"); + cmd.arg("--release"); + } + BuildProfile::Release => { + cmd.arg("--release"); + } + BuildProfile::Dev => { + // Plain cargo builds use the dev cargo profile, which includes + // debug info by default. + } } cmd.arg("--target").arg("wasm32-unknown-unknown"); child::run(log, cmd, "cargo build").context("Compiling your crate to WebAssembly failed")?; diff --git a/src/command/build.rs b/src/command/build.rs index 34c79f4d3..d3dc15f07 100644 --- a/src/command/build.rs +++ b/src/command/build.rs @@ -25,9 +25,8 @@ pub struct Build { pub scope: Option, pub disable_dts: bool, pub target: String, - pub debug: bool, + pub profile: BuildProfile, pub mode: BuildMode, - // build_config: Option, pub out_dir: PathBuf, pub bindgen: Option, pub cache: Cache, @@ -64,6 +63,18 @@ impl FromStr for BuildMode { } } +/// The build profile controls whether optimizations, debug info, and assertions +/// are enabled or disabled. +#[derive(Clone, Copy, Debug)] +pub enum BuildProfile { + /// Enable assertions and debug info. Disable optimizations. + Dev, + /// Enable optimizations. Disable assertions and debug info. + Release, + /// Enable optimizations and debug info. Disable assertions. + Profiling, +} + /// Everything required to configure and run the `wasm-pack build` command. #[derive(Debug, StructOpt)] pub struct BuildOptions { @@ -97,6 +108,14 @@ pub struct BuildOptions { /// optimizations. dev: bool, + #[structopt(long = "release")] + /// Create a release build. Enable optimizations and disable debug info. + release: bool, + + #[structopt(long = "profiling")] + /// Create a profiling build. Enable optimizations and debug info. + profiling: bool, + #[structopt(long = "out-dir", short = "d", default_value = "pkg")] /// Sets the output directory with a relative path. pub out_dir: String, @@ -110,16 +129,25 @@ impl Build { let crate_path = set_crate_path(build_opts.path)?; let crate_data = manifest::CrateData::new(&crate_path)?; let out_dir = crate_path.join(PathBuf::from(build_opts.out_dir)); - // let build_config = manifest::xxx(&crate_path).xxx(); + + let dev = build_opts.dev || build_opts.debug; + let profile = match (dev, build_opts.release, build_opts.profiling) { + (false, false, false) | (false, true, false) => BuildProfile::Release, + (true, false, false) => BuildProfile::Dev, + (false, false, true) => BuildProfile::Profiling, + // Unfortunately, `structopt` doesn't expose clap's `conflicts_with` + // functionality yet, so we have to implement it ourselves. + _ => bail!("Can only supply one of the --dev, --release, or --profiling flags"), + }; + Ok(Build { crate_path, crate_data, scope: build_opts.scope, disable_dts: build_opts.disable_dts, target: build_opts.target, - debug: build_opts.dev || build_opts.debug, + profile, mode: build_opts.mode, - // build_config, out_dir, bindgen: None, cache: Cache::new()?, @@ -227,7 +255,7 @@ impl Build { fn step_build_wasm(&mut self, step: &Step, log: &Logger) -> Result<(), Error> { info!(&log, "Building wasm..."); - build::cargo_build_wasm(log, &self.crate_path, self.debug, step)?; + build::cargo_build_wasm(log, &self.crate_path, self.profile, step)?; info!( &log, @@ -302,7 +330,7 @@ impl Build { &self.out_dir, self.disable_dts, &self.target, - self.debug, + self.profile, step, log, )?; diff --git a/src/manifest/mod.rs b/src/manifest/mod.rs index e418cd3f9..f631a63cf 100644 --- a/src/manifest/mod.rs +++ b/src/manifest/mod.rs @@ -2,13 +2,16 @@ mod npm; +use std::fmt; use std::fs; +use std::marker::PhantomData; use std::path::Path; use self::npm::{ repository::Repository, CommonJSPackage, ESModulesPackage, NoModulesPackage, NpmPackage, }; use cargo_metadata::Metadata; +use command::build::BuildProfile; use emoji; use failure::{Error, ResultExt}; use progressbar::Step; @@ -26,6 +29,9 @@ pub struct CrateData { #[derive(Deserialize)] struct CargoManifest { package: CargoPackage, + + #[serde(default)] + metadata: CargoMetadata, } #[derive(Deserialize)] @@ -36,6 +42,120 @@ struct CargoPackage { repository: Option, } +#[derive(Default, Deserialize)] +struct CargoMetadata { + #[serde(default, rename = "wasm-pack")] + wasm_pack: CargoWasmPack, +} + +#[derive(Default, Deserialize)] +struct CargoWasmPack { + #[serde(default)] + profile: CargoWasmPackProfiles, +} + +#[derive(Default, Deserialize)] +struct CargoWasmPackProfiles { + #[serde(default)] + dev: CargoWasmPackProfile, + + #[serde(default)] + release: CargoWasmPackProfile, + + #[serde(default)] + profiling: CargoWasmPackProfile, +} + +#[derive(Default, Deserialize)] +struct CargoWasmPackProfile { + // This is where configuration goes for wasm-bindgen, wasm-opt, wasm-snip, + // or anything else that wasm-pack runs. + #[serde(default, rename = "wasm-bindgen")] + wasm_bindgen: CargoWasmPackProfileWasmBindgen

, +} + +/// A set of pre-configured default values for a particular wasm-pack profile. +trait ProfileDefaults: fmt::Debug + Default { + fn wasm_bindgen_debug() -> bool { + false + } + + fn wasm_bindgen_demangle() -> bool { + true + } + + fn wasm_bindgen_keep_debug() -> bool { + false + } +} + +#[derive(Debug, Default, Deserialize)] +struct Dev; +impl ProfileDefaults for Dev { + fn wasm_bindgen_debug() -> bool { + true + } +} + +#[derive(Debug, Default, Deserialize)] +struct Release; +impl ProfileDefaults for Release {} + +#[derive(Debug, Default, Deserialize)] +struct Profiling; +impl ProfileDefaults for Profiling {} + +#[derive(Deserialize)] +struct CargoWasmPackProfileWasmBindgen { + #[serde(default = "P::wasm_bindgen_debug")] + debug: bool, + + #[serde(default = "P::wasm_bindgen_demangle")] + demangle: bool, + + #[serde(rename = "keep-debug", default = "P::wasm_bindgen_keep_debug")] + keep_debug: bool, + + #[serde(skip)] + _phantom: PhantomData

, +} + +impl Default for CargoWasmPackProfileWasmBindgen

{ + fn default() -> Self { + CargoWasmPackProfileWasmBindgen { + debug: P::wasm_bindgen_debug(), + demangle: P::wasm_bindgen_demangle(), + keep_debug: P::wasm_bindgen_keep_debug(), + _phantom: PhantomData, + } + } +} + +/// A configured profile with all info from the toml file overwriting the +/// pre-configured defaults. +pub trait ConfiguredProfile { + /// Should we supply the `--debug` flag to `wasm-bidngen` or not? + fn wasm_bindgen_debug(&self) -> bool; + /// Should we supply the `--no-demangle` flag to `wasm-bindgen` or not? + fn wasm_bindgen_demangle(&self) -> bool; + /// Should we supply the `--keep-debug` flag to `wasm-bindgen` or not? + fn wasm_bindgen_keep_debug(&self) -> bool; +} + +impl ConfiguredProfile for CargoWasmPackProfile

{ + fn wasm_bindgen_debug(&self) -> bool { + self.wasm_bindgen.debug + } + + fn wasm_bindgen_demangle(&self) -> bool { + self.wasm_bindgen.demangle + } + + fn wasm_bindgen_keep_debug(&self) -> bool { + self.wasm_bindgen.keep_debug + } +} + struct NpmData { name: String, files: Vec, @@ -88,6 +208,15 @@ impl CrateData { } } + /// Get the configured profile. + pub fn configured_profile(&self, profile: BuildProfile) -> &dyn ConfiguredProfile { + match profile { + BuildProfile::Dev => &self.manifest.metadata.wasm_pack.profile.dev, + BuildProfile::Profiling => &self.manifest.metadata.wasm_pack.profile.profiling, + BuildProfile::Release => &self.manifest.metadata.wasm_pack.profile.release, + } + } + /// Check that the crate the given path is properly configured. pub fn check_crate_config(&self, step: &Step) -> Result<(), Error> { let msg = format!("{}Checking crate configuration...", emoji::WRENCH); diff --git a/tests/all/build.rs b/tests/all/build.rs index 5757b8c26..1ed9356bf 100644 --- a/tests/all/build.rs +++ b/tests/all/build.rs @@ -1,3 +1,4 @@ +use std::fs; use std::path::Path; use structopt::StructOpt; use utils; @@ -138,3 +139,92 @@ fn it_should_build_nested_project_with_transitive_dependencies() { .unwrap(); fixture.run(cli.cmd).unwrap(); } + +#[test] +fn build_different_profiles() { + let fixture = utils::fixture::js_hello_world(); + fixture.install_local_wasm_bindgen(); + + for profile in ["--dev", "--debug", "--profiling", "--release"] + .iter() + .cloned() + { + let cli = Cli::from_iter_safe(vec![ + "wasm-pack", + "build", + profile, + &fixture.path.display().to_string(), + ]) + .unwrap(); + fixture.run(cli.cmd).unwrap(); + } +} + +#[test] +fn build_with_and_without_wasm_bindgen_debug() { + for debug in [true, false].iter().cloned() { + let fixture = utils::fixture::Fixture::new(); + fixture + .readme() + .file( + "Cargo.toml", + format!( + r#" + [package] + authors = ["The wasm-pack developers"] + description = "so awesome rust+wasm package" + license = "WTFPL" + name = "whatever" + repository = "https://github.com/rustwasm/wasm-pack.git" + version = "0.1.0" + + [lib] + crate-type = ["cdylib"] + + [dependencies] + wasm-bindgen = "0.2" + + [metadata.wasm-pack.profile.dev.wasm-bindgen] + debug = {} + "#, + debug + ), + ) + .file( + "src/lib.rs", + r#" + extern crate wasm_bindgen; + use wasm_bindgen::prelude::*; + + #[wasm_bindgen] + pub struct MyThing {} + + #[wasm_bindgen] + impl MyThing { + pub fn new() -> MyThing { + MyThing {} + } + + pub fn take(self) {} + } + "#, + ); + + let cli = Cli::from_iter_safe(vec![ + "wasm-pack", + "build", + "--dev", + &fixture.path.display().to_string(), + ]) + .unwrap(); + + fixture.run(cli.cmd).unwrap(); + + let contents = fs::read_to_string(fixture.path.join("pkg/whatever.js")).unwrap(); + assert_eq!( + contents.contains("throw new Error('Attempt to use a moved value')"), + debug, + "Should only contain moved value assertions when debug assertions are enabled" + ); + } +} diff --git a/tests/all/manifest.rs b/tests/all/manifest.rs index 2c60f7813..e2820aca9 100644 --- a/tests/all/manifest.rs +++ b/tests/all/manifest.rs @@ -2,8 +2,10 @@ use std::collections::HashSet; use std::fs; use std::path::PathBuf; +use structopt::StructOpt; + use utils::{self, fixture}; -use wasm_pack::{self, manifest}; +use wasm_pack::{self, manifest, Cli}; #[test] fn it_gets_the_crate_name_default_path() { @@ -286,3 +288,46 @@ fn it_does_not_error_when_wasm_bindgen_is_declared() { let step = wasm_pack::progressbar::Step::new(1); crate_data.check_crate_config(&step).unwrap(); } + +#[test] +fn configure_wasm_bindgen_debug_incorrectly_is_error() { + let fixture = utils::fixture::Fixture::new(); + fixture + .readme() + .file( + "Cargo.toml", + r#" + [package] + authors = ["The wasm-pack developers"] + description = "so awesome rust+wasm package" + license = "WTFPL" + name = "whatever" + repository = "https://github.com/rustwasm/wasm-pack.git" + version = "0.1.0" + + [lib] + crate-type = ["cdylib"] + + [dependencies] + wasm-bindgen = "0.2" + + [metadata.wasm-pack.profile.dev.wasm-bindgen] + debug = "not a boolean" + "#, + ) + .hello_world_src_lib(); + + let cli = Cli::from_iter_safe(vec![ + "wasm-pack", + "build", + "--dev", + &fixture.path.display().to_string(), + ]) + .unwrap(); + + let result = fixture.run(cli.cmd); + assert!(result.is_err()); + + let err = result.unwrap_err().to_string(); + assert!(err.contains("debug")); +}