From 164bcd7eb075336135e58415a9d5ace1b0a5fd5c Mon Sep 17 00:00:00 2001 From: Guillaume Chatelet Date: Fri, 13 Sep 2024 11:53:30 +0200 Subject: [PATCH] Move `c99` flag from BUILD file to bazel cmd line (#366) * Move `c99` flag from BUILD file to bazel cmd line Requiring c99 for everyone breaks downstream users. * Remove requiring bzlmod --- .bazelrc | 32 ++++++++++++++++++++++++++++++++ BUILD.bazel | 1 - bazel/ci/docker/Dockerfile | 10 ++-------- 3 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 .bazelrc diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 0000000..0c91ab7 --- /dev/null +++ b/.bazelrc @@ -0,0 +1,32 @@ +############################################################################### +# Common flags that apply to all configurations. +# Use sparingly for things common to all compilers and platforms. +############################################################################### + +# Prevent invalid caching if input files are modified during a build. +build --experimental_guard_against_concurrent_changes + +############################################################################### +# Options for continuous integration. +############################################################################### + +# Speedup bazel using a ramdisk. +build:ci --sandbox_base=/dev/shm + +# Show as many errors as possible. +build:ci --keep_going + +# Show subcommands when building +build:ci --subcommands=true + +# Make sure we test for C99 compliance when building the library +build:ci --conlyopt=-std=c99 + +# Show test errors. +test:ci --test_output=errors + +############################################################################### + +# The user.bazelrc file is not checked in but available for local mods. +# Always keep this at the end of the file so that user flags override. +try-import %workspace%/user.bazelrc diff --git a/BUILD.bazel b/BUILD.bazel index f55c47f..2c4c5c0 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -14,7 +14,6 @@ exports_files(["LICENSE"]) INCLUDES = ["include"] C99_FLAGS = [ - "-std=c99", "-Wall", "-Wextra", "-Wmissing-declarations", diff --git a/bazel/ci/docker/Dockerfile b/bazel/ci/docker/Dockerfile index a46b493..ed33464 100644 --- a/bazel/ci/docker/Dockerfile +++ b/bazel/ci/docker/Dockerfile @@ -25,13 +25,7 @@ COPY . . FROM devel AS build RUN bazel version -RUN bazel build \ - -c opt \ - --subcommands=true \ - ... +RUN bazel build --config=ci ... FROM build AS test -RUN bazel test \ - -c opt \ - --test_output=errors \ - ... +RUN bazel test --config=ci ...