[bazel] Clean up bazel scripts (#7984)

This commit is contained in:
PJ Reiniger
2025-06-13 23:53:09 -04:00
committed by GitHub
parent 5dfc664b93
commit fbbc4bc53c
54 changed files with 1774 additions and 854 deletions

View File

@@ -2,7 +2,7 @@
build:systemcore --config=base_linux
build:systemcore --platforms=@rules_bzlmodrio_toolchains//platforms/systemcore
build:systemcore --build_tag_filters=-no-bookworm
build:systemcore --build_tag_filters=-no-systemcore
build:systemcore --features=compiler_param_file
build:systemcore --platform_suffix=systemcore
build:systemcore --incompatible_enable_cc_toolchain_resolution

View File

@@ -0,0 +1,60 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
def third_party_cc_lib_helper(
name,
include_root,
src_root = None,
src_excludes = [],
visibility = None):
"""
Helper for src / headers pairs that aren't directly compiled, but rather pulled into a bigger library.
Due to allwpilibs directory structure of includes and sources living next to eachother, it often is required
to make a header shim to deal with the include path, and a filegroup of the sources. This pattern is extermely
common for the thirdparty libraries that live beneath certain libraries.
This will produce a library shim with the include path stripped, and a filegroup of sources.
Params
include_root: The package relative path to the header files. This will be used to glob the files and strip the include prefix
src_root: Optional. The package relative path to the source files.
src_excludes: Optional. Used to exclude files from the src_root glob
visibilty: The visibility of header shim / source files / package files
"""
cc_library(
name = name + "-headers",
hdrs = native.glob([
include_root + "/**",
]),
includes = [include_root],
strip_include_prefix = include_root,
visibility = visibility,
)
if src_root:
native.filegroup(
name = name + "-srcs",
srcs = native.glob([src_root + "/**"], exclude = src_excludes),
visibility = visibility,
)
def wpilib_cc_library(
name,
srcs = [],
deps = [],
third_party_libraries = [],
third_party_header_only_libraries = [],
**kwargs):
"""
This function is used to ease the creation of a cc_library with helpers for handling thirdparty libraries in the standard allwpilib format.
Params:
third_party_libraries: These are helper dependencies, created by third_party_cc_lib_helper. Header shims will be added as deps and src filegroups will be added to srcs
third_party_header_only_libraries: Similar to third_party_libraries, but for shims that contain no sources
"""
cc_library(
name = name,
srcs = srcs + [lib + "-srcs" for lib in third_party_libraries],
deps = deps + [lib + "-headers" for lib in third_party_libraries + third_party_header_only_libraries],
**kwargs
)

View File

@@ -3,6 +3,9 @@ load("@rules_python//python:defs.bzl", "py_binary")
py_binary(
name = "gen_resources",
srcs = ["gen_resources.py"],
tags = ["manual"],
target_compatible_with = select({
"@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,18 @@
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library")
def wpilib_halsim_extension(
name,
**kwargs):
"""
Helper wrapper for creating a HALSIM extension. Provides some of the default argments for creating the library.
"""
wpilib_cc_library(
name = name,
includes = ["src/main/native/include"],
target_compatible_with = select({
"@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
**kwargs
)

View File

@@ -30,6 +30,6 @@ def wpilib_java_junit5_test(
main_class = "org.junit.platform.console.ConsoleLauncher",
use_testrunner = False,
testonly = True,
tags = tags + ["no-roborio", "no-bionic", "no-raspbian", "allwpilib-build-java", "no-asan", "no-tsan", "no-ubsan"],
tags = tags + ["allwpilib-build-java", "no-asan", "no-tsan", "no-ubsan"],
**kwargs
)

View File

@@ -81,7 +81,6 @@ def wpilib_jni_java_library(
jni = "@rules_bzlmodrio_toolchains//jni"
_jni_headers(
name = headers_name,
tags = ["manual"],
jni = jni,
lib = ":" + name,
testonly = testonly,