diff --git a/Makefile.am b/Makefile.am index a5fc43102..bb44bdb5e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -179,7 +179,7 @@ CARGO_FEATURE_ARGS += --features variations endif rusile.so: $(rusile_so_SOURCES) $(bin_PROGRAMS) - $(CARGO_ENV) $(CARGO) build $(CARGO_VERBOSE) $(RUSILE_FEATURE_ARG) $(CARGO_RELEASE_ARGS) -p rusile + $(CARGO_ENV) $(CARGO) build $(CARGO_VERBOSE) --target $(CARGO_TARGET_TRIPLE) $(RUSILE_FEATURE_ARG) $(CARGO_RELEASE_ARGS) -p rusile $(INSTALL) @builddir@/target/@RUST_TARGET_SUBDIR@/lib$@ $@ DEPDIR := .deps diff --git a/build-aux/que_rust_boilerplate.am b/build-aux/que_rust_boilerplate.am index a1ba65af4..26de4ef58 100644 --- a/build-aux/que_rust_boilerplate.am +++ b/build-aux/que_rust_boilerplate.am @@ -57,8 +57,8 @@ $(COMPLETIONS_OUT_DIR)/_$(TRANSFORMED_PACKAGE_NAME): $(CARGO_BIN) | $(COMPLETION $(_RUST_OUT) $(CARGO_BIN): $(@PACKAGE_VAR@_SOURCES) $(nodist_@PACKAGE_VAR@_SOURCES) $(EXTRA_@PACKAGE_VAR@_SOURCES) set -e export AUTOTOOLS_DEPENDENCIES="$^" - $(CARGO_ENV) $(CARGO) build $(CARGO_VERBOSE) $(CARGO_FEATURE_ARGS) $(CARGO_RELEASE_ARGS) - $(CARGO_ENV) $(CARGO) build --quiet --message-format=json $(CARGO_FEATURE_ARGS) $(CARGO_RELEASE_ARGS) | \ + $(CARGO_ENV) $(CARGO) build $(CARGO_VERBOSE) --target $(CARGO_TARGET_TRIPLE) $(CARGO_FEATURE_ARGS) $(CARGO_RELEASE_ARGS) + $(CARGO_ENV) $(CARGO) build --target $(CARGO_TARGET_TRIPLE) --quiet --message-format=json $(CARGO_FEATURE_ARGS) $(CARGO_RELEASE_ARGS) | \ $(JQ) -sr 'map(select(.reason == "build-script-executed")) | last | .out_dir' > $(_RUST_OUT) RUST_DEVELOPER_TARGETS = cargo-test clippy rustfmt diff --git a/build-aux/que_rust_boilerplate.m4 b/build-aux/que_rust_boilerplate.m4 index 36fa0923d..bc3d5ffaf 100644 --- a/build-aux/que_rust_boilerplate.m4 +++ b/build-aux/que_rust_boilerplate.m4 @@ -22,13 +22,17 @@ AC_DEFUN_ONCE([QUE_RUST_BOILERPLATE], [ QUE_PROGVAR([rustfmt]) ]) + AC_ARG_VAR(CARGO_TARGET_TRIPLE, "Target triple for Rust compilations") + if test -z "$CARGO_TARGET_TRIPLE"; then + CARGO_TARGET_TRIPLE="$($RUSTC -vV | $SED -n 's/host: //p')" + fi AC_MSG_CHECKING([whether to build Rust code with debugging information]) AM_COND_IF([DEBUG_RELEASE], [ AC_MSG_RESULT(yes) - RUST_TARGET_SUBDIR=debug + RUST_TARGET_SUBDIR=$CARGO_TARGET_TRIPLE/debug ], [ AC_MSG_RESULT(no) - RUST_TARGET_SUBDIR=release + RUST_TARGET_SUBDIR=$CARGO_TARGET_TRIPLE/release ]) AC_SUBST([RUST_TARGET_SUBDIR])