Skip to content

Commit 689634a

Browse files
committed
refactor(build): Update Rust build macros from another project
1 parent 99f76d9 commit 689634a

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

build-aux/que_git_version.m4

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ AC_DEFUN_ONCE([QUE_GIT_VERSION], [
99
AM_CONDITIONAL([SOURCE_IS_ARCHIVE],
1010
[test ! -d .git -a ! -f .tarball-version])
1111
12-
AC_PROG_AWK
13-
AC_PROG_GREP
12+
AC_REQUIRE([AC_PROG_AWK])
13+
AC_REQUIRE([AC_PROG_GREP])
1414
1515
QUE_TRANSFORM_PACKAGE_NAME
1616

build-aux/que_rust_boilerplate.am

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ $(COMPLETIONS_OUT_DIR)/_$(TRANSFORMED_PACKAGE_NAME).ps1: $(CARGO_BIN) | $(COMPLE
5454
$(COMPLETIONS_OUT_DIR)/_$(TRANSFORMED_PACKAGE_NAME): $(CARGO_BIN) | $(COMPLETIONS_OUT_DIR)
5555
$(INSTALL) -m644 $$(cat $(_RUST_OUT))/$(COMPLETIONS_OUT_DIR)/_$(PACKAGE_NAME) $@
5656

57-
$(_RUST_OUT) $(CARGO_BIN): $(@PACKAGE_VAR@_SOURCES) $(EXTRA_@PACKAGE_VAR@_SOURCES)
57+
$(_RUST_OUT) $(CARGO_BIN): $(@PACKAGE_VAR@_SOURCES) $(nodist_@PACKAGE_VAR@_SOURCES) $(EXTRA_@PACKAGE_VAR@_SOURCES)
5858
set -e
5959
export AUTOTOOLS_DEPENDENCIES="$^"
60-
$(CARGO_ENV) $(CARGO) build $(CARGO_VERBOSE) $(CARGO_FEATURE_ARGS) $(CARGO_RELEASE_ARGS)
61-
$(CARGO_ENV) $(CARGO) build --quiet --message-format=json $(CARGO_FEATURE_ARGS) $(CARGO_RELEASE_ARGS) | \
60+
$(CARGO_ENV) $(CARGO) build $(CARGO_VERBOSE) --target $(CARGO_TARGET_TRIPLE) $(CARGO_FEATURE_ARGS) $(CARGO_RELEASE_ARGS)
61+
$(CARGO_ENV) $(CARGO) build --target $(CARGO_TARGET_TRIPLE) --quiet --message-format=json $(CARGO_FEATURE_ARGS) $(CARGO_RELEASE_ARGS) | \
6262
$(JQ) -sr 'map(select(.reason == "build-script-executed")) | last | .out_dir' > $(_RUST_OUT)
6363

6464
RUST_DEVELOPER_TARGETS = cargo-test clippy rustfmt

build-aux/que_rust_boilerplate.m4

+8-5
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,28 @@ AC_DEFUN_ONCE([QUE_RUST_BOILERPLATE], [
1010
AM_CONDITIONAL([DEBUG_RELEASE], [test "x$debug_release" = "xyes"])
1111
1212
AC_MSG_NOTICE([checking for tools used by automake to build Rust projects])
13-
AC_PROG_INSTALL
14-
AC_PROG_SED
13+
AC_REQUIRE([AC_PROG_INSTALL])
14+
AC_REQUIRE([AC_PROG_SED])
1515
AX_REQUIRE_PROG([cargo])
1616
AX_REQUIRE_PROG([jq])
1717
AX_REQUIRE_PROG([rustc])
18-
AX_REQUIRE_PROG([cmp])
1918
AX_REQUIRE_PROG([xargs])
2019
AM_COND_IF([DEVELOPER_MODE], [
2120
AX_REQUIRE_PROG([git])
2221
AX_REQUIRE_PROG([rustfmt])
2322
])
2423
24+
AC_ARG_VAR(CARGO_TARGET_TRIPLE, "Target triple for Rust compilations")
25+
if test -z "$CARGO_TARGET_TRIPLE"; then
26+
CARGO_TARGET_TRIPLE="$($RUSTC -vV | $SED -n 's/host: //p')"
27+
fi
2528
AC_MSG_CHECKING([whether to build Rust code with debugging information])
2629
AM_COND_IF([DEBUG_RELEASE], [
2730
AC_MSG_RESULT(yes)
28-
RUST_TARGET_SUBDIR=debug
31+
RUST_TARGET_SUBDIR=$CARGO_TARGET_TRIPLE/debug
2932
], [
3033
AC_MSG_RESULT(no)
31-
RUST_TARGET_SUBDIR=release
34+
RUST_TARGET_SUBDIR=$CARGO_TARGET_TRIPLE/release
3235
])
3336
AC_SUBST([RUST_TARGET_SUBDIR])
3437

0 commit comments

Comments
 (0)