Skip to content

Commit

Permalink
build: change the way we set cxx version for bazel.
Browse files Browse the repository at this point in the history
Before, we did set cxx version to c++17 using COPTS in our bazel files.
This was wrong, and part of the dependencies were then built with the
default standard version. This was not an issue until we moved to c++17.

Then, we decided to use the bazel --cxxopt=-std=c++17, but this was only
valid for nix platforms.
The last option left is to ask the user to specify the standard
when building using bazel.
  • Loading branch information
Keenuts committed Feb 15, 2023
1 parent b84c86f commit 90a4af0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
1 change: 0 additions & 1 deletion .bazelrc

This file was deleted.

16 changes: 12 additions & 4 deletions .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,15 @@ jobs:
with:
path: ~/.bazel/cache
key: bazel-cache-${{ runner.os }}
- name: Build All
run: bazel --output_user_root=~/.bazel/cache build //...
- name: Test All
run: bazel --output_user_root=~/.bazel/cache test //...
- name: Build All (Windows)
if: ${{matrix.os == 'windows-latest' }}
run: bazel --output_user_root=~/.bazel/cache build --cxxopt=/std:c++17 //...
- name: Test All (Windows)
if: ${{matrix.os == 'windows-latest' }}
run: bazel --output_user_root=~/.bazel/cache test --cxxopt=/std:c++17 //...
- name: Build All (Linux, MacOS)
if: ${{ matrix.os != 'windows-latest' }}
run: bazel --output_user_root=~/.bazel/cache build --cxxopt=-std=c++17 //...
- name: Test All (Linux, MacOS)
if: ${{ matrix.os != 'windows-latest' }}
run: bazel --output_user_root=~/.bazel/cache test --cxxopt=-std=c++17 //...
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ fuzzer tests.
You can also use [Bazel](https://bazel.build/) to build the project.
```sh
cd <spirv-dir>
bazel build :all
bazel build --cxxopt=-std=c++17 :all
```
### Build a node.js package using Emscripten

Expand Down Expand Up @@ -724,7 +724,7 @@ To run a single test target, specify `:my_test_target` instead of `:all`. Test t
names get printed when you run `bazel test :all`. For example, you can run
`opt_def_use_test` with:
```shell
bazel test :opt_def_use_test
bazel test --cxxopt=-std=c++17 :opt_def_use_test
```


Expand Down
4 changes: 2 additions & 2 deletions kokoro/macos-clang-release-bazel/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ gsutil cp gs://bazel/5.0.0/release/bazel-5.0.0-darwin-x86_64 .
chmod +x bazel-5.0.0-darwin-x86_64

echo $(date): Build everything...
./bazel-5.0.0-darwin-x86_64 build :all
./bazel-5.0.0-darwin-x86_64 build --cxxopt=-std=c++17 :all
echo $(date): Build completed.

echo $(date): Starting bazel test...
./bazel-5.0.0-darwin-x86_64 test :all
./bazel-5.0.0-darwin-x86_64 test --cxxopt=-std=c++17 :all
echo $(date): Bazel test completed.
4 changes: 2 additions & 2 deletions kokoro/scripts/linux/build-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ elif [ $TOOL = "bazel" ]; then
using bazel-5.0.0

echo $(date): Build everything...
bazel build :all
bazel build --cxxopt=-std=c++17 :all
echo $(date): Build completed.

echo $(date): Starting bazel test...
bazel test :all
bazel test --cxxopt=-std=c++17 :all
echo $(date): Bazel test completed.
fi

0 comments on commit 90a4af0

Please sign in to comment.