For testing purposes (e.g. wanting to see if "make distclean" works
correctly with and without building), as well as development purposes
(e.g. wanting to inspect the artifacts produced in the configuration
stage), add `CI_NO_BUILD` to the family of contrarians.
Introduce the environment option CI_FORCE:
* ci_verify_configure.sh is known to fail if an existing build
configuration is found in the top-level directory.
Setting CI_FORCE=1 will run `make distclean` before verification.
* ci_verify_makefiles.sh cannot be reliably executed if random
object files are found in the top-level directory.
Setting CI_FORCE=1 will run `rm *.o *.obj` before verification.
* ci_verify_cmake.sh is not known at this time to fail for similar
reasons; but if it does, we will use CI_FORCE to trigger any
necessary pre-build cleanup.
Work around a limitation in the `shellcheck source` directive, which
does not recognize quotes in shellcheck versions older than 0.9.
Also extend the checks for YAML files over the entire source tree, in
preparation for the introduction of the GitHub Actions config file.
Many build scripts, ports and other third-party add-ons that are
circulating around appear to be distributed under the MIT License.
Examples include the Vcpkg build system (including the libpng port)
and the Meson build definitions (including the libpng definition).
I am, therefore, relicensing our CI scripts once more, as the sole
author (so far), just in case that any of the CI code might travel
from/to such projects. Hopefully, this one last license will stick.
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
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.
Introduce CI_TARGET_TRIPLET and CI_TARGET_ABI.
Rename CI_HOST_MACHINE and CI_TARGET_MACHINE, respectively, to
CI_HOST_ARCH and CI_TARGET_ARCH, following on the conventional
target triplet nomenclature.
Introduce CI_BUILD_SYSTEM and CI_BUILD_ARCH, following on the
GNU Autotools (host/build/target) practice and nomenclature.
Ensure that CI_TARGET_SYSTEM, CI_TARGET_ARCH and CI_TARGET_ABI
are all initialized when verifying a cross-platform build.
Work around an obscure CMake error by ensuring that CMake variables
(CMAKE_AR and CMAKE_RANLIB) are initialized to the full executable
paths of their CI_* equivalents (CI_AR and CI_RANLIB).
Implement other general-purpose improvements:
* Check all CI_NO_* variables in an arithmetic context, to allow
setting them explicitly to zero in external configurations.
* Label the assertions with descriptions of what's being asserted.
* Add more comments and tracing printouts.
Replace CI_SYSTEM_NAME and CI_MACHINE_NAME with CI_HOST_SYSTEM and
CI_HOST_MACHINE, respectively.
Introduce CI_TARGET_SYSTEM and CI_TARGET_MACHINE, defaulting to
CI_HOST_SYSTEM and CI_HOST_MACHINE, respectively.
Use CI_TARGET_SYSTEM and CI_TARGET_MACHINE in the naming scheme of
target build and install directories, in order to allow concurrent
verification builds for multiple cross-platform targets.
Move the common declarations and initializations from ci_verify_*.sh
to ci.lib.sh, and update them as follows:
* Simplify the ci_ function names.
* Refactor the CI_ variable names:
- Add the new variable CI_TOPLEVEL_DIR.
- Rename the variables CI_SCRIPTNAME, CI_SCRIPTDIR, etc.,
to CI_SCRIPT_NAME, CI_SCRIPT_DIR, etc.
- Rename the variables CI_SRCDIR_FROM_BUILDDIR, etc., to
CI_BUILD_TO_SRC_RELDIR, etc.
* Add new functions inside ci.lib.sh:
- Replace ci_err with ci_err_usage, ci_err_fatal, ci_err_internal.
- Add the new functions ci_warn and ci_assert.
* Simplify the ci_ function names inside ci_verify_*.sh.
Apply the following changes:
* Update CI_BUILDDIR and CI_INSTALLDIR to reflect the new script
names.
* Introduce CI_SRCDIR_FROM_BUILDDIR and CI_INSTALLDIR_FROM_BUILDDIR
to the cmake build, to ensure that the Windows tools can handle
native Windows paths correctly when executed via Bash-on-Windows.
* Stop guessing and using CI_SRCDIR_NATIVE and CI_INSTALLDIR_NATIVE
in the cmake build, since we now have a better solution.
* Show the ninja program version in ninja-based cmake builds.
* Move the cleanup of previous builds into separate functions, and
do it in a cleaner manner. No pun intended.
Fix autodetection and use of the cygpath executable on Windows.
Add a new variable CI_CMAKE_TOOLCHAIN_FILE to ci_verify_cmake.sh.
This should help in future cross-platform testing.
Remove the implicit initialization of CI_CC, CI_LD and CI_LIBS from
ci_verify_makefiles.sh. This should help the testing of default values
of their respective make variables (CC, LD and LIBS).
Give the CI scripts new names that better reflect what they do, and
make room for activities such as linting or dependency installation:
* Rename ci_autotools.sh to ci_verify_configure.sh.
* Rename ci_cmake.sh to ci_verify_cmake.sh.
* Rename ci_legacy.sh to ci_verify_makefiles.sh.
Also rename CI_LEGACY_MAKEFILES to CI_MAKEFILES.
Update the config files for Travis CI and AppVeyor CI accordingly.