Commit fd9541ad authored by David Michael's avatar David Michael Committed by Federico Mena Quintero

Support cross-compiling with Rust

The primary change here is to add the --target=$(host) option to
the cargo build command, so the Rust components are compiled for
the target host system specified by the configure command.  The
cargo target subdirectory also needed to be prefixed with the host
triplet for cross-compiling.

Some of the crates' build scripts require cross-pkg-config settings
in the environment, so they are set for the cargo build command.

It's worth noting that Rust targets are limited to built-in values
by default, so the --host value given to configure may not be
supported.  Built in targets can be found by listing the directory
src/librustc_back/target in the rustc source.  When building with
an unsupported target, the user will have to write a target JSON
definition file and set the environment variable RUST_TARGET_PATH
to its directory (as with building any Rust project).

This also sneaks in prefixing the Rust library recipe line with a
"+" character to pass the GNU Make jobserver environment and file
descriptors, which cargo supports to act as a jobserver client.
parent 0f12c89e
......@@ -109,6 +109,10 @@ else
CARGO_RELEASE_ARGS=--release
endif
if CROSS_COMPILING
CARGO_TARGET_ARGS=--target=$(host)
endif
CARGO_VERBOSE = $(cargo_verbose_$(V))
cargo_verbose_ = $(cargo_verbose_$(AM_DEFAULT_VERBOSITY))
cargo_verbose_0 =
......@@ -130,9 +134,9 @@ dist-hook:
mkdir .cargo && \
cp cargo-vendor-config .cargo/config)
@abs_top_builddir@/rust/target/@RUST_TARGET_SUBDIR@/librsvg_internals.a: $(RUST_SOURCES)
cd $(top_srcdir)/rust && \
CARGO_TARGET_DIR=@abs_top_builddir@/rust/target cargo build $(CARGO_VERBOSE) $(CARGO_RELEASE_ARGS)
$(RUST_LIB): $(RUST_SOURCES)
+cd $(top_srcdir)/rust && PKG_CONFIG_ALLOW_CROSS=1 PKG_CONFIG='$(PKG_CONFIG)' \
CARGO_TARGET_DIR=@abs_top_builddir@/rust/target cargo build $(CARGO_VERBOSE) $(CARGO_TARGET_ARGS) $(CARGO_RELEASE_ARGS)
librsvg_@RSVG_API_MAJOR_VERSION@_la_CPPFLAGS = \
-I$(top_srcdir) \
......
......@@ -262,6 +262,9 @@ else
fi
AM_CONDITIONAL([DEBUG_RELEASE], [test "x$debug_release" = "xyes"])
if test "x$cross_compiling" = "xyes" ; then
RUST_TARGET_SUBDIR="$host/$RUST_TARGET_SUBDIR"
fi
AC_SUBST([RUST_TARGET_SUBDIR])
dnl ===========================================================================
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment