Move the main Rust infra (i.e. Cargo.toml) to the toplevel
I think we should have done this as soon as it was clear that Rust was sticking and not just an optional thing. Reasons to make this change now: - More clear that Rust is going to be the majority of code in the future - `cargo build` and `cargo test` in a fresh git clone Just Work - Paves the way for using `cargo` to build C/C++ instead of Automake
This commit is contained in:
parent
264b07eb82
commit
f1488e52f0
@ -16,7 +16,7 @@ parallel rpms: {
|
|||||||
# binaries from PRs in the future) and meshes well with the following stages.
|
# binaries from PRs in the future) and meshes well with the following stages.
|
||||||
export PATH="\$HOME/.cargo/bin:\$PATH"
|
export PATH="\$HOME/.cargo/bin:\$PATH"
|
||||||
cargo install cbindgen
|
cargo install cbindgen
|
||||||
cbindgen -c rust/cbindgen.toml -o rpmostree-rust.h rust
|
cbindgen -c cbindgen.toml -o rpmostree-rust.h .
|
||||||
|
|
||||||
cd packaging
|
cd packaging
|
||||||
make -f Makefile.dist-packaging rpm
|
make -f Makefile.dist-packaging rpm
|
||||||
|
0
rust/Cargo.lock → Cargo.lock
generated
0
rust/Cargo.lock → Cargo.lock
generated
@ -33,11 +33,11 @@ lazy_static = "1.4.0"
|
|||||||
envsubst = "0.2.0"
|
envsubst = "0.2.0"
|
||||||
subprocess = "0.2.6"
|
subprocess = "0.2.6"
|
||||||
chrono = { version = "0.4.19", features = ["serde"] }
|
chrono = { version = "0.4.19", features = ["serde"] }
|
||||||
libdnf-sys = { path = "libdnf-sys", version = "0.1.0" }
|
libdnf-sys = { path = "rust/libdnf-sys", version = "0.1.0" }
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "rpmostree_rust"
|
name = "rpmostree_rust"
|
||||||
path = "src/lib.rs"
|
path = "rust/src/lib.rs"
|
||||||
crate-type = ["staticlib"]
|
crate-type = ["staticlib"]
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
@ -100,23 +100,19 @@ librpmostree_rust_path = @abs_top_builddir@/target/@RUST_TARGET_SUBDIR@/librpmos
|
|||||||
# If the target directory exists, and isn't owned by our uid, then
|
# If the target directory exists, and isn't owned by our uid, then
|
||||||
# we exit with a fatal error, since someone probably did `make && sudo make install`,
|
# we exit with a fatal error, since someone probably did `make && sudo make install`,
|
||||||
# and in this case cargo will download into ~/.root which we don't want.
|
# and in this case cargo will download into ~/.root which we don't want.
|
||||||
LIBRPMOSTREE_RUST_SRCS = $(shell find rust/src/ -name '*.rs') rust/cbindgen.toml
|
LIBRPMOSTREE_RUST_SRCS = $(shell find rust/src/ -name '*.rs') Cargo.toml Cargo.lock cbindgen.toml
|
||||||
$(librpmostree_rust_path): Makefile $(LIBRPMOSTREE_RUST_SRCS)
|
$(librpmostree_rust_path): Makefile $(LIBRPMOSTREE_RUST_SRCS)
|
||||||
cd $(top_srcdir)/rust && \
|
$(cargo_build) $(CARGO_RELEASE_ARGS)
|
||||||
export CARGO_TARGET_DIR=@abs_top_builddir@/target && \
|
EXTRA_DIST += $(LIBRPMOSTREE_RUST_SRCS)
|
||||||
target_subdir=@abs_top_builddir@/target/@RUST_TARGET_SUBDIR@; \
|
|
||||||
if test -d "$${target_subdir}" && [ "$$(stat -c '%u' $${target_subdir})" != "$$(id -u)" ]; then echo "mismatched uids on build"; exit 1; fi && \
|
|
||||||
$(cargo_build) $(CARGO_RELEASE_ARGS)
|
|
||||||
EXTRA_DIST += $(LIBRPMOSTREE_RUST_SRCS) rust/Cargo.lock
|
|
||||||
|
|
||||||
# Generate bindings from Rust to C
|
# Generate bindings from Rust to C
|
||||||
if !HAVE_PREBUILT_CBINDGEN
|
if !HAVE_PREBUILT_CBINDGEN
|
||||||
if HAVE_EXTERNAL_CBINDGEN
|
if HAVE_EXTERNAL_CBINDGEN
|
||||||
rpmostree-rust.h:
|
rpmostree-rust.h:
|
||||||
$(AM_V_GEN) cbindgen -c rust/cbindgen.toml -o $@ $(top_srcdir)/rust
|
$(AM_V_GEN) cbindgen -c rust/cbindgen.toml -o $@ $(top_srcdir)
|
||||||
else
|
else
|
||||||
rpmostree-rust.h: rpmostree-bindgen
|
rpmostree-rust.h: rpmostree-bindgen
|
||||||
$(AM_V_GEN) ./rpmostree-bindgen $(top_srcdir)/rust
|
$(AM_V_GEN) ./rpmostree-bindgen $(top_srcdir)
|
||||||
endif
|
endif
|
||||||
BUILT_SOURCES += rpmostree-rust.h
|
BUILT_SOURCES += rpmostree-rust.h
|
||||||
endif
|
endif
|
||||||
|
@ -40,9 +40,9 @@ mkdir ${tmpd} && touch ${tmpd}/.tmp
|
|||||||
|
|
||||||
(cd ${tmpd}
|
(cd ${tmpd}
|
||||||
mkdir -p .cargo vendor
|
mkdir -p .cargo vendor
|
||||||
(cd ${TOP}/rust && cargo vendor ${tmpd}/vendor)
|
(cd ${TOP} && cargo vendor ${tmpd}/vendor)
|
||||||
cp ${TOP}/rust/Cargo.lock .
|
cp ${TOP}/Cargo.lock .
|
||||||
cp ${TOP}/rust/cargo-vendor-config .cargo/config
|
cp ${TOP}/cargo-vendor-config .cargo/config
|
||||||
# Filter out bundled libcurl and systemd; we always want the pkgconfig ones
|
# Filter out bundled libcurl and systemd; we always want the pkgconfig ones
|
||||||
for crate_subdir in curl-sys/curl \
|
for crate_subdir in curl-sys/curl \
|
||||||
libz-sys/src/zlib \
|
libz-sys/src/zlib \
|
||||||
|
Loading…
Reference in New Issue
Block a user