4ce5f42d12
This allows us to fully use cxx-rs with `extern "C++"`. Now we do call back into the C/C++ today, but it only works outside of cargo/Rust's knowledge. Most notably, it means we can't use our C code in `cargo test`. And that's a problem for moving some C/C++ code to Rust, because we want to port the unit tests too. For now, re-declare our dependencies and part of the build system inside the Cargo build. However, this is also an important step towards using Cargo as our *sole* build system. We don't add build dependencies too often, so the short term duplication should be OK. However, a major unfortunate side effect of this is that we now need to serialize the build process; almost all the C/C++ comes first (`librpmostreeinternals.la`) and then the Rust build, then we finally generate the executable with both. The only way out of this really is to move more of the C/C++ build into Cargo, and we probably want to refactor into internal crates.
152 lines
6.3 KiB
Plaintext
152 lines
6.3 KiB
Plaintext
# Copyright (C) 2013 Colin Walters <walters@verbum.org>
|
|
#
|
|
# This library is free software; you can redistribute it and/or
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
# License as published by the Free Software Foundation; either
|
|
# version 2 of the License, or (at your option) any later version.
|
|
#
|
|
# This library is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
# Lesser General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
# License along with this library; if not, write to the
|
|
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
# Boston, MA 02111-1307, USA.
|
|
|
|
bin_PROGRAMS += rpm-ostree
|
|
|
|
rpm_ostree_SOURCES = src/app/main.cxx
|
|
|
|
noinst_LTLIBRARIES += librpmostreeinternals.la
|
|
|
|
librpmostreeinternals_la_SOURCES = \
|
|
src/app/libmain.cxx \
|
|
src/app/rpmostree-builtins.h \
|
|
src/app/rpmostree-db-builtins.h \
|
|
src/app/rpmostree-compose-builtins.h \
|
|
src/app/rpmostree-builtin-upgrade.cxx \
|
|
src/app/rpmostree-builtin-rollback.cxx \
|
|
src/app/rpmostree-builtin-deploy.cxx \
|
|
src/app/rpmostree-builtin-reload.cxx \
|
|
src/app/rpmostree-builtin-rebase.cxx \
|
|
src/app/rpmostree-builtin-cancel.cxx \
|
|
src/app/rpmostree-builtin-cleanup.cxx \
|
|
src/app/rpmostree-builtin-cliwrap.cxx \
|
|
src/app/rpmostree-builtin-countme.cxx \
|
|
src/app/rpmostree-builtin-initramfs.cxx \
|
|
src/app/rpmostree-builtin-initramfs-etc.cxx \
|
|
src/app/rpmostree-builtin-livefs.cxx \
|
|
src/app/rpmostree-builtin-usroverlay.cxx \
|
|
src/app/rpmostree-builtin-override.cxx \
|
|
src/app/rpmostree-builtin-refresh-md.cxx \
|
|
src/app/rpmostree-builtin-reset.cxx \
|
|
src/app/rpmostree-pkg-builtins.cxx \
|
|
src/app/rpmostree-builtin-status.cxx \
|
|
src/app/rpmostree-builtin-ex.cxx \
|
|
src/app/rpmostree-builtin-testutils.cxx \
|
|
src/app/rpmostree-builtin-shlib-backend.cxx \
|
|
src/app/rpmostree-builtin-db.cxx \
|
|
src/app/rpmostree-builtin-start-daemon.cxx \
|
|
src/app/rpmostree-builtin-finalize-deployment.cxx \
|
|
src/app/rpmostree-db-builtin-diff.cxx \
|
|
src/app/rpmostree-db-builtin-list.cxx \
|
|
src/app/rpmostree-db-builtin-version.cxx \
|
|
src/app/rpmostree-dbus-helpers.cxx \
|
|
src/app/rpmostree-dbus-helpers.h \
|
|
src/app/rpmostree-override-builtins.h \
|
|
src/app/rpmostree-override-builtins.cxx \
|
|
src/app/rpmostree-libbuiltin.cxx \
|
|
src/app/rpmostree-libbuiltin.h \
|
|
src/app/rpmostree-polkit-agent.cxx \
|
|
src/app/rpmostree-polkit-agent.h \
|
|
src/app/rpmostree-builtin-kargs.cxx \
|
|
src/app/rpmostree-compose-builtin-tree.cxx \
|
|
src/app/rpmostree-composeutil.cxx \
|
|
src/app/rpmostree-composeutil.h \
|
|
src/app/rpmostree-builtin-compose.cxx \
|
|
$(librpmostreed_sources) \
|
|
$(librpmostreepriv_sources) \
|
|
$(NULL)
|
|
|
|
if BUILDOPT_ROJIG
|
|
librpmostreeinternals_la_SOURCES += \
|
|
src/app/rpmostree-ex-builtin-commit2rojig.cxx \
|
|
src/app/rpmostree-ex-builtin-rojig2commit.cxx \
|
|
src/app/rpmostree-compose-builtin-rojig.cxx \
|
|
$(NULL)
|
|
endif
|
|
|
|
nodist_librpmostreeinternals_la_SOURCES = $(dbus_built_sources) $(nodist_librpmostreepriv_sources)
|
|
|
|
rpmostree_common_cflags = -I$(srcdir)/src/app -I$(srcdir)/src/daemon \
|
|
-I$(srcdir)/src/lib -I$(srcdir)/src/libpriv -I$(libglnx_srcpath) \
|
|
-DG_LOG_DOMAIN=\"rpm-ostreed\" \
|
|
-DLIBDIR=\"$(libdir)\" -DPKGLIBDIR=\"$(pkglibdir)\" \
|
|
$(PKGDEP_RPMOSTREE_CFLAGS) $(PKGDEP_RPMOSTREE_RS_CFLAGS)
|
|
rpmostree_bin_common_cflags = $(rpmostree_common_cflags)
|
|
rpmostree_common_libs = $(PKGDEP_RPMOSTREE_LIBS) $(CAP_LIBS) libglnx.la librpmostree-1.la librpmostreecxxrs.la $(PKGDEP_RPMOSTREE_RS_LIBS) -lstdc++ -lrt
|
|
rpmostree_bin_common_libs = librpmostreeinternals.la $(librpmostree_rust_path) $(rpmostree_common_libs)
|
|
rpm_ostree_CFLAGS = $(AM_CFLAGS) $(rpmostree_bin_common_cflags)
|
|
rpm_ostree_CXXFLAGS = $(AM_CXXFLAGS) $(rpmostree_bin_common_cflags)
|
|
rpm_ostree_LDADD = librpmostreeinternals.la $(rpmostree_bin_common_libs)
|
|
EXTRA_rpm_ostree_DEPENDENCIES = libdnf.so.2
|
|
librpmostreeinternals_la_CFLAGS = $(AM_CFLAGS) $(rpmostree_common_cflags)
|
|
librpmostreeinternals_la_CXXFLAGS = $(AM_CXXFLAGS) $(rpmostree_common_cflags)
|
|
librpmostreeinternals_la_LIBADD = $(rpmostree_common_libs)
|
|
EXTRA_librpmostreeinternals_la_DEPENDENCIES = libdnf.so.2
|
|
|
|
privdatadir=$(pkglibdir)
|
|
privdata_DATA = src/app/rpm-ostree-0-integration.conf
|
|
|
|
# Propagate automake verbose mode
|
|
cargo_build = $(cargo) build $(if $(subst 0,,$(V)),--verbose,)
|
|
if BUILDOPT_PREBUILT_BINDINGS
|
|
cargo_build += "--offline"
|
|
endif
|
|
|
|
if BUILDOPT_ENABLE_SQLITE_RPMDB_DEFAULT
|
|
cargo_build += --features sqlite-rpmdb-default
|
|
endif
|
|
|
|
librpmostree_rust_path = $(top_srcdir)/target/@RUST_TARGET_SUBDIR@/librpmostree_rust.a
|
|
# 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') Cargo.toml Cargo.lock cbindgen.toml
|
|
# FIXME - build all this code in a rpmostree-sys crate, or just move all the C/C++ build
|
|
# to Rust. Currently this forces build system serialization
|
|
$(librpmostree_rust_path): Makefile $(LIBRPMOSTREE_RUST_SRCS) librpmostreeinternals.la
|
|
$(cargo_build) $(CARGO_RELEASE_ARGS)
|
|
EXTRA_DIST += $(LIBRPMOSTREE_RUST_SRCS)
|
|
|
|
# cbindgen + cxx.rs
|
|
binding_generated_sources = rpmostree-rust.h rpmostree-cxxrs.h rpmostree-cxxrs.cxx
|
|
if BUILDOPT_PREBUILT_BINDINGS
|
|
# In this case we shipped prebuilt versions in the source tarball
|
|
rpmostree-rust.h:
|
|
ln -sfr rpmostree-rust-prebuilt.h $@
|
|
rpmostree-cxxrs.h:
|
|
ln -sfr rpmostree-cxxrs-prebuilt.h $@
|
|
rpmostree-cxxrs.cxx:
|
|
ln -sfr rpmostree-cxxrs-prebuilt.cxx $@
|
|
else
|
|
include Makefile.bindings
|
|
endif
|
|
|
|
noinst_LTLIBRARIES += librpmostreecxxrs.la
|
|
librpmostreecxxrs_la_SOURCES = rpmostree-cxxrs.h rpmostree-cxxrs.cxx
|
|
# Suppress missing-declarations because https://github.com/dtolnay/cxx/issues/590
|
|
librpmostreecxxrs_la_CXXFLAGS = $(AM_CXXFLAGS) $(rpmostree_common_cflags) -Wno-missing-declarations
|
|
librpmostreecxxrs_la_LIBADD = -lstdc++
|
|
GITIGNOREFILES += $(binding_generated_sources)
|
|
BUILT_SOURCES += $(binding_generated_sources)
|
|
|
|
# Wraps `cargo test`. This is always a debug non-release build;
|
|
# the main thing here is we still drop the `target` dir in our build
|
|
# directory, since we nominally support srcdir != builddir.
|
|
rust-test:
|
|
cd $(top_srcdir)/rust && CARGO_TARGET_DIR=@abs_top_builddir@/target cargo test
|
|
.PHONY: rust-test
|