From f1488e52f0fe949c25923211daa9e9b71f1e9cc7 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 8 Dec 2020 18:29:05 +0000 Subject: [PATCH] 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 --- .cci.jenkinsfile | 2 +- rust/Cargo.lock => Cargo.lock | 0 rust/Cargo.toml => Cargo.toml | 4 ++-- Makefile-rpm-ostree.am | 14 +++++--------- rust/cargo-vendor-config => cargo-vendor-config | 0 rust/cbindgen.toml => cbindgen.toml | 0 packaging/make-git-snapshot.sh | 6 +++--- 7 files changed, 11 insertions(+), 15 deletions(-) rename rust/Cargo.lock => Cargo.lock (100%) rename rust/Cargo.toml => Cargo.toml (93%) rename rust/cargo-vendor-config => cargo-vendor-config (100%) rename rust/cbindgen.toml => cbindgen.toml (100%) diff --git a/.cci.jenkinsfile b/.cci.jenkinsfile index 20929eca..77bb2230 100644 --- a/.cci.jenkinsfile +++ b/.cci.jenkinsfile @@ -16,7 +16,7 @@ parallel rpms: { # binaries from PRs in the future) and meshes well with the following stages. export PATH="\$HOME/.cargo/bin:\$PATH" cargo install cbindgen - cbindgen -c rust/cbindgen.toml -o rpmostree-rust.h rust + cbindgen -c cbindgen.toml -o rpmostree-rust.h . cd packaging make -f Makefile.dist-packaging rpm diff --git a/rust/Cargo.lock b/Cargo.lock similarity index 100% rename from rust/Cargo.lock rename to Cargo.lock diff --git a/rust/Cargo.toml b/Cargo.toml similarity index 93% rename from rust/Cargo.toml rename to Cargo.toml index c381c337..ae096a61 100644 --- a/rust/Cargo.toml +++ b/Cargo.toml @@ -33,11 +33,11 @@ lazy_static = "1.4.0" envsubst = "0.2.0" subprocess = "0.2.6" 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] name = "rpmostree_rust" -path = "src/lib.rs" +path = "rust/src/lib.rs" crate-type = ["staticlib"] [profile.release] diff --git a/Makefile-rpm-ostree.am b/Makefile-rpm-ostree.am index 229d9983..b1cfdb12 100644 --- a/Makefile-rpm-ostree.am +++ b/Makefile-rpm-ostree.am @@ -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 # 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. -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) - cd $(top_srcdir)/rust && \ - export CARGO_TARGET_DIR=@abs_top_builddir@/target && \ - 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 + $(cargo_build) $(CARGO_RELEASE_ARGS) +EXTRA_DIST += $(LIBRPMOSTREE_RUST_SRCS) # Generate bindings from Rust to C if !HAVE_PREBUILT_CBINDGEN if HAVE_EXTERNAL_CBINDGEN 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 rpmostree-rust.h: rpmostree-bindgen - $(AM_V_GEN) ./rpmostree-bindgen $(top_srcdir)/rust + $(AM_V_GEN) ./rpmostree-bindgen $(top_srcdir) endif BUILT_SOURCES += rpmostree-rust.h endif diff --git a/rust/cargo-vendor-config b/cargo-vendor-config similarity index 100% rename from rust/cargo-vendor-config rename to cargo-vendor-config diff --git a/rust/cbindgen.toml b/cbindgen.toml similarity index 100% rename from rust/cbindgen.toml rename to cbindgen.toml diff --git a/packaging/make-git-snapshot.sh b/packaging/make-git-snapshot.sh index 853c9aee..fb69c907 100755 --- a/packaging/make-git-snapshot.sh +++ b/packaging/make-git-snapshot.sh @@ -40,9 +40,9 @@ mkdir ${tmpd} && touch ${tmpd}/.tmp (cd ${tmpd} mkdir -p .cargo vendor - (cd ${TOP}/rust && cargo vendor ${tmpd}/vendor) - cp ${TOP}/rust/Cargo.lock . - cp ${TOP}/rust/cargo-vendor-config .cargo/config + (cd ${TOP} && cargo vendor ${tmpd}/vendor) + cp ${TOP}/Cargo.lock . + cp ${TOP}/cargo-vendor-config .cargo/config # Filter out bundled libcurl and systemd; we always want the pkgconfig ones for crate_subdir in curl-sys/curl \ libz-sys/src/zlib \