rpm-ostree/Makefile.bindings
Colin Walters 15811eca4f Makefile.bindings: Use content-based change detection
We've had a problem for a long time that e.g. `rpmostree-rust.h`
didn't have dependencies on the relevant Rust sources, so changing
it required `rm -f rpmostree-rust && make` which is very confusing.

Improve things here for both it and cxx.rs so that we use
content-based change detection (this is a default in more modern
build systems).  This way e.g. `touch Cargo.toml && make` won't
implicitly result in rebuilding all of the C/C++ side.
2021-01-04 13:17:35 +01:00

31 lines
1.1 KiB
Makefile

# This is duplicated with LIBRPMOSTREE_RUST_SRCS because this
# Makefile needs to be independent
binding_rust_sources = $(shell find rust/src/ -name '*.rs') Cargo.toml Cargo.lock cbindgen.toml
# A plain Makefile (not automake) so that we can run this logic
# without running the autotools.
rpmostree-rust.h: $(binding_rust_sources)
$(AM_V_GEN) if cbindgen -c cbindgen.toml -o $@.tmp $(top_srcdir); then \
if test -f $@ && cmp $@.tmp $@ 2>/dev/null; then rm -f $@.tmp; else \
mv $@.tmp $@; \
fi; \
else \
echo cbindgen failed; exit 1; \
fi
BUILT_SOURCES += rpmostree-rust.h
rpmostree-cxxrs.h: $(binding_rust_sources)
$(AM_V_GEN) if cxxbridge rust/src/lib.rs --header > $@.tmp; then \
if test -f $@ && cmp $@.tmp $@ 2>/dev/null; then rm -f $@.tmp; else \
mv $@.tmp $@; \
fi; \
else \
echo cxxbridge failed; exit 1; \
fi
rpmostree-cxxrs.cxx: $(binding_rust_sources) rpmostree-cxxrs.h
$(AM_V_GEN) cxxbridge --include rpmostree-cxxrs.h rust/src/lib.rs > $@
# Invoked in CI
bindings: rpmostree-rust.h rpmostree-cxxrs.h rpmostree-cxxrs.cxx
.PHONY: bindings