Skip to content

Commit

Permalink
Use --enable_platform_specific_config in .bazelrc.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Paul Wankadia <[email protected]>
  • Loading branch information
junyer committed May 26, 2023
1 parent 63aeffa commit 03da4fc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 4 additions & 7 deletions .github/bazel.sh
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion app/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()`.
Expand All @@ -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']
Expand Down

0 comments on commit 03da4fc

Please sign in to comment.