Skip to content

Commit

Permalink
Move root of Rust crate into repo root
Browse files Browse the repository at this point in the history
This enables IDE integration to work (which requires the Cargo.toml to
be in the repo root).

"make clean" no longer runs "cargo clean", because IDE integrations hold
locks on files within the Rust build directory, and an error inside
"cargo clean" error would prevent "make clean" from completing (and
removing other files).
  • Loading branch information
str4d committed Mar 6, 2020
1 parent 90f7234 commit 5fe4165
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
File renamed without changes.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ src/univalue/gen
Makefile

# Rust
src/.cargo/.configured-for-*
src/.cargo/config
src/rust/target
.cargo/.configured-for-*
.cargo/config
target/

# Unit-tests
Makefile.test
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/rust/Cargo.toml → Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ edition = "2018"

[lib]
name = "rustzcash"
path = "src/rustzcash.rs"
path = "src/rust/src/rustzcash.rs"
crate-type = ["staticlib"]

[dependencies]
Expand Down
File renamed without changes.
21 changes: 10 additions & 11 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ 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
LIBRUSTZCASH=$(top_builddir)/target/$(RUST_TARGET)/release/rustzcash.lib
else
LIBRUSTZCASH=rust/target/$(RUST_TARGET)/release/librustzcash.a
LIBRUSTZCASH=$(top_builddir)/target/$(RUST_TARGET)/release/librustzcash.a
endif
LIBSECP256K1=secp256k1/libsecp256k1.la
LIBUNIVALUE=univalue/libunivalue.la
Expand All @@ -65,25 +65,25 @@ 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 = $(top_srcdir)/.cargo/.configured-for-online
$(CARGO_CONFIGURED):
$(AM_V_at)rm -f .cargo/.configured-for-offline .cargo/config
$(AM_V_at)rm -f $(top_srcdir)/.cargo/.configured-for-offline $(top_srcdir)/.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
CARGO_CONFIGURED = $(top_srcdir)/.cargo/.configured-for-offline
$(CARGO_CONFIGURED): $(top_srcdir)/.cargo/config.offline
$(AM_V_at)rm -f $(top_srcdir)/.cargo/.configured-for-online
$(AM_V_at)cp $< $(top_srcdir)/.cargo/config
$(AM_V_at)echo "directory = \"$(RUST_VENDORED_SOURCES)\"" >>$(top_srcdir)/.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
$(RUST_ENV_VARS) $(CARGO) build $(RUST_BUILD_OPTS) --manifest-path $(top_srcdir)/Cargo.toml

$(LIBRUSTZCASH): cargo-build

Expand Down Expand Up @@ -603,7 +603,6 @@ 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
Expand Down

0 comments on commit 5fe4165

Please sign in to comment.