Auto merge of #4430 - str4d:build-fixes, r=str4d

Rust build fixes

Fixes cross-compilation, along with some minor adjustments to the Makefile integration.
This commit is contained in:
Homu 2020-04-09 21:40:23 +00:00
commit 6fcfe529d9
2 changed files with 19 additions and 15 deletions

View File

@ -127,19 +127,19 @@ def util_test():
) == 0
def rust_test():
target_dir = os.path.join(REPOROOT, 'target', 'x86_64-unknown-linux-gnu')
if not os.path.isdir(target_dir):
target_dir = os.path.join(REPOROOT, 'target', 'x86_64-apple-darwin')
depends_dir = os.path.join(REPOROOT, 'depends', 'x86_64-unknown-linux-gnu')
if not os.path.isdir(depends_dir):
depends_dir = os.path.join(REPOROOT, 'depends', 'x86_64-apple-darwin')
if os.path.isdir(target_dir):
# cargo build --tests will produce a binary named something
# like rustzcash-b38184f84aaf9146 (see also https://github.com/rust-lang/cargo/issues/1924)
# so let's find it and run it.
test_files = glob(os.path.join(target_dir, 'release', 'rustzcash*'))
for candidate in test_files:
if candidate[-2::] != ".d":
# Only one test target to run
return subprocess.call([candidate]) == 0
if os.path.isdir(depends_dir):
rust_env = os.environ.copy()
rust_env['RUSTC'] = os.path.join(depends_dir, 'native', 'bin', 'rustc')
return subprocess.call([
os.path.join(depends_dir, 'native', 'bin', 'cargo'),
'test',
'--manifest-path',
os.path.join(REPOROOT, 'Cargo.toml'),
], env=rust_env) == 0
# Didn't manage to run anything
return False

View File

@ -57,7 +57,11 @@ LIBBITCOIN_WALLET=libbitcoin_wallet.a
endif
RUST_ENV_VARS = RUSTC="$(RUSTC)" TERM=dumb
RUST_BUILD_OPTS = --release --target $(RUST_TARGET)
RUST_BUILD_OPTS = --lib --release --target $(RUST_TARGET)
rust_verbose = $(rust_verbose_@AM_V@)
rust_verbose_ = $(rust_verbose_@AM_DEFAULT_V@)
rust_verbose_1 = --verbose
if ENABLE_ONLINE_RUST
# Ensure that .cargo/config does not exist
@ -79,7 +83,7 @@ $(CARGO_CONFIGURED): $(top_srcdir)/.cargo/config.offline
endif
cargo-build: $(CARGO_CONFIGURED)
$(RUST_ENV_VARS) $(CARGO) build --lib --tests $(RUST_BUILD_OPTS) --manifest-path $(top_srcdir)/Cargo.toml
$(RUST_ENV_VARS) $(CARGO) build $(RUST_BUILD_OPTS) $(rust_verbose) --manifest-path $(top_srcdir)/Cargo.toml
if TARGET_WINDOWS
LIBRUSTZCASH_WIN=$(top_builddir)/target/$(RUST_TARGET)/release/rustzcash.lib
@ -613,7 +617,7 @@ DISTCLEANFILES = obj/build.h
EXTRA_DIST = leveldb
clean-local:
rm -f .cargo/config .cargo/.configured-for-online .cargo/.configured-for-offline
rm -f $(top_srcdir)/.cargo/config $(top_srcdir)/.cargo/.configured-for-*
-$(MAKE) -C leveldb clean
-$(MAKE) -C secp256k1 clean
-$(MAKE) -C univalue clean