From 03da4fc0857c285e3a26782f6bc8931c4c950df4 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Fri, 26 May 2023 10:10:36 +0000 Subject: [PATCH] Use `--enable_platform_specific_config` in `.bazelrc`. This magically applies the `linux`, `macos` or `windows` configuration depending on the OS. Apart from simplifying things for us, this should hopefully also unbreak the RE2 build that Bazel folks run in their CI. Fixes #428. Change-Id: I2f4192dd728661558a8c4c4c8dd68a720af3ff71 Reviewed-on: https://code-review.googlesource.com/c/re2/+/61370 Reviewed-by: Perry Lorier Reviewed-by: Paul Wankadia --- .bazelrc | 1 + .github/bazel.sh | 11 ++++------- app/build.sh | 2 +- python/setup.py | 3 +-- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.bazelrc b/.bazelrc index a102ac05b..814163970 100644 --- a/.bazelrc +++ b/.bazelrc @@ -7,6 +7,7 @@ # `BAZEL_USE_CPP_ONLY_TOOLCHAIN` since Bazel wouldn't respect the former without # the latter. However, the latter stopped Bazel from using Xcode and `-framework # Foundation`, which CCTZ (vendored into Abseil) requires. +build --enable_platform_specific_config build:linux --cxxopt=-std=c++14 build:macos --cxxopt=-std=c++14 build:windows --cxxopt=/std:c++14 diff --git a/.github/bazel.sh b/.github/bazel.sh index 2268b5706..7295ec6a8 100755 --- a/.github/bazel.sh +++ b/.github/bazel.sh @@ -1,12 +1,9 @@ #!/bin/bash set -eux -# macOS has GNU bash 3.x, so ${RUNNER_OS,,} isn't supported. -config=--config=$(echo ${RUNNER_OS} | tr '[:upper:]' '[:lower:]') - bazel clean -bazel build ${config} --compilation_mode=dbg -- //:all -bazel test ${config} --compilation_mode=dbg -- //:all \ +bazel build --compilation_mode=dbg -- //:all +bazel test --compilation_mode=dbg -- //:all \ -//:dfa_test \ -//:exhaustive1_test \ -//:exhaustive2_test \ @@ -15,8 +12,8 @@ bazel test ${config} --compilation_mode=dbg -- //:all \ -//:random_test bazel clean -bazel build ${config} --compilation_mode=opt -- //:all -bazel test ${config} --compilation_mode=opt -- //:all \ +bazel build --compilation_mode=opt -- //:all +bazel test --compilation_mode=opt -- //:all \ -//:dfa_test \ -//:exhaustive1_test \ -//:exhaustive2_test \ diff --git a/app/build.sh b/app/build.sh index c8c983745..c272bf5ac 100755 --- a/app/build.sh +++ b/app/build.sh @@ -23,7 +23,7 @@ else # Emscripten doesn't support `-fstack-protector`. AR=emar CC=emcc \ ${BAZEL} build --compilation_mode=opt \ - --config=linux --copt=-fno-stack-protector \ + --copt=-fno-stack-protector \ -- :all # Bazel doesn't retain the `_re2.wasm` artifact; # we have to redo the link command to obtain it. diff --git a/python/setup.py b/python/setup.py index 16d8e69d1..b0cbd5b1e 100644 --- a/python/setup.py +++ b/python/setup.py @@ -45,7 +45,7 @@ class BuildExt(setuptools.command.build_ext.build_ext): def build_extension(self, ext): - if 'RUNNER_OS' not in os.environ: + if 'GITHUB_ACTIONS' not in os.environ: return super().build_extension(ext) # For @pybind11_bazel's `python_configure()`. @@ -55,7 +55,6 @@ def build_extension(self, ext): self.spawn(cmd) cmd = ['bazel', 'build'] - cmd.append(f'--config={os.environ["RUNNER_OS"].lower()}') if 'BAZEL_CPU' in os.environ: cmd.append(f'--cpu={os.environ["BAZEL_CPU"].lower()}') cmd += ['--compilation_mode=opt', '--', ':all']