Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 25 additions & 15 deletions .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ jobs:
fail-fast: false
matrix:
include:
- { name: "Linux System Core", classifier: "linuxsystemcore", os: ubuntu-24.04, container: "wpilib/systemcore-cross-ubuntu:2027-24.04", action: "build" }
- { name: "Linux System Core Debug", classifier: "linuxsystemcoredebug", os: ubuntu-24.04, container: "wpilib/systemcore-cross-ubuntu:2027-24.04", action: "build" }
- { name: "Linux System Core Static", classifier: "linuxsystemcorestatic", os: ubuntu-24.04, container: "wpilib/systemcore-cross-ubuntu:2027-24.04", action: "build" }
- { name: "Linux System Core Static Debug", classifier: "linuxsystemcorestaticdebug", os: ubuntu-24.04, container: "wpilib/systemcore-cross-ubuntu:2027-24.04", action: "build" }
- { name: "Linux x86-64", classifier: "linuxx86-64,headers,sources", os: ubuntu-24.04, container: "wpilib/systemcore-cross-ubuntu:2027-24.04", action: "test" }
- { name: "Linux x86-64 Debug", classifier: "linuxx86-64debug", os: ubuntu-24.04, container: "wpilib/systemcore-cross-ubuntu:2027-24.04", action: "test" }
- { name: "Linux x86-64 Static", classifier: "linuxx86-64static", os: ubuntu-24.04, container: "wpilib/systemcore-cross-ubuntu:2027-24.04", action: "test" }
- { name: "Linux x86-64 Static Debug", classifier: "linuxx86-64staticdebug", os: ubuntu-24.04, container: "wpilib/systemcore-cross-ubuntu:2027-24.04", action: "test" }
- { name: "Linux System Core", classifier: "linuxsystemcore", os: ubuntu-24.04, action: "build" }
- { name: "Linux System Core Debug", classifier: "linuxsystemcoredebug", os: ubuntu-24.04, action: "build" }
- { name: "Linux System Core Static", classifier: "linuxsystemcorestatic", os: ubuntu-24.04, action: "build" }
- { name: "Linux System Core Static Debug", classifier: "linuxsystemcorestaticdebug", os: ubuntu-24.04, action: "build" }
- { name: "Linux x86-64", classifier: "linuxx86-64,headers,sources", os: ubuntu-24.04, action: "test" }
- { name: "Linux x86-64 Debug", classifier: "linuxx86-64debug", os: ubuntu-24.04, action: "test" }
- { name: "Linux x86-64 Static", classifier: "linuxx86-64static", os: ubuntu-24.04, action: "test" }
- { name: "Linux x86-64 Static Debug", classifier: "linuxx86-64staticdebug", os: ubuntu-24.04, action: "test" }

- { name: "macOS", classifier: "osxuniversal,osxuniversaldebug,headers,sources,osxuniversalstatic,osxuniversalstaticdebug,linuxsystemcore,linuxsystemcoredebug,linuxsystemcorestatic,linuxsystemcorestaticdebug", os: macOS-15, action: "test" }

Expand All @@ -34,8 +34,19 @@ jobs:

name: "${{ matrix.action == 'test' && 'Test' || 'Build' }} ${{ matrix.name }}"
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
steps:
- name: Free disk space (Linux)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: false
swap-storage: false
if: startsWith(matrix.os, 'ubuntu')

- uses: actions/checkout@v4
with: { fetch-depth: 0 }

Expand All @@ -45,6 +56,10 @@ jobs:
username: ${{ secrets.BAZEL_CACHE_USERNAME }}
password: ${{ secrets.BAZEL_CACHE_PASSWORD }}

- name: Install apt dependencies
if: matrix.os == 'ubuntu-24.04'
run: sudo apt-get install -y libgl1-mesa-dev libx11-dev libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev

- if: matrix.os == 'ubuntu-24.04'
uses: bazel-contrib/[email protected]
with:
Expand All @@ -64,12 +79,7 @@ jobs:
- name: Free Space
if: always()
shell: bash
run: |
if [[ "${{ matrix.os }}" == "windows-2022" ]]; then
fsutil volume diskfree C:
else
df -h /
fi
run: df -h

buildifier:
name: "buildifier"
Expand Down
93 changes: 93 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ http_archive(
url = "https://github.com/wpilibsuite/rules_bzlmodrio_toolchains/releases/download/2025-1.bcr6/rules_bzlmodrio_toolchains-2025-1.bcr6.tar.gz",
)

# TODO(davo): update version after the next release of toolchains_llvm after 1.5.0
http_archive(
name = "toolchains_llvm",
integrity = "sha256-Ht0UsdgsySFX+H7AU3TS992uZr8nV5TP60lADgKeP7s=",
strip_prefix = "toolchains_llvm-cebf1ed19db1521bcaae489a40dd736d50e9302f",
url = "https://github.com/bazel-contrib/toolchains_llvm/archive/cebf1ed19db1521bcaae489a40dd736d50e9302f.tar.gz",
)
Comment on lines +81 to +87
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no toolchains_llvm release that supports the extra_*_flags parameters yet.


