rust: Support make dist -> cargo vendor

What we do here basically is set things up in a `dist-hook` so that our Rust
sources are vendored at `dist` time. This gives us a single tarball still, and
ideally should be transparent to downstream builders, as long as they have the
`cargo/rust` toolchain.

Closes: #669
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-02-04 11:29:20 -05:00 committed by Atomic Bot
parent 9c0af41710
commit 9169268c31
3 changed files with 20 additions and 1 deletions

View File

@ -25,7 +25,9 @@ noinst_LTLIBRARIES += libostree-kernel-args.la
if ENABLE_RUST if ENABLE_RUST
bupsplitpath = @abs_top_builddir@/target/@RUST_TARGET_SUBDIR@/libbupsplit_rs.a bupsplitpath = @abs_top_builddir@/target/@RUST_TARGET_SUBDIR@/libbupsplit_rs.a
.PHONY: $(bupsplitpath) .PHONY: $(bupsplitpath)
$(bupsplitpath): Makefile rust/src/bupsplit.rs BUPSPLIT_RUST_SOURCES = rust/src/bupsplit.rs
EXTRA_DIST += $(BUPSPLIT_RUST_SOURCES)
$(bupsplitpath): Makefile $(BUPSPLIT_RUST_SOURCES)
cd $(top_srcdir)/rust && CARGO_TARGET_DIR=@abs_top_builddir@/target cargo build --verbose $(CARGO_RELEASE_ARGS) cd $(top_srcdir)/rust && CARGO_TARGET_DIR=@abs_top_builddir@/target cargo build --verbose $(CARGO_RELEASE_ARGS)
else else
bupsplitpath = libbupsplit.la bupsplitpath = libbupsplit.la

View File

@ -73,6 +73,15 @@ check-local:
clean-local: clean-local:
cd $(srcdir)/rust && CARGO_TARGET_DIR=$(abs_top_builddir)/target cargo clean cd $(srcdir)/rust && CARGO_TARGET_DIR=$(abs_top_builddir)/target cargo clean
dist-hook:
(cd $(distdir)/rust && \
cp $(abs_top_srcdir)/rust/Cargo.lock . && \
cargo vendor -q && \
mkdir .cargo && \
cp cargo-vendor-config .cargo/config)
EXTRA_DIST += $(srcdir)/rust/Cargo.toml $(srcdir)/rust/cargo-vendor-config
endif # end ENABLE_RUST endif # end ENABLE_RUST
libglnx_srcpath := $(srcdir)/libglnx libglnx_srcpath := $(srcdir)/libglnx

8
rust/cargo-vendor-config Normal file
View File

@ -0,0 +1,8 @@
# This is used after `cargo vendor` is run from `make dist`
[source.crates-io]
registry = 'https://github.com/rust-lang/crates.io-index'
replace-with = 'vendored-sources'
[source.vendored-sources]
directory = './vendor'