2019-11-14 16:43:07 -05:00
|
|
|
# For use by automake and autoconf
|
|
|
|
#
|
2023-01-17 23:09:25 -05:00
|
|
|
# Copyright (C) 2014-2023 Ryan Specialty, LLC.
|
2020-03-06 11:05:18 -05:00
|
|
|
#
|
|
|
|
# This file is part of TAME.
|
2019-11-14 16:43:07 -05:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program 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 General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
##
|
|
|
|
|
|
|
|
m4_include([build-aux/m4/ax_compare_version.m4])
|
|
|
|
|
|
|
|
# version string is dynamically generated
|
|
|
|
m4_define([ver], m4_esyscmd(build-aux/vergen))
|
|
|
|
m4_if(ver, [], [m4_exit(1)])
|
|
|
|
|
|
|
|
AC_INIT([tame], [ver], [dev@lovullo.com])
|
|
|
|
AC_CONFIG_AUX_DIR([build-aux])
|
|
|
|
AM_INIT_AUTOMAKE([foreign])
|
|
|
|
|
|
|
|
# provide more granular version numbers based on the version string, using
|
|
|
|
# the format MAJOR.MINOR.REV[-SUFFIX], where SUFFIX can itself contain
|
|
|
|
# dashes (and often will)
|
|
|
|
m4_define([ver_split],
|
|
|
|
m4_split(
|
|
|
|
patsubst(AC_PACKAGE_VERSION, [^\([^-]+\)-], [\1.]),
|
|
|
|
[\.]))
|
|
|
|
AC_SUBST(MAJOR, m4_argn(1, ver_split))
|
|
|
|
AC_SUBST(MINOR, m4_argn(2, ver_split))
|
|
|
|
AC_SUBST(REV, m4_argn(3, ver_split))
|
|
|
|
AC_SUBST(SUFFIX, m4_argn(4, ver_split))
|
|
|
|
|
|
|
|
AC_ARG_VAR([CARGO], [Rust Cargo executable])
|
|
|
|
AC_CHECK_PROGS(CARGO, [cargo])
|
|
|
|
|
|
|
|
test -n "$CARGO" || AC_MSG_ERROR([cargo not found])
|
|
|
|
|
2023-06-05 15:58:26 -04:00
|
|
|
# Derive the expected nightly version from `rust-toolchain.toml` and
|
|
|
|
# configure the build system to use that version explicitly for each cargo
|
|
|
|
# invoation in the Makefile.
|
|
|
|
#
|
|
|
|
# See rust-toolchain.toml for information about this process. Note that
|
|
|
|
# this file will only trigger an auto-update if it is actually used to
|
|
|
|
# derive the version (if TAMER_RUST_TOOLCHAIN is _not_ used).
|
|
|
|
AC_ARG_VAR([TAMER_RUST_TOOLCHAIN],
|
|
|
|
[Rust toolchain channel to use in place of rust-toolchain.toml contents])
|
|
|
|
AC_MSG_CHECKING([toolchain channel])
|
|
|
|
AS_IF([test -n "$TAMER_RUST_TOOLCHAIN"],
|
|
|
|
[AC_MSG_RESULT([$TAMER_RUST_TOOLCHAIN (from TAMER_RUST_TOOLCHAIN)])
|
|
|
|
AC_SUBST(RUST_TC, [$TAMER_RUST_TOOLCHAIN])],
|
|
|
|
[rust_channel=$($AWK -F '[[ "]]' '$1=="channel" { print $4 }' rust-toolchain.toml)
|
|
|
|
AS_IF([test -n "$rust_channel"],
|
|
|
|
[AC_MSG_RESULT([$rust_channel (from rust-toolchain.toml)])
|
|
|
|
AC_SUBST([RUST_TC], [$rust_channel])],
|
|
|
|
[AC_MSG_RESULT([missing (from both rust-toolchain.toml and TAMER_RUST_TOOLCHAIN)])
|
|
|
|
AC_MSG_ERROR([rust-toolchain.toml is missing or does not contain channel])])
|
|
|
|
AC_SUBST([CONFIG_STATUS_DEPENDENCIES], rust-toolchain.toml)])
|
|
|
|
|
2021-12-02 11:34:56 -05:00
|
|
|
# There is no reason the build should _ever_ access the network.
|
|
|
|
# This both helps with reproducibility and helps to mitigate supply chain
|
|
|
|
# attacks by requiring developers to explicitly indicate their intent to
|
|
|
|
# fetch a network resource (by invoking cargo manually).
|
|
|
|
AC_SUBST([CARGO_FLAGS], "--frozen --offline")
|
|
|
|
|
2023-06-05 15:58:26 -04:00
|
|
|
# This is the version of Rust that would be required if we were not
|
|
|
|
# utilizing nightly features. This serves as a lower version bound, whereas
|
|
|
|
# the nightly check above serves as an upper bound.
|
2023-04-12 11:42:01 -04:00
|
|
|
rustc_ver_req=1.70
|
2019-11-14 16:43:07 -05:00
|
|
|
|
|
|
|
AC_CHECK_PROGS(RUSTC, [rustc])
|
2021-10-01 09:38:31 -04:00
|
|
|
AC_MSG_CHECKING([rustc $RUST_TC version >= $rustc_ver_req])
|
|
|
|
rustc_version=$("$RUSTC" "+$RUST_TC" --version | cut -d' ' -f2)
|
2023-06-05 15:58:26 -04:00
|
|
|
AS_IF([test -z "$rustc_version"],
|
|
|
|
[AC_MSG_ERROR([
|
|
|
|
failed to execute rustc with toolchain $RUST_TC (see above for error message)
|
|
|
|
- if the above toolchain is not found, try running `bootstrap`])])
|
2019-11-14 16:43:07 -05:00
|
|
|
AX_COMPARE_VERSION([$rustc_version], [ge], [$rustc_ver_req],
|
|
|
|
[AC_MSG_RESULT([yes ($rustc_version)])],
|
2023-06-05 15:58:26 -04:00
|
|
|
[AC_MSG_RESULT([no ($rustc_version)])])
|
2019-11-14 16:43:07 -05:00
|
|
|
|
2019-11-27 09:17:27 -05:00
|
|
|
AC_ARG_VAR([CARGO_BUILD_FLAGS],
|
|
|
|
[Flags to be passed to `cargo build' when invoked via Make])
|
2022-12-14 19:56:57 -05:00
|
|
|
AC_ARG_VAR([RUSTFLAGS],
|
|
|
|
[Flags to be passed to `rustc' when invoked via Make])
|
2019-11-27 09:17:27 -05:00
|
|
|
|
2021-06-21 13:10:00 -04:00
|
|
|
# All currently-used doc features are stable (this used to be used for
|
|
|
|
# intra-doc links)
|
|
|
|
AC_SUBST([CARGO_DOC_FLAGS], [])
|
2019-12-04 11:18:12 -05:00
|
|
|
|
2019-12-04 09:57:08 -05:00
|
|
|
# The `test` feature is required for benchmarking. If unavailable, then
|
|
|
|
# it's still an unstable feature and we'll need to use nightly. We don't
|
|
|
|
# check for nightly here, though---if it's missing, then cargo will tell the
|
|
|
|
# user what to do.
|
2021-10-01 09:38:31 -04:00
|
|
|
AC_MSG_CHECKING([`test` feature support on $RUST_TC])
|
|
|
|
AS_IF(["$RUSTC" "+$RUST_TC" --crate-type lib build-aux/bench_check.rs &>/dev/null],
|
2019-12-04 09:57:08 -05:00
|
|
|
[AC_MSG_RESULT(available)],
|
|
|
|
[AC_MSG_RESULT([no (nightly required)])
|
2021-08-19 16:43:14 -04:00
|
|
|
AC_SUBST([CARGO_BENCH_PRE_FLAGS], [+nightly])])
|
2019-12-04 09:57:08 -05:00
|
|
|
|
2019-12-03 13:53:29 -05:00
|
|
|
# Cargo commands may be available but not necessarily installed for the
|
|
|
|
# active toolchain. Let's check that.
|
2021-10-01 09:38:31 -04:00
|
|
|
AC_MSG_CHECKING([whether cargo-fmt is available on $RUST_TC])
|
|
|
|
AS_IF([cargo "+$RUST_TC" fmt --help &>/dev/null],
|
2019-12-03 13:53:29 -05:00
|
|
|
[AC_MSG_RESULT(yes)],
|
|
|
|
[AC_MSG_RESULT(no)
|
2021-10-01 09:38:31 -04:00
|
|
|
cargo "+$RUST_TC" fmt --help # run again so user can see output
|
|
|
|
AC_MSG_ERROR([missing cargo-fmt on $RUST_TC])])
|
2019-12-03 13:53:29 -05:00
|
|
|
|
2019-12-04 11:18:12 -05:00
|
|
|
# Cargo commands may be available but not necessarily installed for the
|
|
|
|
# active toolchain. Let's check that.
|
2021-10-01 09:38:31 -04:00
|
|
|
AC_MSG_CHECKING([whether cargo-doc is available on $RUST_TC])
|
|
|
|
AS_IF([cargo "+$RUST_TC" $CARGO_DOC_FLAGS doc --help &>/dev/null],
|
2019-12-04 11:18:12 -05:00
|
|
|
[AC_MSG_RESULT(yes)],
|
|
|
|
[AC_MSG_RESULT(no)
|
2020-03-05 11:16:15 -05:00
|
|
|
# run again so user can see output
|
2021-10-01 09:38:31 -04:00
|
|
|
cargo "+$RUST_TC" $CARGO_DOC_FLAGS doc --help 2>&1 | sed 's/^.*: //'
|
|
|
|
AC_MSG_WARN([missing cargo-doc on $RUST_TC])
|
2020-03-05 11:16:15 -05:00
|
|
|
AC_MSG_WARN([`make html` will not work])])
|
2019-12-04 11:18:12 -05:00
|
|
|
|
tamer: Integrate clippy
This invokes clippy as part of `make check` now, which I had previously
avoided doing (I'll elaborate on that below).
This commit represents the changes needed to resolve all the warnings
presented by clippy. Many changes have been made where I find the lints to
be useful and agreeable, but there are a number of lints, rationalized in
`src/lib.rs`, where I found the lints to be disagreeable. I have provided
rationale, primarily for those wondering why I desire to deviate from the
default lints, though it does feel backward to rationalize why certain lints
ought to be applied (the reverse should be true).
With that said, this did catch some legitimage issues, and it was also
helpful in getting some older code up-to-date with new language additions
that perhaps I used in new code but hadn't gone back and updated old code
for. My goal was to get clippy working without errors so that, in the
future, when others get into TAMER and are still getting used to Rust,
clippy is able to help guide them in the right direction.
One of the reasons I went without clippy for so long (though I admittedly
forgot I wasn't using it for a period of time) was because there were a
number of suggestions that I found disagreeable, and I didn't take the time
to go through them and determine what I wanted to follow. Furthermore, it
was hard to make that judgment when I was new to the language and lacked
the necessary experience to do so.
One thing I would like to comment further on is the use of `format!` with
`expect`, which is also what the diagnostic system convenience methods
do (which clippy does not cover). Because of all the work I've done trying
to understand Rust and looking at disassemblies and seeing what it
optimizes, I falsely assumed that Rust would convert such things into
conditionals in my otherwise-pure code...but apparently that's not the case,
when `format!` is involved.
I noticed that, after making the suggested fix with `get_ident`, Rust
proceeded to then inline it into each call site and then apply further
optimizations. It was also previously invoking the thread lock (for the
interner) unconditionally and invoking the `Display` implementation. That
is not at all what I intended for, despite knowing the eager semantics of
function calls in Rust.
Anyway, possibly more to come on that, I'm just tired of typing and need to
move on. I'll be returning to investigate further diagnostic messages soon.
2023-01-12 10:46:48 -05:00
|
|
|
AC_MSG_CHECKING([whether cargo-clippy is available on $RUST_TC])
|
|
|
|
AS_IF([cargo "+$RUST_TC" clippy --help &>/dev/null],
|
|
|
|
[AC_MSG_RESULT(yes)],
|
|
|
|
[AC_MSG_RESULT(no)
|
|
|
|
cargo "+$RUST_TC" clippy --help # run again so user can see output
|
|
|
|
AC_MSG_ERROR([missing cargo-fmt on $RUST_TC])])
|
|
|
|
|
2021-07-23 10:16:44 -04:00
|
|
|
AC_ARG_VAR([FEATURES],
|
|
|
|
[Cargo features flags for TAMER, comma-delimited])
|
|
|
|
|
2023-02-22 21:55:51 -05:00
|
|
|
AC_SUBST([FEATURES_RAW], [])
|
|
|
|
|
2021-07-23 10:16:44 -04:00
|
|
|
test -z "$FEATURES" || {
|
|
|
|
AC_MSG_RESULT([requested features: $FEATURES])
|
2023-02-22 21:55:51 -05:00
|
|
|
FEATURES_RAW="$FEATURES"
|
2021-07-23 10:16:44 -04:00
|
|
|
FEATURES="--features $FEATURES"
|
|
|
|
}
|
|
|
|
|
2023-02-22 23:03:42 -05:00
|
|
|
# Other programs used by scripts
|
|
|
|
AC_CHECK_PROGS(XMLLINT, [xmllint])
|
|
|
|
test -n "$XMLLINT" || AC_MSG_ERROR([xmllint not found])
|
|
|
|
|
2023-03-10 14:11:55 -05:00
|
|
|
AC_CHECK_PROGS(DOT, [dot])
|
|
|
|
test -n "$DOT" || AC_MSG_ERROR([Graphviz dot not found])
|
|
|
|
|
2023-02-22 21:55:51 -05:00
|
|
|
AC_CONFIG_FILES([Makefile conf.sh])
|
2019-11-14 16:43:07 -05:00
|
|
|
|
|
|
|
AC_OUTPUT
|