Parcourir la source

refactor(cli): decouple bundler from cargo (#1269)

Lucas Fernandes Nogueira il y a 4 ans
Parent
commit
b1e6b74a4f

+ 5 - 0
.changes/bundle-decouple-cargo.md

@@ -0,0 +1,5 @@
+---
+"tauri-bundler": minor
+---
+
+The Tauri bundler is now a general purpose library instead of a Cargo custom subcommand.

+ 50 - 320
cli/core/Cargo.lock

@@ -39,15 +39,6 @@ dependencies = [
  "memchr 2.3.4",
 ]
 
-[[package]]
-name = "ansi_term"
-version = "0.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
-dependencies = [
- "winapi 0.3.9",
-]
-
 [[package]]
 name = "anyhow"
 version = "1.0.38"
@@ -92,12 +83,6 @@ dependencies = [
  "winapi 0.3.9",
 ]
 
-[[package]]
-name = "autocfg"
-version = "0.1.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2"
-
 [[package]]
 name = "autocfg"
 version = "1.0.1"
@@ -231,26 +216,11 @@ checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
 dependencies = [
  "libc",
  "num-integer",
- "num-traits 0.2.14",
+ "num-traits",
  "time",
  "winapi 0.3.9",
 ]
 
-[[package]]
-name = "clap"
-version = "2.33.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
-dependencies = [
- "ansi_term",
- "atty",
- "bitflags",
- "strsim 0.8.0",
- "textwrap 0.11.0",
- "unicode-width",
- "vec_map",
-]
-
 [[package]]
 name = "clap"
 version = "3.0.0-beta.2"
@@ -263,9 +233,9 @@ dependencies = [
  "indexmap",
  "lazy_static",
  "os_str_bytes",
- "strsim 0.10.0",
+ "strsim",
  "termcolor",
- "textwrap 0.12.1",
+ "textwrap",
  "unicode-width",
  "vec_map",
  "yaml-rust",
@@ -284,15 +254,6 @@ dependencies = [
  "syn",
 ]
 
-[[package]]
-name = "cloudabi"
-version = "0.0.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
-dependencies = [
- "bitflags",
-]
-
 [[package]]
 name = "color_quant"
 version = "1.1.0"
@@ -401,7 +362,7 @@ version = "0.8.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "02d96d1e189ef58269ebe5b97953da3274d83a93af647c2ddd6f9dab28cedb8d"
 dependencies = [
- "autocfg 1.0.1",
+ "autocfg",
  "cfg-if 1.0.0",
  "lazy_static",
 ]
@@ -426,7 +387,7 @@ dependencies = [
  "ident_case",
  "proc-macro2",
  "quote",
- "strsim 0.10.0",
+ "strsim",
  "syn",
 ]
 
@@ -490,12 +451,6 @@ dependencies = [
  "winapi 0.3.9",
 ]
 
-[[package]]
-name = "dtoa"
-version = "0.4.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "88d7ed2934d741c6b37e33e3832298e8850b53fd2d2bea03873375596c7cea4e"
-
 [[package]]
 name = "dyn-clone"
 version = "1.0.4"
@@ -606,12 +561,6 @@ dependencies = [
  "libc",
 ]
 
-[[package]]
-name = "fuchsia-cprng"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
-
 [[package]]
 name = "fuchsia-zircon"
 version = "0.3.3"
@@ -701,8 +650,8 @@ dependencies = [
  "pest",
  "pest_derive",
  "quick-error",
- "serde 1.0.123",
- "serde_json 1.0.62",
+ "serde",
+ "serde_json",
 ]
 
 [[package]]
@@ -743,7 +692,7 @@ checksum = "7245cd7449cc792608c3c8a9eaf69bd4eabbabf802713748fd739c98b82f0747"
 dependencies = [
  "bytes",
  "fnv",
- "itoa 0.4.7",
+ "itoa",
 ]
 
 [[package]]
@@ -786,7 +735,7 @@ dependencies = [
  "jpeg-decoder",
  "num-iter",
  "num-rational",
- "num-traits 0.2.14",
+ "num-traits",
  "png",
  "scoped_threadpool",
  "tiff",
@@ -798,7 +747,7 @@ version = "1.6.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b"
 dependencies = [
- "autocfg 1.0.1",
+ "autocfg",
  "hashbrown",
 ]
 
@@ -831,12 +780,6 @@ dependencies = [
  "libc",
 ]
 
-[[package]]
-name = "itoa"
-version = "0.3.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c"
-
 [[package]]
 name = "itoa"
 version = "0.4.7"
@@ -858,8 +801,8 @@ version = "0.2.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "f995a3c8f2bc3dd52a18a583e90f9ec109c047fa1603a853e46bcda14d2e279d"
 dependencies = [
- "serde 1.0.123",
- "serde_json 1.0.62",
+ "serde",
+ "serde_json",
  "treediff",
 ]
 
@@ -869,7 +812,7 @@ version = "0.3.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "5fe841b94e719a482213cee19dd04927cf412f26d8dc84c5a446c081e49c2997"
 dependencies = [
- "serde_json 1.0.62",
+ "serde_json",
 ]
 
 [[package]]
@@ -878,8 +821,8 @@ version = "2.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "effcb749443c905fbaef49d214f8b1049c240e0adb7af9baa0e201e625e4f9de"
 dependencies = [
- "serde 1.0.123",
- "serde_json 1.0.62",
+ "serde",
+ "serde_json",
 ]
 
 [[package]]
@@ -982,7 +925,7 @@ version = "0.6.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87"
 dependencies = [
- "autocfg 1.0.1",
+ "autocfg",
 ]
 
 [[package]]
@@ -1001,7 +944,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d"
 dependencies = [
  "adler",
- "autocfg 1.0.1",
+ "autocfg",
 ]
 
 [[package]]
@@ -1100,8 +1043,8 @@ version = "0.1.44"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
 dependencies = [
- "autocfg 1.0.1",
- "num-traits 0.2.14",
+ "autocfg",
+ "num-traits",
 ]
 
 [[package]]
@@ -1110,9 +1053,9 @@ version = "0.1.42"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59"
 dependencies = [
- "autocfg 1.0.1",
+ "autocfg",
  "num-integer",
- "num-traits 0.2.14",
+ "num-traits",
 ]
 
 [[package]]
@@ -1121,18 +1064,9 @@ version = "0.3.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07"
 dependencies = [
- "autocfg 1.0.1",
+ "autocfg",
  "num-integer",
- "num-traits 0.2.14",
-]
-
-[[package]]
-name = "num-traits"
-version = "0.1.43"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31"
-dependencies = [
- "num-traits 0.2.14",
+ "num-traits",
 ]
 
 [[package]]
@@ -1141,7 +1075,7 @@ version = "0.2.14"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
 dependencies = [
- "autocfg 1.0.1",
+ "autocfg",
 ]
 
 [[package]]
@@ -1204,7 +1138,7 @@ version = "0.9.60"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "921fc71883267538946025deffb622905ecad223c28efbfdef9bb59a0175f3e6"
 dependencies = [
- "autocfg 1.0.1",
+ "autocfg",
  "cc",
  "libc",
  "pkg-config",
@@ -1266,32 +1200,13 @@ dependencies = [
  "sha-1",
 ]
 
-[[package]]
-name = "phf"
-version = "0.7.24"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b3da44b85f8e8dfaec21adae67f95d93244b2ecf6ad2a692320598dcc8e6dd18"
-dependencies = [
- "phf_shared 0.7.24",
-]
-
 [[package]]
 name = "phf"
 version = "0.8.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12"
 dependencies = [
- "phf_shared 0.8.0",
-]
-
-[[package]]
-name = "phf_codegen"
-version = "0.7.24"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e"
-dependencies = [
- "phf_generator 0.7.24",
- "phf_shared 0.7.24",
+ "phf_shared",
 ]
 
 [[package]]
@@ -1300,18 +1215,8 @@ version = "0.8.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "cbffee61585b0411840d3ece935cce9cb6321f01c45477d30066498cd5e1a815"
 dependencies = [
- "phf_generator 0.8.0",
- "phf_shared 0.8.0",
-]
-
-[[package]]
-name = "phf_generator"
-version = "0.7.24"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662"
-dependencies = [
- "phf_shared 0.7.24",
- "rand 0.6.5",
+ "phf_generator",
+ "phf_shared",
 ]
 
 [[package]]
@@ -1320,26 +1225,17 @@ version = "0.8.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526"
 dependencies = [
- "phf_shared 0.8.0",
+ "phf_shared",
  "rand 0.7.3",
 ]
 
-[[package]]
-name = "phf_shared"
-version = "0.7.24"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0"
-dependencies = [
- "siphasher 0.2.3",
-]
-
 [[package]]
 name = "phf_shared"
 version = "0.8.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7"
 dependencies = [
- "siphasher 0.3.3",
+ "siphasher",
 ]
 
 [[package]]
@@ -1427,25 +1323,6 @@ dependencies = [
  "proc-macro2",
 ]
 
-[[package]]
-name = "rand"
-version = "0.6.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca"
-dependencies = [
- "autocfg 0.1.7",
- "libc",
- "rand_chacha 0.1.1",
- "rand_core 0.4.2",
- "rand_hc 0.1.0",
- "rand_isaac",
- "rand_jitter",
- "rand_os",
- "rand_pcg 0.1.2",
- "rand_xorshift",
- "winapi 0.3.9",
-]
-
 [[package]]
 name = "rand"
 version = "0.7.3"
@@ -1457,7 +1334,7 @@ dependencies = [
  "rand_chacha 0.2.2",
  "rand_core 0.5.1",
  "rand_hc 0.2.0",
- "rand_pcg 0.2.1",
+ "rand_pcg",
 ]
 
 [[package]]
@@ -1472,16 +1349,6 @@ dependencies = [
  "rand_hc 0.3.0",
 ]
 
-[[package]]
-name = "rand_chacha"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef"
-dependencies = [
- "autocfg 0.1.7",
- "rand_core 0.3.1",
-]
-
 [[package]]
 name = "rand_chacha"
 version = "0.2.2"
@@ -1502,21 +1369,6 @@ dependencies = [
  "rand_core 0.6.2",
 ]
 
-[[package]]
-name = "rand_core"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
-dependencies = [
- "rand_core 0.4.2",
-]
-
-[[package]]
-name = "rand_core"
-version = "0.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
-
 [[package]]
 name = "rand_core"
 version = "0.5.1"
@@ -1535,15 +1387,6 @@ dependencies = [
  "getrandom 0.2.2",
 ]
 
-[[package]]
-name = "rand_hc"
-version = "0.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4"
-dependencies = [
- "rand_core 0.3.1",
-]
-
 [[package]]
 name = "rand_hc"
 version = "0.2.0"
@@ -1562,50 +1405,6 @@ dependencies = [
  "rand_core 0.6.2",
 ]
 
-[[package]]
-name = "rand_isaac"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08"
-dependencies = [
- "rand_core 0.3.1",
-]
-
-[[package]]
-name = "rand_jitter"
-version = "0.1.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b"
-dependencies = [
- "libc",
- "rand_core 0.4.2",
- "winapi 0.3.9",
-]
-
-[[package]]
-name = "rand_os"
-version = "0.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071"
-dependencies = [
- "cloudabi",
- "fuchsia-cprng",
- "libc",
- "rand_core 0.4.2",
- "rdrand",
- "winapi 0.3.9",
-]
-
-[[package]]
-name = "rand_pcg"
-version = "0.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44"
-dependencies = [
- "autocfg 0.1.7",
- "rand_core 0.4.2",
-]
-
 [[package]]
 name = "rand_pcg"
 version = "0.2.1"
@@ -1615,22 +1414,13 @@ dependencies = [
  "rand_core 0.5.1",
 ]
 
-[[package]]
-name = "rand_xorshift"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c"
-dependencies = [
- "rand_core 0.3.1",
-]
-
 [[package]]
 name = "rayon"
 version = "1.5.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674"
 dependencies = [
- "autocfg 1.0.1",
+ "autocfg",
  "crossbeam-deque",
  "either",
  "rayon-core",
@@ -1649,15 +1439,6 @@ dependencies = [
  "num_cpus",
 ]
 
-[[package]]
-name = "rdrand"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
-dependencies = [
- "rand_core 0.3.1",
-]
-
 [[package]]
 name = "redox_syscall"
 version = "0.2.5"
@@ -1778,8 +1559,8 @@ checksum = "763f667253711994847f7e73befe859d6fff7bea2b7a7f01669d2c5b60765c37"
 dependencies = [
  "dyn-clone",
  "schemars_derive",
- "serde 1.0.123",
- "serde_json 1.0.62",
+ "serde",
+ "serde_json",
 ]
 
 [[package]]
@@ -1829,12 +1610,6 @@ dependencies = [
  "libc",
 ]
 
-[[package]]
-name = "serde"
-version = "0.9.15"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "34b623917345a631dc9608d5194cc206b3fe6c3554cd1c75b937e55e285254af"
-
 [[package]]
 name = "serde"
 version = "1.0.123"
@@ -1866,27 +1641,15 @@ dependencies = [
  "syn",
 ]
 
-[[package]]
-name = "serde_json"
-version = "0.9.10"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ad8bcf487be7d2e15d3d543f04312de991d631cfe1b43ea0ade69e6a8a5b16a1"
-dependencies = [
- "dtoa",
- "itoa 0.3.4",
- "num-traits 0.1.43",
- "serde 0.9.15",
-]
-
 [[package]]
 name = "serde_json"
 version = "1.0.62"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "ea1c6153794552ea7cf7cf63b1231a25de00ec90db326ba6264440fa08e31486"
 dependencies = [
- "itoa 0.4.7",
+ "itoa",
  "ryu",
- "serde 1.0.123",
+ "serde",
 ]
 
 [[package]]
@@ -1895,7 +1658,7 @@ version = "1.6.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "b44be9227e214a0420707c9ca74c2d4991d9955bae9415a8f93f05cebf561be5"
 dependencies = [
- "serde 1.0.123",
+ "serde",
  "serde_with_macros",
 ]
 
@@ -1952,12 +1715,6 @@ dependencies = [
  "winapi 0.3.9",
 ]
 
-[[package]]
-name = "siphasher"
-version = "0.2.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac"
-
 [[package]]
 name = "siphasher"
 version = "0.3.3"
@@ -1970,12 +1727,6 @@ version = "0.4.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
 
-[[package]]
-name = "strsim"
-version = "0.8.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
-
 [[package]]
 name = "strsim"
 version = "0.10.0"
@@ -2004,17 +1755,6 @@ dependencies = [
  "xattr",
 ]
 
-[[package]]
-name = "target_build_utils"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "013d134ae4a25ee744ad6129db589018558f620ddfa44043887cdd45fa08e75c"
-dependencies = [
- "phf 0.7.24",
- "phf_codegen 0.7.24",
- "serde_json 0.9.10",
-]
-
 [[package]]
 name = "tauri-bundler"
 version = "0.9.4"
@@ -2023,7 +1763,6 @@ dependencies = [
  "ar",
  "attohttpc",
  "chrono",
- "clap 2.33.3",
  "dirs-next",
  "glob",
  "handlebars",
@@ -2035,12 +1774,11 @@ dependencies = [
  "md5",
  "regex 1.4.3",
  "runas",
- "serde 1.0.123",
- "serde_json 1.0.62",
+ "serde",
+ "serde_json",
  "sha2",
- "strsim 0.10.0",
+ "strsim",
  "tar",
- "target_build_utils",
  "termcolor",
  "thiserror",
  "toml",
@@ -2054,17 +1792,18 @@ name = "tauri-cli"
 version = "0.1.0"
 dependencies = [
  "anyhow",
- "clap 3.0.0-beta.2",
+ "clap",
  "colored",
  "json-patch",
  "notify",
  "once_cell",
  "schemars",
- "serde 1.0.123",
- "serde_json 1.0.62",
+ "serde",
+ "serde_json",
  "serde_with",
  "shared_child",
  "tauri-bundler",
+ "toml",
  "toml_edit",
  "valico",
  "which 4.0.2",
@@ -2093,15 +1832,6 @@ dependencies = [
  "winapi-util",
 ]
 
-[[package]]
-name = "textwrap"
-version = "0.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
-dependencies = [
- "unicode-width",
-]
-
 [[package]]
 name = "textwrap"
 version = "0.12.1"
@@ -2201,7 +1931,7 @@ version = "0.5.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa"
 dependencies = [
- "serde 1.0.123",
+ "serde",
 ]
 
 [[package]]
@@ -2221,7 +1951,7 @@ version = "3.0.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "761e8d5ad7ce14bb82b7e61ccc0ca961005a275a060b9644a2431aa11553c2ff"
 dependencies = [
- "serde_json 1.0.62",
+ "serde_json",
 ]
 
 [[package]]
@@ -2329,12 +2059,12 @@ dependencies = [
  "json-pointer",
  "jsonway",
  "percent-encoding",
- "phf 0.8.0",
- "phf_codegen 0.8.0",
+ "phf",
+ "phf_codegen",
  "publicsuffix",
  "regex 1.4.3",
- "serde 1.0.123",
- "serde_json 1.0.62",
+ "serde",
+ "serde_json",
  "uritemplate",
  "url",
  "uuid",

+ 1 - 0
cli/core/Cargo.toml

@@ -24,6 +24,7 @@ shared_child = "0.3"
 toml_edit = "0.2"
 json-patch = "0.2"
 schemars = "0.8"
+toml = "0.5.8"
 valico = "3.5"
 
 [build-dependencies]

+ 38 - 35
cli/core/src/build.rs

@@ -1,7 +1,4 @@
-use tauri_bundler::{
-  build_project,
-  bundle::{bundle_project, PackageType, SettingsBuilder},
-};
+use tauri_bundler::bundle::{bundle_project, PackageType, SettingsBuilder};
 
 use crate::helpers::{
   app_paths::{app_dir, tauri_dir},
@@ -10,8 +7,11 @@ use crate::helpers::{
   manifest::rewrite_manifest,
   Logger, TauriScript,
 };
+
 use std::{env::set_current_dir, fs::File, io::Write, path::PathBuf, process::Command};
 
+mod rust;
+
 #[derive(Default)]
 pub struct Build {
   debug: bool,
@@ -49,34 +49,6 @@ impl Build {
     let logger = Logger::new("tauri:build");
     let config = get_config(self.config.as_deref())?;
 
-    let mut settings_builder = SettingsBuilder::new().features(vec!["embedded-server".to_string()]);
-    if !self.debug {
-      settings_builder = settings_builder.release();
-    }
-    if self.verbose {
-      settings_builder = settings_builder.verbose();
-    }
-    if let Some(names) = self.targets {
-      let mut types = vec![];
-      for name in names {
-        if name == "none" {
-          break;
-        }
-        match PackageType::from_short_name(&name) {
-          Some(package_type) => {
-            types.push(package_type);
-          }
-          None => {
-            return Err(anyhow::anyhow!(format!(
-              "Unsupported bundle format: {}",
-              name
-            )));
-          }
-        }
-      }
-      settings_builder = settings_builder.package_types(types);
-    }
-
     let tauri_path = tauri_dir();
     set_current_dir(&tauri_path)?;
 
@@ -93,8 +65,6 @@ impl Build {
     let mut tauri_script_file = File::create(tauri_script_path)?;
     tauri_script_file.write_all(tauri_script.as_bytes())?;
 
-    let settings = settings_builder.build()?;
-
     if let Some(before_build) = &config_.build.before_build_command {
       let mut cmd: Option<&str> = None;
       let mut args: Vec<&str> = vec![];
@@ -119,10 +89,43 @@ impl Build {
       }
     }
 
-    build_project(&settings)?;
+    rust::build_project(self.debug)?;
+
     if config_.tauri.bundle.active {
+      let bundler_settings = rust::get_bundler_settings(&config_, self.debug)?;
+      let mut settings_builder = SettingsBuilder::new()
+        .package_settings(bundler_settings.package_settings)
+        .bundle_settings(bundler_settings.bundle_settings)
+        .binaries(bundler_settings.binaries)
+        .project_out_directory(bundler_settings.out_dir);
+
+      if self.verbose {
+        settings_builder = settings_builder.verbose();
+      }
+      if let Some(names) = self.targets {
+        let mut types = vec![];
+        for name in names {
+          if name == "none" {
+            break;
+          }
+          match PackageType::from_short_name(&name) {
+            Some(package_type) => {
+              types.push(package_type);
+            }
+            None => {
+              return Err(anyhow::anyhow!(format!(
+                "Unsupported bundle format: {}",
+                name
+              )));
+            }
+          }
+        }
+        settings_builder = settings_builder.package_types(types);
+      }
+      let settings = settings_builder.build()?;
       bundle_project(settings)?;
     }
+
     Ok(())
   }
 }

+ 252 - 0
cli/core/src/build/rust.rs

@@ -0,0 +1,252 @@
+use std::{fs::File, io::Read, path::PathBuf, process::Command, str::FromStr};
+
+use serde::Deserialize;
+
+use crate::helpers::{app_paths::tauri_dir, config::Config};
+use tauri_bundler::{AppCategory, BundleBinary, BundleSettings, PackageSettings};
+
+/// The `workspace` section of the app configuration (read from Cargo.toml).
+#[derive(Clone, Debug, Deserialize)]
+struct WorkspaceSettings {
+  /// the workspace members.
+  members: Option<Vec<String>>,
+}
+
+#[derive(Clone, Debug, Deserialize)]
+struct BinarySettings {
+  name: String,
+  path: Option<String>,
+}
+
+/// The Cargo settings (Cargo.toml root descriptor).
+#[derive(Clone, Debug, Deserialize)]
+struct CargoSettings {
+  /// the package settings.
+  ///
+  /// it's optional because ancestor workspace Cargo.toml files may not have package info.
+  package: Option<PackageSettings>,
+  /// the workspace settings.
+  ///
+  /// it's present if the read Cargo.toml belongs to a workspace root.
+  workspace: Option<WorkspaceSettings>,
+  /// the binary targets configuration.
+  bin: Option<Vec<BinarySettings>>,
+}
+
+impl CargoSettings {
+  /// Try to load a set of CargoSettings from a "Cargo.toml" file in the specified directory.
+  fn load(dir: &PathBuf) -> crate::Result<Self> {
+    let toml_path = dir.join("Cargo.toml");
+    let mut toml_str = String::new();
+    let mut toml_file = File::open(toml_path)?;
+    toml_file.read_to_string(&mut toml_str)?;
+    toml::from_str(&toml_str).map_err(Into::into)
+  }
+}
+
+#[derive(Deserialize)]
+struct CargoBuildConfig {
+  #[serde(rename = "target-dir")]
+  target_dir: Option<String>,
+}
+
+#[derive(Deserialize)]
+struct CargoConfig {
+  build: Option<CargoBuildConfig>,
+}
+
+pub fn build_project(debug: bool) -> crate::Result<()> {
+  let mut args = vec!["build", "--features=embedded-server"];
+
+  if !debug {
+    args.push("--release");
+  }
+
+  let status = Command::new("cargo").args(args).status()?;
+  if !status.success() {
+    return Err(anyhow::anyhow!(format!(
+      "Result of `cargo build` operation was unsuccessful: {}",
+      status
+    )));
+  }
+
+  Ok(())
+}
+
+pub struct BundlerSettings {
+  pub package_settings: PackageSettings,
+  pub bundle_settings: BundleSettings,
+  pub binaries: Vec<BundleBinary>,
+  pub out_dir: PathBuf,
+}
+
+pub fn get_bundler_settings(config: &Config, debug: bool) -> crate::Result<BundlerSettings> {
+  let tauri_dir = tauri_dir();
+  let cargo_settings = CargoSettings::load(&tauri_dir)?;
+
+  let package = match cargo_settings.package {
+    Some(package_info) => package_info,
+    None => {
+      return Err(anyhow::anyhow!(
+        "No package info in the config file".to_owned(),
+      ))
+    }
+  };
+  let workspace_dir = get_workspace_dir(&tauri_dir);
+  let target_dir = get_target_dir(&workspace_dir, None, !debug)?;
+  let bundle_settings = tauri_config_to_bundle_settings(config.tauri.bundle.clone())?;
+
+  let mut binaries: Vec<BundleBinary> = vec![];
+  if let Some(bin) = cargo_settings.bin {
+    let default_run = package
+      .default_run
+      .clone()
+      .unwrap_or_else(|| "".to_string());
+    for binary in bin {
+      binaries.push(
+        BundleBinary::new(
+          binary.name.clone(),
+          binary.name.as_str() == package.name || binary.name.as_str() == default_run,
+        )
+        .set_src_path(binary.path),
+      )
+    }
+  }
+
+  let mut bins_path = tauri_dir;
+  bins_path.push("src/bin");
+  if let Ok(fs_bins) = std::fs::read_dir(bins_path) {
+    for entry in fs_bins {
+      let path = entry?.path();
+      if let Some(name) = path.file_stem() {
+        let bin_exists = binaries.iter().any(|bin| {
+          bin.name() == name || path.ends_with(bin.src_path().as_ref().unwrap_or(&"".to_string()))
+        });
+        if !bin_exists {
+          binaries.push(BundleBinary::new(name.to_string_lossy().to_string(), false))
+        }
+      }
+    }
+  }
+
+  if let Some(default_run) = package.default_run.as_ref() {
+    if !binaries.iter().any(|bin| bin.name() == default_run) {
+      binaries.push(BundleBinary::new(default_run.to_string(), true));
+    }
+  }
+
+  if binaries.len() == 1 {
+    binaries.get_mut(0).unwrap().set_main(true);
+  }
+
+  Ok(BundlerSettings {
+    package_settings: package,
+    bundle_settings,
+    binaries,
+    out_dir: target_dir,
+  })
+}
+
+/// This function determines where 'target' dir is and suffixes it with 'release' or 'debug'
+/// to determine where the compiled binary will be located.
+fn get_target_dir(
+  project_root_dir: &PathBuf,
+  target: Option<String>,
+  is_release: bool,
+) -> crate::Result<PathBuf> {
+  let mut path: PathBuf = match std::env::var_os("CARGO_TARGET_DIR") {
+    Some(target_dir) => target_dir.into(),
+    None => {
+      let mut root_dir = project_root_dir.clone();
+      let target_path: Option<PathBuf> = loop {
+        // cargo reads configs under .cargo/config.toml or .cargo/config
+        let mut cargo_config_path = root_dir.join(".cargo/config");
+        if !cargo_config_path.exists() {
+          cargo_config_path = root_dir.join(".cargo/config.toml");
+        }
+        // if the path exists, parse it
+        if cargo_config_path.exists() {
+          let mut config_str = String::new();
+          let mut config_file = File::open(cargo_config_path)?;
+          config_file.read_to_string(&mut config_str)?;
+          let config: CargoConfig = toml::from_str(&config_str)?;
+          if let Some(build) = config.build {
+            if let Some(target_dir) = build.target_dir {
+              break Some(target_dir.into());
+            }
+          }
+        }
+        if !root_dir.pop() {
+          break None;
+        }
+      };
+      target_path.unwrap_or_else(|| project_root_dir.join("target"))
+    }
+  };
+
+  if let Some(ref triple) = target {
+    path.push(triple);
+  }
+  path.push(if is_release { "release" } else { "debug" });
+  Ok(path)
+}
+
+/// Walks up the file system, looking for a Cargo.toml file
+/// If one is found before reaching the root, then the current_dir's package belongs to that parent workspace if it's listed on [workspace.members].
+///
+/// If this package is part of a workspace, returns the path to the workspace directory
+/// Otherwise returns the current directory.
+pub fn get_workspace_dir(current_dir: &PathBuf) -> PathBuf {
+  let mut dir = current_dir.clone();
+  let project_path = current_dir.clone();
+
+  while dir.pop() {
+    if let Ok(cargo_settings) = CargoSettings::load(&dir) {
+      if let Some(workspace_settings) = cargo_settings.workspace {
+        if let Some(members) = workspace_settings.members {
+          if members
+            .iter()
+            .any(|member| dir.join(member) == project_path)
+          {
+            return dir;
+          }
+        }
+      }
+    }
+  }
+
+  // Nothing found walking up the file system, return the starting directory
+  current_dir.clone()
+}
+
+fn tauri_config_to_bundle_settings(
+  config: crate::helpers::config::BundleConfig,
+) -> crate::Result<BundleSettings> {
+  Ok(BundleSettings {
+    name: config.name,
+    identifier: config.identifier,
+    icon: config.icon,
+    version: config.version,
+    resources: config.resources,
+    copyright: config.copyright,
+    category: match config.category {
+      Some(category) => Some(AppCategory::from_str(&category).map_err(|e| match e {
+        Some(e) => anyhow::anyhow!("invalid category, did you mean `{}`?", e),
+        None => anyhow::anyhow!("invalid category"),
+      })?),
+      None => None,
+    },
+    short_description: config.short_description,
+    long_description: config.long_description,
+    script: config.script,
+    deb_depends: config.deb.depends,
+    deb_use_bootstrapper: Some(config.deb.use_bootstrapper),
+    osx_frameworks: config.osx.frameworks,
+    osx_minimum_system_version: config.osx.minimum_system_version,
+    osx_license: config.osx.license,
+    osx_use_bootstrapper: Some(config.osx.use_bootstrapper),
+    external_bin: config.external_bin,
+    exception_domain: config.osx.exception_domain,
+    ..Default::default()
+  })
+}

+ 30 - 324
cli/tauri-bundler/Cargo.lock

@@ -30,15 +30,6 @@ dependencies = [
  "memchr",
 ]
 
-[[package]]
-name = "ansi_term"
-version = "0.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
-dependencies = [
- "winapi",
-]
-
 [[package]]
 name = "anyhow"
 version = "1.0.33"
@@ -66,23 +57,6 @@ dependencies = [
  "wildmatch",
 ]
 
-[[package]]
-name = "atty"
-version = "0.2.14"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
-dependencies = [
- "hermit-abi",
- "libc",
- "winapi",
-]
-
-[[package]]
-name = "autocfg"
-version = "0.1.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2"
-
 [[package]]
 name = "autocfg"
 version = "1.0.1"
@@ -210,35 +184,11 @@ checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
 dependencies = [
  "libc",
  "num-integer",
- "num-traits 0.2.12",
+ "num-traits",
  "time",
  "winapi",
 ]
 
-[[package]]
-name = "clap"
-version = "2.33.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
-dependencies = [
- "ansi_term",
- "atty",
- "bitflags",
- "strsim 0.8.0",
- "textwrap",
- "unicode-width",
- "vec_map",
-]
-
-[[package]]
-name = "cloudabi"
-version = "0.0.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
-dependencies = [
- "bitflags",
-]
-
 [[package]]
 name = "color_quant"
 version = "1.1.0"
@@ -303,7 +253,7 @@ version = "0.8.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace"
 dependencies = [
- "autocfg 1.0.1",
+ "autocfg",
  "cfg-if 0.1.10",
  "crossbeam-utils",
  "lazy_static",
@@ -318,7 +268,7 @@ version = "0.7.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
 dependencies = [
- "autocfg 1.0.1",
+ "autocfg",
  "cfg-if 0.1.10",
  "lazy_static",
 ]
@@ -372,12 +322,6 @@ dependencies = [
  "winapi",
 ]
 
-[[package]]
-name = "dtoa"
-version = "0.4.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "134951f4028bdadb9b84baf4232681efbf277da25144b9b0ad65df75946c422b"
-
 [[package]]
 name = "either"
 version = "1.6.1"
@@ -444,12 +388,6 @@ version = "0.1.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
 
-[[package]]
-name = "fuchsia-cprng"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
-
 [[package]]
 name = "generic-array"
 version = "0.12.3"
@@ -512,8 +450,8 @@ dependencies = [
  "pest",
  "pest_derive",
  "quick-error",
- "serde 1.0.117",
- "serde_json 1.0.59",
+ "serde",
+ "serde_json",
 ]
 
 [[package]]
@@ -539,7 +477,7 @@ checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9"
 dependencies = [
  "bytes",
  "fnv",
- "itoa 0.4.6",
+ "itoa",
 ]
 
 [[package]]
@@ -576,18 +514,12 @@ dependencies = [
  "jpeg-decoder",
  "num-iter",
  "num-rational",
- "num-traits 0.2.12",
+ "num-traits",
  "png",
  "scoped_threadpool",
  "tiff",
 ]
 
-[[package]]
-name = "itoa"
-version = "0.3.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c"
-
 [[package]]
 name = "itoa"
 version = "0.4.6"
@@ -679,7 +611,7 @@ version = "0.5.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa"
 dependencies = [
- "autocfg 1.0.1",
+ "autocfg",
 ]
 
 [[package]]
@@ -698,7 +630,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d"
 dependencies = [
  "adler",
- "autocfg 1.0.1",
+ "autocfg",
 ]
 
 [[package]]
@@ -725,8 +657,8 @@ version = "0.1.43"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b"
 dependencies = [
- "autocfg 1.0.1",
- "num-traits 0.2.12",
+ "autocfg",
+ "num-traits",
 ]
 
 [[package]]
@@ -735,9 +667,9 @@ version = "0.1.41"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "7a6e6b7c748f995c4c29c5f5ae0248536e04a5739927c74ec0fa564805094b9f"
 dependencies = [
- "autocfg 1.0.1",
+ "autocfg",
  "num-integer",
- "num-traits 0.2.12",
+ "num-traits",
 ]
 
 [[package]]
@@ -746,18 +678,9 @@ version = "0.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "a5b4d7360f362cfb50dde8143501e6940b22f644be75a4cc90b2d81968908138"
 dependencies = [
- "autocfg 1.0.1",
+ "autocfg",
  "num-integer",
- "num-traits 0.2.12",
-]
-
-[[package]]
-name = "num-traits"
-version = "0.1.43"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31"
-dependencies = [
- "num-traits 0.2.12",
+ "num-traits",
 ]
 
 [[package]]
@@ -766,7 +689,7 @@ version = "0.2.12"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611"
 dependencies = [
- "autocfg 1.0.1",
+ "autocfg",
 ]
 
 [[package]]
@@ -823,7 +746,7 @@ version = "0.9.58"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "a842db4709b604f0fe5d1170ae3565899be2ad3d9cbc72dedc789ac0511f78de"
 dependencies = [
- "autocfg 1.0.1",
+ "autocfg",
  "cc",
  "libc",
  "pkg-config",
@@ -879,44 +802,6 @@ dependencies = [
  "sha-1",
 ]
 
-[[package]]
-name = "phf"
-version = "0.7.24"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b3da44b85f8e8dfaec21adae67f95d93244b2ecf6ad2a692320598dcc8e6dd18"
-dependencies = [
- "phf_shared",
-]
-
-[[package]]
-name = "phf_codegen"
-version = "0.7.24"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e"
-dependencies = [
- "phf_generator",
- "phf_shared",
-]
-
-[[package]]
-name = "phf_generator"
-version = "0.7.24"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662"
-dependencies = [
- "phf_shared",
- "rand 0.6.5",
-]
-
-[[package]]
-name = "phf_shared"
-version = "0.7.24"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0"
-dependencies = [
- "siphasher",
-]
-
 [[package]]
 name = "pkg-config"
 version = "0.3.19"
@@ -965,25 +850,6 @@ dependencies = [
  "proc-macro2",
 ]
 
-[[package]]
-name = "rand"
-version = "0.6.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca"
-dependencies = [
- "autocfg 0.1.7",
- "libc",
- "rand_chacha 0.1.1",
- "rand_core 0.4.2",
- "rand_hc 0.1.0",
- "rand_isaac",
- "rand_jitter",
- "rand_os",
- "rand_pcg",
- "rand_xorshift",
- "winapi",
-]
-
 [[package]]
 name = "rand"
 version = "0.7.3"
@@ -992,19 +858,9 @@ checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
 dependencies = [
  "getrandom",
  "libc",
- "rand_chacha 0.2.2",
- "rand_core 0.5.1",
- "rand_hc 0.2.0",
-]
-
-[[package]]
-name = "rand_chacha"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef"
-dependencies = [
- "autocfg 0.1.7",
- "rand_core 0.3.1",
+ "rand_chacha",
+ "rand_core",
+ "rand_hc",
 ]
 
 [[package]]
@@ -1014,24 +870,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
 dependencies = [
  "ppv-lite86",
- "rand_core 0.5.1",
-]
-
-[[package]]
-name = "rand_core"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
-dependencies = [
- "rand_core 0.4.2",
+ "rand_core",
 ]
 
-[[package]]
-name = "rand_core"
-version = "0.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
-
 [[package]]
 name = "rand_core"
 version = "0.5.1"
@@ -1041,75 +882,13 @@ dependencies = [
  "getrandom",
 ]
 
-[[package]]
-name = "rand_hc"
-version = "0.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4"
-dependencies = [
- "rand_core 0.3.1",
-]
-
 [[package]]
 name = "rand_hc"
 version = "0.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
 dependencies = [
- "rand_core 0.5.1",
-]
-
-[[package]]
-name = "rand_isaac"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08"
-dependencies = [
- "rand_core 0.3.1",
-]
-
-[[package]]
-name = "rand_jitter"
-version = "0.1.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b"
-dependencies = [
- "libc",
- "rand_core 0.4.2",
- "winapi",
-]
-
-[[package]]
-name = "rand_os"
-version = "0.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071"
-dependencies = [
- "cloudabi",
- "fuchsia-cprng",
- "libc",
- "rand_core 0.4.2",
- "rdrand",
- "winapi",
-]
-
-[[package]]
-name = "rand_pcg"
-version = "0.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44"
-dependencies = [
- "autocfg 0.1.7",
- "rand_core 0.4.2",
-]
-
-[[package]]
-name = "rand_xorshift"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c"
-dependencies = [
- "rand_core 0.3.1",
+ "rand_core",
 ]
 
 [[package]]
@@ -1118,7 +897,7 @@ version = "1.4.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "dcf6960dc9a5b4ee8d3e4c5787b4a112a8818e0290a42ff664ad60692fdf2032"
 dependencies = [
- "autocfg 1.0.1",
+ "autocfg",
  "crossbeam-deque",
  "either",
  "rayon-core",
@@ -1137,15 +916,6 @@ dependencies = [
  "num_cpus",
 ]
 
-[[package]]
-name = "rdrand"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
-dependencies = [
- "rand_core 0.3.1",
-]
-
 [[package]]
 name = "redox_syscall"
 version = "0.1.57"
@@ -1271,12 +1041,6 @@ dependencies = [
  "libc",
 ]
 
-[[package]]
-name = "serde"
-version = "0.9.15"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "34b623917345a631dc9608d5194cc206b3fe6c3554cd1c75b937e55e285254af"
-
 [[package]]
 name = "serde"
 version = "1.0.117"
@@ -1297,27 +1061,15 @@ dependencies = [
  "syn",
 ]
 
-[[package]]
-name = "serde_json"
-version = "0.9.10"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ad8bcf487be7d2e15d3d543f04312de991d631cfe1b43ea0ade69e6a8a5b16a1"
-dependencies = [
- "dtoa",
- "itoa 0.3.4",
- "num-traits 0.1.43",
- "serde 0.9.15",
-]
-
 [[package]]
 name = "serde_json"
 version = "1.0.59"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "dcac07dbffa1c65e7f816ab9eba78eb142c6d44410f4eeba1e26e4f5dfa56b95"
 dependencies = [
- "itoa 0.4.6",
+ "itoa",
  "ryu",
- "serde 1.0.117",
+ "serde",
 ]
 
 [[package]]
@@ -1351,18 +1103,6 @@ dependencies = [
  "opaque-debug 0.3.0",
 ]
 
-[[package]]
-name = "siphasher"
-version = "0.2.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac"
-
-[[package]]
-name = "strsim"
-version = "0.8.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
-
 [[package]]
 name = "strsim"
 version = "0.10.0"
@@ -1392,17 +1132,6 @@ dependencies = [
  "xattr",
 ]
 
-[[package]]
-name = "target_build_utils"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "013d134ae4a25ee744ad6129db589018558f620ddfa44043887cdd45fa08e75c"
-dependencies = [
- "phf",
- "phf_codegen",
- "serde_json 0.9.10",
-]
-
 [[package]]
 name = "tauri-bundler"
 version = "0.9.4"
@@ -1411,7 +1140,6 @@ dependencies = [
  "ar",
  "attohttpc",
  "chrono",
- "clap",
  "dirs-next",
  "glob",
  "handlebars",
@@ -1423,12 +1151,11 @@ dependencies = [
  "md5",
  "regex",
  "runas",
- "serde 1.0.117",
- "serde_json 1.0.59",
+ "serde",
+ "serde_json",
  "sha2",
- "strsim 0.10.0",
+ "strsim",
  "tar",
- "target_build_utils",
  "tempfile",
  "termcolor",
  "thiserror",
@@ -1446,7 +1173,7 @@ checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
 dependencies = [
  "cfg-if 0.1.10",
  "libc",
- "rand 0.7.3",
+ "rand",
  "redox_syscall",
  "remove_dir_all",
  "winapi",
@@ -1461,15 +1188,6 @@ dependencies = [
  "winapi-util",
 ]
 
-[[package]]
-name = "textwrap"
-version = "0.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
-dependencies = [
- "unicode-width",
-]
-
 [[package]]
 name = "thiserror"
 version = "1.0.21"
@@ -1533,7 +1251,7 @@ version = "0.5.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa"
 dependencies = [
- "serde 1.0.117",
+ "serde",
 ]
 
 [[package]]
@@ -1566,12 +1284,6 @@ dependencies = [
  "tinyvec",
 ]
 
-[[package]]
-name = "unicode-width"
-version = "0.1.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
-
 [[package]]
 name = "unicode-xid"
 version = "0.2.1"
@@ -1604,12 +1316,6 @@ version = "0.2.10"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c"
 
-[[package]]
-name = "vec_map"
-version = "0.8.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
-
 [[package]]
 name = "version_check"
 version = "0.9.2"

+ 0 - 6
cli/tauri-bundler/Cargo.toml

@@ -19,7 +19,6 @@ edition = "2018"
 [dependencies]
 ar = "0.8.0"
 chrono = "0.4"
-clap = "^2"
 dirs-next = "2.0.0"
 glob = "0.3.0"
 icns = "0.3"
@@ -32,7 +31,6 @@ serde_json = "1.0"
 serde = { version = "1.0", features = [ "derive" ] }
 strsim = "0.10.0"
 tar = "0.4"
-target_build_utils = "0.3"
 termcolor = "1.1.2"
 toml = "0.5.8"
 walkdir = "2"
@@ -53,10 +51,6 @@ hex = { version = "0.4" }
 [dev-dependencies]
 tempfile = "3"
 
-[[bin]]
-name = "cargo-tauri-bundler"
-path = "src/bin.rs"
-
 [lib]
 name = "tauri_bundler"
 path = "src/lib.rs"

+ 0 - 128
cli/tauri-bundler/src/bin.rs

@@ -1,128 +0,0 @@
-use tauri_bundler::{
-  build_project,
-  bundle::{bundle_project, check_icons, print_error, PackageType, SettingsBuilder},
-};
-pub use tauri_bundler::{Error, Result};
-
-use clap::{crate_version, App, AppSettings, Arg, SubCommand};
-
-#[cfg(windows)]
-use runas::Command;
-use std::env;
-
-// Runs the CLI.
-fn run() -> crate::Result<()> {
-  let all_formats: Vec<&str> = PackageType::all()
-    .iter()
-    .map(PackageType::short_name)
-    .collect();
-  let m = App::new("cargo-tauri-bundler")
-    .version(format!("v{}", crate_version!()).as_str())
-    .bin_name("cargo")
-    .setting(AppSettings::GlobalVersion)
-    .setting(AppSettings::SubcommandRequired)
-    .subcommand(
-      SubCommand::with_name("tauri-bundler")
-        .author("George Burton <burtonageo@gmail.com>, Lucas Fernandes Gonçalves Nogueira <lucas@tauri.studio>, Daniel Thompson-Yvetot <denjell@sfosc.org>, Tensor Programming <tensordeveloper@gmail.com>")
-        .about("Bundle Rust executables into OS bundles")
-        .setting(AppSettings::DisableVersion)
-        .setting(AppSettings::UnifiedHelpMessage)
-        .arg(
-          Arg::with_name("bin")
-            .long("bin")
-            .value_name("NAME")
-            .help("Bundle the specified binary"),
-        )
-        .arg(
-          Arg::with_name("example")
-            .long("example")
-            .value_name("NAME")
-            .conflicts_with("bin")
-            .help("Bundle the specified example"),
-        )
-        .arg(
-          Arg::with_name("format")
-            .long("format")
-            .value_name("FORMAT")
-            .possible_values(&all_formats)
-            .multiple(true)
-            .help("Which bundle format to produce"),
-        )
-        .arg(
-          Arg::with_name("release")
-            .long("release")
-            .help("Build a bundle from a target built in release mode"),
-        )
-        .arg(
-          Arg::with_name("target")
-            .long("target")
-            .value_name("TRIPLE")
-            .help("Build a bundle for the target triple"),
-        )
-        .arg(
-          Arg::with_name("features")
-            .long("features")
-            .value_name("FEATURES")
-            .multiple(true)
-            .help("Which features to build"),
-        )
-        .arg(
-          Arg::with_name("version")
-            .long("version")
-            .short("v")
-            .help("Read the version of the bundler"),
-        ),
-    )
-    .get_matches();
-
-  if let Some(matches) = m.subcommand_matches("tauri-bundler") {
-    if matches.is_present("version") {
-      println!("{}", crate_version!());
-    } else {
-      let mut settings_builder = SettingsBuilder::new();
-      if let Some(names) = matches.values_of("format") {
-        let mut types = vec![];
-        for name in names {
-          match PackageType::from_short_name(name) {
-            Some(package_type) => {
-              types.push(package_type);
-            }
-            None => {
-              return Err(crate::Error::GenericError(format!(
-                "Unsupported bundle format: {}",
-                name
-              )));
-            }
-          }
-        }
-        settings_builder = settings_builder.package_types(types);
-      }
-
-      if let Some(triple) = matches.value_of("target") {
-        settings_builder = settings_builder.target(triple.to_string());
-      }
-      if let Some(features) = matches.values_of_lossy("features") {
-        settings_builder = settings_builder.features(features);
-      }
-
-      settings_builder
-        .build()
-        .and_then(|s| {
-          if check_icons(&s)? {
-            build_project(&s)?;
-            Ok(s)
-          } else {
-            Err(crate::Error::IconPathError)
-          }
-        })
-        .and_then(bundle_project)?;
-    }
-  }
-  Ok(())
-}
-
-fn main() {
-  if let Err(error) = run() {
-    print_error(&error.into()).expect("Failed to call print error in main");
-  }
-}

+ 21 - 23
cli/tauri-bundler/src/bundle.rs

@@ -11,18 +11,18 @@ mod path_utils;
 mod platform;
 mod rpm_bundle;
 mod settings;
-pub mod tauri_config;
 #[cfg(target_os = "windows")]
 mod wix;
 
 #[cfg(windows)]
 use std::process::Command;
-#[cfg(windows)]
-use tauri_config::get as get_tauri_config;
 
 pub use self::{
+  category::AppCategory,
   common::{print_error, print_info},
-  settings::{PackageType, Settings, SettingsBuilder},
+  settings::{
+    BundleBinary, BundleSettings, PackageSettings, PackageType, Settings, SettingsBuilder,
+  },
 };
 use common::print_finished;
 
@@ -58,27 +58,25 @@ pub fn bundle_project(settings: Settings) -> crate::Result<Vec<PathBuf>> {
 
   #[cfg(windows)]
   {
-    if get_tauri_config().is_ok() {
-      let exempt_output = Command::new("CheckNetIsolation")
-        .args(&vec!["LoopbackExempt", "-s"])
-        .output()
-        .expect("failed to read LoopbackExempt -s");
+    let exempt_output = Command::new("CheckNetIsolation")
+      .args(&vec!["LoopbackExempt", "-s"])
+      .output()
+      .expect("failed to read LoopbackExempt -s");
 
-      if !exempt_output.status.success() {
-        panic!("Failed to execute CheckNetIsolation LoopbackExempt -s");
-      }
+    if !exempt_output.status.success() {
+      panic!("Failed to execute CheckNetIsolation LoopbackExempt -s");
+    }
 
-      let output_str = String::from_utf8_lossy(&exempt_output.stdout).to_lowercase();
-      if !output_str.contains("win32webviewhost_cw5n1h2txyewy") {
-        println!("Running Loopback command");
-        runas::Command::new("powershell")
-          .args(&[
-            "CheckNetIsolation LoopbackExempt -a -n=\"Microsoft.Win32WebViewHost_cw5n1h2txyewy\"",
-          ])
-          .force_prompt(true)
-          .status()
-          .expect("failed to run Loopback command");
-      }
+    let output_str = String::from_utf8_lossy(&exempt_output.stdout).to_lowercase();
+    if !output_str.contains("win32webviewhost_cw5n1h2txyewy") {
+      println!("Running Loopback command");
+      runas::Command::new("powershell")
+        .args(&[
+          "CheckNetIsolation LoopbackExempt -a -n=\"Microsoft.Win32WebViewHost_cw5n1h2txyewy\"",
+        ])
+        .force_prompt(true)
+        .status()
+        .expect("failed to run Loopback command");
     }
   }
 

+ 8 - 3
cli/tauri-bundler/src/bundle/category.rs

@@ -1,4 +1,4 @@
-use std::fmt;
+use std::{fmt, str::FromStr};
 
 const CONFIDENCE_THRESHOLD: f64 = 0.8;
 
@@ -53,10 +53,12 @@ pub enum AppCategory {
   Weather,
 }
 
-impl AppCategory {
+impl FromStr for AppCategory {
+  type Err = Option<&'static str>;
+
   /// Given a string, returns the `AppCategory` it refers to, or the closest
   /// string that the user might have intended (if any).
-  pub fn from_str(input: &str) -> Result<AppCategory, Option<&'static str>> {
+  fn from_str(input: &str) -> Result<AppCategory, Self::Err> {
     // Canonicalize input:
     let mut input = input.to_ascii_lowercase();
     if input.starts_with(OSX_APP_CATEGORY_PREFIX) {
@@ -80,7 +82,9 @@ impl AppCategory {
     }
     Err(best_category.map(AppCategory::canonical))
   }
+}
 
+impl AppCategory {
   /// Map an AppCategory to the string we recommend to use in Cargo.toml if
   /// the users misspells the category name.
   fn canonical(self) -> &'static str {
@@ -338,6 +342,7 @@ const CATEGORY_STRINGS: &[(&str, AppCategory)] = &[
 #[cfg(test)]
 mod tests {
   use super::AppCategory;
+  use std::str::FromStr;
 
   #[test]
   fn category_from_string_ok() {

+ 74 - 485
cli/tauri-bundler/src/bundle/settings.rs

@@ -2,12 +2,9 @@ use super::category::AppCategory;
 use crate::bundle::{common, platform::target_triple};
 
 use serde::Deserialize;
-use target_build_utils::TargetInfo;
 
 use std::{
   collections::HashMap,
-  fs::File,
-  io::Read,
   path::{Path, PathBuf},
 };
 
@@ -81,43 +78,60 @@ const ALL_PACKAGE_TYPES: &[PackageType] = &[
   PackageType::AppImage,
 ];
 
+/// The package settings.
+#[derive(Debug, Clone, Deserialize)]
+pub struct PackageSettings {
+  /// the package's name.
+  pub name: String,
+  /// the package's version.
+  pub version: String,
+  /// the package's description.
+  pub description: String,
+  /// the package's homepage.
+  pub homepage: Option<String>,
+  /// the package's authors.
+  pub authors: Option<Vec<String>>,
+  /// the default binary to run.
+  pub default_run: Option<String>,
+}
+
 /// The bundle settings of the BuildArtifact we're bundling.
 #[derive(Clone, Debug, Deserialize, Default)]
-struct BundleSettings {
+pub struct BundleSettings {
   // General settings:
   /// the name of the bundle.
-  name: Option<String>,
+  pub name: Option<String>,
   /// the app's identifier.
-  identifier: Option<String>,
+  pub identifier: Option<String>,
   /// the app's icon list.
-  icon: Option<Vec<String>>,
+  pub icon: Option<Vec<String>>,
   /// the app's version.
-  version: Option<String>,
+  pub version: Option<String>,
   /// the app's resources to bundle.
   ///
   /// each item can be a path to a file or a path to a folder.
   ///
   /// supports glob patterns.
-  resources: Option<Vec<String>>,
+  pub resources: Option<Vec<String>>,
   /// the app's copyright.
-  copyright: Option<String>,
+  pub copyright: Option<String>,
   /// the app's category.
-  category: Option<AppCategory>,
+  pub category: Option<AppCategory>,
   /// the app's short description.
-  short_description: Option<String>,
+  pub short_description: Option<String>,
   /// the app's long description.
-  long_description: Option<String>,
+  pub long_description: Option<String>,
   /// the app's script to run when unpackaging the bundle.
-  script: Option<PathBuf>,
+  pub script: Option<PathBuf>,
   // OS-specific settings:
   /// the list of debian dependencies.
-  deb_depends: Option<Vec<String>>,
+  pub deb_depends: Option<Vec<String>>,
   /// whether we should use the bootstrap script on debian or not.
   ///
   /// this script goal is to allow your app to access environment variables e.g $PATH.
   ///
   /// without it, you can't run some applications installed by the user.
-  deb_use_bootstrapper: Option<bool>,
+  pub deb_use_bootstrapper: Option<bool>,
   /// Mac OS X frameworks that need to be bundled with the app.
   ///
   /// Each string can either be the name of a framework (without the `.framework` extension, e.g. `"SDL2"`),
@@ -128,24 +142,24 @@ struct BundleSettings {
   /// - arranging for the compiled binary to link against those frameworks (e.g. by emitting lines like `cargo:rustc-link-lib=framework=SDL2` from your `build.rs` script)
   ///
   /// - embedding the correct rpath in your binary (e.g. by running `install_name_tool -add_rpath "@executable_path/../Frameworks" path/to/binary` after compiling)
-  osx_frameworks: Option<Vec<String>>,
+  pub osx_frameworks: Option<Vec<String>>,
   /// A version string indicating the minimum Mac OS X version that the bundled app supports (e.g. `"10.11"`).
   /// If you are using this config field, you may also want have your `build.rs` script emit `cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET=10.11`.
-  osx_minimum_system_version: Option<String>,
+  pub osx_minimum_system_version: Option<String>,
   /// The path to the LICENSE file for macOS apps.
   /// Currently only used by the dmg bundle.
-  osx_license: Option<String>,
+  pub osx_license: Option<String>,
   /// whether we should use the bootstrap script on macOS .app or not.
   ///
   /// this script goal is to allow your app to access environment variables e.g $PATH.
   ///
   /// without it, you can't run some applications installed by the user.
-  osx_use_bootstrapper: Option<bool>,
+  pub osx_use_bootstrapper: Option<bool>,
   // Bundles for other binaries/examples:
   /// Configuration map for the possible [bin] apps to bundle.
-  bin: Option<HashMap<String, BundleSettings>>,
+  pub bin: Option<HashMap<String, BundleSettings>>,
   /// Configuration map for the possible example apps to bundle.
-  example: Option<HashMap<String, BundleSettings>>,
+  pub example: Option<HashMap<String, BundleSettings>>,
   /// External binaries to add to the bundle.
   ///
   /// Note that each binary name will have the target platform's target triple appended,
@@ -154,73 +168,11 @@ struct BundleSettings {
   /// and `sqlite3-x86_64-pc-windows-gnu.exe` on windows.
   ///
   /// The possible target triples can be seen by running `$ rustup target list`.
-  external_bin: Option<Vec<String>>,
+  pub external_bin: Option<Vec<String>>,
   /// The exception domain to use on the macOS .app bundle.
   ///
   /// This allows communication to the outside world e.g. a web server you're shipping.
-  exception_domain: Option<String>,
-}
-
-/// The `metadata` section of the package configuration.
-///
-/// # Example Cargo.toml
-/// [package]
-/// name = "..."
-///
-/// [package.metadata.bundle]
-/// identifier = "..."
-/// ...other properties from BundleSettings
-#[derive(Clone, Debug, Deserialize)]
-struct MetadataSettings {
-  /// the bundle settings of the package.
-  bundle: Option<BundleSettings>,
-}
-
-/// The `package` section of the app configuration (read from Cargo.toml).
-#[derive(Clone, Debug, Deserialize)]
-struct PackageSettings {
-  /// the package's name.
-  name: String,
-  /// the package's version.
-  version: String,
-  /// the package's description.
-  description: String,
-  /// the package's homepage.
-  homepage: Option<String>,
-  /// the package's authors.
-  authors: Option<Vec<String>>,
-  /// the package's metadata.
-  metadata: Option<MetadataSettings>,
-  /// the default binary to run.
-  default_run: Option<String>,
-}
-
-/// The `workspace` section of the app configuration (read from Cargo.toml).
-#[derive(Clone, Debug, Deserialize)]
-struct WorkspaceSettings {
-  /// the workspace members.
-  members: Option<Vec<String>>,
-}
-
-#[derive(Clone, Debug, Deserialize)]
-struct BinarySettings {
-  name: String,
-  path: Option<String>,
-}
-
-/// The Cargo settings (Cargo.toml root descriptor).
-#[derive(Clone, Debug, Deserialize)]
-struct CargoSettings {
-  /// the package settings.
-  ///
-  /// it's optional because ancestor workspace Cargo.toml files may not have package info.
-  package: Option<PackageSettings>,
-  /// the workspace settings.
-  ///
-  /// it's present if the read Cargo.toml belongs to a workspace root.
-  workspace: Option<WorkspaceSettings>,
-  /// the binary targets configuration.
-  bin: Option<Vec<BinarySettings>>,
+  pub exception_domain: Option<String>,
 }
 
 #[derive(Clone, Debug)]
@@ -248,7 +200,11 @@ impl BundleBinary {
     self
   }
 
-  pub fn name(&self) -> &String {
+  pub fn set_main(&mut self, main: bool) {
+    self.main = main;
+  }
+
+  pub fn name(&self) -> &str {
     &self.name
   }
 
@@ -256,6 +212,10 @@ impl BundleBinary {
   pub fn main(&self) -> bool {
     self.main
   }
+
+  pub fn src_path(&self) -> &Option<String> {
+    &self.src_path
+  }
 }
 
 /// The Settings exposed by the module.
@@ -267,14 +227,8 @@ pub struct Settings {
   ///
   /// if not present, we'll use the PackageType list for the target OS.
   package_types: Option<Vec<PackageType>>,
-  /// the target platform of the build
-  target: Option<(String, TargetInfo)>,
-  /// the features to use to build the app with `cargo build --features foo bar`.
-  features: Option<Vec<String>>,
   /// the directory where the bundles will be placed.
   project_out_directory: PathBuf,
-  /// whether we should build the app with release mode or not.
-  is_release: bool,
   /// whether or not to enable verbose logging
   is_verbose: bool,
   /// the bundle settings.
@@ -283,35 +237,14 @@ pub struct Settings {
   binaries: Vec<BundleBinary>,
 }
 
-impl CargoSettings {
-  /// Try to load a set of CargoSettings from a "Cargo.toml" file in the specified directory.
-  fn load(dir: &PathBuf) -> crate::Result<Self> {
-    let toml_path = dir.join("Cargo.toml");
-    let mut toml_str = String::new();
-    let mut toml_file = File::open(toml_path)?;
-    toml_file.read_to_string(&mut toml_str)?;
-    toml::from_str(&toml_str).map_err(Into::into)
-  }
-}
-
-#[derive(Deserialize)]
-struct CargoBuildConfig {
-  #[serde(rename = "target-dir")]
-  target_dir: Option<String>,
-}
-
-#[derive(Deserialize)]
-struct CargoConfig {
-  build: Option<CargoBuildConfig>,
-}
-
 #[derive(Default)]
 pub struct SettingsBuilder {
-  target_triple: Option<String>,
-  release: bool,
+  project_out_directory: Option<PathBuf>,
   verbose: bool,
   package_types: Option<Vec<PackageType>>,
-  features: Option<Vec<String>>,
+  package_settings: Option<PackageSettings>,
+  bundle_settings: BundleSettings,
+  binaries: Vec<BundleBinary>,
 }
 
 impl SettingsBuilder {
@@ -319,13 +252,10 @@ impl SettingsBuilder {
     Default::default()
   }
 
-  pub fn target(mut self, target_triple: String) -> Self {
-    self.target_triple = Some(target_triple);
+  pub fn project_out_directory<P: AsRef<Path>>(mut self, path: P) -> Self {
     self
-  }
-
-  pub fn release(mut self) -> Self {
-    self.release = true;
+      .project_out_directory
+      .replace(path.as_ref().to_path_buf());
     self
   }
 
@@ -339,8 +269,18 @@ impl SettingsBuilder {
     self
   }
 
-  pub fn features(mut self, features: Vec<String>) -> Self {
-    self.features = Some(features);
+  pub fn package_settings(mut self, settings: PackageSettings) -> Self {
+    self.package_settings.replace(settings);
+    self
+  }
+
+  pub fn bundle_settings(mut self, settings: BundleSettings) -> Self {
+    self.bundle_settings = settings;
+    self
+  }
+
+  pub fn binaries(mut self, binaries: Vec<BundleBinary>) -> Self {
+    self.binaries = binaries;
     self
   }
 
@@ -350,184 +290,22 @@ impl SettingsBuilder {
   ///
   /// Bundle settings will be read from from $TAURI_DIR/tauri.conf.json if it exists and fallback to Cargo.toml's [package.metadata.bundle].
   pub fn build(self) -> crate::Result<Settings> {
-    let current_dir = std::env::current_dir()?;
-    let cargo_settings = CargoSettings::load(&current_dir)?;
-    let tauri_config = super::tauri_config::get();
-
-    let package = match cargo_settings.package {
-      Some(package_info) => package_info,
-      None => {
-        return Err(crate::Error::GenericError(
-          "No package info in the config file".to_owned(),
-        ))
-      }
-    };
-    let workspace_dir = Settings::get_workspace_dir(&current_dir);
-    let target = if let Some(target_triple) = self.target_triple {
-      Some((target_triple.clone(), TargetInfo::from_str(&target_triple)?))
-    } else {
-      None
-    };
-    let target_dir = Settings::get_target_dir(&workspace_dir, &target, self.release)?;
-    let bundle_settings = match tauri_config {
-      Ok(config) => merge_settings(BundleSettings::default(), config.tauri.bundle),
-      Err(e) => {
-        let error_message = e.to_string();
-        if !error_message.contains("No such file or directory") {
-          return Err(crate::Error::GenericError(format!(
-            "Failed to read tauri config: {}",
-            error_message
-          )));
-        }
-        if let Some(bundle_settings) = package
-          .metadata
-          .as_ref()
-          .and_then(|metadata| metadata.bundle.as_ref())
-        {
-          bundle_settings.clone()
-        } else {
-          return Err(crate::Error::GenericError(
-            "No 'bundle' key in the tauri.conf.json".to_owned(),
-          ));
-        }
-      }
-    };
-
-    let mut binaries: Vec<BundleBinary> = vec![];
-    if let Some(bin) = cargo_settings.bin {
-      let default_run = package
-        .default_run
-        .clone()
-        .unwrap_or_else(|| "".to_string());
-      for binary in bin {
-        binaries.push(
-          BundleBinary::new(
-            binary.name.clone(),
-            binary.name.as_str() == package.name || binary.name.as_str() == default_run,
-          )
-          .set_src_path(binary.path),
-        )
-      }
-    }
-
-    let mut bins_path = current_dir;
-    bins_path.push("src/bin");
-    if let Ok(fs_bins) = std::fs::read_dir(bins_path) {
-      for entry in fs_bins {
-        let path = entry?.path();
-        if let Some(name) = path.file_stem() {
-          let bin_exists = binaries.iter().any(|bin| {
-            bin.name.as_str() == name
-              || path.ends_with(bin.src_path.as_ref().unwrap_or(&"".to_string()))
-          });
-          if !bin_exists {
-            binaries.push(BundleBinary::new(name.to_string_lossy().to_string(), false))
-          }
-        }
-      }
-    }
-
-    if let Some(default_run) = package.default_run.as_ref() {
-      if !binaries.iter().any(|bin| bin.name.as_str() == default_run) {
-        binaries.push(BundleBinary::new(default_run.to_string(), true));
-      }
-    }
-
-    if binaries.len() == 1 {
-      if let Some(bin) = binaries.get_mut(0) {
-        bin.main = true;
-      }
-    }
-
-    let bundle_settings = parse_external_bin(bundle_settings)?;
+    let bundle_settings = parse_external_bin(self.bundle_settings)?;
 
     Ok(Settings {
-      package,
+      package: self.package_settings.expect("package settings is required"),
       package_types: self.package_types,
-      target,
-      features: self.features,
-      is_release: self.release,
       is_verbose: self.verbose,
-      project_out_directory: target_dir,
-      binaries,
+      project_out_directory: self
+        .project_out_directory
+        .expect("out directory is required"),
+      binaries: self.binaries,
       bundle_settings,
     })
   }
 }
 
 impl Settings {
-  /// This function determines where 'target' dir is and suffixes it with 'release' or 'debug'
-  /// to determine where the compiled binary will be located.
-  fn get_target_dir(
-    project_root_dir: &PathBuf,
-    target: &Option<(String, TargetInfo)>,
-    is_release: bool,
-  ) -> crate::Result<PathBuf> {
-    let mut path: PathBuf = match std::env::var_os("CARGO_TARGET_DIR") {
-      Some(target_dir) => target_dir.into(),
-      None => {
-        let mut root_dir = project_root_dir.clone();
-        let target_path: Option<PathBuf> = loop {
-          // cargo reads configs under .cargo/config.toml or .cargo/config
-          let mut cargo_config_path = root_dir.join(".cargo/config");
-          if !cargo_config_path.exists() {
-            cargo_config_path = root_dir.join(".cargo/config.toml");
-          }
-          // if the path exists, parse it
-          if cargo_config_path.exists() {
-            let mut config_str = String::new();
-            let mut config_file = File::open(cargo_config_path)?;
-            config_file.read_to_string(&mut config_str)?;
-            let config: CargoConfig = toml::from_str(&config_str)?;
-            if let Some(build) = config.build {
-              if let Some(target_dir) = build.target_dir {
-                break Some(target_dir.into());
-              }
-            }
-          }
-          if !root_dir.pop() {
-            break None;
-          }
-        };
-        target_path.unwrap_or_else(|| project_root_dir.join("target"))
-      }
-    };
-
-    if let Some((ref triple, _)) = *target {
-      path.push(triple);
-    }
-    path.push(if is_release { "release" } else { "debug" });
-    Ok(path)
-  }
-
-  /// Walks up the file system, looking for a Cargo.toml file
-  /// If one is found before reaching the root, then the current_dir's package belongs to that parent workspace if it's listed on [workspace.members].
-  ///
-  /// If this package is part of a workspace, returns the path to the workspace directory
-  /// Otherwise returns the current directory.
-  pub fn get_workspace_dir(current_dir: &PathBuf) -> PathBuf {
-    let mut dir = current_dir.clone();
-    let project_path = current_dir.clone();
-
-    while dir.pop() {
-      if let Ok(cargo_settings) = CargoSettings::load(&dir) {
-        if let Some(workspace_settings) = cargo_settings.workspace {
-          if let Some(members) = workspace_settings.members {
-            if members
-              .iter()
-              .any(|member| dir.join(member) == project_path)
-            {
-              return dir;
-            }
-          }
-        }
-      }
-    }
-
-    // Nothing found walking up the file system, return the starting directory
-    current_dir.clone()
-  }
-
   /// Returns the directory where the bundle should be placed.
   pub fn project_out_directory(&self) -> &Path {
     &self.project_out_directory
@@ -535,11 +313,7 @@ impl Settings {
 
   /// Returns the architecture for the binary being bundled (e.g. "arm", "x86" or "x86_64").
   pub fn binary_arch(&self) -> &str {
-    if let Some((_, ref info)) = self.target {
-      info.target_arch()
-    } else {
-      std::env::consts::ARCH
-    }
+    std::env::consts::ARCH
   }
 
   /// Returns the file name of the binary being bundled.
@@ -574,11 +348,7 @@ impl Settings {
   ///
   /// Fails if the host/target's native package type is not supported.
   pub fn package_types(&self) -> crate::Result<Vec<PackageType>> {
-    let target_os = if let Some((_, ref info)) = self.target {
-      info.target_os()
-    } else {
-      std::env::consts::OS
-    };
+    let target_os = std::env::consts::OS;
     let platform_types = match target_os {
       "macos" => vec![PackageType::OsxBundle, PackageType::Dmg],
       "ios" => vec![PackageType::IosBundle],
@@ -610,27 +380,6 @@ impl Settings {
     }
   }
 
-  /// If the bundle is being cross-compiled, returns the target triple string
-  /// (e.g. `"x86_64-apple-darwin"`). If the bundle is targeting the host
-  /// environment, returns `None`.
-  pub fn target_triple(&self) -> Option<&str> {
-    match self.target {
-      Some((ref triple, _)) => Some(triple.as_str()),
-      None => None,
-    }
-  }
-
-  /// Returns the features that is being built.
-  pub fn build_features(&self) -> Option<Vec<String>> {
-    self.features.to_owned()
-  }
-
-  /// Returns true if the bundle is being compiled in release mode, false if
-  /// it's being compiled in debug mode.
-  pub fn is_release_build(&self) -> bool {
-    self.is_release
-  }
-
   /// Returns true if verbose logging is enabled
   pub fn is_verbose(&self) -> bool {
     self.is_verbose
@@ -823,49 +572,6 @@ fn parse_external_bin(bundle_settings: BundleSettings) -> crate::Result<BundleSe
   })
 }
 
-/// Returns the first Option with a value, or None if both are None.
-fn options_value<T>(first: Option<T>, second: Option<T>) -> Option<T> {
-  if first.is_some() {
-    first
-  } else {
-    second
-  }
-}
-
-/// Merges the bundle settings from Cargo.toml and tauri.conf.json
-fn merge_settings(
-  bundle_settings: BundleSettings,
-  config: crate::bundle::tauri_config::BundleConfig,
-) -> BundleSettings {
-  BundleSettings {
-    name: options_value(config.name, bundle_settings.name),
-    identifier: options_value(config.identifier, bundle_settings.identifier),
-    icon: options_value(config.icon, bundle_settings.icon),
-    version: options_value(config.version, bundle_settings.version),
-    resources: options_value(config.resources, bundle_settings.resources),
-    copyright: options_value(config.copyright, bundle_settings.copyright),
-    category: options_value(config.category, bundle_settings.category),
-    short_description: options_value(config.short_description, bundle_settings.short_description),
-    long_description: options_value(config.long_description, bundle_settings.long_description),
-    script: options_value(config.script, bundle_settings.script),
-    deb_depends: options_value(config.deb.depends, bundle_settings.deb_depends),
-    deb_use_bootstrapper: Some(config.deb.use_bootstrapper),
-    osx_frameworks: options_value(config.osx.frameworks, bundle_settings.osx_frameworks),
-    osx_minimum_system_version: options_value(
-      config.osx.minimum_system_version,
-      bundle_settings.osx_minimum_system_version,
-    ),
-    osx_license: options_value(config.osx.license, bundle_settings.osx_license),
-    osx_use_bootstrapper: Some(config.osx.use_bootstrapper),
-    external_bin: options_value(config.external_bin, bundle_settings.external_bin),
-    exception_domain: options_value(
-      config.osx.exception_domain,
-      bundle_settings.exception_domain,
-    ),
-    ..bundle_settings
-  }
-}
-
 /// A helper to iterate through resources.
 pub struct ResourcePaths<'a> {
   /// the patterns to iterate.
@@ -958,120 +664,3 @@ impl<'a> Iterator for ResourcePaths<'a> {
     }
   }
 }
-
-#[cfg(test)]
-mod tests {
-  use super::{AppCategory, BundleSettings, CargoSettings};
-
-  #[test]
-  fn parse_cargo_toml() {
-    let toml_str = "\
-                    [package]\n\
-                    name = \"example\"\n\
-                    version = \"0.1.0\"\n\
-                    authors = [\"Jane Doe\"]\n\
-                    license = \"MIT\"\n\
-                    description = \"An example application.\"\n\
-                    build = \"build.rs\"\n\
-                    \n\
-                    [package.metadata.bundle]\n\
-                    name = \"Example Application\"\n\
-                    identifier = \"com.example.app\"\n\
-                    resources = [\"data\", \"foo/bar\"]\n\
-                    category = \"Puzzle Game\"\n\
-                    long_description = \"\"\"\n\
-                    This is an example of a\n\
-                    simple application.\n\
-                    \"\"\"\n\
-                    \n\
-                    [dependencies]\n\
-                    rand = \"0.4\"\n";
-    let cargo_settings: CargoSettings = toml::from_str(toml_str).unwrap();
-    let package = cargo_settings.package.expect("Couldn't get package");
-    assert_eq!(package.name, "example");
-    assert_eq!(package.version, "0.1.0");
-    assert_eq!(package.description, "An example application.");
-    assert_eq!(package.homepage, None);
-    assert_eq!(package.authors, Some(vec!["Jane Doe".to_string()]));
-    assert!(package.metadata.is_some());
-    let metadata = package
-      .metadata
-      .as_ref()
-      .expect("Failed to get metadata ref");
-    assert!(metadata.bundle.is_some());
-    let bundle = metadata.bundle.as_ref().expect("Failed to get bundle ref");
-    assert_eq!(bundle.name, Some("Example Application".to_string()));
-    assert_eq!(bundle.identifier, Some("com.example.app".to_string()));
-    assert_eq!(bundle.icon, None);
-    assert_eq!(bundle.version, None);
-    assert_eq!(
-      bundle.resources,
-      Some(vec!["data".to_string(), "foo/bar".to_string()])
-    );
-    assert_eq!(bundle.category, Some(AppCategory::PuzzleGame));
-    assert_eq!(
-      bundle.long_description,
-      Some(
-        "This is an example of a\n\
-         simple application.\n"
-          .to_string()
-      )
-    );
-  }
-
-  #[test]
-  fn parse_bin_and_example_bundles() {
-    let toml_str = "\
-            [package]\n\
-            name = \"example\"\n\
-            version = \"0.1.0\"\n\
-            description = \"An example application.\"\n\
-            \n\
-            [package.metadata.bundle.bin.foo]\n\
-            name = \"Foo App\"\n\
-            \n\
-            [package.metadata.bundle.bin.bar]\n\
-            name = \"Bar App\"\n\
-            \n\
-            [package.metadata.bundle.example.baz]\n\
-            name = \"Baz Example\"\n\
-            \n\
-            [[bin]]\n\
-            name = \"foo\"\n
-            \n\
-            [[bin]]\n\
-            name = \"bar\"\n
-            \n\
-            [[example]]\n\
-            name = \"baz\"\n";
-    let cargo_settings: CargoSettings = toml::from_str(toml_str).expect("Failed to read from toml");
-    assert!(cargo_settings.package.is_some());
-    let package = cargo_settings
-      .package
-      .as_ref()
-      .expect("Failed to get package ref");
-    assert!(package.metadata.is_some());
-    let metadata = package
-      .metadata
-      .as_ref()
-      .expect("Failed to get metadata ref");
-    assert!(metadata.bundle.is_some());
-    let bundle = metadata.bundle.as_ref().expect("Failed to get bundle ref");
-    assert!(bundle.example.is_some());
-
-    let bins = bundle.bin.as_ref().expect("Failed to get bin ref");
-    assert!(bins.contains_key("foo"));
-    let foo_settings: &BundleSettings = bins.get("foo").expect("Failed to get foo bundle settings");
-    assert_eq!(foo_settings.name, Some("Foo App".to_string()));
-    assert!(bins.contains_key("bar"));
-    let bar_settings: &BundleSettings = bins.get("bar").expect("Failed to get bar bundle settings");
-    assert_eq!(bar_settings.name, Some("Bar App".to_string()));
-
-    let examples = bundle.example.as_ref().expect("Failed to get example ref");
-    assert!(examples.contains_key("baz"));
-    let baz_settings: &BundleSettings = examples
-      .get("baz")
-      .expect("Failed to get baz bundle settings");
-    assert_eq!(baz_settings.name, Some("Baz Example".to_string()));
-  }
-}

+ 0 - 75
cli/tauri-bundler/src/bundle/tauri_config.rs

@@ -1,75 +0,0 @@
-use super::category::AppCategory;
-use serde::Deserialize;
-use std::path::PathBuf;
-
-use std::fs;
-
-#[derive(PartialEq, Deserialize, Clone, Debug, Default)]
-#[serde(tag = "deb", rename_all = "camelCase")]
-pub struct DebConfig {
-  pub depends: Option<Vec<String>>,
-  #[serde(default)]
-  pub use_bootstrapper: bool,
-}
-
-#[derive(PartialEq, Deserialize, Clone, Debug, Default)]
-#[serde(tag = "osx", rename_all = "camelCase")]
-pub struct OsxConfig {
-  pub frameworks: Option<Vec<String>>,
-  pub minimum_system_version: Option<String>,
-  pub exception_domain: Option<String>,
-  pub license: Option<String>,
-  #[serde(default)]
-  pub use_bootstrapper: bool,
-}
-
-#[derive(PartialEq, Deserialize, Clone, Debug, Default)]
-#[serde(tag = "bundle", rename_all = "camelCase")]
-pub struct BundleConfig {
-  pub name: Option<String>,
-  pub identifier: Option<String>,
-  pub icon: Option<Vec<String>>,
-  pub version: Option<String>,
-  pub resources: Option<Vec<String>>,
-  pub copyright: Option<String>,
-  pub category: Option<AppCategory>,
-  pub short_description: Option<String>,
-  pub long_description: Option<String>,
-  pub script: Option<PathBuf>,
-  #[serde(default)]
-  pub deb: DebConfig,
-  #[serde(default)]
-  pub osx: OsxConfig,
-  pub external_bin: Option<Vec<String>>,
-}
-
-#[derive(PartialEq, Deserialize, Clone, Debug, Default)]
-#[serde(tag = "tauri", rename_all = "camelCase")]
-pub struct TauriConfig {
-  #[serde(default)]
-  pub bundle: BundleConfig,
-}
-
-#[derive(PartialEq, Deserialize, Clone, Debug)]
-#[serde(rename_all = "camelCase")]
-pub struct Config {
-  #[serde(default)]
-  pub tauri: TauriConfig,
-}
-
-pub fn get() -> crate::Result<Config> {
-  match std::env::var_os("TAURI_CONFIG") {
-    Some(config) => {
-      let json = &config.into_string().expect("failed to read TAURI_CONFIG");
-      Ok(serde_json::from_str(json)?)
-    }
-    None => match std::env::var_os("TAURI_DIR") {
-      Some(tauri_dir) => {
-        let tauri_dir_str = tauri_dir.into_string().expect("failed to read TAURI_DIR");
-        let json = &fs::read_to_string(format!("{}{}", tauri_dir_str, "/tauri.conf.json"))?;
-        Ok(serde_json::from_str(json)?)
-      }
-      None => Err(crate::Error::EnvironmentError),
-    },
-  }
-}

+ 1 - 3
cli/tauri-bundler/src/bundle/wix.rs

@@ -442,9 +442,7 @@ pub fn build_wix_app_installer(
 
   let mut data = BTreeMap::new();
 
-  if crate::bundle::tauri_config::get().is_ok() {
-    data.insert("embedded_server", to_json(true));
-  }
+  data.insert("embedded_server", to_json(true));
 
   data.insert("product_name", to_json(settings.bundle_name()));
   data.insert("version", to_json(settings.version_string()));

+ 0 - 2
cli/tauri-bundler/src/error.rs

@@ -15,8 +15,6 @@ pub enum Error {
   #[error("`{0}`")]
   ImageError(#[from] image::ImageError),
   #[error("`{0}`")]
-  TargetError(#[from] target_build_utils::Error),
-  #[error("`{0}`")]
   TomlError(#[from] toml::de::Error),
   #[error("`{0}`")]
   WalkdirError(#[from] walkdir::Error),

+ 1 - 29
cli/tauri-bundler/src/lib.rs

@@ -1,32 +1,4 @@
 pub mod bundle;
 mod error;
+pub use bundle::*;
 pub use error::{Error, Result};
-
-use bundle::Settings;
-use std::process;
-
-// Runs `cargo build` to make sure the binary file is up-to-date.
-pub fn build_project(settings: &Settings) -> crate::Result<()> {
-  let mut args = vec!["build".to_string()];
-
-  if let Some(triple) = settings.target_triple() {
-    args.push(format!("--target={}", triple));
-  }
-
-  if settings.is_release_build() {
-    args.push("--release".to_string());
-  }
-
-  if let Some(features) = settings.build_features() {
-    args.push(format!("--features={}", features.join(" ")));
-  }
-
-  let status = process::Command::new("cargo").args(args).status()?;
-  if !status.success() {
-    return Err(crate::Error::GenericError(format!(
-      "Result of `cargo build` operation was unsuccessful: {}",
-      status
-    )));
-  }
-  Ok(())
-}