Fix and improve support for rpmostree-rust.h being pre-generated
First, we now need the `vendor/` directory at the toplevel because that's where `Cargo.toml` is. Now this triggers another bug introduced in the build system with how we're handling the `rpmostree-rust.h` header. We ended up vendoring a pre-generated one in the tarball mainly because RHEL doesn't include cbindgen. Now probably in the future I'd like to fix that. But let's clean this up - the tarball generation process copies the file into `rpmostree-rust-prebuilt.h`, and build machinery detects that and entirely skips looking for or trying to build our internal cbindgen.
This commit is contained in:
parent
0c7de65f8e
commit
c718f34d43
@ -106,6 +106,10 @@ $(librpmostree_rust_path): Makefile $(LIBRPMOSTREE_RUST_SRCS)
|
|||||||
EXTRA_DIST += $(LIBRPMOSTREE_RUST_SRCS)
|
EXTRA_DIST += $(LIBRPMOSTREE_RUST_SRCS)
|
||||||
|
|
||||||
# Generate bindings from Rust to C
|
# 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_PREBUILT_CBINDGEN
|
||||||
if HAVE_EXTERNAL_CBINDGEN
|
if HAVE_EXTERNAL_CBINDGEN
|
||||||
rpmostree-rust.h:
|
rpmostree-rust.h:
|
||||||
@ -114,8 +118,9 @@ else
|
|||||||
rpmostree-rust.h: rpmostree-bindgen
|
rpmostree-rust.h: rpmostree-bindgen
|
||||||
$(AM_V_GEN) ./rpmostree-bindgen $(top_srcdir)
|
$(AM_V_GEN) ./rpmostree-bindgen $(top_srcdir)
|
||||||
endif
|
endif
|
||||||
BUILT_SOURCES += rpmostree-rust.h
|
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
BUILT_SOURCES += rpmostree-rust.h
|
||||||
|
|
||||||
rpm_ostree_CFLAGS += $(PKGDEP_RPMOSTREE_RS_CFLAGS)
|
rpm_ostree_CFLAGS += $(PKGDEP_RPMOSTREE_RS_CFLAGS)
|
||||||
rpm_ostree_LDADD += $(librpmostree_rust_path) $(PKGDEP_RPMOSTREE_RS_LIBS) -lstdc++
|
rpm_ostree_LDADD += $(librpmostree_rust_path) $(PKGDEP_RPMOSTREE_RS_LIBS) -lstdc++
|
||||||
|
@ -195,14 +195,18 @@ AS_IF([test -z "$cargo"], [AC_MSG_ERROR([cargo is required for --enable-rust])])
|
|||||||
AC_PATH_PROG([rustc], [rustc])
|
AC_PATH_PROG([rustc], [rustc])
|
||||||
AS_IF([test -z "$rustc"], [AC_MSG_ERROR([rustc is required for --enable-rust])])
|
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 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 - External /usr/bin/cbindgen (Fedora + CI)
|
||||||
dnl - Downloading it from crates.io (CentOS + CI builds)
|
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],
|
AS_IF([test -d "${srcdir}"/rust/vendor],
|
||||||
[cbindgen=dist],
|
[cbindgen=dist],
|
||||||
[AC_PATH_PROG([cbindgen], [cbindgen])])
|
[AC_PATH_PROG([cbindgen], [cbindgen])])
|
||||||
|
])
|
||||||
AM_CONDITIONAL(HAVE_PREBUILT_CBINDGEN, [test "${cbindgen}" = "dist"])
|
AM_CONDITIONAL(HAVE_PREBUILT_CBINDGEN, [test "${cbindgen}" = "dist"])
|
||||||
AM_CONDITIONAL(HAVE_EXTERNAL_CBINDGEN, [test -n "${cbindgen}" && test "${cbindgen}" != dist])
|
AM_CONDITIONAL(HAVE_EXTERNAL_CBINDGEN, [test -n "${cbindgen}" && test "${cbindgen}" != dist])
|
||||||
|
|
||||||
|
@ -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)}
|
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
|
open(checksum_file, "w").write(json.dumps(j))' $crate_subdir
|
||||||
done
|
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 finally, vendor rpmostree-rust.h; it's generated by cbindgen,
|
||||||
# and it's easier than vendoring all of the source for that too.
|
# 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
|
# This is currently the *only* generated file we treat this way. See also
|
||||||
# https://github.com/projectatomic/rpm-ostree/pull/1573
|
# 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}
|
mv ${TARFILE_TMP} ${TARFILE}
|
||||||
|
Loading…
Reference in New Issue
Block a user