From 90f723413600e7900f79b02640b78f574dd8b0a8 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 4 Feb 2020 12:20:49 +0000 Subject: [PATCH] Replace librustzcash from depends system with src/rust The --enable-online-rust configure flag replicates the behaviour of the LIBRUSTZCASH_OVERRIDE environment variable (enabling the build system to use crates.io instead of vendored dependencies). --- .gitignore | 2 + configure.ac | 13 ++- depends/Makefile | 1 + depends/config.site.in | 3 + depends/packages/crate_bellman.mk | 4 +- depends/packages/crate_ff.mk | 15 +++ depends/packages/crate_ff_derive.mk | 15 +++ depends/packages/crate_group.mk | 15 +++ depends/packages/crate_pairing.mk | 4 +- depends/packages/crate_zcash_primitives.mk | 15 +++ depends/packages/crate_zcash_proofs.mk | 15 +++ depends/packages/librustzcash.mk | 73 ------------- depends/packages/packages.mk | 11 +- depends/patches/librustzcash/cargo.config | 20 ---- .../librustzcash/remove-dev-dependencies.diff | 102 ------------------ src/.cargo/config.offline | 5 + src/Makefile.am | 40 ++++++- src/Makefile.bench.include | 2 +- src/Makefile.gtest.include | 2 +- src/Makefile.test.include | 2 +- 20 files changed, 153 insertions(+), 206 deletions(-) create mode 100644 depends/packages/crate_ff.mk create mode 100644 depends/packages/crate_ff_derive.mk create mode 100644 depends/packages/crate_group.mk create mode 100644 depends/packages/crate_zcash_primitives.mk create mode 100644 depends/packages/crate_zcash_proofs.mk delete mode 100644 depends/packages/librustzcash.mk delete mode 100644 depends/patches/librustzcash/cargo.config delete mode 100644 depends/patches/librustzcash/remove-dev-dependencies.diff create mode 100644 src/.cargo/config.offline diff --git a/.gitignore b/.gitignore index 80f7ae7b7..6ce5e4ded 100644 --- a/.gitignore +++ b/.gitignore @@ -73,6 +73,8 @@ src/univalue/gen Makefile # Rust +src/.cargo/.configured-for-* +src/.cargo/config src/rust/target # Unit-tests diff --git a/configure.ac b/configure.ac index d839c02f5..9958a3783 100644 --- a/configure.ac +++ b/configure.ac @@ -77,12 +77,21 @@ AC_PATH_TOOL(GCOV, gcov) AC_PATH_PROG(LCOV, lcov) AC_PATH_PROG(GENHTML, genhtml) AC_PATH_PROG([GIT], [git]) +AC_PATH_PROG(RUSTC, rustc) +AC_PATH_PROG(CARGO, cargo) AC_PATH_PROG(CCACHE,ccache) AC_PATH_PROG(XGETTEXT,xgettext) AC_PATH_PROG(HEXDUMP,hexdump) AC_PATH_TOOL(READELF,readelf) AC_PATH_TOOL(CPPFILT,c++filt) +AC_ARG_ENABLE([online-rust], + [AS_HELP_STRING([--enable-online-rust], + [enable Rust to fetch dependencies from the network (default is to use vendored dependencies)])], + [enable_online_rust=$enableval], + [enable_online_rust=no]) +AM_CONDITIONAL(ENABLE_ONLINE_RUST, test "$enable_online_rust" != no) + # Enable wallet AC_ARG_ENABLE([wallet], [AS_HELP_STRING([--disable-wallet], @@ -809,7 +818,7 @@ else fi fi -RUST_LIBS="-lrustzcash" +RUST_LIBS="" case $host in *mingw*) ;; @@ -933,6 +942,8 @@ AC_SUBST(BITCOIN_DAEMON_NAME) AC_SUBST(BITCOIN_CLI_NAME) AC_SUBST(BITCOIN_TX_NAME) +AC_SUBST(RUST_TARGET) +AC_SUBST(RUST_VENDORED_SOURCES) AC_SUBST(RELDFLAGS) AC_SUBST(DEBUG_CPPFLAGS) AC_SUBST(DEBUG_CXXFLAGS) diff --git a/depends/Makefile b/depends/Makefile index bb353182c..750f51012 100644 --- a/depends/Makefile +++ b/depends/Makefile @@ -117,6 +117,7 @@ $(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_ -e 's|@CXXFLAGS@|$(strip $(host_CXXFLAGS) $(host_$(release_type)_CXXFLAGS))|' \ -e 's|@CPPFLAGS@|$(strip $(host_CPPFLAGS) $(host_$(release_type)_CPPFLAGS))|' \ -e 's|@LDFLAGS@|$(strip $(host_LDFLAGS) $(host_$(release_type)_LDFLAGS))|' \ + -e 's|@rust_target@|$(if $(rust_rust_target_$(canonical_host)),$(rust_rust_target_$(canonical_host)),$(canonical_host))|' \ -e 's|@no_wallet@|$(NO_WALLET)|' \ -e 's|@debug@|$(DEBUG)|' \ $< > $@ diff --git a/depends/config.site.in b/depends/config.site.in index 8cdbcd2e4..dbcb7a6e4 100644 --- a/depends/config.site.in +++ b/depends/config.site.in @@ -13,6 +13,9 @@ if test -z $enable_wallet && test -n "@no_wallet@"; then enable_wallet=no fi +RUST_TARGET="@rust_target@" +RUST_VENDORED_SOURCES="$depends_prefix/vendored-sources" + if test x@host_os@ = xdarwin; then BREW=no PORT=no diff --git a/depends/packages/crate_bellman.mk b/depends/packages/crate_bellman.mk index 5c7d904ca..279ea677f 100644 --- a/depends/packages/crate_bellman.mk +++ b/depends/packages/crate_bellman.mk @@ -1,9 +1,9 @@ package=crate_bellman $(package)_crate_name=bellman -$(package)_version=0.1.0 +$(package)_version=0.2.0 $(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) $(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=eae372472c7ea8f7c8fc6a62f7d5535db8302de7f1aafda2e13a97c4830d3bcf +$(package)_sha256_hash=8a8b3143b11715f8105882a1df9b3d36386aa8e3a6cfd573a2974c9ea9a22fea $(package)_crate_versioned_name=$($(package)_crate_name) define $(package)_preprocess_cmds diff --git a/depends/packages/crate_ff.mk b/depends/packages/crate_ff.mk new file mode 100644 index 000000000..8b7dd1084 --- /dev/null +++ b/depends/packages/crate_ff.mk @@ -0,0 +1,15 @@ +package=crate_ff +$(package)_crate_name=ff +$(package)_version=0.5.0 +$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) +$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate +$(package)_sha256_hash=44b4c77ad8a724f1ebb882af5d2d7a2ab62f4d63c8e401d40ab0de1d75262ea3 +$(package)_crate_versioned_name=$($(package)_crate_name) + +define $(package)_preprocess_cmds + $(call generate_crate_checksum,$(package)) +endef + +define $(package)_stage_cmds + $(call vendor_crate_source,$(package)) +endef diff --git a/depends/packages/crate_ff_derive.mk b/depends/packages/crate_ff_derive.mk new file mode 100644 index 000000000..eb05c2665 --- /dev/null +++ b/depends/packages/crate_ff_derive.mk @@ -0,0 +1,15 @@ +package=crate_ff_derive +$(package)_crate_name=ff_derive +$(package)_version=0.4.0 +$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) +$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate +$(package)_sha256_hash=a9cb38a53026415988765d8d7d81b680187a77a486ba9e249dbccd5a3e74429b +$(package)_crate_versioned_name=$($(package)_crate_name) + +define $(package)_preprocess_cmds + $(call generate_crate_checksum,$(package)) +endef + +define $(package)_stage_cmds + $(call vendor_crate_source,$(package)) +endef diff --git a/depends/packages/crate_group.mk b/depends/packages/crate_group.mk new file mode 100644 index 000000000..cfe083c06 --- /dev/null +++ b/depends/packages/crate_group.mk @@ -0,0 +1,15 @@ +package=crate_group +$(package)_crate_name=group +$(package)_version=0.2.0 +$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) +$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate +$(package)_sha256_hash=8cbdfc48f95bef47e3daf3b9d552a1dde6311e3a5fefa43e16c59f651d56fe5b +$(package)_crate_versioned_name=$($(package)_crate_name) + +define $(package)_preprocess_cmds + $(call generate_crate_checksum,$(package)) +endef + +define $(package)_stage_cmds + $(call vendor_crate_source,$(package)) +endef diff --git a/depends/packages/crate_pairing.mk b/depends/packages/crate_pairing.mk index c81e23bed..c86cbca0a 100644 --- a/depends/packages/crate_pairing.mk +++ b/depends/packages/crate_pairing.mk @@ -1,9 +1,9 @@ package=crate_pairing $(package)_crate_name=pairing -$(package)_version=0.14.2 +$(package)_version=0.15.0 $(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) $(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=ceda21136251c6d5a422d3d798d8ac22515a6e8d3521bb60c59a8349d36d0d57 +$(package)_sha256_hash=0ec7b64119b36952d5a0c7baf959ef061a07665751706f046f9f6f0f9d83d459 $(package)_crate_versioned_name=$($(package)_crate_name) define $(package)_preprocess_cmds diff --git a/depends/packages/crate_zcash_primitives.mk b/depends/packages/crate_zcash_primitives.mk new file mode 100644 index 000000000..bbfefff49 --- /dev/null +++ b/depends/packages/crate_zcash_primitives.mk @@ -0,0 +1,15 @@ +package=crate_zcash_primitives +$(package)_crate_name=zcash_primitives +$(package)_version=0.1.0 +$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) +$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate +$(package)_sha256_hash=9530749bc784c4ca0d7bf000333cec29acf94f1875ad8db088e12dfee1095d13 +$(package)_crate_versioned_name=$($(package)_crate_name) + +define $(package)_preprocess_cmds + $(call generate_crate_checksum,$(package)) +endef + +define $(package)_stage_cmds + $(call vendor_crate_source,$(package)) +endef diff --git a/depends/packages/crate_zcash_proofs.mk b/depends/packages/crate_zcash_proofs.mk new file mode 100644 index 000000000..93a1d1555 --- /dev/null +++ b/depends/packages/crate_zcash_proofs.mk @@ -0,0 +1,15 @@ +package=crate_zcash_proofs +$(package)_crate_name=zcash_proofs +$(package)_version=0.1.0 +$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) +$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate +$(package)_sha256_hash=6f12228d3bff81779e848bc7e7a68f282c717ef2f67a69e6477f4667fbb06078 +$(package)_crate_versioned_name=$($(package)_crate_name) + +define $(package)_preprocess_cmds + $(call generate_crate_checksum,$(package)) +endef + +define $(package)_stage_cmds + $(call vendor_crate_source,$(package)) +endef diff --git a/depends/packages/librustzcash.mk b/depends/packages/librustzcash.mk deleted file mode 100644 index 2cad26f00..000000000 --- a/depends/packages/librustzcash.mk +++ /dev/null @@ -1,73 +0,0 @@ -package=librustzcash -$(package)_version=0.2.0 -$(package)_download_path=https://github.com/zcash/$(package)/archive/ -$(package)_file_name=$(package)-$($(package)_git_commit).tar.gz -$(package)_download_file=$($(package)_git_commit).tar.gz -$(package)_sha256_hash=dfb80e9a57d944a91092094a423a8a6631e38b602b337aad5f98dc21002ca6dc -$(package)_git_commit=a57dc7f47807ea50cb0a5deec9b84b3e7da11bc0 -$(package)_dependencies=rust -ifeq ($(LIBRUSTZCASH_OVERRIDE),) -$(package)_dependencies+=$(rust_crates) -$(package)_patches=cargo.config remove-dev-dependencies.diff -endif - -$(package)_rust_target=$(if $(rust_rust_target_$(canonical_host)),$(rust_rust_target_$(canonical_host)),$(canonical_host)) - -ifeq ($(host_os),mingw32) -$(package)_library_file=target/x86_64-pc-windows-gnu/release/rustzcash.lib -else ifneq ($(canonical_host),$(build)) -$(package)_library_file=target/$($(package)_rust_target)/release/librustzcash.a -else -$(package)_library_file=target/release/librustzcash.a -endif - -define $(package)_set_vars -$(package)_build_opts=--release -ifeq ($(LIBRUSTZCASH_OVERRIDE),) -$(package)_build_opts+=--frozen -endif -ifneq ($(canonical_host),$(build)) -$(package)_build_opts+=--target=$($(package)_rust_target) -endif -endef - -ifneq ($(LIBRUSTZCASH_OVERRIDE),) - -define $(package)_fetch_cmds -endef - -define $(package)_extract_cmds -endef - -define $(package)_build_cmds - cd $(LIBRUSTZCASH_OVERRIDE) && \ - $(host_prefix)/native/bin/cargo build --package librustzcash $($(package)_build_opts) -endef - -define $(package)_stage_cmds - mkdir $($(package)_staging_dir)$(host_prefix)/lib/ && \ - mkdir $($(package)_staging_dir)$(host_prefix)/include/ && \ - cp $(LIBRUSTZCASH_OVERRIDE)/$($(package)_library_file) $($(package)_staging_dir)$(host_prefix)/lib/ && \ - cp $(LIBRUSTZCASH_OVERRIDE)/librustzcash/include/librustzcash.h $($(package)_staging_dir)$(host_prefix)/include/ -endef - -else - -define $(package)_preprocess_cmds - patch -p1 < $($(package)_patch_dir)/remove-dev-dependencies.diff && \ - mkdir .cargo && \ - cat $($(package)_patch_dir)/cargo.config | sed 's|CRATE_REGISTRY|$(host_prefix)/$(CRATE_REGISTRY)|' > .cargo/config -endef - -define $(package)_build_cmds - $(host_prefix)/native/bin/cargo build --package librustzcash $($(package)_build_opts) -endef - -define $(package)_stage_cmds - mkdir $($(package)_staging_dir)$(host_prefix)/lib/ && \ - mkdir $($(package)_staging_dir)$(host_prefix)/include/ && \ - cp $($(package)_library_file) $($(package)_staging_dir)$(host_prefix)/lib/ && \ - cp librustzcash/include/librustzcash.h $($(package)_staging_dir)$(host_prefix)/include/ -endef - -endif diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk index 02e78c512..dc247e84c 100644 --- a/depends/packages/packages.mk +++ b/depends/packages/packages.mk @@ -6,6 +6,7 @@ rust_crates := \ crate_arrayvec \ crate_autocfg \ crate_bech32 \ + crate_bellman \ crate_bit_vec \ crate_blake2b_simd \ crate_blake2s_simd \ @@ -28,11 +29,14 @@ rust_crates := \ crate_digest \ crate_directories \ crate_fake_simd \ + crate_ff_derive \ + crate_ff \ crate_fpe \ crate_futures_cpupool \ crate_futures \ crate_generic_array \ crate_getrandom \ + crate_group \ crate_hex \ crate_lazy_static \ crate_libc \ @@ -44,6 +48,7 @@ rust_crates := \ crate_num_integer \ crate_num_traits \ crate_opaque_debug \ + crate_pairing \ crate_ppv_lite86 \ crate_proc_macro2 \ crate_quote \ @@ -64,8 +69,10 @@ rust_crates := \ crate_wasi \ crate_winapi_i686_pc_windows_gnu \ crate_winapi \ - crate_winapi_x86_64_pc_windows_gnu -rust_packages := rust $(rust_crates) librustzcash + crate_winapi_x86_64_pc_windows_gnu \ + crate_zcash_primitives \ + crate_zcash_proofs +rust_packages := rust $(rust_crates) proton_packages := proton zcash_packages := libsodium utfcpp packages := boost openssl libevent zeromq $(zcash_packages) googletest diff --git a/depends/patches/librustzcash/cargo.config b/depends/patches/librustzcash/cargo.config deleted file mode 100644 index 84d447afb..000000000 --- a/depends/patches/librustzcash/cargo.config +++ /dev/null @@ -1,20 +0,0 @@ -[source.crates-io] -replace-with = "vendored-sources" - -[source."https://github.com/gtank/blake2-rfc"] -git = "https://github.com/gtank/blake2-rfc" -rev = "7a5b5fc99ae483a0043db7547fb79a6fa44b88a9" -replace-with = "vendored-sources" - -[source."https://github.com/zcash-hackworks/sapling-crypto"] -git = "https://github.com/zcash-hackworks/sapling-crypto" -rev = "21084bde2019c04bd34208e63c3560fe2c02fb0e" -replace-with = "vendored-sources" - -[source."https://github.com/zcash-hackworks/zip32"] -git = "https://github.com/zcash-hackworks/zip32" -rev = "176470ef41583b5bd0bd749bd1b61d417aa8ec79" -replace-with = "vendored-sources" - -[source.vendored-sources] -directory = "CRATE_REGISTRY" diff --git a/depends/patches/librustzcash/remove-dev-dependencies.diff b/depends/patches/librustzcash/remove-dev-dependencies.diff deleted file mode 100644 index 3cc75eaae..000000000 --- a/depends/patches/librustzcash/remove-dev-dependencies.diff +++ /dev/null @@ -1,102 +0,0 @@ -diff --git a/Cargo.lock b/Cargo.lock -index 7a33a24..d60f744 100644 ---- a/Cargo.lock -+++ b/Cargo.lock -@@ -64,7 +64,6 @@ dependencies = [ - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "group 0.2.0", -- "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "pairing 0.15.0", - "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -@@ -328,23 +327,6 @@ name = "hex" - version = "0.3.2" - source = "registry+https://github.com/rust-lang/crates.io-index" - --[[package]] --name = "hex-literal" --version = "0.2.1" --source = "registry+https://github.com/rust-lang/crates.io-index" --dependencies = [ -- "hex-literal-impl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -- "proc-macro-hack 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", --] -- --[[package]] --name = "hex-literal-impl" --version = "0.2.1" --source = "registry+https://github.com/rust-lang/crates.io-index" --dependencies = [ -- "proc-macro-hack 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", --] -- - [[package]] - name = "lazy_static" - version = "1.4.0" -@@ -449,16 +431,6 @@ name = "ppv-lite86" - version = "0.2.5" - source = "registry+https://github.com/rust-lang/crates.io-index" - --[[package]] --name = "proc-macro-hack" --version = "0.5.9" --source = "registry+https://github.com/rust-lang/crates.io-index" --dependencies = [ -- "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", -- "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", -- "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", --] -- - [[package]] - name = "proc-macro2" - version = "1.0.3" -@@ -624,7 +596,6 @@ dependencies = [ - "ff 0.5.0", - "fpe 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", -- "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "pairing 0.15.0", -@@ -685,8 +656,6 @@ dependencies = [ - "checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" - "checksum getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571" - "checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" --"checksum hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "961de220ec9a91af2e1e5bd80d02109155695e516771762381ef8581317066e0" --"checksum hex-literal-impl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9d4c5c844e2fee0bf673d54c2c177f1713b3d2af2ff6e666b49cb7572e6cf42d" - "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - "checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" - "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -@@ -698,7 +667,6 @@ dependencies = [ - "checksum num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273" - "checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - "checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" --"checksum proc-macro-hack 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e688f31d92ffd7c1ddc57a1b4e6d773c0f2a14ee437a4b0a4f5a69c80eb221c8" - "checksum proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e98a83a9f9b331f54b924e68a66acb1bb35cb01fb0a23645139967abefb697e8" - "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" - "checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" -diff --git a/bellman/Cargo.toml b/bellman/Cargo.toml -index 4f125b4..6a72152 100644 ---- a/bellman/Cargo.toml -+++ b/bellman/Cargo.toml -@@ -24,7 +24,6 @@ rand_core = "0.5" - byteorder = "1" - - [dev-dependencies] --hex-literal = "0.2" - rand = "0.7" - rand_xorshift = "0.2" - sha2 = "0.8" -diff --git a/zcash_primitives/Cargo.toml b/zcash_primitives/Cargo.toml -index c83ecf1..6674144 100644 ---- a/zcash_primitives/Cargo.toml -+++ b/zcash_primitives/Cargo.toml -@@ -28,7 +28,6 @@ rand_core = "0.5.1" - sha2 = "0.8" - - [dev-dependencies] --hex-literal = "0.2" - rand_xorshift = "0.2" - - [badges] diff --git a/src/.cargo/config.offline b/src/.cargo/config.offline new file mode 100644 index 000000000..a6339df37 --- /dev/null +++ b/src/.cargo/config.offline @@ -0,0 +1,5 @@ +[source.crates-io] +replace-with = "vendored-sources" + +[source.vendored-sources] +# The directory for this source is set to RUST_VENDORED_SOURCES by src/Makefile.am diff --git a/src/Makefile.am b/src/Makefile.am index bad284155..a7d50acc8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,6 +29,7 @@ endif BITCOIN_CONFIG_INCLUDES=-I$(builddir)/config BITCOIN_INCLUDES=-I$(builddir) -I$(builddir)/obj $(BDB_CPPFLAGS) $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) $(CRYPTO_CFLAGS) $(SSL_CFLAGS) +BITCOIN_INCLUDES += -I$(srcdir)/rust/include BITCOIN_INCLUDES += -I$(srcdir)/secp256k1/include BITCOIN_INCLUDES += -I$(srcdir)/univalue/include @@ -37,6 +38,11 @@ LIBBITCOIN_COMMON=libbitcoin_common.a LIBBITCOIN_CLI=libbitcoin_cli.a LIBBITCOIN_UTIL=libbitcoin_util.a LIBBITCOIN_CRYPTO=crypto/libbitcoin_crypto.a +if TARGET_WINDOWS +LIBRUSTZCASH=rust/target/$(RUST_TARGET)/release/rustzcash.lib +else +LIBRUSTZCASH=rust/target/$(RUST_TARGET)/release/librustzcash.a +endif LIBSECP256K1=secp256k1/libsecp256k1.la LIBUNIVALUE=univalue/libunivalue.la LIBZCASH=libzcash.a @@ -54,6 +60,33 @@ if ENABLE_WALLET LIBBITCOIN_WALLET=libbitcoin_wallet.a endif +RUST_ENV_VARS = RUSTC="$(RUSTC)" TERM=dumb +RUST_BUILD_OPTS = --release --target $(RUST_TARGET) + +if ENABLE_ONLINE_RUST +# Ensure that .cargo/config does not exist +CARGO_CONFIGURED = .cargo/.configured-for-online +$(CARGO_CONFIGURED): + $(AM_V_at)rm -f .cargo/.configured-for-offline .cargo/config + $(AM_V_at)touch $@ + +else +# Enable dependency vendoring +RUST_BUILD_OPTS += --locked --offline + +CARGO_CONFIGURED = .cargo/.configured-for-offline +$(CARGO_CONFIGURED): .cargo/config.offline + $(AM_V_at)rm -f .cargo/.configured-for-online + $(AM_V_at)cp $< .cargo/config + $(AM_V_at)echo "directory = \"$(RUST_VENDORED_SOURCES)\"" >>.cargo/config + $(AM_V_at)touch $@ +endif + +cargo-build: $(CARGO_CONFIGURED) + $(RUST_ENV_VARS) $(CARGO) build $(RUST_BUILD_OPTS) --manifest-path $(srcdir)/rust/Cargo.toml + +$(LIBRUSTZCASH): cargo-build + $(LIBSECP256K1): $(wildcard secp256k1/src/*) $(wildcard secp256k1/include/*) $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) @@ -102,7 +135,7 @@ LIBZCASH_H = \ zcash/util.h \ zcash/Zcash.h -.PHONY: FORCE check-symbols check-security +.PHONY: FORCE cargo-build check-symbols check-security # bitcoin core # BITCOIN_CORE_H = \ addressindex.h \ @@ -449,6 +482,7 @@ zcashd_LDADD = \ $(LIBBITCOIN_PROTON) \ $(LIBBITCOIN_CRYPTO) \ $(LIBZCASH) \ + $(LIBRUSTZCASH) \ $(LIBLEVELDB) \ $(LIBMEMENV) \ $(LIBSECP256K1) @@ -484,6 +518,7 @@ zcash_cli_LDADD = \ $(CRYPTO_LIBS) \ $(EVENT_LIBS) \ $(LIBZCASH) \ + $(LIBRUSTZCASH) \ $(LIBBITCOIN_CRYPTO) \ $(LIBZCASH_LIBS) # @@ -505,6 +540,7 @@ zcash_tx_LDADD = \ $(LIBBITCOIN_UTIL) \ $(LIBSECP256K1) \ $(LIBZCASH) \ + $(LIBRUSTZCASH) \ $(LIBBITCOIN_CRYPTO) \ $(LIBZCASH_LIBS) @@ -567,6 +603,8 @@ DISTCLEANFILES = obj/build.h EXTRA_DIST = leveldb clean-local: + $(CARGO) clean --manifest-path $(srcdir)/rust/Cargo.toml + rm -f .cargo/config .cargo/.configured-for-online .cargo/.configured-for-offline -$(MAKE) -C leveldb clean -$(MAKE) -C secp256k1 clean -$(MAKE) -C univalue clean diff --git a/src/Makefile.bench.include b/src/Makefile.bench.include index 555853942..5a8356aa5 100644 --- a/src/Makefile.bench.include +++ b/src/Makefile.bench.include @@ -29,7 +29,7 @@ bench_bench_bitcoin_LDADD = \ $(LIBMEMENV) \ $(LIBSECP256K1) \ $(LIBZCASH) \ - $(LIBSNARK) + $(LIBRUSTZCASH) if ENABLE_ZMQ bench_bench_bitcoin_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS) diff --git a/src/Makefile.gtest.include b/src/Makefile.gtest.include index 7782fa206..6f0545109 100644 --- a/src/Makefile.gtest.include +++ b/src/Makefile.gtest.include @@ -63,7 +63,7 @@ if ENABLE_WALLET zcash_gtest_LDADD += $(LIBBITCOIN_WALLET) endif -zcash_gtest_LDADD += $(LIBZCASH_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(LIBZCASH) $(LIBZCASH_LIBS) +zcash_gtest_LDADD += $(LIBZCASH_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(LIBZCASH) $(LIBRUSTZCASH) $(LIBZCASH_LIBS) if ENABLE_PROTON zcash_gtest_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS) diff --git a/src/Makefile.test.include b/src/Makefile.test.include index 5f77ec0d4..8c5421034 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -127,7 +127,7 @@ test_test_bitcoin_LDADD += $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_C $(LIBLEVELDB) $(LIBMEMENV) $(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LIBSECP256K1) $(EVENT_LIBS) $(EVENT_PTHREADS_LIBS) test_test_bitcoin_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -test_test_bitcoin_LDADD += $(LIBZCASH_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(LIBZCASH) $(LIBZCASH_LIBS) +test_test_bitcoin_LDADD += $(LIBZCASH_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(LIBZCASH) $(LIBRUSTZCASH) $(LIBZCASH_LIBS) test_test_bitcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static if ENABLE_ZMQ