http_archive(
name = "pybind11_bazel",
integrity = "sha256-iwRj1wuX2pDS6t6DqiCfhIXisv4y+7CvxSJtZoSAzGw=",
Expand Down Expand Up @@ -128,10 +136,95 @@ load("@bazel_features//:deps.bzl", "bazel_features_deps")

bazel_features_deps()

load("@toolchains_llvm//toolchain:deps.bzl", "bazel_toolchain_dependencies")

bazel_toolchain_dependencies()

load("@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependencies")

apple_support_dependencies()

load("@toolchains_llvm//toolchain:rules.bzl", "llvm_toolchain")

COMMON_EXTRA_COMPILE_FLAGS = [
"-Wextra",
"-Werror",
"-pedantic",
"-Wno-unused-parameter",
"-fPIC",
]

LINUX_EXTRA_COMPILE_FLAGS = COMMON_EXTRA_COMPILE_FLAGS + ["-gz=zlib"]

MACOS_EXTRA_COMPILE_FLAGS = COMMON_EXTRA_COMPILE_FLAGS + [
"-Wno-shorten-64-to-32",
"-Wno-gcc-compat",
"-Wno-missing-field-initializers",
"-Wno-unused-private-field",
]

CONLY_FLAGS = ["-Wno-c23-extensions"]

COMMON_EXTRA_CXX_FLAGS = [
"-Wformat=2",
"-Wno-unused-parameter",
"-pthread",
"-Wno-deprecated-enum-enum-conversion",
"-Wno-nontrivial-memcall", # warning in imgui.h inline functions
]

LINUX_EXTRA_CXX_FLAGS = COMMON_EXTRA_CXX_FLAGS + ["-Wno-psabi"]

MACOS_EXTRA_CXX_FLAGS = COMMON_EXTRA_CXX_FLAGS + [
"-Wno-unused-const-variable",
"-Wno-error=c11-extensions",
"-Wno-deprecated-anon-enum-enum-conversion",
]

LINUX_EXTRA_LINK_FLAGS = ["-Wl,-rpath,$ORIGIN"]

MACOS_EXTRA_LINK_FLAGS = ["-Wl,-rpath,@loader_path"]

llvm_toolchain(
name = "llvm_toolchain",
conly_flags = {
"darwin-aarch64": CONLY_FLAGS,
"darwin-x86_64": CONLY_FLAGS,
"linux-aarch64": CONLY_FLAGS,
"linux-x86_64": CONLY_FLAGS,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AustinSchuh was there a particular reason bazel-contrib/toolchains_llvm#435 doesn't allow specifying a global conly_flags default with the empty string key like the other params?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason other than it probably didn't exist when that code was originally written 6 years ago.

},
cxx_standard = {"": "c++20"},
extra_compile_flags = {
"darwin-aarch64": MACOS_EXTRA_COMPILE_FLAGS,
"darwin-x86_64": MACOS_EXTRA_COMPILE_FLAGS,
"linux-aarch64": LINUX_EXTRA_COMPILE_FLAGS,
"linux-x86_64": LINUX_EXTRA_COMPILE_FLAGS,
},
extra_cxx_flags = {
"darwin-aarch64": MACOS_EXTRA_CXX_FLAGS,
"darwin-x86_64": MACOS_EXTRA_CXX_FLAGS,
"linux-aarch64": LINUX_EXTRA_CXX_FLAGS,
"linux-x86_64": LINUX_EXTRA_CXX_FLAGS,
},
extra_link_flags = {
"darwin-aarch64": MACOS_EXTRA_LINK_FLAGS,
"darwin-x86_64": MACOS_EXTRA_LINK_FLAGS,
"linux-aarch64": LINUX_EXTRA_LINK_FLAGS,
"linux-x86_64": LINUX_EXTRA_LINK_FLAGS,
},
llvm_version = "20.1.7",
stdlib = {
"darwin-aarch64": "builtin-libc++",
"darwin-x86_64": "builtin-libc++",
"linux-aarch64": "stdc++",
"linux-x86_64": "stdc++",
},
)

load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains")

llvm_register_toolchains()

load("@rules_cc//cc:repositories.bzl", "rules_cc_toolchains")

rules_cc_toolchains()
Expand Down
10 changes: 5 additions & 5 deletions apriltag/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ cc_library(
srcs = glob(["src/main/native/thirdparty/apriltag/src/**"]),
hdrs = glob(["src/main/native/thirdparty/apriltag/include/**"]),
copts = select({
"@platforms//os:osx": [
"@bazel_tools//tools/cpp:gcc": [
"-Wno-format-nonliteral",
"-Wno-gnu-zero-variadic-macro-arguments",
"-Wno-uninitialized",
"-Wno-maybe-uninitialized",
"-Wno-sign-compare",
"-Wno-type-limits",
],
Expand All @@ -47,9 +46,10 @@ cc_library(
"/wd4267",
"/wd4996",
],
"@rules_bzlmodrio_toolchains//constraints/combined:is_linux": [
"//conditions:default": [
"-Wno-format-nonliteral",
"-Wno-maybe-uninitialized",
"-Wno-gnu-zero-variadic-macro-arguments",
"-Wno-uninitialized",
"-Wno-sign-compare",
"-Wno-type-limits",
],
Expand Down
2 changes: 1 addition & 1 deletion shared/bazel/compiler_flags/linux_flags.rc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ build:linux --host_cxxopt=-Wno-attributes
# Ignore potential issues in third party code on the host
build:linux --host_cxxopt=-Wno-pedantic
build:linux --host_cxxopt=-Wno-format-nonliteral
build:linux --host_cxxopt=-Wno-missing-requires
#build:linux --host_cxxopt=-Wno-missing-requires
build:linux --host_cxxopt=-Wno-implicit-fallthrough

build:linux --host_per_file_copt=external/zlib/.*\.c@-Wno-deprecated-non-prototype
Expand Down
2 changes: 1 addition & 1 deletion tools/wpical/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ osx_copts = unix_copts

copts = select({
"@platforms//os:linux": unix_copts + [
"-Wno-maybe-uninitialized",
"-Wno-sometimes-uninitialized",
],
"@platforms//os:osx": osx_copts,
"@platforms//os:windows": [
Expand Down
Loading