FTXUI/tools/test_bazel.sh
ArthurSonzogni 773e5eb7d2
Bazel: general improvements.
Improve the Bazel build. Attempt to fix previous errors recorded while
trying to publish ftxui in the Bazel Central Registry:
- https://github.com/bazelbuild/bazel-central-registry/pull/4485
- https://buildkite.com/bazel/bcr-presubmit/builds/13601#01968b61-f5b2-4d16-94d0-c87a03a1a23b

Test against "recent" platforms
-------------------------------

Previously, I got the error:
```
gcc: error: unrecognized command line option '-std-c++20'; did you mean '-std-c++2a'?
```
This was due to using old distribution like ubuntu 2004. Test against
newer platforms only to avoid GCC version<-9.x.y

Downgrade gtest version.
------------------------

I suspect this caused the Bazel Central Registry error:
```
file:///workdir/modules/googletest/1.15.2/MODULE.bazel:68:20: name 'use_repo_rule' is not defined
```
I hoped using a lower version will fix the issue.

Tag gtest as dev_dependency
---------------------------

Presumably, this should avoid dependants to fetch it?

Enable --features-layering_check
--------------------------------

Aka clang `-Wprivate-header`. Fix the encountered errors.

Use clang in the CI
-------------------

The CI was defining clang/gcc in the matrix, but was not using it. Fix
the bug.
2025-05-05 01:43:13 +02:00

28 lines
847 B
Bash
Executable File

# This script tests the project with different versions of Bazel and compilers
# locally. This avoids waiting on the CI to run the tests.
# Version
# -------
# - Version >= 7 are supported
# - Version <= 6 fail with the error:
# ERROR: Analysis of target '//:component' failed; build aborted: no such
# package '@rules_cc//cc/compiler': BUILD file not found in directory
# 'cc/compiler' of external repository @rules_cc. Add a BUILD file to a
# directory to mark it as a package.
#
for ver in \
"7.0.0" \
"8.0.0"
do
for cc in \
"gcc" \
"clang"
do
echo "=== Testing with Bazel ${ver} with ${cc} ==="
USE_BAZEL_VERSION=${ver} CC=${cc} bazel clean --expunge
USE_BAZEL_VERSION=${ver} CC=${cc} bazel build //...
USE_BAZEL_VERSION=${ver} CC=${cc} bazel test //...
done
done