diff --git a/Makefile-rpm-ostree.am b/Makefile-rpm-ostree.am index b1cfdb12..713d4b00 100644 --- a/Makefile-rpm-ostree.am +++ b/Makefile-rpm-ostree.am @@ -106,6 +106,10 @@ $(librpmostree_rust_path): Makefile $(LIBRPMOSTREE_RUST_SRCS) EXTRA_DIST += $(LIBRPMOSTREE_RUST_SRCS) # Generate bindings from Rust to C +if BUILDOPT_PREBUILT_BINDINGS +rpmostree-rust.h: + ln -sfr rpmostree-rust-prebuilt.h $@ +else if !HAVE_PREBUILT_CBINDGEN if HAVE_EXTERNAL_CBINDGEN rpmostree-rust.h: @@ -114,8 +118,9 @@ else rpmostree-rust.h: rpmostree-bindgen $(AM_V_GEN) ./rpmostree-bindgen $(top_srcdir) endif -BUILT_SOURCES += rpmostree-rust.h endif +endif +BUILT_SOURCES += rpmostree-rust.h rpm_ostree_CFLAGS += $(PKGDEP_RPMOSTREE_RS_CFLAGS) rpm_ostree_LDADD += $(librpmostree_rust_path) $(PKGDEP_RPMOSTREE_RS_LIBS) -lstdc++ diff --git a/configure.ac b/configure.ac index d319e2fe..e1d2d205 100644 --- a/configure.ac +++ b/configure.ac @@ -195,14 +195,18 @@ AS_IF([test -z "$cargo"], [AC_MSG_ERROR([cargo is required for --enable-rust])]) AC_PATH_PROG([rustc], [rustc]) AS_IF([test -z "$rustc"], [AC_MSG_ERROR([rustc is required for --enable-rust])]) +dnl this is true effectively iff we used make-git-snapshot.sh +AM_CONDITIONAL(BUILDOPT_PREBUILT_BINDINGS, [test -f rpmostree-rust-prebuilt.h]) + +AM_COND_IF([BUILDOPT_PREBUILT_BINDINGS], [cbindgen=prebuilt], [ dnl https://github.com/projectatomic/rpm-ostree/pull/1573 -dnl We support 3 modes for bindgen: +dnl We support 2 modes for bindgen: dnl - External /usr/bin/cbindgen (Fedora + CI) dnl - Downloading it from crates.io (CentOS + CI builds) -dnl - Not running it at all, and using a pre-built rpmostree-rust.h (Koji) AS_IF([test -d "${srcdir}"/rust/vendor], [cbindgen=dist], [AC_PATH_PROG([cbindgen], [cbindgen])]) +]) AM_CONDITIONAL(HAVE_PREBUILT_CBINDGEN, [test "${cbindgen}" = "dist"]) AM_CONDITIONAL(HAVE_EXTERNAL_CBINDGEN, [test -n "${cbindgen}" && test "${cbindgen}" != dist]) diff --git a/packaging/make-git-snapshot.sh b/packaging/make-git-snapshot.sh index fb69c907..d9102609 100755 --- a/packaging/make-git-snapshot.sh +++ b/packaging/make-git-snapshot.sh @@ -57,13 +57,13 @@ j = json.load(open(checksum_file)) j["files"] = {f:c for f, c in j["files"].items() if not f.startswith(subdir)} open(checksum_file, "w").write(json.dumps(j))' $crate_subdir done - tar --transform="s,^,${PKG_VER}/rust/," -rf ${TARFILE_TMP} * .cargo/ + tar --transform="s,^,${PKG_VER}/," -rf ${TARFILE_TMP} * .cargo/ ) # And finally, vendor rpmostree-rust.h; it's generated by cbindgen, # and it's easier than vendoring all of the source for that too. # This is currently the *only* generated file we treat this way. See also # https://github.com/projectatomic/rpm-ostree/pull/1573 -(cd ${srcdir} && tar --transform "s,^,${PKG_VER}/," -rf ${TARFILE_TMP} rpmostree-rust.h) +(cd ${srcdir} && cp rpmostree-rust{,-prebuilt}.h && tar --transform "s,^,${PKG_VER}/," -rf ${TARFILE_TMP} rpmostree-rust-prebuilt.h) mv ${TARFILE_TMP} ${TARFILE}