ci: Update the support for cross-build verifications; refactor

Rename `CI_HOST_ARCH` and `CI_HOST_SYSTEM`, to `CI_BUILD_ARCH` and
`CI_BUILD_SYSTEM`, following the nomenclature used by GNU Autotools.
Unfortunately, the word "host" has confusingly opposite meanings in
CMake (and Bazel, etc.) vs. Autotools (and Meson, etc.)

Remove `CI_TARGET_TRIPLET` and `CI_TARGET_ABI` (for now).

Introduce the function `ci_expr` as a fast and easy equivalent of
`expr >/dev/null`.

Rephrase the assertions using an implementation pattern that is more
expressive, yet (arguably) just as readable. Remove `ci_assert`.

Modify the main functions to display more useful information in case
of usage error.
This commit is contained in:
Cosmin Truta
2023-10-18 19:36:38 +03:00
parent f2294569cf
commit 53d2188fa5
5 changed files with 65 additions and 88 deletions

View File

@@ -22,7 +22,7 @@ CI_INSTALL_DIR="$CI_OUT_DIR/ci_verify_configure.$CI_TARGET_SYSTEM.$CI_TARGET_ARC
function ci_init_build {
# Ensure that the mandatory variables are initialized.
CI_MAKE="${CI_MAKE:-make}"
[[ "$CI_TARGET_SYSTEM.$CI_TARGET_ARCH" != "$CI_HOST_SYSTEM.$CI_HOST_ARCH" ]] || {
[[ "$CI_TARGET_SYSTEM.$CI_TARGET_ARCH" != "$CI_BUILD_SYSTEM.$CI_BUILD_ARCH" ]] || {
# For native builds, set CI_CC to "cc" by default if the cc command is available.
# The configure script defaults CC to "gcc", which is not always a good idea.
[[ -x $(command -v cc) ]] && CI_CC="${CI_CC:-cc}"
@@ -36,12 +36,11 @@ function ci_init_build {
function ci_trace_build {
ci_info "## START OF CONFIGURATION ##"
ci_info "host arch: $CI_HOST_ARCH"
ci_info "host system: $CI_HOST_SYSTEM"
[[ "$CI_TARGET_SYSTEM.$CI_TARGET_ARCH" != "$CI_HOST_SYSTEM.$CI_HOST_ARCH" ]] && {
ci_info "build arch: $CI_BUILD_ARCH"
ci_info "build system: $CI_BUILD_SYSTEM"
[[ "$CI_TARGET_SYSTEM.$CI_TARGET_ARCH" != "$CI_BUILD_SYSTEM.$CI_BUILD_ARCH" ]] && {
ci_info "target arch: $CI_TARGET_ARCH"
ci_info "target system: $CI_TARGET_SYSTEM"
ci_info "target ABI: $CI_TARGET_ABI"
}
ci_info "source directory: $CI_SRC_DIR"
ci_info "build directory: $CI_BUILD_DIR"
@@ -107,15 +106,15 @@ function ci_build {
ci_spawn "$CI_SRC_DIR/configure" --prefix="$CI_INSTALL_DIR" $CI_CONFIGURE_FLAGS
# Spawn "make".
ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS
[[ $((CI_NO_TEST)) -ne 0 ]] || {
ci_expr $((CI_NO_TEST)) || {
# Spawn "make test" if testing is not disabled.
ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS test
}
[[ $((CI_NO_INSTALL)) -ne 0 ]] || {
ci_expr $((CI_NO_INSTALL)) || {
# Spawn "make install" if installation is not disabled.
ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS install
}
[[ $((CI_NO_CLEAN)) -ne 0 ]] || {
ci_expr $((CI_NO_CLEAN)) || {
# Spawn "make clean" and "make distclean" if cleaning is not disabled.
ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS clean
ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS distclean
@@ -124,12 +123,12 @@ function ci_build {
}
function main {
[[ $# -eq 0 ]] || {
ci_info "note: this program accepts environment options only"
ci_err "unsupported command argument: '$1'"
}
ci_init_build
ci_trace_build
[[ $# -eq 0 ]] || {
ci_info "note: this program accepts environment options only (see above)"
ci_err "unexpected command argument: '$1'"
}
ci_cleanup_old_build
ci_build
}