From 3636e48f8050ff9d6fd168c6cdcdc32e5f8f8274 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Fri, 23 Aug 2024 01:31:30 -0400 Subject: [PATCH 01/38] [bazel] MVP for building wpiutil with bazel --- .bazelignore | 20 +++ .bazelrc | 41 ++++++ .bazelversion | 1 + .github/workflows/bazel.yml | 118 ++++++++++++++++++ WORKSPACE | 86 +++++++++++++ shared/bazel/compiler_flags/coverage_flags.rc | 5 + shared/bazel/compiler_flags/linux_flags.rc | 31 +++++ shared/bazel/compiler_flags/osx_flags.rc | 44 +++++++ shared/bazel/compiler_flags/roborio_flags.rc | 35 ++++++ shared/bazel/compiler_flags/sanitizers.rc | 27 ++++ .../bazel/compiler_flags/windows_arm_flags.rc | 34 +++++ shared/bazel/compiler_flags/windows_flags.rc | 36 ++++++ shared/bazel/rules/gen/BUILD.bazel | 8 ++ shared/bazel/rules/gen/gen-resources.bzl | 10 ++ shared/bazel/rules/gen/gen_resources.py | 58 +++++++++ thirdparty/googletest/BUILD.bazel | 10 ++ wpiutil/examples/printlog/BUILD.bazel | 16 +++ wpiutil/examples/writelog/BUILD.bazel | 9 ++ .../dev/java/edu/wpi/first/util/BUILD.bazel | 9 ++ wpiutil/src/dev/native/cpp/BUILD.bazel | 9 ++ .../main/java/edu/wpi/first/util/BUILD.bazel | 13 ++ wpiutil/src/main/native/BUILD.bazel | 53 ++++++++ .../native/thirdparty/expected/BUILD.bazel | 11 ++ .../main/native/thirdparty/fmtlib/BUILD.bazel | 17 +++ .../main/native/thirdparty/json/BUILD.bazel | 11 ++ .../main/native/thirdparty/llvm/BUILD.bazel | 17 +++ .../main/native/thirdparty/memory/BUILD.bazel | 17 +++ .../main/native/thirdparty/mpack/BUILD.bazel | 17 +++ .../native/thirdparty/protobuf/BUILD.bazel | 18 +++ .../native/thirdparty/sigslot/BUILD.bazel | 11 ++ .../src/printlog/java/printlog/BUILD.bazel | 9 ++ wpiutil/src/test/native/BUILD.bazel | 21 ++++ 32 files changed, 822 insertions(+) create mode 100644 .bazelignore create mode 100644 .bazelrc create mode 100644 .bazelversion create mode 100644 .github/workflows/bazel.yml create mode 100644 WORKSPACE create mode 100644 shared/bazel/compiler_flags/coverage_flags.rc create mode 100644 shared/bazel/compiler_flags/linux_flags.rc create mode 100644 shared/bazel/compiler_flags/osx_flags.rc create mode 100644 shared/bazel/compiler_flags/roborio_flags.rc create mode 100644 shared/bazel/compiler_flags/sanitizers.rc create mode 100644 shared/bazel/compiler_flags/windows_arm_flags.rc create mode 100644 shared/bazel/compiler_flags/windows_flags.rc create mode 100644 shared/bazel/rules/gen/BUILD.bazel create mode 100644 shared/bazel/rules/gen/gen-resources.bzl create mode 100644 shared/bazel/rules/gen/gen_resources.py create mode 100644 thirdparty/googletest/BUILD.bazel create mode 100644 wpiutil/examples/printlog/BUILD.bazel create mode 100644 wpiutil/examples/writelog/BUILD.bazel create mode 100644 wpiutil/src/dev/java/edu/wpi/first/util/BUILD.bazel create mode 100644 wpiutil/src/dev/native/cpp/BUILD.bazel create mode 100644 wpiutil/src/main/java/edu/wpi/first/util/BUILD.bazel create mode 100644 wpiutil/src/main/native/BUILD.bazel create mode 100644 wpiutil/src/main/native/thirdparty/expected/BUILD.bazel create mode 100644 wpiutil/src/main/native/thirdparty/fmtlib/BUILD.bazel create mode 100644 wpiutil/src/main/native/thirdparty/json/BUILD.bazel create mode 100644 wpiutil/src/main/native/thirdparty/llvm/BUILD.bazel create mode 100644 wpiutil/src/main/native/thirdparty/memory/BUILD.bazel create mode 100644 wpiutil/src/main/native/thirdparty/mpack/BUILD.bazel create mode 100644 wpiutil/src/main/native/thirdparty/protobuf/BUILD.bazel create mode 100644 wpiutil/src/main/native/thirdparty/sigslot/BUILD.bazel create mode 100644 wpiutil/src/printlog/java/printlog/BUILD.bazel create mode 100644 wpiutil/src/test/native/BUILD.bazel diff --git a/.bazelignore b/.bazelignore new file mode 100644 index 00000000000..792570baee3 --- /dev/null +++ b/.bazelignore @@ -0,0 +1,20 @@ +build_cmake +build-cmake + +# Auto generated by vscode +apriltag/bin +cameraserver/bin +cameraserver/multiCameraServer/bin +cscore/bin +fieldImages/bin +hal/bin +developerRobot/bin +ntcore/bin +romiVendordep/bin +wpilibNewCommands/bin +wpilibj/bin +wpimath/bin +wpinet/bin +wpiutil/bin +wpiunits/bin +xrpVendordep/bin diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 00000000000..ebbec68242c --- /dev/null +++ b/.bazelrc @@ -0,0 +1,41 @@ +try-import %workspace%/user.bazelrc + +build --java_language_version=17 +build --java_runtime_version=roboriojdk_17 +build --tool_java_language_version=17 +build --tool_java_runtime_version=remotejdk_17 + +test --test_output=errors +test --test_verbose_timeout_warnings + +import shared/bazel/compiler_flags/sanitizers.rc +import shared/bazel/compiler_flags/linux_flags.rc +import shared/bazel/compiler_flags/osx_flags.rc +import shared/bazel/compiler_flags/roborio_flags.rc +import shared/bazel/compiler_flags/windows_flags.rc +import shared/bazel/compiler_flags/windows_arm_flags.rc +import shared/bazel/compiler_flags/coverage_flags.rc + +build:build_java --test_tag_filters=allwpilib-build-java --build_tag_filters=allwpilib-build-java +build:build_cpp --test_tag_filters=+allwpilib-build-cpp --build_tag_filters=+allwpilib-build-cpp +build:no_example --test_tag_filters=-wpi-example --build_tag_filters=-wpi-example +test:no_example --test_tag_filters=-wpi-example --build_tag_filters=-wpi-example + + +build:remote --bes_results_url=https://app.buildbuddy.io/invocation/ +build:remote --bes_backend=grpcs://cloud.buildbuddy.io +build:remote --remote_cache=grpcs://cloud.buildbuddy.io +build:remote --remote_timeout=3600 + +# This config should be used locally. It downloads more than the CI version +build:remote_user --config=remote +build:remote_user --remote_download_toplevel + +# This config should be used on CI. It downloads at little as possible to complete the build +build:ci --config=remote +build:ci --remote_download_minimal + +build --proto_toolchain_for_cc=//:proto_cc_toolchain + +build:linux --per_file_copt=external/com_google_protobuf/...@-Wno-missing-field-initializers,-Wno-deprecated-enum-enum-conversion +build:macos --per_file_copt=external/com_google_protobuf/...@-Wno-deprecated-non-prototype diff --git a/.bazelversion b/.bazelversion new file mode 100644 index 00000000000..0ee843cc604 --- /dev/null +++ b/.bazelversion @@ -0,0 +1 @@ +7.2.0 diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml new file mode 100644 index 00000000000..e32e1649802 --- /dev/null +++ b/.github/workflows/bazel.yml @@ -0,0 +1,118 @@ +name: Bazel + +on: [pull_request, push] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + build-windows: + strategy: + fail-fast: false + matrix: + include: + - { name: "Windows (native)", os: windows-2022, action: "test", config: "--noenable_bzlmod --config=windows", } + - { name: "Windows (arm)", os: windows-2022, action: "build", config: "--noenable_bzlmod --config=windows_arm", } + - { name: "Windows (roborio)", os: windows-2022, action: "build", config: "--noenable_bzlmod --config=roborio", } + + name: "Build ${{ matrix.name }}" + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + with: { fetch-depth: 0 } + - uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: 17 + architecture: x64 + + - name: Build + run: bazel --output_user_root=C:\\bazelroot ${{ matrix.action }} -k ... --config=ci ${{ matrix.config }} --verbose_failures + shell: bash + + build-mac: + strategy: + fail-fast: false + matrix: + include: + - { name: "Mac (native)", os: macos-14, action: "test", config: "--noenable_bzlmod --config=osx -c opt", } + - { name: "Mac (roborio)", os: macos-14, action: "build", config: "--noenable_bzlmod --config=roborio -c opt", } + + name: "${{ matrix.name }}" + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + with: { fetch-depth: 0 } + + - name: Build + run: bazel ${{ matrix.action }} -k ... --config=ci ${{ matrix.config }} --nojava_header_compilation --verbose_failures + shell: bash + + build-linux: + strategy: + fail-fast: false + matrix: + include: + - { name: "Linux (native)", os: ubuntu-22.04, action: "test", config: "--noenable_bzlmod --config=linux -c opt", } + - { name: "Linux (roborio)", os: ubuntu-22.04, action: "build", config: "--noenable_bzlmod --config=roborio -c opt", } + name: "${{ matrix.name }}" + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + with: { fetch-depth: 0 } + - uses: bazelbuild/setup-bazelisk@v3 + + - name: Build and Test + run: bazel ${{ matrix.action }} ... --config=ci ${{ matrix.config }} -k --verbose_failures + + build-sanitizers: + strategy: + fail-fast: false + matrix: + include: + - config: "asan" + - config: "ubsan" + runs-on: ubuntu-22.04 + container: wpilib/ubuntu-base:22.04 + name: "Sanitizer ${{ matrix.config }}" + steps: + - uses: actions/checkout@v4 + with: { fetch-depth: 0 } + - uses: bazelbuild/setup-bazelisk@v3 + - name: Build and Test + run: bazel test -k --config=ci --noenable_bzlmod --config=linux --config=${{ matrix.config }} //... + + buildifier: + name: "buildifier" + runs-on: ubuntu-22.04 + steps: + - name: Set up Go 1.15.x + uses: actions/setup-go@v5 + with: + go-version: 1.15.x + id: go + + - name: Install Buildifier + run: | + cd $(mktemp -d) + GO111MODULE=on go get github.com/bazelbuild/buildtools/buildifier@6.0.0 + + - uses: actions/checkout@v4 + with: { fetch-depth: 0 } + + - name: Run buildifier + run: buildifier -warnings all --lint=fix -r . + + - name: Check Output + run: git --no-pager diff --exit-code HEAD + + - name: Generate diff + run: git diff HEAD > bazel-lint-fixes.patch + if: ${{ failure() }} + + - uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.platform }}-bazel-lint-fixes + path: bazel-lint-fixes.patch + if: ${{ failure() }} diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 00000000000..bb6decc1b81 --- /dev/null +++ b/WORKSPACE @@ -0,0 +1,86 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +# Download Extra java rules +http_archive( + name = "rules_jvm_external", + sha256 = "08ea921df02ffe9924123b0686dc04fd0ff875710bfadb7ad42badb931b0fd50", + strip_prefix = "rules_jvm_external-6.1", + url = "https://github.com/bazelbuild/rules_jvm_external/releases/download/6.1/rules_jvm_external-6.1.tar.gz", +) + +load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps") + +rules_jvm_external_deps() + +load("@rules_jvm_external//:defs.bzl", "maven_install") + +maven_artifacts = [ + "org.ejml:ejml-simple:0.43.1", + "com.fasterxml.jackson.core:jackson-annotations:2.15.2", + "com.fasterxml.jackson.core:jackson-core:2.15.2", + "com.fasterxml.jackson.core:jackson-databind:2.15.2", + "us.hebi.quickbuf:quickbuf-runtime:1.3.3", +] + +maven_install( + name = "maven", + artifacts = maven_artifacts, + repositories = [ + "https://repo1.maven.org/maven2", + "https://frcmaven.wpi.edu/artifactory/release/", + ], +) + +# Download toolchains +http_archive( + name = "rules_bzlmodrio_toolchains", + sha256 = "cd3ff046427e9c6dbc0c86a458c8cf081b8045fc3fb4265d08c0ebfc17f9cb30", + url = "https://github.com/bzlmodRio/rules_bzlmodRio_toolchains/releases/download/2024-1/rules_bzlmodRio_toolchains-2024-1.tar.gz", +) + +load("@rules_bzlmodrio_toolchains//:maven_deps.bzl", "setup_legacy_setup_toolchains_dependencies") + +setup_legacy_setup_toolchains_dependencies() + +load("@rules_bzlmodrio_toolchains//toolchains:load_toolchains.bzl", "load_toolchains") + +load_toolchains() + +# +http_archive( + name = "rules_bzlmodrio_jdk", + sha256 = "a00d5fa971fbcad8a17b1968cdc5350688397035e90b0cb94e040d375ecd97b4", + url = "https://github.com/bzlmodRio/rules_bzlmodRio_jdk/releases/download/17.0.8.1-1/rules_bzlmodRio_jdk-17.0.8.1-1.tar.gz", +) + +load("@rules_bzlmodrio_jdk//:maven_deps.bzl", "setup_legacy_setup_jdk_dependencies") + +setup_legacy_setup_jdk_dependencies() + +register_toolchains( + "@local_roborio//:macos", + "@local_roborio//:linux", + "@local_roborio//:windows", + "@local_raspi_32//:macos", + "@local_raspi_32//:linux", + "@local_raspi_32//:windows", + "@local_bullseye_32//:macos", + "@local_bullseye_32//:linux", + "@local_bullseye_32//:windows", + "@local_bullseye_64//:macos", + "@local_bullseye_64//:linux", + "@local_bullseye_64//:windows", +) + +setup_legacy_setup_jdk_dependencies() + +# Download other dependencies +http_archive( + name = "bzlmodrio-ni", + sha256 = "02a9b1d9722ad3cc7d55ee31a709938884d981f69634dfe93f92e3986bb7a43f", + url = "https://github.com/bzlmodRio/bzlmodRio-ni/releases/download/2024.2.1/bzlmodRio-ni-2024.2.1.tar.gz", +) + +load("@bzlmodrio-ni//:maven_cpp_deps.bzl", "setup_legacy_bzlmodrio_ni_cpp_dependencies") + +setup_legacy_bzlmodrio_ni_cpp_dependencies() diff --git a/shared/bazel/compiler_flags/coverage_flags.rc b/shared/bazel/compiler_flags/coverage_flags.rc new file mode 100644 index 00000000000..0f0a02c470b --- /dev/null +++ b/shared/bazel/compiler_flags/coverage_flags.rc @@ -0,0 +1,5 @@ + +coverage --combined_report=lcov +coverage --build_tests_only +coverage --cache_test_results=no +coverage --coverage_report_generator=@bazel_tools//tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:Main diff --git a/shared/bazel/compiler_flags/linux_flags.rc b/shared/bazel/compiler_flags/linux_flags.rc new file mode 100644 index 00000000000..e09bcebbb46 --- /dev/null +++ b/shared/bazel/compiler_flags/linux_flags.rc @@ -0,0 +1,31 @@ + +# Warning level +build:linux --copt=-Wall +build:linux --copt=-Wextra +build:linux --copt=-Werror + +# C++ args +build:linux --cxxopt=-std=c++20 +build:linux --cxxopt=-Wformat=2 +build:linux --cxxopt=-pedantic +build:linux --cxxopt=-Wno-psabi +build:linux --cxxopt=-Wno-unused-parameter +# build:linux --cxxopt=-Wno-error=deprecated-declarations +build:linux --cxxopt=-Wno-error=deprecated-enum-enum-conversion +build:linux --cxxopt=-fPIC +build:linux --cxxopt=-pthread + +# C only +build:linux --conlyopt=-Wformat=2 +build:linux --conlyopt=-pedantic +build:linux --conlyopt=-Wno-psabi +build:linux --conlyopt=-Wno-unused-parameter +build:linux --conlyopt=-fPIC +build:linux --conlyopt=-pthread + +# Linker +build:linux --linkopt=-rdynamic +build:linux --linkopt=-pthread +build:linux --linkopt=-ldl +build:linux --linkopt=-latomic +build:linux --linkopt=-Wl,-rpath,'$ORIGIN' diff --git a/shared/bazel/compiler_flags/osx_flags.rc b/shared/bazel/compiler_flags/osx_flags.rc new file mode 100644 index 00000000000..f3aa347571b --- /dev/null +++ b/shared/bazel/compiler_flags/osx_flags.rc @@ -0,0 +1,44 @@ + +# Warning level +build:osx --copt=-Wall +build:osx --copt=-Wextra +build:osx --copt=-Werror + + +# C++ only +build:osx --cxxopt=-std=c++20 +build:osx --cxxopt=-pedantic +build:osx --cxxopt=-fPIC +build:osx --cxxopt=-Wno-unused-parameter +build:osx --cxxopt=-Wno-error=deprecated-enum-enum-conversion +build:osx --cxxopt=-Wno-missing-field-initializers +build:osx --cxxopt=-Wno-unused-private-field +build:osx --cxxopt=-Wno-unused-const-variable +build:osx --cxxopt=-Wno-error=c11-extensions +build:osx --cxxopt=-pthread +build:osx --cxxopt=-Wno-deprecated-anon-enum-enum-conversion + +# C only +build:osx --conlyopt=-pedantic +build:osx --conlyopt=-fPIC +build:osx --conlyopt=-Wno-unused-parameter +build:osx --conlyopt=-Wno-missing-field-initializers +build:osx --conlyopt=-Wno-unused-private-field +build:osx --conlyopt=-Wno-fixed-enum-extension" + + +build:osx --linkopt=-framework +build:osx --linkopt=CoreFoundation +build:osx --linkopt=-framework +build:osx --linkopt=AVFoundation +build:osx --linkopt=-framework +build:osx --linkopt=Foundation +build:osx --linkopt=-framework +build:osx --linkopt=CoreMedia +build:osx --linkopt=-framework +build:osx --linkopt=CoreVideo +build:osx --linkopt=-headerpad_max_install_names +build:osx --linkopt=-Wl,-rpath,'@loader_path'" + +# Things not in nativetools +build:osx --copt=-Wno-shorten-64-to-32 diff --git a/shared/bazel/compiler_flags/roborio_flags.rc b/shared/bazel/compiler_flags/roborio_flags.rc new file mode 100644 index 00000000000..86a61e625cd --- /dev/null +++ b/shared/bazel/compiler_flags/roborio_flags.rc @@ -0,0 +1,35 @@ + +build:roborio --platforms=@rules_bzlmodrio_toolchains//platforms/roborio +build:roborio --build_tag_filters=-no-roborio +build:roborio --features=compiler_param_file +build:roborio --platform_suffix=roborio +build:roborio --incompatible_enable_cc_toolchain_resolution + +# C++ only +build:roborio --cxxopt=-std=c++20 +build:roborio --cxxopt=-Wformat=2 +build:roborio --cxxopt=-pedantic +build:roborio --cxxopt=-Wno-psabi +build:roborio --cxxopt=-Wno-unused-parameter +build:roborio --cxxopt=-fPIC +build:roborio --cxxopt=-pthread + +build:roborio --cxxopt=-Wno-error=deprecated-declarations + +# Extra 11 +build:roborio --cxxopt=-Wno-error=deprecated-enum-enum-conversion + +# C Only +build:roborio --conlyopt=-Wformat=2 +build:roborio --conlyopt=-pedantic +build:roborio --conlyopt=-Wno-psabi +build:roborio --conlyopt=-Wno-unused-parameter +build:roborio --conlyopt=-fPIC +build:roborio --conlyopt=-pthread + +# Linker +build:roborio --linkopt=-rdynamic +build:roborio --linkopt=-pthread +build:roborio --linkopt=-ldl +build:roborio --linkopt=-latomic +build:roborio --linkopt=-Wl,-rpath,'$ORIGIN' diff --git a/shared/bazel/compiler_flags/sanitizers.rc b/shared/bazel/compiler_flags/sanitizers.rc new file mode 100644 index 00000000000..739a568a3fc --- /dev/null +++ b/shared/bazel/compiler_flags/sanitizers.rc @@ -0,0 +1,27 @@ +# ASAN (address sanitizer) config +build:asan --copt -fsanitize=address +build:asan --copt -fno-omit-frame-pointer +build:asan --linkopt -fsanitize=address +build:asan --build_tests_only +build:asan --test_tag_filters=-no-asan + +# TSAN (thread sanitizer) +build:tsan --strip=never +build:tsan --copt -fsanitize=thread +build:tsan --copt -DTHREAD_SANITIZER +build:tsan --copt -DDYNAMIC_ANNOTATIONS_ENABLED=1 +build:tsan --copt -DDYNAMIC_ANNOTATIONS_EXTERNAL_IMPL=1 +build:tsan --copt -O1 +build:tsan --copt -fno-omit-frame-pointer +build:tsan --linkopt -fsanitize=thread +build:tsan --build_tests_only +build:tsan --test_tag_filters=-no-tsan + +# USAN (Undefined Behavior Sanitizer) +build:ubsan --copt -fsanitize=undefined +build:ubsan --copt -fno-sanitize-recover=all +build:ubsan --copt -fno-omit-frame-pointer +build:ubsan --linkopt -fsanitize=undefined +build:ubsan --linkopt -fno-sanitize-recover=all +build:ubsan --build_tests_only +build:ubsan --test_tag_filters=-no-ubsan diff --git a/shared/bazel/compiler_flags/windows_arm_flags.rc b/shared/bazel/compiler_flags/windows_arm_flags.rc new file mode 100644 index 00000000000..5fea7f246e8 --- /dev/null +++ b/shared/bazel/compiler_flags/windows_arm_flags.rc @@ -0,0 +1,34 @@ + +build:windows_arm --cpu=arm64_windows + +# Warning level +build:windows_arm --copt=/W3 +build:windows_arm --copt=/WX + +# C++ options +build:windows_arm --cxxopt=/utf-8 +build:windows_arm --cxxopt=/EHsc +build:windows_arm --cxxopt=/FS +build:windows_arm --cxxopt=/Zc:inline +build:windows_arm --cxxopt=/wd4244 +build:windows_arm --cxxopt=/wd4267 +build:windows_arm --cxxopt=/wd4146 +build:windows_arm --cxxopt=/wd4996 +build:windows_arm --cxxopt=/Zc:throwingNew +build:windows_arm --cxxopt=/D_CRT_SECURE_NO_WARNINGS +build:windows_arm --cxxopt=/std:c++20 +build:windows_arm --cxxopt=/permissive- +build:windows_arm --cxxopt=/bigobj +build:windows_arm --cxxopt=/Zc:__cplusplus +build:windows_arm --cxxopt=/Zc:preprocessor +build:windows_arm --cxxopt=/wd5105 + +# C Only +build:windows_arm --conlyopt=/FS +build:windows_arm --conlyopt=/Zc:inline +build:windows_arm --conlyopt=/D_CRT_SECURE_NO_WARNINGS + +build:windows_arm --linkopt=/IGNORE:4099 + +# TODO there is a "bug" in bazel that forces "/D_WIN32_WINNT=0x0601". Remove it from the files that break because of this. +build:windows_arm --per_file_copt=wpiutil/src/main/native/cpp/timestamp.cpp,wpinet/src/main/native/thirdparty/libuv/src/win/util.cpp,hal/src/main/native/sim/HAL.cpp@/U_WIN32_WINNT \ No newline at end of file diff --git a/shared/bazel/compiler_flags/windows_flags.rc b/shared/bazel/compiler_flags/windows_flags.rc new file mode 100644 index 00000000000..9a2a4ee6c45 --- /dev/null +++ b/shared/bazel/compiler_flags/windows_flags.rc @@ -0,0 +1,36 @@ + +# Warning level +build:windows --copt=/W3 +build:windows --copt=/WX + +# C++ options +build:windows --cxxopt=/EHsc +build:windows --cxxopt=/FS +build:windows --cxxopt=/Zc:inline +build:windows --cxxopt=/wd4244 +build:windows --cxxopt=/wd4267 +build:windows --cxxopt=/wd4146 +build:windows --cxxopt=/wd4996 +build:windows --cxxopt=/Zc:throwingNew +build:windows --cxxopt=/D_CRT_SECURE_NO_WARNINGS +build:windows --cxxopt=/std:c++20 +build:windows --cxxopt=/permissive- +build:windows --cxxopt=/utf-8 +build:windows --cxxopt=/bigobj +build:windows --cxxopt=/Zc:__cplusplus +build:windows --cxxopt=/Zc:preprocessor +build:windows --cxxopt=/wd5105 + +# C Only +build:windows --conlyopt=/FS +build:windows --conlyopt=/Zc:inline +build:windows --conlyopt=/D_CRT_SECURE_NO_WARNINGS + +# build:windows --linkopt=/IGNORE:4099 +build:windows --linkopt=/DEPENDENTLOADFLAG:0x1100 + +# TODO +build:windows --copt=/D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR + +# TODO there is a "bug" in bazel that forces "/D_WIN32_WINNT=0x0601". Remove it from the files that break because of this. +build:windows --per_file_copt=wpiutil/src/main/native/cpp/timestamp.cpp,wpinet/src/main/native/thirdparty/libuv/src/win/util.cpp,hal/src/main/native/sim/HAL.cpp@/U_WIN32_WINNT \ No newline at end of file diff --git a/shared/bazel/rules/gen/BUILD.bazel b/shared/bazel/rules/gen/BUILD.bazel new file mode 100644 index 00000000000..49f2e10eb96 --- /dev/null +++ b/shared/bazel/rules/gen/BUILD.bazel @@ -0,0 +1,8 @@ +load("@rules_python//python:defs.bzl", "py_binary") + +py_binary( + name = "gen_resources", + srcs = ["gen_resources.py"], + tags = ["manual"], + visibility = ["//visibility:public"], +) diff --git a/shared/bazel/rules/gen/gen-resources.bzl b/shared/bazel/rules/gen/gen-resources.bzl new file mode 100644 index 00000000000..65dbf3fedca --- /dev/null +++ b/shared/bazel/rules/gen/gen-resources.bzl @@ -0,0 +1,10 @@ +def generate_resources(name, resource_files, prefix, namespace, visibility = None): + cmd = "$(locations //shared/bazel/rules/gen:gen_resources) --prefix={} --namespace={} --resources $(SRCS) --output_files $(OUTS)".format(prefix, namespace, resource_files) + native.genrule( + name = name, + srcs = resource_files, + outs = ["{}.cpp".format(input_file) for input_file in resource_files], + cmd = cmd, + tools = ["//shared/bazel/rules/gen:gen_resources"], + visibility = visibility, + ) diff --git a/shared/bazel/rules/gen/gen_resources.py b/shared/bazel/rules/gen/gen_resources.py new file mode 100644 index 00000000000..869ff1d5914 --- /dev/null +++ b/shared/bazel/rules/gen/gen_resources.py @@ -0,0 +1,58 @@ +import os +import argparse +import binascii + + +def generate_file(resource_file, output_file, prefix, namespace): + func_name = "GetResource_" + os.path.basename(resource_file).replace( + "-", "_" + ).replace(".", "_") + + with open(resource_file, "rb") as f: + raw_data = f.read() + hex = str(binascii.hexlify(raw_data), "ascii") + data = ", ".join("0x" + hex[i : i + 2] for i in range(0, len(hex), 2)) + data_size = len(raw_data) + + output = """#include +#include +extern "C" {{ +static const unsigned char contents[] = {{ {data} }}; +const unsigned char* {prefix}_{func_name}(size_t* len) {{ + *len = {data_size}; + return contents; +}} +}} +namespace {namespace} {{ +std::string_view {func_name}() {{ + return std::string_view(reinterpret_cast(contents), {data_size}); +}} +}} +""".format( + func_name=func_name, + data_size=data_size, + prefix=prefix, + data=data, + namespace=namespace, + ) + + with open(output_file, "w") as f: + f.write(output) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--namespace") + parser.add_argument("--prefix") + parser.add_argument("--resources", nargs="+") + parser.add_argument("--output_files", nargs="+") + + args = parser.parse_args() + assert len(args.resources) == len(args.output_files) + + for i, resource in enumerate(args.resources): + generate_file(resource, args.output_files[i], args.prefix, args.namespace) + + +if __name__ == "__main__": + main() diff --git a/thirdparty/googletest/BUILD.bazel b/thirdparty/googletest/BUILD.bazel new file mode 100644 index 00000000000..6db884b78c9 --- /dev/null +++ b/thirdparty/googletest/BUILD.bazel @@ -0,0 +1,10 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + +cc_library( + name = "googletest", + srcs = glob(["src/**"]), + hdrs = glob(["include/**"]), + includes = ["src/googletest"], + strip_include_prefix = "include", + visibility = ["//visibility:public"], +) diff --git a/wpiutil/examples/printlog/BUILD.bazel b/wpiutil/examples/printlog/BUILD.bazel new file mode 100644 index 00000000000..83b73213eaa --- /dev/null +++ b/wpiutil/examples/printlog/BUILD.bazel @@ -0,0 +1,16 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary") +load("@rules_python//python:defs.bzl", "py_binary") + +py_binary( + name = "datalog", + srcs = ["datalog.py"], + tags = ["manual"], +) + +cc_binary( + name = "printlog", + srcs = ["printlog.cpp"], + deps = [ + "//wpiutil/src/main/native:wpiutil.static", + ], +) diff --git a/wpiutil/examples/writelog/BUILD.bazel b/wpiutil/examples/writelog/BUILD.bazel new file mode 100644 index 00000000000..76a5cb9a613 --- /dev/null +++ b/wpiutil/examples/writelog/BUILD.bazel @@ -0,0 +1,9 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary") + +cc_binary( + name = "writelog", + srcs = ["writelog.cpp"], + deps = [ + "//wpiutil/src/main/native:wpiutil.static", + ], +) diff --git a/wpiutil/src/dev/java/edu/wpi/first/util/BUILD.bazel b/wpiutil/src/dev/java/edu/wpi/first/util/BUILD.bazel new file mode 100644 index 00000000000..663b6794b18 --- /dev/null +++ b/wpiutil/src/dev/java/edu/wpi/first/util/BUILD.bazel @@ -0,0 +1,9 @@ +load("@rules_java//java:defs.bzl", "java_binary") + +java_binary( + name = "DevMain", + srcs = ["DevMain.java"], + deps = [ + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + ], +) diff --git a/wpiutil/src/dev/native/cpp/BUILD.bazel b/wpiutil/src/dev/native/cpp/BUILD.bazel new file mode 100644 index 00000000000..caa66bf4039 --- /dev/null +++ b/wpiutil/src/dev/native/cpp/BUILD.bazel @@ -0,0 +1,9 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary") + +cc_binary( + name = "DevMain", + srcs = ["main.cpp"], + deps = [ + "//wpiutil/src/main/native:wpiutil.static", + ], +) diff --git a/wpiutil/src/main/java/edu/wpi/first/util/BUILD.bazel b/wpiutil/src/main/java/edu/wpi/first/util/BUILD.bazel new file mode 100644 index 00000000000..a8f1823154e --- /dev/null +++ b/wpiutil/src/main/java/edu/wpi/first/util/BUILD.bazel @@ -0,0 +1,13 @@ +load("@rules_java//java:defs.bzl", "java_library") + +java_library( + name = "wpiutil", + srcs = glob(["**/*.java"]), + visibility = ["//visibility:public"], + deps = [ + "@maven//:com_fasterxml_jackson_core_jackson_annotations", + "@maven//:com_fasterxml_jackson_core_jackson_core", + "@maven//:com_fasterxml_jackson_core_jackson_databind", + "@maven//:us_hebi_quickbuf_quickbuf_runtime", + ], +) diff --git a/wpiutil/src/main/native/BUILD.bazel b/wpiutil/src/main/native/BUILD.bazel new file mode 100644 index 00000000000..3986a25edcb --- /dev/null +++ b/wpiutil/src/main/native/BUILD.bazel @@ -0,0 +1,53 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") +load("//shared/bazel/rules/gen:gen-resources.bzl", "generate_resources") + +generate_resources( + name = "generate-resources", + namespace = "dlt", + prefix = "DLT", + resource_files = glob(["resources/*"]), +) + +filegroup( + name = "native-srcs", + srcs = select({ + "@bazel_tools//src/conditions:windows": glob([ + "windows/*.cpp", + "windows/*.h", + ]), + "@rules_bzlmodrio_toolchains//constraints/combined:is_unix": glob(["unix/*.cpp"]), + }), +) + +cc_library( + name = "wpiutil.static", + srcs = glob( + ["cpp/**"], + exclude = ["cpp/jni/**"], + ) + [ + ":generate-resources", + ":native-srcs", + "//wpiutil/src/main/native/thirdparty/fmtlib:fmtlib-srcs", + "//wpiutil/src/main/native/thirdparty/llvm:llvm-srcs", + "//wpiutil/src/main/native/thirdparty/memory:memory-srcs", + "//wpiutil/src/main/native/thirdparty/mpack:mpack-srcs", + "//wpiutil/src/main/native/thirdparty/protobuf:protobuf-srcs", + ], + hdrs = glob(["include/**/*"]), + includes = ["include"], + strip_include_prefix = "include", + visibility = ["//visibility:public"], + deps = [ + "//wpiutil/src/main/native/thirdparty/expected:expected-headers", + "//wpiutil/src/main/native/thirdparty/fmtlib:fmtlib-headers", + "//wpiutil/src/main/native/thirdparty/json:json-headers", + "//wpiutil/src/main/native/thirdparty/llvm:llvm-headers", + "//wpiutil/src/main/native/thirdparty/memory:memory-headers", + "//wpiutil/src/main/native/thirdparty/mpack:mpack-headers", + "//wpiutil/src/main/native/thirdparty/protobuf:protobuf-headers", + "//wpiutil/src/main/native/thirdparty/sigslot:sigslot-headers", + ] + select({ + "@rules_bzlmodrio_toolchains//constraints/is_roborio:roborio": ["@bzlmodrio-ni//libraries/cpp/ni:shared"], + "//conditions:default": [], + }), +) diff --git a/wpiutil/src/main/native/thirdparty/expected/BUILD.bazel b/wpiutil/src/main/native/thirdparty/expected/BUILD.bazel new file mode 100644 index 00000000000..16109c86388 --- /dev/null +++ b/wpiutil/src/main/native/thirdparty/expected/BUILD.bazel @@ -0,0 +1,11 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + +cc_library( + name = "expected-headers", + hdrs = glob([ + "include/**/*", + ]), + includes = ["include"], + strip_include_prefix = "include", + visibility = ["//wpiutil:__subpackages__"], +) diff --git a/wpiutil/src/main/native/thirdparty/fmtlib/BUILD.bazel b/wpiutil/src/main/native/thirdparty/fmtlib/BUILD.bazel new file mode 100644 index 00000000000..a3e69baa40f --- /dev/null +++ b/wpiutil/src/main/native/thirdparty/fmtlib/BUILD.bazel @@ -0,0 +1,17 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + +cc_library( + name = "fmtlib-headers", + hdrs = glob([ + "include/**/*.h", + ]), + includes = ["include"], + strip_include_prefix = "include", + visibility = ["//wpiutil:__subpackages__"], +) + +filegroup( + name = "fmtlib-srcs", + srcs = glob(["src/**"]), + visibility = ["//wpiutil:__subpackages__"], +) diff --git a/wpiutil/src/main/native/thirdparty/json/BUILD.bazel b/wpiutil/src/main/native/thirdparty/json/BUILD.bazel new file mode 100644 index 00000000000..860b4e23e7f --- /dev/null +++ b/wpiutil/src/main/native/thirdparty/json/BUILD.bazel @@ -0,0 +1,11 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + +cc_library( + name = "json-headers", + hdrs = glob([ + "include/**/*.h", + ]), + includes = ["include"], + strip_include_prefix = "include", + visibility = ["//wpiutil:__subpackages__"], +) diff --git a/wpiutil/src/main/native/thirdparty/llvm/BUILD.bazel b/wpiutil/src/main/native/thirdparty/llvm/BUILD.bazel new file mode 100644 index 00000000000..a59db1a4711 --- /dev/null +++ b/wpiutil/src/main/native/thirdparty/llvm/BUILD.bazel @@ -0,0 +1,17 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + +cc_library( + name = "llvm-headers", + hdrs = glob([ + "include/**/*.h", + ]), + includes = ["include"], + strip_include_prefix = "include", + visibility = ["//wpiutil:__subpackages__"], +) + +filegroup( + name = "llvm-srcs", + srcs = glob(["cpp/**"]), + visibility = ["//wpiutil:__subpackages__"], +) diff --git a/wpiutil/src/main/native/thirdparty/memory/BUILD.bazel b/wpiutil/src/main/native/thirdparty/memory/BUILD.bazel new file mode 100644 index 00000000000..6e457bca9f8 --- /dev/null +++ b/wpiutil/src/main/native/thirdparty/memory/BUILD.bazel @@ -0,0 +1,17 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + +cc_library( + name = "memory-headers", + hdrs = glob([ + "include/**/*.hpp", + ]), + includes = ["include"], + strip_include_prefix = "include", + visibility = ["//wpiutil:__subpackages__"], +) + +filegroup( + name = "memory-srcs", + srcs = glob(["src/**"]), + visibility = ["//wpiutil:__subpackages__"], +) diff --git a/wpiutil/src/main/native/thirdparty/mpack/BUILD.bazel b/wpiutil/src/main/native/thirdparty/mpack/BUILD.bazel new file mode 100644 index 00000000000..83e404221fa --- /dev/null +++ b/wpiutil/src/main/native/thirdparty/mpack/BUILD.bazel @@ -0,0 +1,17 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + +cc_library( + name = "mpack-headers", + hdrs = glob([ + "include/**/*.h", + ]), + includes = ["include"], + strip_include_prefix = "include", + visibility = ["//wpiutil:__subpackages__"], +) + +filegroup( + name = "mpack-srcs", + srcs = glob(["src/**"]), + visibility = ["//wpiutil:__subpackages__"], +) diff --git a/wpiutil/src/main/native/thirdparty/protobuf/BUILD.bazel b/wpiutil/src/main/native/thirdparty/protobuf/BUILD.bazel new file mode 100644 index 00000000000..c8d38365426 --- /dev/null +++ b/wpiutil/src/main/native/thirdparty/protobuf/BUILD.bazel @@ -0,0 +1,18 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + +cc_library( + name = "protobuf-headers", + hdrs = glob([ + "include/**/*.h", + "include/**/*.inc", + ]), + includes = ["include"], + strip_include_prefix = "include", + visibility = ["//wpiutil:__subpackages__"], +) + +filegroup( + name = "protobuf-srcs", + srcs = glob(["src/**"]), + visibility = ["//wpiutil:__subpackages__"], +) diff --git a/wpiutil/src/main/native/thirdparty/sigslot/BUILD.bazel b/wpiutil/src/main/native/thirdparty/sigslot/BUILD.bazel new file mode 100644 index 00000000000..4c451dc8581 --- /dev/null +++ b/wpiutil/src/main/native/thirdparty/sigslot/BUILD.bazel @@ -0,0 +1,11 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + +cc_library( + name = "sigslot-headers", + hdrs = glob([ + "include/**/*.h", + ]), + includes = ["include"], + strip_include_prefix = "include", + visibility = ["//wpiutil:__subpackages__"], +) diff --git a/wpiutil/src/printlog/java/printlog/BUILD.bazel b/wpiutil/src/printlog/java/printlog/BUILD.bazel new file mode 100644 index 00000000000..5e5736a232a --- /dev/null +++ b/wpiutil/src/printlog/java/printlog/BUILD.bazel @@ -0,0 +1,9 @@ +load("@rules_java//java:defs.bzl", "java_binary") + +java_binary( + name = "printlog", + srcs = ["PrintLog.java"], + deps = [ + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + ], +) diff --git a/wpiutil/src/test/native/BUILD.bazel b/wpiutil/src/test/native/BUILD.bazel new file mode 100644 index 00000000000..f660403ed57 --- /dev/null +++ b/wpiutil/src/test/native/BUILD.bazel @@ -0,0 +1,21 @@ +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") + +cc_library( + name = "wpiutil-testlib", + hdrs = glob(["include/**"]), + strip_include_prefix = "include", + visibility = ["//visibility:public"], +) + +cc_test( + name = "wpiutil-test", + size = "small", + srcs = glob(["cpp/**"]), + linkstatic = True, + tags = ["no-tsan"], # TODO(pj.reiniger) Find problem + deps = [ + ":wpiutil-testlib", + "//thirdparty/googletest", + "//wpiutil/src/main/native:wpiutil.static", + ], +) From ccfe1703a4e7993464c51e0ce74a47fdde829ba7 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Fri, 23 Aug 2024 01:33:30 -0400 Subject: [PATCH 02/38] Add wpinet --- wpinet/examples/dsclient/BUILD.bazel | 9 +++ wpinet/examples/parallelconnect/BUILD.bazel | 9 +++ wpinet/examples/webserver/BUILD.bazel | 9 +++ .../dev/java/edu/wpi/first/net/BUILD.bazel | 10 +++ wpinet/src/dev/native/cpp/BUILD.bazel | 9 +++ .../main/java/edu/wpi/first/net/BUILD.bazel | 10 +++ wpinet/src/main/native/BUILD.bazel | 47 +++++++++++++ .../main/native/thirdparty/libuv/BUILD.bazel | 69 +++++++++++++++++++ .../native/thirdparty/tcpsockets/BUILD.bazel | 17 +++++ .../netconsoleServer/native/cpp/BUILD.bazel | 13 ++++ .../src/netconsoleTee/native/cpp/BUILD.bazel | 9 +++ wpinet/src/test/native/cpp/BUILD.bazel | 16 +++++ 12 files changed, 227 insertions(+) create mode 100644 wpinet/examples/dsclient/BUILD.bazel create mode 100644 wpinet/examples/parallelconnect/BUILD.bazel create mode 100644 wpinet/examples/webserver/BUILD.bazel create mode 100644 wpinet/src/dev/java/edu/wpi/first/net/BUILD.bazel create mode 100644 wpinet/src/dev/native/cpp/BUILD.bazel create mode 100644 wpinet/src/main/java/edu/wpi/first/net/BUILD.bazel create mode 100644 wpinet/src/main/native/BUILD.bazel create mode 100644 wpinet/src/main/native/thirdparty/libuv/BUILD.bazel create mode 100644 wpinet/src/main/native/thirdparty/tcpsockets/BUILD.bazel create mode 100644 wpinet/src/netconsoleServer/native/cpp/BUILD.bazel create mode 100644 wpinet/src/netconsoleTee/native/cpp/BUILD.bazel create mode 100644 wpinet/src/test/native/cpp/BUILD.bazel diff --git a/wpinet/examples/dsclient/BUILD.bazel b/wpinet/examples/dsclient/BUILD.bazel new file mode 100644 index 00000000000..507d05e9a16 --- /dev/null +++ b/wpinet/examples/dsclient/BUILD.bazel @@ -0,0 +1,9 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary") + +cc_binary( + name = "dsclient", + srcs = ["dsclient.cpp"], + deps = [ + "//wpinet/src/main/native:wpinet.static", + ], +) diff --git a/wpinet/examples/parallelconnect/BUILD.bazel b/wpinet/examples/parallelconnect/BUILD.bazel new file mode 100644 index 00000000000..fa56611b965 --- /dev/null +++ b/wpinet/examples/parallelconnect/BUILD.bazel @@ -0,0 +1,9 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary") + +cc_binary( + name = "parallelconnect", + srcs = ["parallelconnect.cpp"], + deps = [ + "//wpinet/src/main/native:wpinet.static", + ], +) diff --git a/wpinet/examples/webserver/BUILD.bazel b/wpinet/examples/webserver/BUILD.bazel new file mode 100644 index 00000000000..1a60ded9860 --- /dev/null +++ b/wpinet/examples/webserver/BUILD.bazel @@ -0,0 +1,9 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary") + +cc_binary( + name = "webserver", + srcs = ["webserver.cpp"], + deps = [ + "//wpinet/src/main/native:wpinet.static", + ], +) diff --git a/wpinet/src/dev/java/edu/wpi/first/net/BUILD.bazel b/wpinet/src/dev/java/edu/wpi/first/net/BUILD.bazel new file mode 100644 index 00000000000..47ad6913df4 --- /dev/null +++ b/wpinet/src/dev/java/edu/wpi/first/net/BUILD.bazel @@ -0,0 +1,10 @@ +load("@rules_java//java:defs.bzl", "java_binary") + +java_binary( + name = "DevMain", + srcs = ["DevMain.java"], + deps = [ + "//wpinet/src/main/java/edu/wpi/first/net:wpinet", + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + ], +) diff --git a/wpinet/src/dev/native/cpp/BUILD.bazel b/wpinet/src/dev/native/cpp/BUILD.bazel new file mode 100644 index 00000000000..c3ab6c5fbb5 --- /dev/null +++ b/wpinet/src/dev/native/cpp/BUILD.bazel @@ -0,0 +1,9 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary") + +cc_binary( + name = "DevMain", + srcs = ["main.cpp"], + deps = [ + "//wpinet/src/main/native:wpinet.static", + ], +) diff --git a/wpinet/src/main/java/edu/wpi/first/net/BUILD.bazel b/wpinet/src/main/java/edu/wpi/first/net/BUILD.bazel new file mode 100644 index 00000000000..20bfaf3951c --- /dev/null +++ b/wpinet/src/main/java/edu/wpi/first/net/BUILD.bazel @@ -0,0 +1,10 @@ +load("@rules_java//java:defs.bzl", "java_library") + +java_library( + name = "wpinet", + srcs = glob(["**/*.java"]), + visibility = ["//visibility:public"], + deps = [ + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + ], +) diff --git a/wpinet/src/main/native/BUILD.bazel b/wpinet/src/main/native/BUILD.bazel new file mode 100644 index 00000000000..22c5eaa5caa --- /dev/null +++ b/wpinet/src/main/native/BUILD.bazel @@ -0,0 +1,47 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") +load("//shared/bazel/rules/gen:gen-resources.bzl", "generate_resources") + +generate_resources( + name = "generate-resources", + namespace = "dlt", + prefix = "DLT", + resource_files = glob(["resources/*"]), +) + +filegroup( + name = "native-srcs", + srcs = ["generate-resources"] + select({ + "@bazel_tools//src/conditions:darwin": glob(["macOS/*"]), + "@bazel_tools//src/conditions:windows": glob(["windows/*"]), + "@rules_bzlmodrio_toolchains//constraints/combined:is_linux": glob(["linux/*"]), + }), +) + +cc_library( + name = "private_includes", + hdrs = glob([ + "cpp/*.h", + ]), + strip_include_prefix = "cpp", +) + +cc_library( + name = "wpinet.static", + srcs = glob( + ["cpp/**"], + exclude = ["cpp/jni/**"], + ) + [ + "//wpinet/src/main/native/thirdparty/libuv:libuv-srcs", + "//wpinet/src/main/native/thirdparty/tcpsockets:tcpsockets-srcs", + ] + ["native-srcs"], + hdrs = glob(["include/**/*"]), + includes = ["include"], + strip_include_prefix = "include", + visibility = ["//visibility:public"], + deps = [ + ":private_includes", + "//wpinet/src/main/native/thirdparty/libuv:libuv-headers", + "//wpinet/src/main/native/thirdparty/tcpsockets:tcpsockets-headers", + "//wpiutil/src/main/native:wpiutil.static", + ], +) diff --git a/wpinet/src/main/native/thirdparty/libuv/BUILD.bazel b/wpinet/src/main/native/thirdparty/libuv/BUILD.bazel new file mode 100644 index 00000000000..3363eaca334 --- /dev/null +++ b/wpinet/src/main/native/thirdparty/libuv/BUILD.bazel @@ -0,0 +1,69 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + +WIN_UV_SRCS = glob([ + "src/win/*.cpp", + "src/win/*.h", +]) + +UNIX_UV_SRCS = [ + "src/unix/async.cpp", + "src/unix/core.cpp", + "src/unix/dl.cpp", + "src/unix/fs.cpp", + "src/unix/getaddrinfo.cpp", + "src/unix/getnameinfo.cpp", + "src/unix/loop-watcher.cpp", + "src/unix/loop.cpp", + "src/unix/pipe.cpp", + "src/unix/poll.cpp", + "src/unix/process.cpp", + "src/unix/random-devurandom.cpp", + "src/unix/random-getentropy.cpp", + "src/unix/random-getrandom.cpp", + "src/unix/signal.cpp", + "src/unix/stream.cpp", + "src/unix/tcp.cpp", + "src/unix/thread.cpp", + "src/unix/tty.cpp", + "src/unix/udp.cpp", +] + glob(["src/unix/*.h"]) + +MAC_UV_SRCS = [ + "src/unix/bsd-ifaddrs.cpp", + "src/unix/darwin.cpp", + "src/unix/darwin-proctitle.cpp", + "src/unix/fsevents.cpp", + "src/unix/kqueue.cpp", + "src/unix/proctitle.cpp", +] + +LINUX_UV_SRCS = [ + "src/unix/linux.cpp", + "src/unix/procfs-exepath.cpp", + "src/unix/proctitle.cpp", + "src/unix/random-sysctl-linux.cpp", +] + +cc_library( + name = "libuv-headers", + hdrs = glob([ + "include/**/*.h", + ]), + includes = ["src"], + strip_include_prefix = "include", + visibility = ["//wpinet:__subpackages__"], +) + +filegroup( + name = "libuv-srcs", + srcs = select({ + "@rules_bzlmodrio_toolchains//constraints/combined:is_unix": UNIX_UV_SRCS, + "//conditions:default": [], + }) + + select({ + "@bazel_tools//src/conditions:darwin": MAC_UV_SRCS, + "@bazel_tools//src/conditions:windows": WIN_UV_SRCS, + "@rules_bzlmodrio_toolchains//constraints/combined:is_linux": LINUX_UV_SRCS, + }) + glob(["src/*"]), + visibility = ["//wpinet:__subpackages__"], +) diff --git a/wpinet/src/main/native/thirdparty/tcpsockets/BUILD.bazel b/wpinet/src/main/native/thirdparty/tcpsockets/BUILD.bazel new file mode 100644 index 00000000000..d12517784fe --- /dev/null +++ b/wpinet/src/main/native/thirdparty/tcpsockets/BUILD.bazel @@ -0,0 +1,17 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + +cc_library( + name = "tcpsockets-headers", + hdrs = glob([ + "include/**/*.h", + ]), + includes = ["include"], + strip_include_prefix = "include", + visibility = ["//wpinet:__subpackages__"], +) + +filegroup( + name = "tcpsockets-srcs", + srcs = glob(["cpp/**"]), + visibility = ["//wpinet:__subpackages__"], +) diff --git a/wpinet/src/netconsoleServer/native/cpp/BUILD.bazel b/wpinet/src/netconsoleServer/native/cpp/BUILD.bazel new file mode 100644 index 00000000000..a2de1d13cbb --- /dev/null +++ b/wpinet/src/netconsoleServer/native/cpp/BUILD.bazel @@ -0,0 +1,13 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary") + +cc_binary( + name = "netconsoleServer", + srcs = ["main.cpp"], + linkopts = select({ + "@rules_bzlmodrio_toolchains//constraints/combined:is_linux": ["-lutil"], + "//conditions:default": [], + }), + deps = [ + "//wpinet/src/main/native:wpinet.static", + ], +) diff --git a/wpinet/src/netconsoleTee/native/cpp/BUILD.bazel b/wpinet/src/netconsoleTee/native/cpp/BUILD.bazel new file mode 100644 index 00000000000..9bf9e1b9164 --- /dev/null +++ b/wpinet/src/netconsoleTee/native/cpp/BUILD.bazel @@ -0,0 +1,9 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary") + +cc_binary( + name = "netconsoleTee", + srcs = ["main.cpp"], + deps = [ + "//wpinet/src/main/native:wpinet.static", + ], +) diff --git a/wpinet/src/test/native/cpp/BUILD.bazel b/wpinet/src/test/native/cpp/BUILD.bazel new file mode 100644 index 00000000000..36103a6be60 --- /dev/null +++ b/wpinet/src/test/native/cpp/BUILD.bazel @@ -0,0 +1,16 @@ +load("@rules_cc//cc:defs.bzl", "cc_test") + +cc_test( + name = "wpinet-test", + size = "small", + srcs = glob([ + "**/*.cpp", + "**/*.h", + ]), + tags = ["no-asan"], + deps = [ + "//thirdparty/googletest", + "//wpinet/src/main/native:wpinet.static", + "//wpiutil/src/test/native:wpiutil-testlib", + ], +) From 7e3cf21ab867a2566cc4c5ca1f3bee45f08ea172 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Fri, 23 Aug 2024 01:36:32 -0400 Subject: [PATCH 03/38] Add ntcore --- ntcore/BUILD.bazel | 24 +++++++++++++++ .../dev/java/edu/wpi/first/ntcore/BUILD.bazel | 10 +++++++ ntcore/src/dev/native/cpp/BUILD.bazel | 9 ++++++ .../edu/wpi/first/networktables/BUILD.bazel | 11 +++++++ ntcore/src/main/native/BUILD.bazel | 30 +++++++++++++++++++ ntcore/src/test/native/cpp/BUILD.bazel | 20 +++++++++++++ 6 files changed, 104 insertions(+) create mode 100644 ntcore/BUILD.bazel create mode 100644 ntcore/src/dev/java/edu/wpi/first/ntcore/BUILD.bazel create mode 100644 ntcore/src/dev/native/cpp/BUILD.bazel create mode 100644 ntcore/src/main/java/edu/wpi/first/networktables/BUILD.bazel create mode 100644 ntcore/src/main/native/BUILD.bazel create mode 100644 ntcore/src/test/native/cpp/BUILD.bazel diff --git a/ntcore/BUILD.bazel b/ntcore/BUILD.bazel new file mode 100644 index 00000000000..0b7567dec7b --- /dev/null +++ b/ntcore/BUILD.bazel @@ -0,0 +1,24 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + +cc_library( + name = "generated_cc_headers", + hdrs = glob(["src/generated/main/native/include/**"]), + includes = ["src/generated/main/native/include"], + strip_include_prefix = "src/generated/main/native/include", + visibility = ["//ntcore:__subpackages__"], +) + +filegroup( + name = "generated_cc_source", + srcs = glob( + ["src/generated/main/native/cpp/**"], + exclude = ["src/generated/main/native/cpp/jni/**"], + ), + visibility = ["//ntcore:__subpackages__"], +) + +filegroup( + name = "generated_java", + srcs = glob(["src/generated/main/java/**/*.java"]), + visibility = ["//ntcore:__subpackages__"], +) diff --git a/ntcore/src/dev/java/edu/wpi/first/ntcore/BUILD.bazel b/ntcore/src/dev/java/edu/wpi/first/ntcore/BUILD.bazel new file mode 100644 index 00000000000..b5e370e72d2 --- /dev/null +++ b/ntcore/src/dev/java/edu/wpi/first/ntcore/BUILD.bazel @@ -0,0 +1,10 @@ +load("@rules_java//java:defs.bzl", "java_binary") + +java_binary( + name = "DevMain", + srcs = ["DevMain.java"], + deps = [ + "//ntcore/src/main/java/edu/wpi/first/networktables", + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + ], +) diff --git a/ntcore/src/dev/native/cpp/BUILD.bazel b/ntcore/src/dev/native/cpp/BUILD.bazel new file mode 100644 index 00000000000..c480ed2acca --- /dev/null +++ b/ntcore/src/dev/native/cpp/BUILD.bazel @@ -0,0 +1,9 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary") + +cc_binary( + name = "DevMain", + srcs = ["main.cpp"], + deps = [ + "//ntcore/src/main/native:ntcore.static", + ], +) diff --git a/ntcore/src/main/java/edu/wpi/first/networktables/BUILD.bazel b/ntcore/src/main/java/edu/wpi/first/networktables/BUILD.bazel new file mode 100644 index 00000000000..48b1f6517e4 --- /dev/null +++ b/ntcore/src/main/java/edu/wpi/first/networktables/BUILD.bazel @@ -0,0 +1,11 @@ +load("@rules_java//java:defs.bzl", "java_library") + +java_library( + name = "networktables", + srcs = glob(["**/*.java"]) + ["//ntcore:generated_java"], + visibility = ["//visibility:public"], + deps = [ + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + "@maven//:us_hebi_quickbuf_quickbuf_runtime", + ], +) diff --git a/ntcore/src/main/native/BUILD.bazel b/ntcore/src/main/native/BUILD.bazel new file mode 100644 index 00000000000..68f9543e8e3 --- /dev/null +++ b/ntcore/src/main/native/BUILD.bazel @@ -0,0 +1,30 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + +cc_library( + name = "private_includes", + hdrs = glob([ + "cpp/*.h", + "cpp/net/*.h", + "cpp/net/*.inc", + "cpp/net3/*.h", + ]), + strip_include_prefix = "cpp", +) + +cc_library( + name = "ntcore.static", + srcs = glob( + ["cpp/**"], + exclude = ["cpp/jni/**"], + ) + ["//ntcore:generated_cc_source"], + hdrs = glob(["include/**/*"]), + includes = ["include"], + strip_include_prefix = "include", + visibility = ["//visibility:public"], + deps = [ + ":private_includes", + "//ntcore:generated_cc_headers", + "//wpinet/src/main/native:wpinet.static", + "//wpiutil/src/main/native:wpiutil.static", + ], +) diff --git a/ntcore/src/test/native/cpp/BUILD.bazel b/ntcore/src/test/native/cpp/BUILD.bazel new file mode 100644 index 00000000000..cc1aaa0aca3 --- /dev/null +++ b/ntcore/src/test/native/cpp/BUILD.bazel @@ -0,0 +1,20 @@ +load("@rules_cc//cc:defs.bzl", "cc_test") + +cc_test( + name = "ntcore-test", + size = "small", + srcs = glob([ + "**/*.cpp", + "**/*.h", + ]), + tags = [ + "exclusive", + "no-asan", + "no-tsan", + ], + deps = [ + "//ntcore/src/main/native:ntcore.static", + "//thirdparty/googletest", + "//wpiutil/src/test/native:wpiutil-testlib", + ], +) From 8ddbdb9928d31f74ca6d7d5cc3945c04150fb1b0 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Fri, 23 Aug 2024 01:39:11 -0400 Subject: [PATCH 04/38] Add hal --- hal/BUILD.bazel | 15 +++++++++++++++ hal/src/dev/java/edu/wpi/first/hal/BUILD.bazel | 8 ++++++++ hal/src/main/java/edu/wpi/first/hal/BUILD.bazel | 10 ++++++++++ 3 files changed, 33 insertions(+) create mode 100644 hal/BUILD.bazel create mode 100644 hal/src/dev/java/edu/wpi/first/hal/BUILD.bazel create mode 100644 hal/src/main/java/edu/wpi/first/hal/BUILD.bazel diff --git a/hal/BUILD.bazel b/hal/BUILD.bazel new file mode 100644 index 00000000000..9ba51885a66 --- /dev/null +++ b/hal/BUILD.bazel @@ -0,0 +1,15 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + +cc_library( + name = "generated_cc_headers", + hdrs = glob(["src/generated/main/native/include/**"]), + includes = ["src/generated/main/native/include"], + strip_include_prefix = "src/generated/main/native/include", + visibility = ["//hal:__subpackages__"], +) + +filegroup( + name = "generated_java", + srcs = glob(["src/generated/main/java/**/*.java"]), + visibility = ["//hal:__subpackages__"], +) diff --git a/hal/src/dev/java/edu/wpi/first/hal/BUILD.bazel b/hal/src/dev/java/edu/wpi/first/hal/BUILD.bazel new file mode 100644 index 00000000000..214327c3f85 --- /dev/null +++ b/hal/src/dev/java/edu/wpi/first/hal/BUILD.bazel @@ -0,0 +1,8 @@ +load("@rules_java//java:defs.bzl", "java_binary") + +java_binary( + name = "DevMain", + srcs = ["DevMain.java"], + deps = [ + ], +) diff --git a/hal/src/main/java/edu/wpi/first/hal/BUILD.bazel b/hal/src/main/java/edu/wpi/first/hal/BUILD.bazel new file mode 100644 index 00000000000..34579d58e7e --- /dev/null +++ b/hal/src/main/java/edu/wpi/first/hal/BUILD.bazel @@ -0,0 +1,10 @@ +load("@rules_java//java:defs.bzl", "java_library") + +java_library( + name = "hal", + srcs = ["//hal:generated_java"] + glob(["**/*.java"]), + visibility = ["//visibility:public"], + deps = [ + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + ], +) From 80e6627ee57c15383012b9d99c0d5987d4e9efbf Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Fri, 23 Aug 2024 01:42:47 -0400 Subject: [PATCH 05/38] Add hal --- hal/src/dev/native/cpp/BUILD.bazel | 9 +++++ hal/src/main/native/BUILD.bazel | 53 +++++++++++++++++++++++++++++ hal/src/test/native/cpp/BUILD.bazel | 14 ++++++++ 3 files changed, 76 insertions(+) create mode 100644 hal/src/dev/native/cpp/BUILD.bazel create mode 100644 hal/src/main/native/BUILD.bazel create mode 100644 hal/src/test/native/cpp/BUILD.bazel diff --git a/hal/src/dev/native/cpp/BUILD.bazel b/hal/src/dev/native/cpp/BUILD.bazel new file mode 100644 index 00000000000..fe2a27b3b5a --- /dev/null +++ b/hal/src/dev/native/cpp/BUILD.bazel @@ -0,0 +1,9 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary") + +cc_binary( + name = "DevMain", + srcs = ["main.cpp"], + deps = [ + "//hal/src/main/native:wpiHal.static", + ], +) diff --git a/hal/src/main/native/BUILD.bazel b/hal/src/main/native/BUILD.bazel new file mode 100644 index 00000000000..dfb736f4f51 --- /dev/null +++ b/hal/src/main/native/BUILD.bazel @@ -0,0 +1,53 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + +ATHENA_SRCS = glob([ + "athena/*.cpp", + "athena/*.h", + "athena/cpp/*.cpp", + "athena/ctre/*.cpp", + "athena/ctre/*.h", + "athena/rev/*.cpp", + "athena/rev/*.h", + "athena/frccansae/*.h", + "athena/mockdata/*.cpp", +]) + +ATHENA_DEPS = ["@bzlmodrio-ni//libraries/cpp/ni:shared"] + +SIM_SRCS = glob([ + "sim/*.cpp", + "sim/mockdata/*.cpp", + "sim/*.h", + "sim/mockdata/*.h", +]) + +SIM_DEPS = [] + +HAL_DEPS = select({ + "@rules_bzlmodrio_toolchains//constraints/is_roborio:roborio": ATHENA_DEPS, + "//conditions:default": SIM_DEPS, +}) + +filegroup( + name = "platform-srcs", + srcs = select({ + "@rules_bzlmodrio_toolchains//constraints/is_roborio:roborio": ATHENA_SRCS, + "//conditions:default": SIM_SRCS, + }), +) + +cc_library( + name = "wpiHal.static", + srcs = ["platform-srcs"] + glob( + ["cpp/**"], + exclude = ["cpp/jni/**"], + ), + hdrs = glob(["include/**/*"]), + includes = ["include"], + strip_include_prefix = "include", + visibility = ["//visibility:public"], + deps = [ + "//hal:generated_cc_headers", + "//wpiutil/src/main/native:wpiutil.static", + ] + HAL_DEPS, +) diff --git a/hal/src/test/native/cpp/BUILD.bazel b/hal/src/test/native/cpp/BUILD.bazel new file mode 100644 index 00000000000..000c90a0a30 --- /dev/null +++ b/hal/src/test/native/cpp/BUILD.bazel @@ -0,0 +1,14 @@ +load("@rules_cc//cc:defs.bzl", "cc_test") + +cc_test( + name = "hal-cpp-test", + size = "small", + srcs = glob([ + "**/*.cpp", + "**/*.h", + ]), + deps = [ + "//hal/src/main/native:wpiHal.static", + "//thirdparty/googletest", + ], +) From 2a6389411522f458f768a80a486462c4c688b1c8 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Fri, 23 Aug 2024 01:51:22 -0400 Subject: [PATCH 06/38] wpiunits --- wpiunits/src/dev/java/edu/wpi/first/units/BUILD.bazel | 9 +++++++++ wpiunits/src/main/java/edu/wpi/first/units/BUILD.bazel | 8 ++++++++ 2 files changed, 17 insertions(+) create mode 100644 wpiunits/src/dev/java/edu/wpi/first/units/BUILD.bazel create mode 100644 wpiunits/src/main/java/edu/wpi/first/units/BUILD.bazel diff --git a/wpiunits/src/dev/java/edu/wpi/first/units/BUILD.bazel b/wpiunits/src/dev/java/edu/wpi/first/units/BUILD.bazel new file mode 100644 index 00000000000..5718f15922b --- /dev/null +++ b/wpiunits/src/dev/java/edu/wpi/first/units/BUILD.bazel @@ -0,0 +1,9 @@ +load("@rules_java//java:defs.bzl", "java_binary") + +java_binary( + name = "DevMain", + srcs = ["DevMain.java"], + deps = [ + "//wpiunits/src/main/java/edu/wpi/first/units:wpiunits", + ], +) diff --git a/wpiunits/src/main/java/edu/wpi/first/units/BUILD.bazel b/wpiunits/src/main/java/edu/wpi/first/units/BUILD.bazel new file mode 100644 index 00000000000..cb1cb8f99dc --- /dev/null +++ b/wpiunits/src/main/java/edu/wpi/first/units/BUILD.bazel @@ -0,0 +1,8 @@ +load("@rules_java//java:defs.bzl", "java_library") + +java_library( + name = "wpiunits", + srcs = glob(["**/*.java"]), + visibility = ["//visibility:public"], + deps = [], +) From 3799ff2e177faff87df9008b2355870a4f152bf8 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Fri, 23 Aug 2024 01:55:53 -0400 Subject: [PATCH 07/38] Opencv --- WORKSPACE | 20 +++++++++++++++++++ .../dev/java/edu/wpi/first/cscore/BUILD.bazel | 10 ++++++++++ .../java/edu/wpi/first/cscore/BUILD.bazel | 11 ++++++++++ 3 files changed, 41 insertions(+) create mode 100644 cscore/src/dev/java/edu/wpi/first/cscore/BUILD.bazel create mode 100644 cscore/src/main/java/edu/wpi/first/cscore/BUILD.bazel diff --git a/WORKSPACE b/WORKSPACE index bb6decc1b81..da155562167 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -75,6 +75,12 @@ register_toolchains( setup_legacy_setup_jdk_dependencies() # Download other dependencies +http_archive( + name = "rules_bazelrio", + sha256 = "0c5a98476ac5b606689863b7b9ef3f7d685c47ce2681e448ca977e8e95de31c1", + url = "https://github.com/bzlmodRio/rules_bazelrio/releases/download/0.0.14/rules_bazelrio-0.0.14.tar.gz", +) + http_archive( name = "bzlmodrio-ni", sha256 = "02a9b1d9722ad3cc7d55ee31a709938884d981f69634dfe93f92e3986bb7a43f", @@ -84,3 +90,17 @@ http_archive( load("@bzlmodrio-ni//:maven_cpp_deps.bzl", "setup_legacy_bzlmodrio_ni_cpp_dependencies") setup_legacy_bzlmodrio_ni_cpp_dependencies() + +http_archive( + name = "bzlmodrio-opencv", + sha256 = "f61f21220bf3d01d9585af30d23714b774235fe0f5334446745f6eee682a9b14", + url = "https://github.com/bzlmodRio/bzlmodRio-opencv/releases/download/2024.4.8.0-4/bzlmodRio-opencv-2024.4.8.0-4.tar.gz", +) + +load("@bzlmodrio-opencv//:maven_cpp_deps.bzl", "setup_legacy_bzlmodrio_opencv_cpp_dependencies") + +setup_legacy_bzlmodrio_opencv_cpp_dependencies() + +load("@bzlmodrio-opencv//:maven_java_deps.bzl", "setup_legacy_bzlmodrio_opencv_java_dependencies") + +setup_legacy_bzlmodrio_opencv_java_dependencies() diff --git a/cscore/src/dev/java/edu/wpi/first/cscore/BUILD.bazel b/cscore/src/dev/java/edu/wpi/first/cscore/BUILD.bazel new file mode 100644 index 00000000000..8cb7263b2f7 --- /dev/null +++ b/cscore/src/dev/java/edu/wpi/first/cscore/BUILD.bazel @@ -0,0 +1,10 @@ +load("@rules_java//java:defs.bzl", "java_binary") + +java_binary( + name = "DevMain", + srcs = ["DevMain.java"], + deps = [ + "//cscore/src/main/java/edu/wpi/first/cscore", + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + ], +) diff --git a/cscore/src/main/java/edu/wpi/first/cscore/BUILD.bazel b/cscore/src/main/java/edu/wpi/first/cscore/BUILD.bazel new file mode 100644 index 00000000000..d4edc2bf21b --- /dev/null +++ b/cscore/src/main/java/edu/wpi/first/cscore/BUILD.bazel @@ -0,0 +1,11 @@ +load("@rules_java//java:defs.bzl", "java_library") + +java_library( + name = "cscore", + srcs = glob(["**/*.java"]), + visibility = ["//visibility:public"], + deps = [ + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + "@bzlmodrio-opencv//libraries/java/opencv", + ], +) From 99c7b85c1f3634519eb50487cb33bd1c04f67f27 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Fri, 23 Aug 2024 01:58:07 -0400 Subject: [PATCH 08/38] wpimath --- wpimath/BUILD.bazel | 5 +++++ wpimath/algorithms/BUILD.bazel | 7 +++++++ .../dev/java/edu/wpi/first/math/BUILD.bazel | 9 +++++++++ .../main/java/edu/wpi/first/math/BUILD.bazel | 18 ++++++++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 wpimath/BUILD.bazel create mode 100644 wpimath/algorithms/BUILD.bazel create mode 100644 wpimath/src/dev/java/edu/wpi/first/math/BUILD.bazel create mode 100644 wpimath/src/main/java/edu/wpi/first/math/BUILD.bazel diff --git a/wpimath/BUILD.bazel b/wpimath/BUILD.bazel new file mode 100644 index 00000000000..0abedace51f --- /dev/null +++ b/wpimath/BUILD.bazel @@ -0,0 +1,5 @@ +filegroup( + name = "generated_java", + srcs = glob(["src/generated/main/java/**/*.java"]), + visibility = ["//wpimath:__subpackages__"], +) diff --git a/wpimath/algorithms/BUILD.bazel b/wpimath/algorithms/BUILD.bazel new file mode 100644 index 00000000000..7b3c016738a --- /dev/null +++ b/wpimath/algorithms/BUILD.bazel @@ -0,0 +1,7 @@ +load("@rules_python//python:defs.bzl", "py_binary") + +py_binary( + name = "ExponentialProfileModel", + srcs = ["ExponentialProfileModel.py"], + tags = ["manual"], +) diff --git a/wpimath/src/dev/java/edu/wpi/first/math/BUILD.bazel b/wpimath/src/dev/java/edu/wpi/first/math/BUILD.bazel new file mode 100644 index 00000000000..4382b70a0db --- /dev/null +++ b/wpimath/src/dev/java/edu/wpi/first/math/BUILD.bazel @@ -0,0 +1,9 @@ +load("@rules_java//java:defs.bzl", "java_binary") + +java_binary( + name = "DevMain", + srcs = ["DevMain.java"], + deps = [ + "//wpimath/src/main/java/edu/wpi/first/math:wpimath", + ], +) diff --git a/wpimath/src/main/java/edu/wpi/first/math/BUILD.bazel b/wpimath/src/main/java/edu/wpi/first/math/BUILD.bazel new file mode 100644 index 00000000000..c4696241879 --- /dev/null +++ b/wpimath/src/main/java/edu/wpi/first/math/BUILD.bazel @@ -0,0 +1,18 @@ +load("@rules_java//java:defs.bzl", "java_library") + +java_library( + name = "wpimath", + srcs = ["//wpimath:generated_java"] + glob(["**/*.java"]), + visibility = ["//visibility:public"], + deps = [ + "//wpiunits/src/main/java/edu/wpi/first/units:wpiunits", + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + "@maven//:com_fasterxml_jackson_core_jackson_annotations", + "@maven//:com_fasterxml_jackson_core_jackson_core", + "@maven//:com_fasterxml_jackson_core_jackson_databind", + "@maven//:org_ejml_ejml_core", + "@maven//:org_ejml_ejml_ddense", + "@maven//:org_ejml_ejml_simple", + "@maven//:us_hebi_quickbuf_quickbuf_runtime", + ], +) From d155569a9d66c65de683bd8c54dfd421bf61f727 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Fri, 23 Aug 2024 01:58:33 -0400 Subject: [PATCH 09/38] cameraserver --- WORKSPACE | 1 + .../src/main/java/edu/wpi/BUILD.bazel | 15 +++++++++++++++ .../java/edu/wpi/first/cameraserver/BUILD.bazel | 8 ++++++++ cameraserver/src/dev/native/cpp/BUILD.bazel | 8 ++++++++ .../src/main/java/edu/wpi/first/BUILD.bazel | 16 ++++++++++++++++ 5 files changed, 48 insertions(+) create mode 100644 cameraserver/multiCameraServer/src/main/java/edu/wpi/BUILD.bazel create mode 100644 cameraserver/src/dev/java/edu/wpi/first/cameraserver/BUILD.bazel create mode 100644 cameraserver/src/dev/native/cpp/BUILD.bazel create mode 100644 cameraserver/src/main/java/edu/wpi/first/BUILD.bazel diff --git a/WORKSPACE b/WORKSPACE index da155562167..baa9b32c584 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -20,6 +20,7 @@ maven_artifacts = [ "com.fasterxml.jackson.core:jackson-core:2.15.2", "com.fasterxml.jackson.core:jackson-databind:2.15.2", "us.hebi.quickbuf:quickbuf-runtime:1.3.3", + "com.google.code.gson:gson:2.10.1", ] maven_install( diff --git a/cameraserver/multiCameraServer/src/main/java/edu/wpi/BUILD.bazel b/cameraserver/multiCameraServer/src/main/java/edu/wpi/BUILD.bazel new file mode 100644 index 00000000000..8751eb7e929 --- /dev/null +++ b/cameraserver/multiCameraServer/src/main/java/edu/wpi/BUILD.bazel @@ -0,0 +1,15 @@ +load("@rules_java//java:defs.bzl", "java_binary") + +java_binary( + name = "multiCameraServer", + srcs = ["Main.java"], + deps = [ + "//cameraserver/src/main/java/edu/wpi/first:cameraserver", + "//cscore/src/main/java/edu/wpi/first/cscore", + "//hal/src/main/java/edu/wpi/first/hal", + "//ntcore/src/main/java/edu/wpi/first/networktables", + "//wpimath/src/main/java/edu/wpi/first/math:wpimath", + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + "@maven//:com_google_code_gson_gson", + ], +) diff --git a/cameraserver/src/dev/java/edu/wpi/first/cameraserver/BUILD.bazel b/cameraserver/src/dev/java/edu/wpi/first/cameraserver/BUILD.bazel new file mode 100644 index 00000000000..214327c3f85 --- /dev/null +++ b/cameraserver/src/dev/java/edu/wpi/first/cameraserver/BUILD.bazel @@ -0,0 +1,8 @@ +load("@rules_java//java:defs.bzl", "java_binary") + +java_binary( + name = "DevMain", + srcs = ["DevMain.java"], + deps = [ + ], +) diff --git a/cameraserver/src/dev/native/cpp/BUILD.bazel b/cameraserver/src/dev/native/cpp/BUILD.bazel new file mode 100644 index 00000000000..e7bef5da6f7 --- /dev/null +++ b/cameraserver/src/dev/native/cpp/BUILD.bazel @@ -0,0 +1,8 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary") + +cc_binary( + name = "DevMain", + srcs = ["main.cpp"], + deps = [ + ], +) diff --git a/cameraserver/src/main/java/edu/wpi/first/BUILD.bazel b/cameraserver/src/main/java/edu/wpi/first/BUILD.bazel new file mode 100644 index 00000000000..9a8b2c3de94 --- /dev/null +++ b/cameraserver/src/main/java/edu/wpi/first/BUILD.bazel @@ -0,0 +1,16 @@ +load("@rules_java//java:defs.bzl", "java_library") + +java_library( + name = "cameraserver", + srcs = glob(["**/*.java"]), + visibility = ["//visibility:public"], + deps = [ + "//cscore/src/main/java/edu/wpi/first/cscore", + "//hal/src/main/java/edu/wpi/first/hal", + "//ntcore/src/main/java/edu/wpi/first/networktables", + "//wpimath/src/main/java/edu/wpi/first/math:wpimath", + "//wpinet/src/main/java/edu/wpi/first/net:wpinet", + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + "@bzlmodrio-opencv//libraries/java/opencv", + ], +) From ea8c00991a6a1a638a8394d7b586951374785437 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Fri, 23 Aug 2024 02:00:30 -0400 Subject: [PATCH 10/38] wpilibj --- shared/bazel/rules/gen/gen-version-file.bzl | 19 +++++++++++ wpilibj/BUILD.bazel | 5 +++ .../java/edu/wpi/first/wpilibj/BUILD.bazel | 12 +++++++ wpilibj/src/dev/native/cpp/BUILD.bazel | 8 +++++ wpilibj/src/generate/BUILD.bazel | 34 +++++++++++++++++++ .../java/edu/wpi/first/wpilibj/BUILD.bazel | 19 +++++++++++ wpilibj/src/test/resources/BUILD.bazel | 8 +++++ 7 files changed, 105 insertions(+) create mode 100644 shared/bazel/rules/gen/gen-version-file.bzl create mode 100644 wpilibj/BUILD.bazel create mode 100644 wpilibj/src/dev/java/edu/wpi/first/wpilibj/BUILD.bazel create mode 100644 wpilibj/src/dev/native/cpp/BUILD.bazel create mode 100644 wpilibj/src/generate/BUILD.bazel create mode 100644 wpilibj/src/main/java/edu/wpi/first/wpilibj/BUILD.bazel create mode 100644 wpilibj/src/test/resources/BUILD.bazel diff --git a/shared/bazel/rules/gen/gen-version-file.bzl b/shared/bazel/rules/gen/gen-version-file.bzl new file mode 100644 index 00000000000..7ec27f3c4cf --- /dev/null +++ b/shared/bazel/rules/gen/gen-version-file.bzl @@ -0,0 +1,19 @@ +def _generate_version_file_impl(ctx): + out = ctx.actions.declare_file(ctx.attr.output_file) + ctx.actions.expand_template( + output = out, + template = ctx.file.template, + substitutions = {"${wpilib_version}": "TODO - Built with bazel"}, + ) + return [DefaultInfo(files = depset([out]))] + +generate_version_file = rule( + implementation = _generate_version_file_impl, + attrs = { + "output_file": attr.string(mandatory = True), + "template": attr.label( + allow_single_file = True, + mandatory = True, + ), + }, +) diff --git a/wpilibj/BUILD.bazel b/wpilibj/BUILD.bazel new file mode 100644 index 00000000000..73130905951 --- /dev/null +++ b/wpilibj/BUILD.bazel @@ -0,0 +1,5 @@ +filegroup( + name = "generated_java", + srcs = glob(["src/generated/main/java/**/*.java"]), + visibility = ["//wpilibj:__subpackages__"], +) diff --git a/wpilibj/src/dev/java/edu/wpi/first/wpilibj/BUILD.bazel b/wpilibj/src/dev/java/edu/wpi/first/wpilibj/BUILD.bazel new file mode 100644 index 00000000000..6f52a070ef6 --- /dev/null +++ b/wpilibj/src/dev/java/edu/wpi/first/wpilibj/BUILD.bazel @@ -0,0 +1,12 @@ +load("@rules_java//java:defs.bzl", "java_binary") + +java_binary( + name = "DevMain", + srcs = ["DevMain.java"], + deps = [ + "//hal/src/main/java/edu/wpi/first/hal", + "//ntcore/src/main/java/edu/wpi/first/networktables", + "//wpimath/src/main/java/edu/wpi/first/math:wpimath", + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + ], +) diff --git a/wpilibj/src/dev/native/cpp/BUILD.bazel b/wpilibj/src/dev/native/cpp/BUILD.bazel new file mode 100644 index 00000000000..e7bef5da6f7 --- /dev/null +++ b/wpilibj/src/dev/native/cpp/BUILD.bazel @@ -0,0 +1,8 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary") + +cc_binary( + name = "DevMain", + srcs = ["main.cpp"], + deps = [ + ], +) diff --git a/wpilibj/src/generate/BUILD.bazel b/wpilibj/src/generate/BUILD.bazel new file mode 100644 index 00000000000..a963496af7d --- /dev/null +++ b/wpilibj/src/generate/BUILD.bazel @@ -0,0 +1,34 @@ +load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file") + +generate_version_file( + name = "generate-version", + output_file = "WPILibVersion.java", + template = "WPILibVersion.java.in", + visibility = ["//visibility:public"], +) + +filegroup( + name = "hid_schema", + srcs = [ + "hids.json", + "hids.schema.json", + ], + visibility = ["//visibility:public"], +) + +filegroup( + name = "pwm_schema", + srcs = [ + "pwm_motor_controllers.json", + ], + visibility = ["//visibility:public"], +) + +filegroup( + name = "templates", + srcs = glob(["*.jinja"]) + [ + ":hid_schema", + ":pwm_schema", + ], + visibility = ["//visibility:public"], +) diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/BUILD.bazel b/wpilibj/src/main/java/edu/wpi/first/wpilibj/BUILD.bazel new file mode 100644 index 00000000000..f794ee61e09 --- /dev/null +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/BUILD.bazel @@ -0,0 +1,19 @@ +load("@rules_java//java:defs.bzl", "java_library") + +java_library( + name = "wpilibj", + srcs = ["//wpilibj/src/generate:generate-version"] + glob(["**/*.java"]) + ["//wpilibj:generated_java"], + visibility = ["//visibility:public"], + deps = [ + "//cameraserver/src/main/java/edu/wpi/first:cameraserver", + "//cscore/src/main/java/edu/wpi/first/cscore", + "//hal/src/main/java/edu/wpi/first/hal", + "//ntcore/src/main/java/edu/wpi/first/networktables", + "//wpimath/src/main/java/edu/wpi/first/math:wpimath", + "//wpinet/src/main/java/edu/wpi/first/net:wpinet", + "//wpiunits/src/main/java/edu/wpi/first/units:wpiunits", + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + "@maven//:org_ejml_ejml_core", + "@maven//:org_ejml_ejml_simple", + ], +) diff --git a/wpilibj/src/test/resources/BUILD.bazel b/wpilibj/src/test/resources/BUILD.bazel new file mode 100644 index 00000000000..1765de1f631 --- /dev/null +++ b/wpilibj/src/test/resources/BUILD.bazel @@ -0,0 +1,8 @@ +load("@rules_java//java:defs.bzl", "java_library") + +java_library( + name = "resources", + testonly = True, + resources = glob(["**"]), + visibility = ["//wpilibj/src/test:__subpackages__"], +) From da393c1149e556fd2456f581f3b875f161ec60ee Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Fri, 23 Aug 2024 02:03:04 -0400 Subject: [PATCH 11/38] lint --- shared/bazel/compiler_flags/windows_arm_flags.rc | 2 +- shared/bazel/compiler_flags/windows_flags.rc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shared/bazel/compiler_flags/windows_arm_flags.rc b/shared/bazel/compiler_flags/windows_arm_flags.rc index 5fea7f246e8..4a35fe7e94d 100644 --- a/shared/bazel/compiler_flags/windows_arm_flags.rc +++ b/shared/bazel/compiler_flags/windows_arm_flags.rc @@ -31,4 +31,4 @@ build:windows_arm --conlyopt=/D_CRT_SECURE_NO_WARNINGS build:windows_arm --linkopt=/IGNORE:4099 # TODO there is a "bug" in bazel that forces "/D_WIN32_WINNT=0x0601". Remove it from the files that break because of this. -build:windows_arm --per_file_copt=wpiutil/src/main/native/cpp/timestamp.cpp,wpinet/src/main/native/thirdparty/libuv/src/win/util.cpp,hal/src/main/native/sim/HAL.cpp@/U_WIN32_WINNT \ No newline at end of file +build:windows_arm --per_file_copt=wpiutil/src/main/native/cpp/timestamp.cpp,wpinet/src/main/native/thirdparty/libuv/src/win/util.cpp,hal/src/main/native/sim/HAL.cpp@/U_WIN32_WINNT diff --git a/shared/bazel/compiler_flags/windows_flags.rc b/shared/bazel/compiler_flags/windows_flags.rc index 9a2a4ee6c45..c3fb238d7be 100644 --- a/shared/bazel/compiler_flags/windows_flags.rc +++ b/shared/bazel/compiler_flags/windows_flags.rc @@ -33,4 +33,4 @@ build:windows --linkopt=/DEPENDENTLOADFLAG:0x1100 build:windows --copt=/D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR # TODO there is a "bug" in bazel that forces "/D_WIN32_WINNT=0x0601". Remove it from the files that break because of this. -build:windows --per_file_copt=wpiutil/src/main/native/cpp/timestamp.cpp,wpinet/src/main/native/thirdparty/libuv/src/win/util.cpp,hal/src/main/native/sim/HAL.cpp@/U_WIN32_WINNT \ No newline at end of file +build:windows --per_file_copt=wpiutil/src/main/native/cpp/timestamp.cpp,wpinet/src/main/native/thirdparty/libuv/src/win/util.cpp,hal/src/main/native/sim/HAL.cpp@/U_WIN32_WINNT From 64e180b464689a4a5e04e4b51710563b652de69e Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Fri, 23 Aug 2024 02:10:21 -0400 Subject: [PATCH 12/38] Suppress bazel changes in upstream utils --- .github/workflows/upstream-utils.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upstream-utils.yml b/.github/workflows/upstream-utils.yml index bd8ebb75a06..c9cd4d681c1 100644 --- a/.github/workflows/upstream-utils.yml +++ b/.github/workflows/upstream-utils.yml @@ -133,4 +133,4 @@ jobs: - name: Add untracked files to index so they count as changes run: git add -A - name: Check output - run: git --no-pager diff --exit-code HEAD + run: git --no-pager diff --exit-code HEAD ':!*.bazel' From e167510750c02575404132a8f61ac06f2b650f56 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 24 Aug 2024 11:47:26 -0400 Subject: [PATCH 13/38] Fixup flags --- .bazelrc | 2 + .github/workflows/bazel.yml | 16 +++--- shared/bazel/compiler_flags/osx_flags.rc | 66 ++++++++++++------------ 3 files changed, 43 insertions(+), 41 deletions(-) diff --git a/.bazelrc b/.bazelrc index ebbec68242c..2b05f7b6fc5 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,5 +1,7 @@ try-import %workspace%/user.bazelrc +common --noenable_bzlmod + build --java_language_version=17 build --java_runtime_version=roboriojdk_17 build --tool_java_language_version=17 diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index e32e1649802..62234c0e068 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -12,9 +12,9 @@ jobs: fail-fast: false matrix: include: - - { name: "Windows (native)", os: windows-2022, action: "test", config: "--noenable_bzlmod --config=windows", } - - { name: "Windows (arm)", os: windows-2022, action: "build", config: "--noenable_bzlmod --config=windows_arm", } - - { name: "Windows (roborio)", os: windows-2022, action: "build", config: "--noenable_bzlmod --config=roborio", } + - { name: "Windows (native)", os: windows-2022, action: "test", config: "--config=windows", } + - { name: "Windows (arm)", os: windows-2022, action: "build", config: "--config=windows_arm", } + - { name: "Windows (roborio)", os: windows-2022, action: "build", config: "--config=roborio", } name: "Build ${{ matrix.name }}" runs-on: ${{ matrix.os }} @@ -36,8 +36,8 @@ jobs: fail-fast: false matrix: include: - - { name: "Mac (native)", os: macos-14, action: "test", config: "--noenable_bzlmod --config=osx -c opt", } - - { name: "Mac (roborio)", os: macos-14, action: "build", config: "--noenable_bzlmod --config=roborio -c opt", } + - { name: "Mac (native)", os: macos-14, action: "test", config: "--config=macos -c opt", } + - { name: "Mac (roborio)", os: macos-14, action: "build", config: "--config=roborio -c opt", } name: "${{ matrix.name }}" runs-on: ${{ matrix.os }} @@ -54,8 +54,8 @@ jobs: fail-fast: false matrix: include: - - { name: "Linux (native)", os: ubuntu-22.04, action: "test", config: "--noenable_bzlmod --config=linux -c opt", } - - { name: "Linux (roborio)", os: ubuntu-22.04, action: "build", config: "--noenable_bzlmod --config=roborio -c opt", } + - { name: "Linux (native)", os: ubuntu-22.04, action: "test", config: "--config=linux -c opt", } + - { name: "Linux (roborio)", os: ubuntu-22.04, action: "build", config: "--config=roborio -c opt", } name: "${{ matrix.name }}" runs-on: ${{ matrix.os }} steps: @@ -81,7 +81,7 @@ jobs: with: { fetch-depth: 0 } - uses: bazelbuild/setup-bazelisk@v3 - name: Build and Test - run: bazel test -k --config=ci --noenable_bzlmod --config=linux --config=${{ matrix.config }} //... + run: bazel test -k --config=ci --config=linux --config=${{ matrix.config }} //... buildifier: name: "buildifier" diff --git a/shared/bazel/compiler_flags/osx_flags.rc b/shared/bazel/compiler_flags/osx_flags.rc index f3aa347571b..da12307993e 100644 --- a/shared/bazel/compiler_flags/osx_flags.rc +++ b/shared/bazel/compiler_flags/osx_flags.rc @@ -1,44 +1,44 @@ # Warning level -build:osx --copt=-Wall -build:osx --copt=-Wextra -build:osx --copt=-Werror +build:macos --copt=-Wall +build:macos --copt=-Wextra +build:macos --copt=-Werror # C++ only -build:osx --cxxopt=-std=c++20 -build:osx --cxxopt=-pedantic -build:osx --cxxopt=-fPIC -build:osx --cxxopt=-Wno-unused-parameter -build:osx --cxxopt=-Wno-error=deprecated-enum-enum-conversion -build:osx --cxxopt=-Wno-missing-field-initializers -build:osx --cxxopt=-Wno-unused-private-field -build:osx --cxxopt=-Wno-unused-const-variable -build:osx --cxxopt=-Wno-error=c11-extensions -build:osx --cxxopt=-pthread -build:osx --cxxopt=-Wno-deprecated-anon-enum-enum-conversion +build:macos --cxxopt=-std=c++20 +build:macos --cxxopt=-pedantic +build:macos --cxxopt=-fPIC +build:macos --cxxopt=-Wno-unused-parameter +build:macos --cxxopt=-Wno-error=deprecated-enum-enum-conversion +build:macos --cxxopt=-Wno-missing-field-initializers +build:macos --cxxopt=-Wno-unused-private-field +build:macos --cxxopt=-Wno-unused-const-variable +build:macos --cxxopt=-Wno-error=c11-extensions +build:macos --cxxopt=-pthread +build:macos --cxxopt=-Wno-deprecated-anon-enum-enum-conversion # C only -build:osx --conlyopt=-pedantic -build:osx --conlyopt=-fPIC -build:osx --conlyopt=-Wno-unused-parameter -build:osx --conlyopt=-Wno-missing-field-initializers -build:osx --conlyopt=-Wno-unused-private-field -build:osx --conlyopt=-Wno-fixed-enum-extension" +build:macos --conlyopt=-pedantic +build:macos --conlyopt=-fPIC +build:macos --conlyopt=-Wno-unused-parameter +build:macos --conlyopt=-Wno-missing-field-initializers +build:macos --conlyopt=-Wno-unused-private-field +build:macos --conlyopt=-Wno-fixed-enum-extension" -build:osx --linkopt=-framework -build:osx --linkopt=CoreFoundation -build:osx --linkopt=-framework -build:osx --linkopt=AVFoundation -build:osx --linkopt=-framework -build:osx --linkopt=Foundation -build:osx --linkopt=-framework -build:osx --linkopt=CoreMedia -build:osx --linkopt=-framework -build:osx --linkopt=CoreVideo -build:osx --linkopt=-headerpad_max_install_names -build:osx --linkopt=-Wl,-rpath,'@loader_path'" +build:macos --linkopt=-framework +build:macos --linkopt=CoreFoundation +build:macos --linkopt=-framework +build:macos --linkopt=AVFoundation +build:macos --linkopt=-framework +build:macos --linkopt=Foundation +build:macos --linkopt=-framework +build:macos --linkopt=CoreMedia +build:macos --linkopt=-framework +build:macos --linkopt=CoreVideo +build:macos --linkopt=-headerpad_max_install_names +build:macos --linkopt=-Wl,-rpath,'@loader_path'" # Things not in nativetools -build:osx --copt=-Wno-shorten-64-to-32 +build:macos --copt=-Wno-shorten-64-to-32 From 856eb2988b8b33ce3260a4d95280c16d07551ffc Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 24 Aug 2024 12:06:23 -0400 Subject: [PATCH 14/38] Share compiler flags across similar arch --- .bazelrc | 2 +- .../bazel/compiler_flags/base_linux_flags.rc | 28 ++++++++ shared/bazel/compiler_flags/linux_flags.rc | 33 +++------ shared/bazel/compiler_flags/roborio_flags.rc | 29 ++------ .../bazel/compiler_flags/windows_arm_flags.rc | 34 ---------- shared/bazel/compiler_flags/windows_flags.rc | 67 ++++++++++++------- 6 files changed, 84 insertions(+), 109 deletions(-) create mode 100644 shared/bazel/compiler_flags/base_linux_flags.rc delete mode 100644 shared/bazel/compiler_flags/windows_arm_flags.rc diff --git a/.bazelrc b/.bazelrc index 2b05f7b6fc5..74d3a783b8d 100644 --- a/.bazelrc +++ b/.bazelrc @@ -11,11 +11,11 @@ test --test_output=errors test --test_verbose_timeout_warnings import shared/bazel/compiler_flags/sanitizers.rc +import shared/bazel/compiler_flags/base_linux_flags.rc import shared/bazel/compiler_flags/linux_flags.rc import shared/bazel/compiler_flags/osx_flags.rc import shared/bazel/compiler_flags/roborio_flags.rc import shared/bazel/compiler_flags/windows_flags.rc -import shared/bazel/compiler_flags/windows_arm_flags.rc import shared/bazel/compiler_flags/coverage_flags.rc build:build_java --test_tag_filters=allwpilib-build-java --build_tag_filters=allwpilib-build-java diff --git a/shared/bazel/compiler_flags/base_linux_flags.rc b/shared/bazel/compiler_flags/base_linux_flags.rc new file mode 100644 index 00000000000..a49b0f14587 --- /dev/null +++ b/shared/bazel/compiler_flags/base_linux_flags.rc @@ -0,0 +1,28 @@ + +############################### +# Linux Common +############################### + +# C++ only +build:base_linux --cxxopt=-std=c++20 +build:base_linux --cxxopt=-Wformat=2 +build:base_linux --cxxopt=-pedantic +build:base_linux --cxxopt=-Wno-psabi +build:base_linux --cxxopt=-Wno-unused-parameter +build:base_linux --cxxopt=-fPIC +build:base_linux --cxxopt=-pthread + +# C Only +build:base_linux --conlyopt=-Wformat=2 +build:base_linux --conlyopt=-pedantic +build:base_linux --conlyopt=-Wno-psabi +build:base_linux --conlyopt=-Wno-unused-parameter +build:base_linux --conlyopt=-fPIC +build:base_linux --conlyopt=-pthread + +# Linker +build:base_linux --linkopt=-rdynamic +build:base_linux --linkopt=-pthread +build:base_linux --linkopt=-ldl +build:base_linux --linkopt=-latomic +build:base_linux --linkopt=-Wl,-rpath,'$ORIGIN' diff --git a/shared/bazel/compiler_flags/linux_flags.rc b/shared/bazel/compiler_flags/linux_flags.rc index e09bcebbb46..c32d516691f 100644 --- a/shared/bazel/compiler_flags/linux_flags.rc +++ b/shared/bazel/compiler_flags/linux_flags.rc @@ -1,31 +1,14 @@ + +############################### +# Linux +############################### +build:linux --config=base_linux + # Warning level build:linux --copt=-Wall build:linux --copt=-Wextra build:linux --copt=-Werror -# C++ args -build:linux --cxxopt=-std=c++20 -build:linux --cxxopt=-Wformat=2 -build:linux --cxxopt=-pedantic -build:linux --cxxopt=-Wno-psabi -build:linux --cxxopt=-Wno-unused-parameter -# build:linux --cxxopt=-Wno-error=deprecated-declarations -build:linux --cxxopt=-Wno-error=deprecated-enum-enum-conversion -build:linux --cxxopt=-fPIC -build:linux --cxxopt=-pthread - -# C only -build:linux --conlyopt=-Wformat=2 -build:linux --conlyopt=-pedantic -build:linux --conlyopt=-Wno-psabi -build:linux --conlyopt=-Wno-unused-parameter -build:linux --conlyopt=-fPIC -build:linux --conlyopt=-pthread - -# Linker -build:linux --linkopt=-rdynamic -build:linux --linkopt=-pthread -build:linux --linkopt=-ldl -build:linux --linkopt=-latomic -build:linux --linkopt=-Wl,-rpath,'$ORIGIN' +# Not in nativetools +build:linux --copt=-Wno-deprecated-enum-enum-conversion diff --git a/shared/bazel/compiler_flags/roborio_flags.rc b/shared/bazel/compiler_flags/roborio_flags.rc index 86a61e625cd..691da8d5e6e 100644 --- a/shared/bazel/compiler_flags/roborio_flags.rc +++ b/shared/bazel/compiler_flags/roborio_flags.rc @@ -1,35 +1,16 @@ +############################### +# Roborio +############################### +build:roborio --config=base_linux + build:roborio --platforms=@rules_bzlmodrio_toolchains//platforms/roborio build:roborio --build_tag_filters=-no-roborio build:roborio --features=compiler_param_file build:roborio --platform_suffix=roborio build:roborio --incompatible_enable_cc_toolchain_resolution -# C++ only -build:roborio --cxxopt=-std=c++20 -build:roborio --cxxopt=-Wformat=2 -build:roborio --cxxopt=-pedantic -build:roborio --cxxopt=-Wno-psabi -build:roborio --cxxopt=-Wno-unused-parameter -build:roborio --cxxopt=-fPIC -build:roborio --cxxopt=-pthread - build:roborio --cxxopt=-Wno-error=deprecated-declarations # Extra 11 build:roborio --cxxopt=-Wno-error=deprecated-enum-enum-conversion - -# C Only -build:roborio --conlyopt=-Wformat=2 -build:roborio --conlyopt=-pedantic -build:roborio --conlyopt=-Wno-psabi -build:roborio --conlyopt=-Wno-unused-parameter -build:roborio --conlyopt=-fPIC -build:roborio --conlyopt=-pthread - -# Linker -build:roborio --linkopt=-rdynamic -build:roborio --linkopt=-pthread -build:roborio --linkopt=-ldl -build:roborio --linkopt=-latomic -build:roborio --linkopt=-Wl,-rpath,'$ORIGIN' diff --git a/shared/bazel/compiler_flags/windows_arm_flags.rc b/shared/bazel/compiler_flags/windows_arm_flags.rc deleted file mode 100644 index 4a35fe7e94d..00000000000 --- a/shared/bazel/compiler_flags/windows_arm_flags.rc +++ /dev/null @@ -1,34 +0,0 @@ - -build:windows_arm --cpu=arm64_windows - -# Warning level -build:windows_arm --copt=/W3 -build:windows_arm --copt=/WX - -# C++ options -build:windows_arm --cxxopt=/utf-8 -build:windows_arm --cxxopt=/EHsc -build:windows_arm --cxxopt=/FS -build:windows_arm --cxxopt=/Zc:inline -build:windows_arm --cxxopt=/wd4244 -build:windows_arm --cxxopt=/wd4267 -build:windows_arm --cxxopt=/wd4146 -build:windows_arm --cxxopt=/wd4996 -build:windows_arm --cxxopt=/Zc:throwingNew -build:windows_arm --cxxopt=/D_CRT_SECURE_NO_WARNINGS -build:windows_arm --cxxopt=/std:c++20 -build:windows_arm --cxxopt=/permissive- -build:windows_arm --cxxopt=/bigobj -build:windows_arm --cxxopt=/Zc:__cplusplus -build:windows_arm --cxxopt=/Zc:preprocessor -build:windows_arm --cxxopt=/wd5105 - -# C Only -build:windows_arm --conlyopt=/FS -build:windows_arm --conlyopt=/Zc:inline -build:windows_arm --conlyopt=/D_CRT_SECURE_NO_WARNINGS - -build:windows_arm --linkopt=/IGNORE:4099 - -# TODO there is a "bug" in bazel that forces "/D_WIN32_WINNT=0x0601". Remove it from the files that break because of this. -build:windows_arm --per_file_copt=wpiutil/src/main/native/cpp/timestamp.cpp,wpinet/src/main/native/thirdparty/libuv/src/win/util.cpp,hal/src/main/native/sim/HAL.cpp@/U_WIN32_WINNT diff --git a/shared/bazel/compiler_flags/windows_flags.rc b/shared/bazel/compiler_flags/windows_flags.rc index c3fb238d7be..7e604e43c9f 100644 --- a/shared/bazel/compiler_flags/windows_flags.rc +++ b/shared/bazel/compiler_flags/windows_flags.rc @@ -1,36 +1,53 @@ - +################################ +# Common Flags +################################ # Warning level -build:windows --copt=/W3 -build:windows --copt=/WX +build:windows_common --copt=/W3 +build:windows_common --copt=/WX # C++ options -build:windows --cxxopt=/EHsc -build:windows --cxxopt=/FS -build:windows --cxxopt=/Zc:inline -build:windows --cxxopt=/wd4244 -build:windows --cxxopt=/wd4267 -build:windows --cxxopt=/wd4146 -build:windows --cxxopt=/wd4996 -build:windows --cxxopt=/Zc:throwingNew -build:windows --cxxopt=/D_CRT_SECURE_NO_WARNINGS -build:windows --cxxopt=/std:c++20 -build:windows --cxxopt=/permissive- -build:windows --cxxopt=/utf-8 -build:windows --cxxopt=/bigobj -build:windows --cxxopt=/Zc:__cplusplus -build:windows --cxxopt=/Zc:preprocessor -build:windows --cxxopt=/wd5105 +build:windows_common --cxxopt=/EHsc +build:windows_common --cxxopt=/FS +build:windows_common --cxxopt=/Zc:inline +build:windows_common --cxxopt=/wd4244 +build:windows_common --cxxopt=/wd4267 +build:windows_common --cxxopt=/wd4146 +build:windows_common --cxxopt=/wd4996 +build:windows_common --cxxopt=/Zc:throwingNew +build:windows_common --cxxopt=/D_CRT_SECURE_NO_WARNINGS +build:windows_common --cxxopt=/std:c++20 +build:windows_common --cxxopt=/permissive- +build:windows_common --cxxopt=/utf-8 +build:windows_common --cxxopt=/bigobj +build:windows_common --cxxopt=/Zc:__cplusplus +build:windows_common --cxxopt=/Zc:preprocessor +build:windows_common --cxxopt=/wd5105 # C Only -build:windows --conlyopt=/FS -build:windows --conlyopt=/Zc:inline -build:windows --conlyopt=/D_CRT_SECURE_NO_WARNINGS +build:windows_common --conlyopt=/FS +build:windows_common --conlyopt=/Zc:inline +build:windows_common --conlyopt=/D_CRT_SECURE_NO_WARNINGS + +# build:windows_common --linkopt=/IGNORE:4099 + +# TODO there is a "bug" in bazel that forces "/D_WIN32_WINNT=0x0601". Remove it from the files that break because of this. +build:windows_common --per_file_copt=wpiutil/src/main/native/cpp/timestamp.cpp,wpinet/src/main/native/thirdparty/libuv/src/win/util.cpp,hal/src/main/native/sim/HAL.cpp@/U_WIN32_WINNT + +################################ +# Standard Windows Flags +################################ +build:windows --config=windows_common -# build:windows --linkopt=/IGNORE:4099 build:windows --linkopt=/DEPENDENTLOADFLAG:0x1100 # TODO build:windows --copt=/D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR -# TODO there is a "bug" in bazel that forces "/D_WIN32_WINNT=0x0601". Remove it from the files that break because of this. -build:windows --per_file_copt=wpiutil/src/main/native/cpp/timestamp.cpp,wpinet/src/main/native/thirdparty/libuv/src/win/util.cpp,hal/src/main/native/sim/HAL.cpp@/U_WIN32_WINNT +################################ +# ARM Windows Flags +################################ +build:windows_arm --config=windows_common + +build:windows_arm --cpu=arm64_windows + +build:windows_arm --linkopt=/IGNORE:4099 From e488f76e84bba9f171f87bfa48ae114236983098 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 24 Aug 2024 21:50:17 -0400 Subject: [PATCH 15/38] Amalgamate build files --- cameraserver/BUILD.bazel | 45 ++++ .../src/main/java/edu/wpi/BUILD.bazel | 15 -- .../edu/wpi/first/cameraserver/BUILD.bazel | 8 - cameraserver/src/dev/native/cpp/BUILD.bazel | 8 - .../src/main/java/edu/wpi/first/BUILD.bazel | 16 -- cscore/BUILD.bazel | 20 ++ .../dev/java/edu/wpi/first/cscore/BUILD.bazel | 10 - .../java/edu/wpi/first/cscore/BUILD.bazel | 11 - hal/BUILD.bazel | 92 ++++++- .../dev/java/edu/wpi/first/hal/BUILD.bazel | 8 - hal/src/dev/native/cpp/BUILD.bazel | 9 - .../main/java/edu/wpi/first/hal/BUILD.bazel | 10 - hal/src/main/native/BUILD.bazel | 53 ---- hal/src/test/native/cpp/BUILD.bazel | 14 - ntcore/BUILD.bazel | 78 +++++- .../dev/java/edu/wpi/first/ntcore/BUILD.bazel | 10 - ntcore/src/dev/native/cpp/BUILD.bazel | 9 - .../edu/wpi/first/networktables/BUILD.bazel | 11 - ntcore/src/main/native/BUILD.bazel | 30 --- ntcore/src/test/native/cpp/BUILD.bazel | 20 -- wpilibj/BUILD.bazel | 88 +++++++ .../java/edu/wpi/first/wpilibj/BUILD.bazel | 12 - wpilibj/src/dev/native/cpp/BUILD.bazel | 8 - wpilibj/src/generate/BUILD.bazel | 34 --- .../java/edu/wpi/first/wpilibj/BUILD.bazel | 19 -- wpilibj/src/test/resources/BUILD.bazel | 8 - wpimath/BUILD.bazel | 34 +++ wpimath/algorithms/BUILD.bazel | 7 - .../dev/java/edu/wpi/first/math/BUILD.bazel | 9 - .../main/java/edu/wpi/first/math/BUILD.bazel | 18 -- wpinet/BUILD.bazel | 217 ++++++++++++++++ wpinet/examples/dsclient/BUILD.bazel | 9 - wpinet/examples/parallelconnect/BUILD.bazel | 9 - wpinet/examples/webserver/BUILD.bazel | 9 - .../dev/java/edu/wpi/first/net/BUILD.bazel | 10 - wpinet/src/dev/native/cpp/BUILD.bazel | 9 - .../main/java/edu/wpi/first/net/BUILD.bazel | 10 - wpinet/src/main/native/BUILD.bazel | 47 ---- .../main/native/thirdparty/libuv/BUILD.bazel | 69 ----- .../native/thirdparty/tcpsockets/BUILD.bazel | 17 -- .../netconsoleServer/native/cpp/BUILD.bazel | 13 - .../src/netconsoleTee/native/cpp/BUILD.bazel | 9 - wpinet/src/test/native/cpp/BUILD.bazel | 16 -- wpiunits/BUILD.bazel | 16 ++ .../dev/java/edu/wpi/first/units/BUILD.bazel | 9 - .../main/java/edu/wpi/first/units/BUILD.bazel | 8 - wpiutil/BUILD.bazel | 244 ++++++++++++++++++ wpiutil/examples/printlog/BUILD.bazel | 16 -- wpiutil/examples/writelog/BUILD.bazel | 9 - .../dev/java/edu/wpi/first/util/BUILD.bazel | 9 - wpiutil/src/dev/native/cpp/BUILD.bazel | 9 - .../main/java/edu/wpi/first/util/BUILD.bazel | 13 - wpiutil/src/main/native/BUILD.bazel | 53 ---- .../native/thirdparty/expected/BUILD.bazel | 11 - .../main/native/thirdparty/fmtlib/BUILD.bazel | 17 -- .../main/native/thirdparty/json/BUILD.bazel | 11 - .../main/native/thirdparty/llvm/BUILD.bazel | 17 -- .../main/native/thirdparty/memory/BUILD.bazel | 17 -- .../main/native/thirdparty/mpack/BUILD.bazel | 17 -- .../native/thirdparty/protobuf/BUILD.bazel | 18 -- .../native/thirdparty/sigslot/BUILD.bazel | 11 - .../src/printlog/java/printlog/BUILD.bazel | 9 - wpiutil/src/test/native/BUILD.bazel | 21 -- 63 files changed, 832 insertions(+), 861 deletions(-) create mode 100644 cameraserver/BUILD.bazel delete mode 100644 cameraserver/multiCameraServer/src/main/java/edu/wpi/BUILD.bazel delete mode 100644 cameraserver/src/dev/java/edu/wpi/first/cameraserver/BUILD.bazel delete mode 100644 cameraserver/src/dev/native/cpp/BUILD.bazel delete mode 100644 cameraserver/src/main/java/edu/wpi/first/BUILD.bazel create mode 100644 cscore/BUILD.bazel delete mode 100644 cscore/src/dev/java/edu/wpi/first/cscore/BUILD.bazel delete mode 100644 cscore/src/main/java/edu/wpi/first/cscore/BUILD.bazel delete mode 100644 hal/src/dev/java/edu/wpi/first/hal/BUILD.bazel delete mode 100644 hal/src/dev/native/cpp/BUILD.bazel delete mode 100644 hal/src/main/java/edu/wpi/first/hal/BUILD.bazel delete mode 100644 hal/src/main/native/BUILD.bazel delete mode 100644 hal/src/test/native/cpp/BUILD.bazel delete mode 100644 ntcore/src/dev/java/edu/wpi/first/ntcore/BUILD.bazel delete mode 100644 ntcore/src/dev/native/cpp/BUILD.bazel delete mode 100644 ntcore/src/main/java/edu/wpi/first/networktables/BUILD.bazel delete mode 100644 ntcore/src/main/native/BUILD.bazel delete mode 100644 ntcore/src/test/native/cpp/BUILD.bazel delete mode 100644 wpilibj/src/dev/java/edu/wpi/first/wpilibj/BUILD.bazel delete mode 100644 wpilibj/src/dev/native/cpp/BUILD.bazel delete mode 100644 wpilibj/src/generate/BUILD.bazel delete mode 100644 wpilibj/src/main/java/edu/wpi/first/wpilibj/BUILD.bazel delete mode 100644 wpilibj/src/test/resources/BUILD.bazel delete mode 100644 wpimath/algorithms/BUILD.bazel delete mode 100644 wpimath/src/dev/java/edu/wpi/first/math/BUILD.bazel delete mode 100644 wpimath/src/main/java/edu/wpi/first/math/BUILD.bazel create mode 100644 wpinet/BUILD.bazel delete mode 100644 wpinet/examples/dsclient/BUILD.bazel delete mode 100644 wpinet/examples/parallelconnect/BUILD.bazel delete mode 100644 wpinet/examples/webserver/BUILD.bazel delete mode 100644 wpinet/src/dev/java/edu/wpi/first/net/BUILD.bazel delete mode 100644 wpinet/src/dev/native/cpp/BUILD.bazel delete mode 100644 wpinet/src/main/java/edu/wpi/first/net/BUILD.bazel delete mode 100644 wpinet/src/main/native/BUILD.bazel delete mode 100644 wpinet/src/main/native/thirdparty/libuv/BUILD.bazel delete mode 100644 wpinet/src/main/native/thirdparty/tcpsockets/BUILD.bazel delete mode 100644 wpinet/src/netconsoleServer/native/cpp/BUILD.bazel delete mode 100644 wpinet/src/netconsoleTee/native/cpp/BUILD.bazel delete mode 100644 wpinet/src/test/native/cpp/BUILD.bazel create mode 100644 wpiunits/BUILD.bazel delete mode 100644 wpiunits/src/dev/java/edu/wpi/first/units/BUILD.bazel delete mode 100644 wpiunits/src/main/java/edu/wpi/first/units/BUILD.bazel create mode 100644 wpiutil/BUILD.bazel delete mode 100644 wpiutil/examples/printlog/BUILD.bazel delete mode 100644 wpiutil/examples/writelog/BUILD.bazel delete mode 100644 wpiutil/src/dev/java/edu/wpi/first/util/BUILD.bazel delete mode 100644 wpiutil/src/dev/native/cpp/BUILD.bazel delete mode 100644 wpiutil/src/main/java/edu/wpi/first/util/BUILD.bazel delete mode 100644 wpiutil/src/main/native/BUILD.bazel delete mode 100644 wpiutil/src/main/native/thirdparty/expected/BUILD.bazel delete mode 100644 wpiutil/src/main/native/thirdparty/fmtlib/BUILD.bazel delete mode 100644 wpiutil/src/main/native/thirdparty/json/BUILD.bazel delete mode 100644 wpiutil/src/main/native/thirdparty/llvm/BUILD.bazel delete mode 100644 wpiutil/src/main/native/thirdparty/memory/BUILD.bazel delete mode 100644 wpiutil/src/main/native/thirdparty/mpack/BUILD.bazel delete mode 100644 wpiutil/src/main/native/thirdparty/protobuf/BUILD.bazel delete mode 100644 wpiutil/src/main/native/thirdparty/sigslot/BUILD.bazel delete mode 100644 wpiutil/src/printlog/java/printlog/BUILD.bazel delete mode 100644 wpiutil/src/test/native/BUILD.bazel diff --git a/cameraserver/BUILD.bazel b/cameraserver/BUILD.bazel new file mode 100644 index 00000000000..800afe6ee6c --- /dev/null +++ b/cameraserver/BUILD.bazel @@ -0,0 +1,45 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary") +load("@rules_java//java:defs.bzl", "java_binary", "java_library") + +java_library( + name = "cameraserver", + srcs = glob(["src/main/java/**/*.java"]), + visibility = ["//visibility:public"], + deps = [ + "//cscore/src/main/java/edu/wpi/first/cscore", + "//hal/src/main/java/edu/wpi/first/hal", + "//ntcore/src/main/java/edu/wpi/first/networktables", + "//wpimath/src/main/java/edu/wpi/first/math:wpimath", + "//wpinet/src/main/java/edu/wpi/first/net:wpinet", + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + "@bzlmodrio-opencv//libraries/java/opencv", + ], +) + +cc_binary( + name = "DevMain-Cpp", + srcs = ["src/dev/native/cpp/main.cpp"], + deps = [ + ], +) + +java_binary( + name = "DevMain-Java", + srcs = ["src/dev/java/edu/wpi/first/cameraserver/DevMain.java"], + deps = [ + ], +) + +java_binary( + name = "multiCameraServer", + srcs = ["Main.java"], + deps = [ + "//cameraserver/src/main/java/edu/wpi/first:cameraserver", + "//cscore/src/main/java/edu/wpi/first/cscore", + "//hal/src/main/java/edu/wpi/first/hal", + "//ntcore/src/main/java/edu/wpi/first/networktables", + "//wpimath/src/main/java/edu/wpi/first/math:wpimath", + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + "@maven//:com_google_code_gson_gson", + ], +) diff --git a/cameraserver/multiCameraServer/src/main/java/edu/wpi/BUILD.bazel b/cameraserver/multiCameraServer/src/main/java/edu/wpi/BUILD.bazel deleted file mode 100644 index 8751eb7e929..00000000000 --- a/cameraserver/multiCameraServer/src/main/java/edu/wpi/BUILD.bazel +++ /dev/null @@ -1,15 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_binary") - -java_binary( - name = "multiCameraServer", - srcs = ["Main.java"], - deps = [ - "//cameraserver/src/main/java/edu/wpi/first:cameraserver", - "//cscore/src/main/java/edu/wpi/first/cscore", - "//hal/src/main/java/edu/wpi/first/hal", - "//ntcore/src/main/java/edu/wpi/first/networktables", - "//wpimath/src/main/java/edu/wpi/first/math:wpimath", - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", - "@maven//:com_google_code_gson_gson", - ], -) diff --git a/cameraserver/src/dev/java/edu/wpi/first/cameraserver/BUILD.bazel b/cameraserver/src/dev/java/edu/wpi/first/cameraserver/BUILD.bazel deleted file mode 100644 index 214327c3f85..00000000000 --- a/cameraserver/src/dev/java/edu/wpi/first/cameraserver/BUILD.bazel +++ /dev/null @@ -1,8 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_binary") - -java_binary( - name = "DevMain", - srcs = ["DevMain.java"], - deps = [ - ], -) diff --git a/cameraserver/src/dev/native/cpp/BUILD.bazel b/cameraserver/src/dev/native/cpp/BUILD.bazel deleted file mode 100644 index e7bef5da6f7..00000000000 --- a/cameraserver/src/dev/native/cpp/BUILD.bazel +++ /dev/null @@ -1,8 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_binary") - -cc_binary( - name = "DevMain", - srcs = ["main.cpp"], - deps = [ - ], -) diff --git a/cameraserver/src/main/java/edu/wpi/first/BUILD.bazel b/cameraserver/src/main/java/edu/wpi/first/BUILD.bazel deleted file mode 100644 index 9a8b2c3de94..00000000000 --- a/cameraserver/src/main/java/edu/wpi/first/BUILD.bazel +++ /dev/null @@ -1,16 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -java_library( - name = "cameraserver", - srcs = glob(["**/*.java"]), - visibility = ["//visibility:public"], - deps = [ - "//cscore/src/main/java/edu/wpi/first/cscore", - "//hal/src/main/java/edu/wpi/first/hal", - "//ntcore/src/main/java/edu/wpi/first/networktables", - "//wpimath/src/main/java/edu/wpi/first/math:wpimath", - "//wpinet/src/main/java/edu/wpi/first/net:wpinet", - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", - "@bzlmodrio-opencv//libraries/java/opencv", - ], -) diff --git a/cscore/BUILD.bazel b/cscore/BUILD.bazel new file mode 100644 index 00000000000..787b2cd4d02 --- /dev/null +++ b/cscore/BUILD.bazel @@ -0,0 +1,20 @@ +load("@rules_java//java:defs.bzl", "java_binary", "java_library") + +java_library( + name = "cscore", + srcs = glob(["src/main/java/**/*.java"]), + visibility = ["//visibility:public"], + deps = [ + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + "@bzlmodrio-opencv//libraries/java/opencv", + ], +) + +java_binary( + name = "DevMain-Java", + srcs = ["src/dev/java/edu/wpi/first/cscore/DevMain.java"], + deps = [ + "//cscore/src/main/java/edu/wpi/first/cscore", + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + ], +) diff --git a/cscore/src/dev/java/edu/wpi/first/cscore/BUILD.bazel b/cscore/src/dev/java/edu/wpi/first/cscore/BUILD.bazel deleted file mode 100644 index 8cb7263b2f7..00000000000 --- a/cscore/src/dev/java/edu/wpi/first/cscore/BUILD.bazel +++ /dev/null @@ -1,10 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_binary") - -java_binary( - name = "DevMain", - srcs = ["DevMain.java"], - deps = [ - "//cscore/src/main/java/edu/wpi/first/cscore", - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", - ], -) diff --git a/cscore/src/main/java/edu/wpi/first/cscore/BUILD.bazel b/cscore/src/main/java/edu/wpi/first/cscore/BUILD.bazel deleted file mode 100644 index d4edc2bf21b..00000000000 --- a/cscore/src/main/java/edu/wpi/first/cscore/BUILD.bazel +++ /dev/null @@ -1,11 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -java_library( - name = "cscore", - srcs = glob(["**/*.java"]), - visibility = ["//visibility:public"], - deps = [ - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", - "@bzlmodrio-opencv//libraries/java/opencv", - ], -) diff --git a/hal/BUILD.bazel b/hal/BUILD.bazel index 9ba51885a66..695c63a0e57 100644 --- a/hal/BUILD.bazel +++ b/hal/BUILD.bazel @@ -1,4 +1,5 @@ -load("@rules_cc//cc:defs.bzl", "cc_library") +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") +load("@rules_java//java:defs.bzl", "java_binary", "java_library") cc_library( name = "generated_cc_headers", @@ -13,3 +14,92 @@ filegroup( srcs = glob(["src/generated/main/java/**/*.java"]), visibility = ["//hal:__subpackages__"], ) + +ATHENA_SRCS = glob([ + "athena/*.cpp", + "athena/*.h", + "athena/cpp/*.cpp", + "athena/ctre/*.cpp", + "athena/ctre/*.h", + "athena/rev/*.cpp", + "athena/rev/*.h", + "athena/frccansae/*.h", + "athena/mockdata/*.cpp", +]) + +ATHENA_DEPS = ["@bzlmodrio-ni//libraries/cpp/ni:shared"] + +SIM_SRCS = glob([ + "sim/*.cpp", + "sim/mockdata/*.cpp", + "sim/*.h", + "sim/mockdata/*.h", +]) + +SIM_DEPS = [] + +HAL_DEPS = select({ + "@rules_bzlmodrio_toolchains//constraints/is_roborio:roborio": ATHENA_DEPS, + "//conditions:default": SIM_DEPS, +}) + +filegroup( + name = "platform-srcs", + srcs = select({ + "@rules_bzlmodrio_toolchains//constraints/is_roborio:roborio": ATHENA_SRCS, + "//conditions:default": SIM_SRCS, + }), +) + +cc_library( + name = "wpiHal.static", + srcs = ["platform-srcs"] + glob( + ["src/main/native/cpp/**"], + exclude = ["src/main/native/cpp/jni/**"], + ), + hdrs = glob(["src/main/native/include/**/*"]), + includes = ["src/main/native/include"], + strip_include_prefix = "src/main/native/include", + visibility = ["//visibility:public"], + deps = [ + "//hal:generated_cc_headers", + "//wpiutil/src/main/native:wpiutil.static", + ] + HAL_DEPS, +) + +java_library( + name = "hal", + srcs = ["//hal:generated_java"] + glob(["src/main/java/**/*.java"]), + visibility = ["//visibility:public"], + deps = [ + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + ], +) + +cc_test( + name = "hal-cpp-test", + size = "small", + srcs = glob([ + "**/*.cpp", + "**/*.h", + ]), + deps = [ + "//hal/src/main/native:wpiHal.static", + "//thirdparty/googletest", + ], +) + +cc_binary( + name = "DevMain-Cpp", + srcs = ["src/dev/native/cpp/main.cpp"], + deps = [ + ":wpiHal.static", + ], +) + +java_binary( + name = "DevMain-Java", + srcs = ["src/dev/java/edu/wpi/first/hal/DevMain.java"], + deps = [ + ], +) diff --git a/hal/src/dev/java/edu/wpi/first/hal/BUILD.bazel b/hal/src/dev/java/edu/wpi/first/hal/BUILD.bazel deleted file mode 100644 index 214327c3f85..00000000000 --- a/hal/src/dev/java/edu/wpi/first/hal/BUILD.bazel +++ /dev/null @@ -1,8 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_binary") - -java_binary( - name = "DevMain", - srcs = ["DevMain.java"], - deps = [ - ], -) diff --git a/hal/src/dev/native/cpp/BUILD.bazel b/hal/src/dev/native/cpp/BUILD.bazel deleted file mode 100644 index fe2a27b3b5a..00000000000 --- a/hal/src/dev/native/cpp/BUILD.bazel +++ /dev/null @@ -1,9 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_binary") - -cc_binary( - name = "DevMain", - srcs = ["main.cpp"], - deps = [ - "//hal/src/main/native:wpiHal.static", - ], -) diff --git a/hal/src/main/java/edu/wpi/first/hal/BUILD.bazel b/hal/src/main/java/edu/wpi/first/hal/BUILD.bazel deleted file mode 100644 index 34579d58e7e..00000000000 --- a/hal/src/main/java/edu/wpi/first/hal/BUILD.bazel +++ /dev/null @@ -1,10 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -java_library( - name = "hal", - srcs = ["//hal:generated_java"] + glob(["**/*.java"]), - visibility = ["//visibility:public"], - deps = [ - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", - ], -) diff --git a/hal/src/main/native/BUILD.bazel b/hal/src/main/native/BUILD.bazel deleted file mode 100644 index dfb736f4f51..00000000000 --- a/hal/src/main/native/BUILD.bazel +++ /dev/null @@ -1,53 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_library") - -ATHENA_SRCS = glob([ - "athena/*.cpp", - "athena/*.h", - "athena/cpp/*.cpp", - "athena/ctre/*.cpp", - "athena/ctre/*.h", - "athena/rev/*.cpp", - "athena/rev/*.h", - "athena/frccansae/*.h", - "athena/mockdata/*.cpp", -]) - -ATHENA_DEPS = ["@bzlmodrio-ni//libraries/cpp/ni:shared"] - -SIM_SRCS = glob([ - "sim/*.cpp", - "sim/mockdata/*.cpp", - "sim/*.h", - "sim/mockdata/*.h", -]) - -SIM_DEPS = [] - -HAL_DEPS = select({ - "@rules_bzlmodrio_toolchains//constraints/is_roborio:roborio": ATHENA_DEPS, - "//conditions:default": SIM_DEPS, -}) - -filegroup( - name = "platform-srcs", - srcs = select({ - "@rules_bzlmodrio_toolchains//constraints/is_roborio:roborio": ATHENA_SRCS, - "//conditions:default": SIM_SRCS, - }), -) - -cc_library( - name = "wpiHal.static", - srcs = ["platform-srcs"] + glob( - ["cpp/**"], - exclude = ["cpp/jni/**"], - ), - hdrs = glob(["include/**/*"]), - includes = ["include"], - strip_include_prefix = "include", - visibility = ["//visibility:public"], - deps = [ - "//hal:generated_cc_headers", - "//wpiutil/src/main/native:wpiutil.static", - ] + HAL_DEPS, -) diff --git a/hal/src/test/native/cpp/BUILD.bazel b/hal/src/test/native/cpp/BUILD.bazel deleted file mode 100644 index 000c90a0a30..00000000000 --- a/hal/src/test/native/cpp/BUILD.bazel +++ /dev/null @@ -1,14 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_test") - -cc_test( - name = "hal-cpp-test", - size = "small", - srcs = glob([ - "**/*.cpp", - "**/*.h", - ]), - deps = [ - "//hal/src/main/native:wpiHal.static", - "//thirdparty/googletest", - ], -) diff --git a/ntcore/BUILD.bazel b/ntcore/BUILD.bazel index 0b7567dec7b..c9f13e25b60 100644 --- a/ntcore/BUILD.bazel +++ b/ntcore/BUILD.bazel @@ -1,4 +1,5 @@ -load("@rules_cc//cc:defs.bzl", "cc_library") +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") +load("@rules_java//java:defs.bzl", "java_binary", "java_library") cc_library( name = "generated_cc_headers", @@ -22,3 +23,78 @@ filegroup( srcs = glob(["src/generated/main/java/**/*.java"]), visibility = ["//ntcore:__subpackages__"], ) + +cc_library( + name = "private_includes", + hdrs = glob([ + "src/main/native/cpp/*.h", + "src/main/native/cpp/net/*.h", + "src/main/native/cpp/net/*.inc", + "src/main/native/cpp/net3/*.h", + ]), + strip_include_prefix = "cpp", +) + +cc_library( + name = "ntcore.static", + srcs = glob( + ["src/main/native/cpp/**"], + exclude = ["src/main/native/cpp/jni/**"], + ) + ["//ntcore:generated_cc_source"], + hdrs = glob(["src/main/native/include/**/*"]), + includes = ["src/main/native/include"], + strip_include_prefix = "src/main/native/include", + visibility = ["//visibility:public"], + deps = [ + ":private_includes", + "//ntcore:generated_cc_headers", + "//wpinet/src/main/native:wpinet.static", + "//wpiutil/src/main/native:wpiutil.static", + ], +) + +java_library( + name = "networktables", + srcs = glob(["src/main/java/**/*.java"]) + ["//ntcore:generated_java"], + visibility = ["//visibility:public"], + deps = [ + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + "@maven//:us_hebi_quickbuf_quickbuf_runtime", + ], +) + +cc_test( + name = "ntcore-test", + size = "small", + srcs = glob([ + "**/*.cpp", + "**/*.h", + ]), + tags = [ + "exclusive", + "no-asan", + "no-tsan", + ], + deps = [ + "//ntcore/src/main/native:ntcore.static", + "//thirdparty/googletest", + "//wpiutil/src/test/native:wpiutil-testlib", + ], +) + +cc_binary( + name = "DevMain-Cpp", + srcs = ["src/dev/native/cpp/main.cpp"], + deps = [ + ":ntcore.static", + ], +) + +java_binary( + name = "DevMain-Java", + srcs = ["src/dev/java/edu/wpi/first/ntcore/DevMain.java"], + deps = [ + "//ntcore/src/main/java/edu/wpi/first/networktables", + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + ], +) diff --git a/ntcore/src/dev/java/edu/wpi/first/ntcore/BUILD.bazel b/ntcore/src/dev/java/edu/wpi/first/ntcore/BUILD.bazel deleted file mode 100644 index b5e370e72d2..00000000000 --- a/ntcore/src/dev/java/edu/wpi/first/ntcore/BUILD.bazel +++ /dev/null @@ -1,10 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_binary") - -java_binary( - name = "DevMain", - srcs = ["DevMain.java"], - deps = [ - "//ntcore/src/main/java/edu/wpi/first/networktables", - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", - ], -) diff --git a/ntcore/src/dev/native/cpp/BUILD.bazel b/ntcore/src/dev/native/cpp/BUILD.bazel deleted file mode 100644 index c480ed2acca..00000000000 --- a/ntcore/src/dev/native/cpp/BUILD.bazel +++ /dev/null @@ -1,9 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_binary") - -cc_binary( - name = "DevMain", - srcs = ["main.cpp"], - deps = [ - "//ntcore/src/main/native:ntcore.static", - ], -) diff --git a/ntcore/src/main/java/edu/wpi/first/networktables/BUILD.bazel b/ntcore/src/main/java/edu/wpi/first/networktables/BUILD.bazel deleted file mode 100644 index 48b1f6517e4..00000000000 --- a/ntcore/src/main/java/edu/wpi/first/networktables/BUILD.bazel +++ /dev/null @@ -1,11 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -java_library( - name = "networktables", - srcs = glob(["**/*.java"]) + ["//ntcore:generated_java"], - visibility = ["//visibility:public"], - deps = [ - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", - "@maven//:us_hebi_quickbuf_quickbuf_runtime", - ], -) diff --git a/ntcore/src/main/native/BUILD.bazel b/ntcore/src/main/native/BUILD.bazel deleted file mode 100644 index 68f9543e8e3..00000000000 --- a/ntcore/src/main/native/BUILD.bazel +++ /dev/null @@ -1,30 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_library") - -cc_library( - name = "private_includes", - hdrs = glob([ - "cpp/*.h", - "cpp/net/*.h", - "cpp/net/*.inc", - "cpp/net3/*.h", - ]), - strip_include_prefix = "cpp", -) - -cc_library( - name = "ntcore.static", - srcs = glob( - ["cpp/**"], - exclude = ["cpp/jni/**"], - ) + ["//ntcore:generated_cc_source"], - hdrs = glob(["include/**/*"]), - includes = ["include"], - strip_include_prefix = "include", - visibility = ["//visibility:public"], - deps = [ - ":private_includes", - "//ntcore:generated_cc_headers", - "//wpinet/src/main/native:wpinet.static", - "//wpiutil/src/main/native:wpiutil.static", - ], -) diff --git a/ntcore/src/test/native/cpp/BUILD.bazel b/ntcore/src/test/native/cpp/BUILD.bazel deleted file mode 100644 index cc1aaa0aca3..00000000000 --- a/ntcore/src/test/native/cpp/BUILD.bazel +++ /dev/null @@ -1,20 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_test") - -cc_test( - name = "ntcore-test", - size = "small", - srcs = glob([ - "**/*.cpp", - "**/*.h", - ]), - tags = [ - "exclusive", - "no-asan", - "no-tsan", - ], - deps = [ - "//ntcore/src/main/native:ntcore.static", - "//thirdparty/googletest", - "//wpiutil/src/test/native:wpiutil-testlib", - ], -) diff --git a/wpilibj/BUILD.bazel b/wpilibj/BUILD.bazel index 73130905951..e05c7d83618 100644 --- a/wpilibj/BUILD.bazel +++ b/wpilibj/BUILD.bazel @@ -1,5 +1,93 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary") +load("@rules_java//java:defs.bzl", "java_binary", "java_library") +load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_library") +load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file") + filegroup( name = "generated_java", srcs = glob(["src/generated/main/java/**/*.java"]), visibility = ["//wpilibj:__subpackages__"], ) + +java_library( + name = "wpilibj", + srcs = ["//wpilibj/src/generate:generate-version"] + glob(["src/main/java/**/*.java"]) + ["//wpilibj:generated_java"], + visibility = ["//visibility:public"], + deps = [ + "//cameraserver/src/main/java/edu/wpi/first:cameraserver", + "//cscore/src/main/java/edu/wpi/first/cscore", + "//hal/src/main/java/edu/wpi/first/hal", + "//ntcore/src/main/java/edu/wpi/first/networktables", + "//wpimath/src/main/java/edu/wpi/first/math:wpimath", + "//wpinet/src/main/java/edu/wpi/first/net:wpinet", + "//wpiunits/src/main/java/edu/wpi/first/units:wpiunits", + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + "@maven//:org_ejml_ejml_core", + "@maven//:org_ejml_ejml_simple", + ], +) + +cc_binary( + name = "DevMain-Cpp", + srcs = ["src/dev/native/cpp/main.cpp"], + deps = [ + ], +) + +java_binary( + name = "DevMain-Java", + srcs = ["src/dev/java/edu/wpi/first/wpilibj/DevMain.java"], + deps = [ + "//hal/src/main/java/edu/wpi/first/hal", + "//ntcore/src/main/java/edu/wpi/first/networktables", + "//wpimath/src/main/java/edu/wpi/first/math:wpimath", + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + ], +) + +wpilib_java_library( + name = "resources", + testonly = True, + resources = glob(["**"]), + visibility = ["//wpilibj/src/test:__subpackages__"], +) + +generate_version_file( + name = "generate-version", + output_file = "WPILibVersion.java", + template = "WPILibVersion.java.in", + visibility = ["//visibility:public"], +) + +filegroup( + name = "hid_schema", + srcs = [ + "hids.json", + "hids.schema.json", + ], + visibility = ["//visibility:public"], +) + +filegroup( + name = "pwm_schema", + srcs = [ + "pwm_motor_controllers.json", + ], + visibility = ["//visibility:public"], +) + +filegroup( + name = "templates", + srcs = glob(["*.jinja"]) + [ + ":hid_schema", + ":pwm_schema", + ], + visibility = ["//visibility:public"], +) + +java_library( + name = "resources", + testonly = True, + resources = glob(["**"]), + visibility = ["//wpilibj/src/test:__subpackages__"], +) diff --git a/wpilibj/src/dev/java/edu/wpi/first/wpilibj/BUILD.bazel b/wpilibj/src/dev/java/edu/wpi/first/wpilibj/BUILD.bazel deleted file mode 100644 index 6f52a070ef6..00000000000 --- a/wpilibj/src/dev/java/edu/wpi/first/wpilibj/BUILD.bazel +++ /dev/null @@ -1,12 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_binary") - -java_binary( - name = "DevMain", - srcs = ["DevMain.java"], - deps = [ - "//hal/src/main/java/edu/wpi/first/hal", - "//ntcore/src/main/java/edu/wpi/first/networktables", - "//wpimath/src/main/java/edu/wpi/first/math:wpimath", - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", - ], -) diff --git a/wpilibj/src/dev/native/cpp/BUILD.bazel b/wpilibj/src/dev/native/cpp/BUILD.bazel deleted file mode 100644 index e7bef5da6f7..00000000000 --- a/wpilibj/src/dev/native/cpp/BUILD.bazel +++ /dev/null @@ -1,8 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_binary") - -cc_binary( - name = "DevMain", - srcs = ["main.cpp"], - deps = [ - ], -) diff --git a/wpilibj/src/generate/BUILD.bazel b/wpilibj/src/generate/BUILD.bazel deleted file mode 100644 index a963496af7d..00000000000 --- a/wpilibj/src/generate/BUILD.bazel +++ /dev/null @@ -1,34 +0,0 @@ -load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file") - -generate_version_file( - name = "generate-version", - output_file = "WPILibVersion.java", - template = "WPILibVersion.java.in", - visibility = ["//visibility:public"], -) - -filegroup( - name = "hid_schema", - srcs = [ - "hids.json", - "hids.schema.json", - ], - visibility = ["//visibility:public"], -) - -filegroup( - name = "pwm_schema", - srcs = [ - "pwm_motor_controllers.json", - ], - visibility = ["//visibility:public"], -) - -filegroup( - name = "templates", - srcs = glob(["*.jinja"]) + [ - ":hid_schema", - ":pwm_schema", - ], - visibility = ["//visibility:public"], -) diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/BUILD.bazel b/wpilibj/src/main/java/edu/wpi/first/wpilibj/BUILD.bazel deleted file mode 100644 index f794ee61e09..00000000000 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/BUILD.bazel +++ /dev/null @@ -1,19 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -java_library( - name = "wpilibj", - srcs = ["//wpilibj/src/generate:generate-version"] + glob(["**/*.java"]) + ["//wpilibj:generated_java"], - visibility = ["//visibility:public"], - deps = [ - "//cameraserver/src/main/java/edu/wpi/first:cameraserver", - "//cscore/src/main/java/edu/wpi/first/cscore", - "//hal/src/main/java/edu/wpi/first/hal", - "//ntcore/src/main/java/edu/wpi/first/networktables", - "//wpimath/src/main/java/edu/wpi/first/math:wpimath", - "//wpinet/src/main/java/edu/wpi/first/net:wpinet", - "//wpiunits/src/main/java/edu/wpi/first/units:wpiunits", - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", - "@maven//:org_ejml_ejml_core", - "@maven//:org_ejml_ejml_simple", - ], -) diff --git a/wpilibj/src/test/resources/BUILD.bazel b/wpilibj/src/test/resources/BUILD.bazel deleted file mode 100644 index 1765de1f631..00000000000 --- a/wpilibj/src/test/resources/BUILD.bazel +++ /dev/null @@ -1,8 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -java_library( - name = "resources", - testonly = True, - resources = glob(["**"]), - visibility = ["//wpilibj/src/test:__subpackages__"], -) diff --git a/wpimath/BUILD.bazel b/wpimath/BUILD.bazel index 0abedace51f..77aa6f5d107 100644 --- a/wpimath/BUILD.bazel +++ b/wpimath/BUILD.bazel @@ -1,5 +1,39 @@ +load("@rules_java//java:defs.bzl", "java_binary", "java_library") +load("@rules_python//python:defs.bzl", "py_binary") + filegroup( name = "generated_java", srcs = glob(["src/generated/main/java/**/*.java"]), visibility = ["//wpimath:__subpackages__"], ) + +java_library( + name = "wpimath", + srcs = ["//wpimath:generated_java"] + glob(["src/main/java/**/*.java"]), + visibility = ["//visibility:public"], + deps = [ + "//wpiunits/src/main/java/edu/wpi/first/units:wpiunits", + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + "@maven//:com_fasterxml_jackson_core_jackson_annotations", + "@maven//:com_fasterxml_jackson_core_jackson_core", + "@maven//:com_fasterxml_jackson_core_jackson_databind", + "@maven//:org_ejml_ejml_core", + "@maven//:org_ejml_ejml_ddense", + "@maven//:org_ejml_ejml_simple", + "@maven//:us_hebi_quickbuf_quickbuf_runtime", + ], +) + +java_binary( + name = "DevMain-Java", + srcs = ["src/dev/java/edu/wpi/first/math/DevMain.java"], + deps = [ + "//wpimath/src/main/java/edu/wpi/first/math:wpimath", + ], +) + +py_binary( + name = "ExponentialProfileModel", + srcs = ["ExponentialProfileModel.py"], + tags = ["manual"], +) diff --git a/wpimath/algorithms/BUILD.bazel b/wpimath/algorithms/BUILD.bazel deleted file mode 100644 index 7b3c016738a..00000000000 --- a/wpimath/algorithms/BUILD.bazel +++ /dev/null @@ -1,7 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_binary") - -py_binary( - name = "ExponentialProfileModel", - srcs = ["ExponentialProfileModel.py"], - tags = ["manual"], -) diff --git a/wpimath/src/dev/java/edu/wpi/first/math/BUILD.bazel b/wpimath/src/dev/java/edu/wpi/first/math/BUILD.bazel deleted file mode 100644 index 4382b70a0db..00000000000 --- a/wpimath/src/dev/java/edu/wpi/first/math/BUILD.bazel +++ /dev/null @@ -1,9 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_binary") - -java_binary( - name = "DevMain", - srcs = ["DevMain.java"], - deps = [ - "//wpimath/src/main/java/edu/wpi/first/math:wpimath", - ], -) diff --git a/wpimath/src/main/java/edu/wpi/first/math/BUILD.bazel b/wpimath/src/main/java/edu/wpi/first/math/BUILD.bazel deleted file mode 100644 index c4696241879..00000000000 --- a/wpimath/src/main/java/edu/wpi/first/math/BUILD.bazel +++ /dev/null @@ -1,18 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -java_library( - name = "wpimath", - srcs = ["//wpimath:generated_java"] + glob(["**/*.java"]), - visibility = ["//visibility:public"], - deps = [ - "//wpiunits/src/main/java/edu/wpi/first/units:wpiunits", - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", - "@maven//:com_fasterxml_jackson_core_jackson_annotations", - "@maven//:com_fasterxml_jackson_core_jackson_core", - "@maven//:com_fasterxml_jackson_core_jackson_databind", - "@maven//:org_ejml_ejml_core", - "@maven//:org_ejml_ejml_ddense", - "@maven//:org_ejml_ejml_simple", - "@maven//:us_hebi_quickbuf_quickbuf_runtime", - ], -) diff --git a/wpinet/BUILD.bazel b/wpinet/BUILD.bazel new file mode 100644 index 00000000000..e9d641147c6 --- /dev/null +++ b/wpinet/BUILD.bazel @@ -0,0 +1,217 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") +load("@rules_java//java:defs.bzl", "java_binary", "java_library") +load("//shared/bazel/rules/gen:gen-resources.bzl", "generate_resources") + +WIN_UV_SRCS = glob([ + "src/main/native/thirdparty/libuv/src/win/*.cpp", + "src/main/native/thirdparty/libuv/src/win/*.h", +]) + +UNIX_UV_SRCS = [ + "src/main/native/thirdparty/libuv/src/unix/async.cpp", + "src/main/native/thirdparty/libuv/src/unix/core.cpp", + "src/main/native/thirdparty/libuv/src/unix/dl.cpp", + "src/main/native/thirdparty/libuv/src/unix/fs.cpp", + "src/main/native/thirdparty/libuv/src/unix/getaddrinfo.cpp", + "src/main/native/thirdparty/libuv/src/unix/getnameinfo.cpp", + "src/main/native/thirdparty/libuv/src/unix/loop-watcher.cpp", + "src/main/native/thirdparty/libuv/src/unix/loop.cpp", + "src/main/native/thirdparty/libuv/src/unix/pipe.cpp", + "src/main/native/thirdparty/libuv/src/unix/poll.cpp", + "src/main/native/thirdparty/libuv/src/unix/process.cpp", + "src/main/native/thirdparty/libuv/src/unix/random-devurandom.cpp", + "src/main/native/thirdparty/libuv/src/unix/random-getentropy.cpp", + "src/main/native/thirdparty/libuv/src/unix/random-getrandom.cpp", + "src/main/native/thirdparty/libuv/src/unix/signal.cpp", + "src/main/native/thirdparty/libuv/src/unix/stream.cpp", + "src/main/native/thirdparty/libuv/src/unix/tcp.cpp", + "src/main/native/thirdparty/libuv/src/unix/thread.cpp", + "src/main/native/thirdparty/libuv/src/unix/tty.cpp", + "src/main/native/thirdparty/libuv/src/unix/udp.cpp", +] + glob(["src/main/native/thirdparty/libuv/src/unix/*.h"]) + +MAC_UV_SRCS = [ + "src/main/native/thirdparty/libuv/src/unix/bsd-ifaddrs.cpp", + "src/main/native/thirdparty/libuv/src/unix/darwin.cpp", + "src/main/native/thirdparty/libuv/src/unix/darwin-proctitle.cpp", + "src/main/native/thirdparty/libuv/src/unix/fsevents.cpp", + "src/main/native/thirdparty/libuv/src/unix/kqueue.cpp", + "src/main/native/thirdparty/libuv/src/unix/proctitle.cpp", +] + +LINUX_UV_SRCS = [ + "src/main/native/thirdparty/libuv/src/unix/linux.cpp", + "src/main/native/thirdparty/libuv/src/unix/procfs-exepath.cpp", + "src/main/native/thirdparty/libuv/src/unix/proctitle.cpp", + "src/main/native/thirdparty/libuv/src/unix/random-sysctl-linux.cpp", +] + +cc_library( + name = "libuv-headers", + hdrs = glob([ + "src/main/native/thirdparty/libuv/include/**/*.h", + ]), + includes = ["src/main/native/thirdparty/libuv/src"], + strip_include_prefix = "src/main/native/thirdparty/libuv/include", + visibility = ["//wpinet:__subpackages__"], +) + +filegroup( + name = "libuv-srcs", + srcs = select({ + "@rules_bzlmodrio_toolchains//constraints/combined:is_unix": UNIX_UV_SRCS, + "//conditions:default": [], + }) + + select({ + "@bazel_tools//src/conditions:darwin": MAC_UV_SRCS, + "@bazel_tools//src/conditions:windows": WIN_UV_SRCS, + "@rules_bzlmodrio_toolchains//constraints/combined:is_linux": LINUX_UV_SRCS, + }) + glob(["src/main/native/thirdparty/libuv/src/*"]), + visibility = ["//wpinet:__subpackages__"], +) + +cc_library( + name = "tcpsockets-headers", + hdrs = glob([ + "src/main/native/thirdparty/tcpsockets/include/**/*.h", + ]), + includes = ["src/main/native/thirdparty/tcpsockets/include"], + strip_include_prefix = "src/main/native/thirdparty/tcpsockets/include", + visibility = ["//wpinet:__subpackages__"], +) + +filegroup( + name = "tcpsockets-srcs", + srcs = glob(["src/main/native/thirdparty/tcpsockets/cpp/**"]), + visibility = ["//wpinet:__subpackages__"], +) + +generate_resources( + name = "generate-resources", + namespace = "dlt", + prefix = "DLT", + resource_files = glob(["resources/*"]), +) + +filegroup( + name = "native-srcs", + srcs = ["generate-resources"] + select({ + "@bazel_tools//src/conditions:darwin": glob(["macOS/*"]), + "@bazel_tools//src/conditions:windows": glob(["windows/*"]), + "@rules_bzlmodrio_toolchains//constraints/combined:is_linux": glob(["linux/*"]), + }), +) + +cc_library( + name = "private_includes", + hdrs = glob([ + "src/main/native/cpp/*.h", + ]), + strip_include_prefix = "cpp", +) + +cc_library( + name = "wpinet.static", + srcs = glob( + ["src/main/native/cpp/**"], + exclude = ["src/main/native/cpp/jni/**"], + ) + [ + ":libuv-srcs", + ":tcpsockets-srcs", + ] + ["native-srcs"], + hdrs = glob(["src/main/native/include/**/*"]), + includes = ["src/main/native/include"], + strip_include_prefix = "src/main/native/include", + visibility = ["//visibility:public"], + deps = [ + ":libuv-headers", + ":private_includes", + ":tcpsockets-headers", + "//wpiutil/src/main/native:wpiutil.static", + ], +) + +java_library( + name = "wpinet", + srcs = glob(["src/main/java/**/*.java"]), + visibility = ["//visibility:public"], + deps = [ + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + ], +) + +cc_test( + name = "wpinet-test", + size = "small", + srcs = glob([ + "**/*.cpp", + "**/*.h", + ]), + tags = ["no-asan"], + deps = [ + "//thirdparty/googletest", + "//wpinet/src/main/native:wpinet.static", + "//wpiutil/src/test/native:wpiutil-testlib", + ], +) + +cc_binary( + name = "DevMain-Cpp", + srcs = ["src/dev/native/cpp/main.cpp"], + deps = [ + ":wpinet.static", + ], +) + +java_binary( + name = "DevMain-Java", + srcs = ["src/dev/java/edu/wpi/first/net/DevMain.java"], + deps = [ + "//wpinet/src/main/java/edu/wpi/first/net:wpinet", + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + ], +) + +cc_binary( + name = "dsclient", + srcs = ["dsclient.cpp"], + deps = [ + ":wpinet.static", + ], +) + +cc_binary( + name = "parallelconnect", + srcs = ["parallelconnect.cpp"], + deps = [ + ":wpinet.static", + ], +) + +cc_binary( + name = "webserver", + srcs = ["webserver.cpp"], + deps = [ + ":wpinet.static", + ], +) + +cc_binary( + name = "netconsoleServer", + srcs = ["main.cpp"], + linkopts = select({ + "@rules_bzlmodrio_toolchains//constraints/combined:is_linux": ["-lutil"], + "//conditions:default": [], + }), + deps = [ + ":wpinet.static", + ], +) + +cc_binary( + name = "netconsoleTee", + srcs = ["main.cpp"], + deps = [ + ":wpinet.static", + ], +) diff --git a/wpinet/examples/dsclient/BUILD.bazel b/wpinet/examples/dsclient/BUILD.bazel deleted file mode 100644 index 507d05e9a16..00000000000 --- a/wpinet/examples/dsclient/BUILD.bazel +++ /dev/null @@ -1,9 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_binary") - -cc_binary( - name = "dsclient", - srcs = ["dsclient.cpp"], - deps = [ - "//wpinet/src/main/native:wpinet.static", - ], -) diff --git a/wpinet/examples/parallelconnect/BUILD.bazel b/wpinet/examples/parallelconnect/BUILD.bazel deleted file mode 100644 index fa56611b965..00000000000 --- a/wpinet/examples/parallelconnect/BUILD.bazel +++ /dev/null @@ -1,9 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_binary") - -cc_binary( - name = "parallelconnect", - srcs = ["parallelconnect.cpp"], - deps = [ - "//wpinet/src/main/native:wpinet.static", - ], -) diff --git a/wpinet/examples/webserver/BUILD.bazel b/wpinet/examples/webserver/BUILD.bazel deleted file mode 100644 index 1a60ded9860..00000000000 --- a/wpinet/examples/webserver/BUILD.bazel +++ /dev/null @@ -1,9 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_binary") - -cc_binary( - name = "webserver", - srcs = ["webserver.cpp"], - deps = [ - "//wpinet/src/main/native:wpinet.static", - ], -) diff --git a/wpinet/src/dev/java/edu/wpi/first/net/BUILD.bazel b/wpinet/src/dev/java/edu/wpi/first/net/BUILD.bazel deleted file mode 100644 index 47ad6913df4..00000000000 --- a/wpinet/src/dev/java/edu/wpi/first/net/BUILD.bazel +++ /dev/null @@ -1,10 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_binary") - -java_binary( - name = "DevMain", - srcs = ["DevMain.java"], - deps = [ - "//wpinet/src/main/java/edu/wpi/first/net:wpinet", - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", - ], -) diff --git a/wpinet/src/dev/native/cpp/BUILD.bazel b/wpinet/src/dev/native/cpp/BUILD.bazel deleted file mode 100644 index c3ab6c5fbb5..00000000000 --- a/wpinet/src/dev/native/cpp/BUILD.bazel +++ /dev/null @@ -1,9 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_binary") - -cc_binary( - name = "DevMain", - srcs = ["main.cpp"], - deps = [ - "//wpinet/src/main/native:wpinet.static", - ], -) diff --git a/wpinet/src/main/java/edu/wpi/first/net/BUILD.bazel b/wpinet/src/main/java/edu/wpi/first/net/BUILD.bazel deleted file mode 100644 index 20bfaf3951c..00000000000 --- a/wpinet/src/main/java/edu/wpi/first/net/BUILD.bazel +++ /dev/null @@ -1,10 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -java_library( - name = "wpinet", - srcs = glob(["**/*.java"]), - visibility = ["//visibility:public"], - deps = [ - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", - ], -) diff --git a/wpinet/src/main/native/BUILD.bazel b/wpinet/src/main/native/BUILD.bazel deleted file mode 100644 index 22c5eaa5caa..00000000000 --- a/wpinet/src/main/native/BUILD.bazel +++ /dev/null @@ -1,47 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_library") -load("//shared/bazel/rules/gen:gen-resources.bzl", "generate_resources") - -generate_resources( - name = "generate-resources", - namespace = "dlt", - prefix = "DLT", - resource_files = glob(["resources/*"]), -) - -filegroup( - name = "native-srcs", - srcs = ["generate-resources"] + select({ - "@bazel_tools//src/conditions:darwin": glob(["macOS/*"]), - "@bazel_tools//src/conditions:windows": glob(["windows/*"]), - "@rules_bzlmodrio_toolchains//constraints/combined:is_linux": glob(["linux/*"]), - }), -) - -cc_library( - name = "private_includes", - hdrs = glob([ - "cpp/*.h", - ]), - strip_include_prefix = "cpp", -) - -cc_library( - name = "wpinet.static", - srcs = glob( - ["cpp/**"], - exclude = ["cpp/jni/**"], - ) + [ - "//wpinet/src/main/native/thirdparty/libuv:libuv-srcs", - "//wpinet/src/main/native/thirdparty/tcpsockets:tcpsockets-srcs", - ] + ["native-srcs"], - hdrs = glob(["include/**/*"]), - includes = ["include"], - strip_include_prefix = "include", - visibility = ["//visibility:public"], - deps = [ - ":private_includes", - "//wpinet/src/main/native/thirdparty/libuv:libuv-headers", - "//wpinet/src/main/native/thirdparty/tcpsockets:tcpsockets-headers", - "//wpiutil/src/main/native:wpiutil.static", - ], -) diff --git a/wpinet/src/main/native/thirdparty/libuv/BUILD.bazel b/wpinet/src/main/native/thirdparty/libuv/BUILD.bazel deleted file mode 100644 index 3363eaca334..00000000000 --- a/wpinet/src/main/native/thirdparty/libuv/BUILD.bazel +++ /dev/null @@ -1,69 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_library") - -WIN_UV_SRCS = glob([ - "src/win/*.cpp", - "src/win/*.h", -]) - -UNIX_UV_SRCS = [ - "src/unix/async.cpp", - "src/unix/core.cpp", - "src/unix/dl.cpp", - "src/unix/fs.cpp", - "src/unix/getaddrinfo.cpp", - "src/unix/getnameinfo.cpp", - "src/unix/loop-watcher.cpp", - "src/unix/loop.cpp", - "src/unix/pipe.cpp", - "src/unix/poll.cpp", - "src/unix/process.cpp", - "src/unix/random-devurandom.cpp", - "src/unix/random-getentropy.cpp", - "src/unix/random-getrandom.cpp", - "src/unix/signal.cpp", - "src/unix/stream.cpp", - "src/unix/tcp.cpp", - "src/unix/thread.cpp", - "src/unix/tty.cpp", - "src/unix/udp.cpp", -] + glob(["src/unix/*.h"]) - -MAC_UV_SRCS = [ - "src/unix/bsd-ifaddrs.cpp", - "src/unix/darwin.cpp", - "src/unix/darwin-proctitle.cpp", - "src/unix/fsevents.cpp", - "src/unix/kqueue.cpp", - "src/unix/proctitle.cpp", -] - -LINUX_UV_SRCS = [ - "src/unix/linux.cpp", - "src/unix/procfs-exepath.cpp", - "src/unix/proctitle.cpp", - "src/unix/random-sysctl-linux.cpp", -] - -cc_library( - name = "libuv-headers", - hdrs = glob([ - "include/**/*.h", - ]), - includes = ["src"], - strip_include_prefix = "include", - visibility = ["//wpinet:__subpackages__"], -) - -filegroup( - name = "libuv-srcs", - srcs = select({ - "@rules_bzlmodrio_toolchains//constraints/combined:is_unix": UNIX_UV_SRCS, - "//conditions:default": [], - }) + - select({ - "@bazel_tools//src/conditions:darwin": MAC_UV_SRCS, - "@bazel_tools//src/conditions:windows": WIN_UV_SRCS, - "@rules_bzlmodrio_toolchains//constraints/combined:is_linux": LINUX_UV_SRCS, - }) + glob(["src/*"]), - visibility = ["//wpinet:__subpackages__"], -) diff --git a/wpinet/src/main/native/thirdparty/tcpsockets/BUILD.bazel b/wpinet/src/main/native/thirdparty/tcpsockets/BUILD.bazel deleted file mode 100644 index d12517784fe..00000000000 --- a/wpinet/src/main/native/thirdparty/tcpsockets/BUILD.bazel +++ /dev/null @@ -1,17 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_library") - -cc_library( - name = "tcpsockets-headers", - hdrs = glob([ - "include/**/*.h", - ]), - includes = ["include"], - strip_include_prefix = "include", - visibility = ["//wpinet:__subpackages__"], -) - -filegroup( - name = "tcpsockets-srcs", - srcs = glob(["cpp/**"]), - visibility = ["//wpinet:__subpackages__"], -) diff --git a/wpinet/src/netconsoleServer/native/cpp/BUILD.bazel b/wpinet/src/netconsoleServer/native/cpp/BUILD.bazel deleted file mode 100644 index a2de1d13cbb..00000000000 --- a/wpinet/src/netconsoleServer/native/cpp/BUILD.bazel +++ /dev/null @@ -1,13 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_binary") - -cc_binary( - name = "netconsoleServer", - srcs = ["main.cpp"], - linkopts = select({ - "@rules_bzlmodrio_toolchains//constraints/combined:is_linux": ["-lutil"], - "//conditions:default": [], - }), - deps = [ - "//wpinet/src/main/native:wpinet.static", - ], -) diff --git a/wpinet/src/netconsoleTee/native/cpp/BUILD.bazel b/wpinet/src/netconsoleTee/native/cpp/BUILD.bazel deleted file mode 100644 index 9bf9e1b9164..00000000000 --- a/wpinet/src/netconsoleTee/native/cpp/BUILD.bazel +++ /dev/null @@ -1,9 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_binary") - -cc_binary( - name = "netconsoleTee", - srcs = ["main.cpp"], - deps = [ - "//wpinet/src/main/native:wpinet.static", - ], -) diff --git a/wpinet/src/test/native/cpp/BUILD.bazel b/wpinet/src/test/native/cpp/BUILD.bazel deleted file mode 100644 index 36103a6be60..00000000000 --- a/wpinet/src/test/native/cpp/BUILD.bazel +++ /dev/null @@ -1,16 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_test") - -cc_test( - name = "wpinet-test", - size = "small", - srcs = glob([ - "**/*.cpp", - "**/*.h", - ]), - tags = ["no-asan"], - deps = [ - "//thirdparty/googletest", - "//wpinet/src/main/native:wpinet.static", - "//wpiutil/src/test/native:wpiutil-testlib", - ], -) diff --git a/wpiunits/BUILD.bazel b/wpiunits/BUILD.bazel new file mode 100644 index 00000000000..7990a454c00 --- /dev/null +++ b/wpiunits/BUILD.bazel @@ -0,0 +1,16 @@ +load("@rules_java//java:defs.bzl", "java_binary", "java_library") + +java_library( + name = "wpiunits", + srcs = glob(["src/main/java/**/*.java"]), + visibility = ["//visibility:public"], + deps = [], +) + +java_binary( + name = "DevMain-Java", + srcs = ["src/dev/java/edu/wpi/first/units/DevMain.java"], + deps = [ + "//wpiunits/src/main/java/edu/wpi/first/units:wpiunits", + ], +) diff --git a/wpiunits/src/dev/java/edu/wpi/first/units/BUILD.bazel b/wpiunits/src/dev/java/edu/wpi/first/units/BUILD.bazel deleted file mode 100644 index 5718f15922b..00000000000 --- a/wpiunits/src/dev/java/edu/wpi/first/units/BUILD.bazel +++ /dev/null @@ -1,9 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_binary") - -java_binary( - name = "DevMain", - srcs = ["DevMain.java"], - deps = [ - "//wpiunits/src/main/java/edu/wpi/first/units:wpiunits", - ], -) diff --git a/wpiunits/src/main/java/edu/wpi/first/units/BUILD.bazel b/wpiunits/src/main/java/edu/wpi/first/units/BUILD.bazel deleted file mode 100644 index cb1cb8f99dc..00000000000 --- a/wpiunits/src/main/java/edu/wpi/first/units/BUILD.bazel +++ /dev/null @@ -1,8 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -java_library( - name = "wpiunits", - srcs = glob(["**/*.java"]), - visibility = ["//visibility:public"], - deps = [], -) diff --git a/wpiutil/BUILD.bazel b/wpiutil/BUILD.bazel new file mode 100644 index 00000000000..5acb6c64cb3 --- /dev/null +++ b/wpiutil/BUILD.bazel @@ -0,0 +1,244 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") +load("@rules_java//java:defs.bzl", "java_binary", "java_library") +load("@rules_python//python:defs.bzl", "py_binary") +load("//shared/bazel/rules/gen:gen-resources.bzl", "generate_resources") + +cc_library( + name = "expected-headers", + hdrs = glob([ + "src/main/native/thirdparty/expected/include/**/*", + ]), + includes = ["src/main/native/thirdparty/expected/include"], + strip_include_prefix = "src/main/native/thirdparty/expected/include", + visibility = ["//wpiutil:__subpackages__"], +) + +cc_library( + name = "fmtlib-headers", + hdrs = glob([ + "src/main/native/thirdparty/fmtlib/include/**/*.h", + ]), + includes = ["src/main/native/thirdparty/fmtlib/include"], + strip_include_prefix = "src/main/native/thirdparty/fmtlib/include", + visibility = ["//wpiutil:__subpackages__"], +) + +filegroup( + name = "fmtlib-srcs", + srcs = glob(["src/main/native/thirdparty/fmtlib/src/**"]), + visibility = ["//wpiutil:__subpackages__"], +) + +cc_library( + name = "json-headers", + hdrs = glob([ + "src/main/native/thirdparty/json/include/**/*.h", + ]), + includes = ["src/main/native/thirdparty/json/include"], + strip_include_prefix = "src/main/native/thirdparty/json/include", + visibility = ["//wpiutil:__subpackages__"], +) + +cc_library( + name = "llvm-headers", + hdrs = glob([ + "src/main/native/thirdparty/llvm/include/**/*.h", + ]), + includes = ["src/main/native/thirdparty/llvm/include"], + strip_include_prefix = "src/main/native/thirdparty/llvm/include", + visibility = ["//wpiutil:__subpackages__"], +) + +filegroup( + name = "llvm-srcs", + srcs = glob(["src/main/native/thirdparty/llvm/cpp/**"]), + visibility = ["//wpiutil:__subpackages__"], +) + +cc_library( + name = "memory-headers", + hdrs = glob([ + "src/main/native/thirdparty/memory/include/**/*.hpp", + ]), + includes = ["src/main/native/thirdparty/memory/include"], + strip_include_prefix = "src/main/native/thirdparty/memory/include", + visibility = ["//wpiutil:__subpackages__"], +) + +filegroup( + name = "memory-srcs", + srcs = glob(["src/main/native/thirdparty/memory/src/**"]), + visibility = ["//wpiutil:__subpackages__"], +) + +cc_library( + name = "mpack-headers", + hdrs = glob([ + "src/main/native/thirdparty/mpack/include/**/*.h", + ]), + includes = ["src/main/native/thirdparty/mpack/include"], + strip_include_prefix = "src/main/native/thirdparty/mpack/include", + visibility = ["//wpiutil:__subpackages__"], +) + +filegroup( + name = "mpack-srcs", + srcs = glob(["src/main/native/thirdparty/mpack/src/**"]), + visibility = ["//wpiutil:__subpackages__"], +) + +cc_library( + name = "protobuf-headers", + hdrs = glob([ + "src/main/native/thirdparty/protobuf/include/**/*.h", + "src/main/native/thirdparty/protobuf/include/**/*.inc", + ]), + includes = ["src/main/native/thirdparty/protobuf/include"], + strip_include_prefix = "src/main/native/thirdparty/protobuf/include", + visibility = ["//wpiutil:__subpackages__"], +) + +filegroup( + name = "protobuf-srcs", + srcs = glob(["src/main/native/thirdparty/protobuf/src/**"]), + visibility = ["//wpiutil:__subpackages__"], +) + +cc_library( + name = "sigslot-headers", + hdrs = glob([ + "src/main/native/thirdparty/sigslot/include/**/*.h", + ]), + includes = ["src/main/native/thirdparty/sigslot/include"], + strip_include_prefix = "src/main/native/thirdparty/sigslot/include", + visibility = ["//wpiutil:__subpackages__"], +) + +generate_resources( + name = "generate-resources", + namespace = "dlt", + prefix = "DLT", + resource_files = glob(["resources/*"]), +) + +filegroup( + name = "native-srcs", + srcs = select({ + "@bazel_tools//src/conditions:windows": glob([ + "windows/*.cpp", + "windows/*.h", + ]), + "@rules_bzlmodrio_toolchains//constraints/combined:is_unix": glob(["unix/*.cpp"]), + }), +) + +cc_library( + name = "wpiutil.static", + srcs = glob( + ["src/main/native/cpp/**"], + exclude = ["src/main/native/cpp/jni/**"], + ) + [ + ":fmtlib-srcs", + ":generate-resources", + ":llvm-srcs", + ":memory-srcs", + ":mpack-srcs", + ":native-srcs", + ":protobuf-srcs", + ], + hdrs = glob(["src/main/native/include/**/*"]), + includes = ["src/main/native/include"], + strip_include_prefix = "src/main/native/include", + visibility = ["//visibility:public"], + deps = [ + ":expected-headers", + ":fmtlib-headers", + ":json-headers", + ":llvm-headers", + ":memory-headers", + ":mpack-headers", + ":protobuf-headers", + ":sigslot-headers", + ] + select({ + "@rules_bzlmodrio_toolchains//constraints/is_roborio:roborio": ["@bzlmodrio-ni//libraries/cpp/ni:shared"], + "//conditions:default": [], + }), +) + +java_library( + name = "wpiutil", + srcs = glob(["src/main/java/**/*.java"]), + visibility = ["//visibility:public"], + deps = [ + "@maven//:com_fasterxml_jackson_core_jackson_annotations", + "@maven//:com_fasterxml_jackson_core_jackson_core", + "@maven//:com_fasterxml_jackson_core_jackson_databind", + "@maven//:us_hebi_quickbuf_quickbuf_runtime", + ], +) + +cc_library( + name = "wpiutil-testlib", + hdrs = glob(["src/test/native/include/**"]), + strip_include_prefix = "src/test/native/include", + visibility = ["//visibility:public"], +) + +cc_test( + name = "wpiutil-test", + size = "small", + srcs = glob(["src/test/native/cpp/**"]), + linkstatic = True, + tags = ["no-tsan"], # TODO(pj.reiniger) Find problem + deps = [ + ":wpiutil.static", + ":wpiutil-testlib", + "//thirdparty/googletest", + ], +) + +cc_binary( + name = "DevMain-Cpp", + srcs = ["src/dev/native/cpp/main.cpp"], + deps = [ + ":wpiutil.static", + ], +) + +java_binary( + name = "DevMain-Java", + srcs = ["src/dev/java/edu/wpi/first/util/DevMain.java"], + deps = [ + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + ], +) + +py_binary( + name = "datalog", + srcs = ["datalog.py"], + tags = ["manual"], +) + +cc_binary( + name = "printlog", + srcs = ["printlog.cpp"], + deps = [ + ":wpiutil.static", + ], +) + +cc_binary( + name = "writelog", + srcs = ["writelog.cpp"], + deps = [ + ":wpiutil.static", + ], +) + +java_binary( + name = "printlog", + srcs = ["PrintLog.java"], + deps = [ + "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + ], +) diff --git a/wpiutil/examples/printlog/BUILD.bazel b/wpiutil/examples/printlog/BUILD.bazel deleted file mode 100644 index 83b73213eaa..00000000000 --- a/wpiutil/examples/printlog/BUILD.bazel +++ /dev/null @@ -1,16 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_binary") -load("@rules_python//python:defs.bzl", "py_binary") - -py_binary( - name = "datalog", - srcs = ["datalog.py"], - tags = ["manual"], -) - -cc_binary( - name = "printlog", - srcs = ["printlog.cpp"], - deps = [ - "//wpiutil/src/main/native:wpiutil.static", - ], -) diff --git a/wpiutil/examples/writelog/BUILD.bazel b/wpiutil/examples/writelog/BUILD.bazel deleted file mode 100644 index 76a5cb9a613..00000000000 --- a/wpiutil/examples/writelog/BUILD.bazel +++ /dev/null @@ -1,9 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_binary") - -cc_binary( - name = "writelog", - srcs = ["writelog.cpp"], - deps = [ - "//wpiutil/src/main/native:wpiutil.static", - ], -) diff --git a/wpiutil/src/dev/java/edu/wpi/first/util/BUILD.bazel b/wpiutil/src/dev/java/edu/wpi/first/util/BUILD.bazel deleted file mode 100644 index 663b6794b18..00000000000 --- a/wpiutil/src/dev/java/edu/wpi/first/util/BUILD.bazel +++ /dev/null @@ -1,9 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_binary") - -java_binary( - name = "DevMain", - srcs = ["DevMain.java"], - deps = [ - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", - ], -) diff --git a/wpiutil/src/dev/native/cpp/BUILD.bazel b/wpiutil/src/dev/native/cpp/BUILD.bazel deleted file mode 100644 index caa66bf4039..00000000000 --- a/wpiutil/src/dev/native/cpp/BUILD.bazel +++ /dev/null @@ -1,9 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_binary") - -cc_binary( - name = "DevMain", - srcs = ["main.cpp"], - deps = [ - "//wpiutil/src/main/native:wpiutil.static", - ], -) diff --git a/wpiutil/src/main/java/edu/wpi/first/util/BUILD.bazel b/wpiutil/src/main/java/edu/wpi/first/util/BUILD.bazel deleted file mode 100644 index a8f1823154e..00000000000 --- a/wpiutil/src/main/java/edu/wpi/first/util/BUILD.bazel +++ /dev/null @@ -1,13 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_library") - -java_library( - name = "wpiutil", - srcs = glob(["**/*.java"]), - visibility = ["//visibility:public"], - deps = [ - "@maven//:com_fasterxml_jackson_core_jackson_annotations", - "@maven//:com_fasterxml_jackson_core_jackson_core", - "@maven//:com_fasterxml_jackson_core_jackson_databind", - "@maven//:us_hebi_quickbuf_quickbuf_runtime", - ], -) diff --git a/wpiutil/src/main/native/BUILD.bazel b/wpiutil/src/main/native/BUILD.bazel deleted file mode 100644 index 3986a25edcb..00000000000 --- a/wpiutil/src/main/native/BUILD.bazel +++ /dev/null @@ -1,53 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_library") -load("//shared/bazel/rules/gen:gen-resources.bzl", "generate_resources") - -generate_resources( - name = "generate-resources", - namespace = "dlt", - prefix = "DLT", - resource_files = glob(["resources/*"]), -) - -filegroup( - name = "native-srcs", - srcs = select({ - "@bazel_tools//src/conditions:windows": glob([ - "windows/*.cpp", - "windows/*.h", - ]), - "@rules_bzlmodrio_toolchains//constraints/combined:is_unix": glob(["unix/*.cpp"]), - }), -) - -cc_library( - name = "wpiutil.static", - srcs = glob( - ["cpp/**"], - exclude = ["cpp/jni/**"], - ) + [ - ":generate-resources", - ":native-srcs", - "//wpiutil/src/main/native/thirdparty/fmtlib:fmtlib-srcs", - "//wpiutil/src/main/native/thirdparty/llvm:llvm-srcs", - "//wpiutil/src/main/native/thirdparty/memory:memory-srcs", - "//wpiutil/src/main/native/thirdparty/mpack:mpack-srcs", - "//wpiutil/src/main/native/thirdparty/protobuf:protobuf-srcs", - ], - hdrs = glob(["include/**/*"]), - includes = ["include"], - strip_include_prefix = "include", - visibility = ["//visibility:public"], - deps = [ - "//wpiutil/src/main/native/thirdparty/expected:expected-headers", - "//wpiutil/src/main/native/thirdparty/fmtlib:fmtlib-headers", - "//wpiutil/src/main/native/thirdparty/json:json-headers", - "//wpiutil/src/main/native/thirdparty/llvm:llvm-headers", - "//wpiutil/src/main/native/thirdparty/memory:memory-headers", - "//wpiutil/src/main/native/thirdparty/mpack:mpack-headers", - "//wpiutil/src/main/native/thirdparty/protobuf:protobuf-headers", - "//wpiutil/src/main/native/thirdparty/sigslot:sigslot-headers", - ] + select({ - "@rules_bzlmodrio_toolchains//constraints/is_roborio:roborio": ["@bzlmodrio-ni//libraries/cpp/ni:shared"], - "//conditions:default": [], - }), -) diff --git a/wpiutil/src/main/native/thirdparty/expected/BUILD.bazel b/wpiutil/src/main/native/thirdparty/expected/BUILD.bazel deleted file mode 100644 index 16109c86388..00000000000 --- a/wpiutil/src/main/native/thirdparty/expected/BUILD.bazel +++ /dev/null @@ -1,11 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_library") - -cc_library( - name = "expected-headers", - hdrs = glob([ - "include/**/*", - ]), - includes = ["include"], - strip_include_prefix = "include", - visibility = ["//wpiutil:__subpackages__"], -) diff --git a/wpiutil/src/main/native/thirdparty/fmtlib/BUILD.bazel b/wpiutil/src/main/native/thirdparty/fmtlib/BUILD.bazel deleted file mode 100644 index a3e69baa40f..00000000000 --- a/wpiutil/src/main/native/thirdparty/fmtlib/BUILD.bazel +++ /dev/null @@ -1,17 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_library") - -cc_library( - name = "fmtlib-headers", - hdrs = glob([ - "include/**/*.h", - ]), - includes = ["include"], - strip_include_prefix = "include", - visibility = ["//wpiutil:__subpackages__"], -) - -filegroup( - name = "fmtlib-srcs", - srcs = glob(["src/**"]), - visibility = ["//wpiutil:__subpackages__"], -) diff --git a/wpiutil/src/main/native/thirdparty/json/BUILD.bazel b/wpiutil/src/main/native/thirdparty/json/BUILD.bazel deleted file mode 100644 index 860b4e23e7f..00000000000 --- a/wpiutil/src/main/native/thirdparty/json/BUILD.bazel +++ /dev/null @@ -1,11 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_library") - -cc_library( - name = "json-headers", - hdrs = glob([ - "include/**/*.h", - ]), - includes = ["include"], - strip_include_prefix = "include", - visibility = ["//wpiutil:__subpackages__"], -) diff --git a/wpiutil/src/main/native/thirdparty/llvm/BUILD.bazel b/wpiutil/src/main/native/thirdparty/llvm/BUILD.bazel deleted file mode 100644 index a59db1a4711..00000000000 --- a/wpiutil/src/main/native/thirdparty/llvm/BUILD.bazel +++ /dev/null @@ -1,17 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_library") - -cc_library( - name = "llvm-headers", - hdrs = glob([ - "include/**/*.h", - ]), - includes = ["include"], - strip_include_prefix = "include", - visibility = ["//wpiutil:__subpackages__"], -) - -filegroup( - name = "llvm-srcs", - srcs = glob(["cpp/**"]), - visibility = ["//wpiutil:__subpackages__"], -) diff --git a/wpiutil/src/main/native/thirdparty/memory/BUILD.bazel b/wpiutil/src/main/native/thirdparty/memory/BUILD.bazel deleted file mode 100644 index 6e457bca9f8..00000000000 --- a/wpiutil/src/main/native/thirdparty/memory/BUILD.bazel +++ /dev/null @@ -1,17 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_library") - -cc_library( - name = "memory-headers", - hdrs = glob([ - "include/**/*.hpp", - ]), - includes = ["include"], - strip_include_prefix = "include", - visibility = ["//wpiutil:__subpackages__"], -) - -filegroup( - name = "memory-srcs", - srcs = glob(["src/**"]), - visibility = ["//wpiutil:__subpackages__"], -) diff --git a/wpiutil/src/main/native/thirdparty/mpack/BUILD.bazel b/wpiutil/src/main/native/thirdparty/mpack/BUILD.bazel deleted file mode 100644 index 83e404221fa..00000000000 --- a/wpiutil/src/main/native/thirdparty/mpack/BUILD.bazel +++ /dev/null @@ -1,17 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_library") - -cc_library( - name = "mpack-headers", - hdrs = glob([ - "include/**/*.h", - ]), - includes = ["include"], - strip_include_prefix = "include", - visibility = ["//wpiutil:__subpackages__"], -) - -filegroup( - name = "mpack-srcs", - srcs = glob(["src/**"]), - visibility = ["//wpiutil:__subpackages__"], -) diff --git a/wpiutil/src/main/native/thirdparty/protobuf/BUILD.bazel b/wpiutil/src/main/native/thirdparty/protobuf/BUILD.bazel deleted file mode 100644 index c8d38365426..00000000000 --- a/wpiutil/src/main/native/thirdparty/protobuf/BUILD.bazel +++ /dev/null @@ -1,18 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_library") - -cc_library( - name = "protobuf-headers", - hdrs = glob([ - "include/**/*.h", - "include/**/*.inc", - ]), - includes = ["include"], - strip_include_prefix = "include", - visibility = ["//wpiutil:__subpackages__"], -) - -filegroup( - name = "protobuf-srcs", - srcs = glob(["src/**"]), - visibility = ["//wpiutil:__subpackages__"], -) diff --git a/wpiutil/src/main/native/thirdparty/sigslot/BUILD.bazel b/wpiutil/src/main/native/thirdparty/sigslot/BUILD.bazel deleted file mode 100644 index 4c451dc8581..00000000000 --- a/wpiutil/src/main/native/thirdparty/sigslot/BUILD.bazel +++ /dev/null @@ -1,11 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_library") - -cc_library( - name = "sigslot-headers", - hdrs = glob([ - "include/**/*.h", - ]), - includes = ["include"], - strip_include_prefix = "include", - visibility = ["//wpiutil:__subpackages__"], -) diff --git a/wpiutil/src/printlog/java/printlog/BUILD.bazel b/wpiutil/src/printlog/java/printlog/BUILD.bazel deleted file mode 100644 index 5e5736a232a..00000000000 --- a/wpiutil/src/printlog/java/printlog/BUILD.bazel +++ /dev/null @@ -1,9 +0,0 @@ -load("@rules_java//java:defs.bzl", "java_binary") - -java_binary( - name = "printlog", - srcs = ["PrintLog.java"], - deps = [ - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", - ], -) diff --git a/wpiutil/src/test/native/BUILD.bazel b/wpiutil/src/test/native/BUILD.bazel deleted file mode 100644 index f660403ed57..00000000000 --- a/wpiutil/src/test/native/BUILD.bazel +++ /dev/null @@ -1,21 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") - -cc_library( - name = "wpiutil-testlib", - hdrs = glob(["include/**"]), - strip_include_prefix = "include", - visibility = ["//visibility:public"], -) - -cc_test( - name = "wpiutil-test", - size = "small", - srcs = glob(["cpp/**"]), - linkstatic = True, - tags = ["no-tsan"], # TODO(pj.reiniger) Find problem - deps = [ - ":wpiutil-testlib", - "//thirdparty/googletest", - "//wpiutil/src/main/native:wpiutil.static", - ], -) From 5ba87d5095542ba41a72551fcbac189f421f055d Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 24 Aug 2024 22:02:12 -0400 Subject: [PATCH 16/38] Fixup amalgamation --- cameraserver/BUILD.bazel | 34 ++++++++++++---------- cscore/BUILD.bazel | 11 +++---- hal/BUILD.bazel | 45 ++++++++++++++-------------- ntcore/BUILD.bazel | 33 +++++++++++---------- wpilibj/BUILD.bazel | 63 ++++++++++++++++++---------------------- wpimath/BUILD.bazel | 13 +++++---- wpinet/BUILD.bazel | 57 ++++++++++++++++++------------------ wpiunits/BUILD.bazel | 5 ++-- wpiutil/BUILD.bazel | 26 +++++++++-------- 9 files changed, 145 insertions(+), 142 deletions(-) diff --git a/cameraserver/BUILD.bazel b/cameraserver/BUILD.bazel index 800afe6ee6c..9f3a3d3c8dd 100644 --- a/cameraserver/BUILD.bazel +++ b/cameraserver/BUILD.bazel @@ -2,44 +2,46 @@ load("@rules_cc//cc:defs.bzl", "cc_binary") load("@rules_java//java:defs.bzl", "java_binary", "java_library") java_library( - name = "cameraserver", + name = "cameraserver-java", srcs = glob(["src/main/java/**/*.java"]), visibility = ["//visibility:public"], deps = [ - "//cscore/src/main/java/edu/wpi/first/cscore", - "//hal/src/main/java/edu/wpi/first/hal", - "//ntcore/src/main/java/edu/wpi/first/networktables", - "//wpimath/src/main/java/edu/wpi/first/math:wpimath", - "//wpinet/src/main/java/edu/wpi/first/net:wpinet", - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + "//cscore:cscore-java", + "//hal:hal-java", + "//ntcore:networktables-java", + "//wpimath:wpimath-java", + "//wpinet:wpinet-java", + "//wpiutil:wpiutil-java", "@bzlmodrio-opencv//libraries/java/opencv", ], ) cc_binary( - name = "DevMain-Cpp", + name = "DevMain-cpp", srcs = ["src/dev/native/cpp/main.cpp"], deps = [ ], ) java_binary( - name = "DevMain-Java", + name = "DevMain-java", srcs = ["src/dev/java/edu/wpi/first/cameraserver/DevMain.java"], + main_class = "edu.wpi.first.cameraserver.DevMain", deps = [ ], ) java_binary( name = "multiCameraServer", - srcs = ["Main.java"], + srcs = ["multiCameraServer/src/main/java/edu/wpi/Main.java"], + main_class = "edu.wpi.Main", deps = [ - "//cameraserver/src/main/java/edu/wpi/first:cameraserver", - "//cscore/src/main/java/edu/wpi/first/cscore", - "//hal/src/main/java/edu/wpi/first/hal", - "//ntcore/src/main/java/edu/wpi/first/networktables", - "//wpimath/src/main/java/edu/wpi/first/math:wpimath", - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + ":cameraserver-java", + "//cscore:cscore-java", + "//hal:hal-java", + "//ntcore:networktables-java", + "//wpimath:wpimath-java", + "//wpiutil:wpiutil-java", "@maven//:com_google_code_gson_gson", ], ) diff --git a/cscore/BUILD.bazel b/cscore/BUILD.bazel index 787b2cd4d02..14059f09851 100644 --- a/cscore/BUILD.bazel +++ b/cscore/BUILD.bazel @@ -1,20 +1,21 @@ load("@rules_java//java:defs.bzl", "java_binary", "java_library") java_library( - name = "cscore", + name = "cscore-java", srcs = glob(["src/main/java/**/*.java"]), visibility = ["//visibility:public"], deps = [ - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + "//wpiutil:wpiutil-java", "@bzlmodrio-opencv//libraries/java/opencv", ], ) java_binary( - name = "DevMain-Java", + name = "DevMain", srcs = ["src/dev/java/edu/wpi/first/cscore/DevMain.java"], + main_class = "edu.wpi.first.cscore.DevMain", deps = [ - "//cscore/src/main/java/edu/wpi/first/cscore", - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + ":cscore-java", + "//wpiutil:wpiutil-java", ], ) diff --git a/hal/BUILD.bazel b/hal/BUILD.bazel index 695c63a0e57..f79895d4d4e 100644 --- a/hal/BUILD.bazel +++ b/hal/BUILD.bazel @@ -16,24 +16,24 @@ filegroup( ) ATHENA_SRCS = glob([ - "athena/*.cpp", - "athena/*.h", - "athena/cpp/*.cpp", - "athena/ctre/*.cpp", - "athena/ctre/*.h", - "athena/rev/*.cpp", - "athena/rev/*.h", - "athena/frccansae/*.h", - "athena/mockdata/*.cpp", + "src/main/native/athena/*.cpp", + "src/main/native/athena/*.h", + "src/main/native/athena/cpp/*.cpp", + "src/main/native/athena/ctre/*.cpp", + "src/main/native/athena/ctre/*.h", + "src/main/native/athena/rev/*.cpp", + "src/main/native/athena/rev/*.h", + "src/main/native/athena/frccansae/*.h", + "src/main/native/athena/mockdata/*.cpp", ]) ATHENA_DEPS = ["@bzlmodrio-ni//libraries/cpp/ni:shared"] SIM_SRCS = glob([ - "sim/*.cpp", - "sim/mockdata/*.cpp", - "sim/*.h", - "sim/mockdata/*.h", + "src/main/native/sim/*.cpp", + "src/main/native/sim/mockdata/*.cpp", + "src/main/native/sim/*.h", + "src/main/native/sim/mockdata/*.h", ]) SIM_DEPS = [] @@ -62,17 +62,17 @@ cc_library( strip_include_prefix = "src/main/native/include", visibility = ["//visibility:public"], deps = [ - "//hal:generated_cc_headers", - "//wpiutil/src/main/native:wpiutil.static", + ":generated_cc_headers", + "//wpiutil:wpiutil.static", ] + HAL_DEPS, ) java_library( - name = "hal", + name = "hal-java", srcs = ["//hal:generated_java"] + glob(["src/main/java/**/*.java"]), visibility = ["//visibility:public"], deps = [ - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + "//wpiutil:wpiutil-java", ], ) @@ -80,17 +80,17 @@ cc_test( name = "hal-cpp-test", size = "small", srcs = glob([ - "**/*.cpp", - "**/*.h", + "src/test/native/**/*.cpp", + "src/test/native/**/*.h", ]), deps = [ - "//hal/src/main/native:wpiHal.static", + ":wpiHal.static", "//thirdparty/googletest", ], ) cc_binary( - name = "DevMain-Cpp", + name = "DevMain", srcs = ["src/dev/native/cpp/main.cpp"], deps = [ ":wpiHal.static", @@ -98,8 +98,9 @@ cc_binary( ) java_binary( - name = "DevMain-Java", + name = "DevMain-java", srcs = ["src/dev/java/edu/wpi/first/hal/DevMain.java"], + main_class = "edu.wpi.first.hal.DevMain", deps = [ ], ) diff --git a/ntcore/BUILD.bazel b/ntcore/BUILD.bazel index c9f13e25b60..9205c6725b5 100644 --- a/ntcore/BUILD.bazel +++ b/ntcore/BUILD.bazel @@ -32,7 +32,7 @@ cc_library( "src/main/native/cpp/net/*.inc", "src/main/native/cpp/net3/*.h", ]), - strip_include_prefix = "cpp", + strip_include_prefix = "src/main/native/cpp", ) cc_library( @@ -40,25 +40,25 @@ cc_library( srcs = glob( ["src/main/native/cpp/**"], exclude = ["src/main/native/cpp/jni/**"], - ) + ["//ntcore:generated_cc_source"], + ) + [":generated_cc_source"], hdrs = glob(["src/main/native/include/**/*"]), includes = ["src/main/native/include"], strip_include_prefix = "src/main/native/include", visibility = ["//visibility:public"], deps = [ + ":generated_cc_headers", ":private_includes", - "//ntcore:generated_cc_headers", - "//wpinet/src/main/native:wpinet.static", - "//wpiutil/src/main/native:wpiutil.static", + "//wpinet:wpinet.static", + "//wpiutil:wpiutil.static", ], ) java_library( - name = "networktables", - srcs = glob(["src/main/java/**/*.java"]) + ["//ntcore:generated_java"], + name = "networktables-java", + srcs = glob(["src/main/java/**/*.java"]) + [":generated_java"], visibility = ["//visibility:public"], deps = [ - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + "//wpiutil:wpiutil-java", "@maven//:us_hebi_quickbuf_quickbuf_runtime", ], ) @@ -67,8 +67,8 @@ cc_test( name = "ntcore-test", size = "small", srcs = glob([ - "**/*.cpp", - "**/*.h", + "src/test/native/**/*.cpp", + "src/test/native/**/*.h", ]), tags = [ "exclusive", @@ -76,14 +76,14 @@ cc_test( "no-tsan", ], deps = [ - "//ntcore/src/main/native:ntcore.static", + ":ntcore.static", "//thirdparty/googletest", - "//wpiutil/src/test/native:wpiutil-testlib", + "//wpiutil:wpiutil-testlib", ], ) cc_binary( - name = "DevMain-Cpp", + name = "DevMain-cpp", srcs = ["src/dev/native/cpp/main.cpp"], deps = [ ":ntcore.static", @@ -91,10 +91,11 @@ cc_binary( ) java_binary( - name = "DevMain-Java", + name = "DevMain-java", srcs = ["src/dev/java/edu/wpi/first/ntcore/DevMain.java"], + main_class = "edu.wpi.first.ntcore.DevMain", deps = [ - "//ntcore/src/main/java/edu/wpi/first/networktables", - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + "networktables-java", + "//wpiutil:wpiutil-java", ], ) diff --git a/wpilibj/BUILD.bazel b/wpilibj/BUILD.bazel index e05c7d83618..a334a90e395 100644 --- a/wpilibj/BUILD.bazel +++ b/wpilibj/BUILD.bazel @@ -1,8 +1,14 @@ load("@rules_cc//cc:defs.bzl", "cc_binary") load("@rules_java//java:defs.bzl", "java_binary", "java_library") -load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_library") load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file") +generate_version_file( + name = "generate-version", + output_file = "WPILibVersion.java", + template = "src/generate/WPILibVersion.java.in", + visibility = ["//visibility:public"], +) + filegroup( name = "generated_java", srcs = glob(["src/generated/main/java/**/*.java"]), @@ -11,59 +17,46 @@ filegroup( java_library( name = "wpilibj", - srcs = ["//wpilibj/src/generate:generate-version"] + glob(["src/main/java/**/*.java"]) + ["//wpilibj:generated_java"], + srcs = [":generate-version"] + glob(["src/main/java/**/*.java"]) + ["//wpilibj:generated_java"], visibility = ["//visibility:public"], deps = [ - "//cameraserver/src/main/java/edu/wpi/first:cameraserver", - "//cscore/src/main/java/edu/wpi/first/cscore", - "//hal/src/main/java/edu/wpi/first/hal", - "//ntcore/src/main/java/edu/wpi/first/networktables", - "//wpimath/src/main/java/edu/wpi/first/math:wpimath", - "//wpinet/src/main/java/edu/wpi/first/net:wpinet", - "//wpiunits/src/main/java/edu/wpi/first/units:wpiunits", - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + "//cameraserver:cameraserver-java", + "//cscore:cscore-java", + "//hal:hal-java", + "//ntcore:networktables-java", + "//wpimath:wpimath-java", + "//wpinet:wpinet-java", + "//wpiunits:wpiunits-java", + "//wpiutil:wpiutil-java", "@maven//:org_ejml_ejml_core", "@maven//:org_ejml_ejml_simple", ], ) cc_binary( - name = "DevMain-Cpp", + name = "DevMain-cpp", srcs = ["src/dev/native/cpp/main.cpp"], deps = [ ], ) java_binary( - name = "DevMain-Java", + name = "DevMain-java", srcs = ["src/dev/java/edu/wpi/first/wpilibj/DevMain.java"], + main_class = "edu.wpi.first.wpilibj.DevMain", deps = [ - "//hal/src/main/java/edu/wpi/first/hal", - "//ntcore/src/main/java/edu/wpi/first/networktables", - "//wpimath/src/main/java/edu/wpi/first/math:wpimath", - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + "//hal:hal-java", + "//ntcore:networktables-java", + "//wpimath:wpimath-java", + "//wpiutil:wpiutil-java", ], ) -wpilib_java_library( - name = "resources", - testonly = True, - resources = glob(["**"]), - visibility = ["//wpilibj/src/test:__subpackages__"], -) - -generate_version_file( - name = "generate-version", - output_file = "WPILibVersion.java", - template = "WPILibVersion.java.in", - visibility = ["//visibility:public"], -) - filegroup( name = "hid_schema", srcs = [ - "hids.json", - "hids.schema.json", + "src/generate/hids.json", + "src/generate/hids.schema.json", ], visibility = ["//visibility:public"], ) @@ -71,14 +64,14 @@ filegroup( filegroup( name = "pwm_schema", srcs = [ - "pwm_motor_controllers.json", + "src/generate/pwm_motor_controllers.json", ], visibility = ["//visibility:public"], ) filegroup( name = "templates", - srcs = glob(["*.jinja"]) + [ + srcs = glob(["src/generate/*.jinja"]) + [ ":hid_schema", ":pwm_schema", ], @@ -88,6 +81,6 @@ filegroup( java_library( name = "resources", testonly = True, - resources = glob(["**"]), + resources = glob(["src/test/resources/**"]), visibility = ["//wpilibj/src/test:__subpackages__"], ) diff --git a/wpimath/BUILD.bazel b/wpimath/BUILD.bazel index 77aa6f5d107..7a7133f4a55 100644 --- a/wpimath/BUILD.bazel +++ b/wpimath/BUILD.bazel @@ -8,12 +8,12 @@ filegroup( ) java_library( - name = "wpimath", - srcs = ["//wpimath:generated_java"] + glob(["src/main/java/**/*.java"]), + name = "wpimath-java", + srcs = [":generated_java"] + glob(["src/main/java/**/*.java"]), visibility = ["//visibility:public"], deps = [ - "//wpiunits/src/main/java/edu/wpi/first/units:wpiunits", - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + "//wpiunits:wpiunits-java", + "//wpiutil:wpiutil-java", "@maven//:com_fasterxml_jackson_core_jackson_annotations", "@maven//:com_fasterxml_jackson_core_jackson_core", "@maven//:com_fasterxml_jackson_core_jackson_databind", @@ -27,13 +27,14 @@ java_library( java_binary( name = "DevMain-Java", srcs = ["src/dev/java/edu/wpi/first/math/DevMain.java"], + main_class = "edu.wpi.first.math.DevMain", deps = [ - "//wpimath/src/main/java/edu/wpi/first/math:wpimath", + ":wpimath-java", ], ) py_binary( name = "ExponentialProfileModel", - srcs = ["ExponentialProfileModel.py"], + srcs = ["algorithms/ExponentialProfileModel.py"], tags = ["manual"], ) diff --git a/wpinet/BUILD.bazel b/wpinet/BUILD.bazel index e9d641147c6..04dbb9ae7c0 100644 --- a/wpinet/BUILD.bazel +++ b/wpinet/BUILD.bazel @@ -90,15 +90,15 @@ generate_resources( name = "generate-resources", namespace = "dlt", prefix = "DLT", - resource_files = glob(["resources/*"]), + resource_files = glob(["src/main/native/resources/*"]), ) filegroup( name = "native-srcs", srcs = ["generate-resources"] + select({ - "@bazel_tools//src/conditions:darwin": glob(["macOS/*"]), - "@bazel_tools//src/conditions:windows": glob(["windows/*"]), - "@rules_bzlmodrio_toolchains//constraints/combined:is_linux": glob(["linux/*"]), + "@bazel_tools//src/conditions:darwin": glob(["src/main/native/macOS/*"]), + "@bazel_tools//src/conditions:windows": glob(["src/main/native/windows/*"]), + "@rules_bzlmodrio_toolchains//constraints/combined:is_linux": glob(["src/main/native/linux/*"]), }), ) @@ -107,7 +107,7 @@ cc_library( hdrs = glob([ "src/main/native/cpp/*.h", ]), - strip_include_prefix = "cpp", + strip_include_prefix = "src/main/native/cpp", ) cc_library( @@ -127,16 +127,16 @@ cc_library( ":libuv-headers", ":private_includes", ":tcpsockets-headers", - "//wpiutil/src/main/native:wpiutil.static", + "//wpiutil:wpiutil.static", ], ) java_library( - name = "wpinet", + name = "wpinet-java", srcs = glob(["src/main/java/**/*.java"]), visibility = ["//visibility:public"], deps = [ - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + "//wpiutil:wpiutil-java", ], ) @@ -144,14 +144,14 @@ cc_test( name = "wpinet-test", size = "small", srcs = glob([ - "**/*.cpp", - "**/*.h", + "src/test/native/**/*.cpp", + "src/test/native/**/*.h", ]), tags = ["no-asan"], deps = [ + ":wpinet.static", "//thirdparty/googletest", - "//wpinet/src/main/native:wpinet.static", - "//wpiutil/src/test/native:wpiutil-testlib", + "//wpiutil:wpiutil-testlib", ], ) @@ -166,51 +166,52 @@ cc_binary( java_binary( name = "DevMain-Java", srcs = ["src/dev/java/edu/wpi/first/net/DevMain.java"], + main_class = "edu.wpi.first.net.DevMain", deps = [ - "//wpinet/src/main/java/edu/wpi/first/net:wpinet", - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + ":wpinet-java", + "//wpiutil:wpiutil-java", ], ) cc_binary( - name = "dsclient", - srcs = ["dsclient.cpp"], + name = "netconsoleServer", + srcs = ["src/netconsoleServer/native/cpp/main.cpp"], + linkopts = select({ + "@rules_bzlmodrio_toolchains//constraints/combined:is_linux": ["-lutil"], + "//conditions:default": [], + }), deps = [ ":wpinet.static", ], ) cc_binary( - name = "parallelconnect", - srcs = ["parallelconnect.cpp"], + name = "netconsoleTee", + srcs = ["src/netconsoleTee/native/cpp/main.cpp"], deps = [ ":wpinet.static", ], ) cc_binary( - name = "webserver", - srcs = ["webserver.cpp"], + name = "dsclient", + srcs = ["examples/dsclient/dsclient.cpp"], deps = [ ":wpinet.static", ], ) cc_binary( - name = "netconsoleServer", - srcs = ["main.cpp"], - linkopts = select({ - "@rules_bzlmodrio_toolchains//constraints/combined:is_linux": ["-lutil"], - "//conditions:default": [], - }), + name = "parallelconnect", + srcs = ["examples/parallelconnect/parallelconnect.cpp"], deps = [ ":wpinet.static", ], ) cc_binary( - name = "netconsoleTee", - srcs = ["main.cpp"], + name = "webserver", + srcs = ["examples/webserver/webserver.cpp"], deps = [ ":wpinet.static", ], diff --git a/wpiunits/BUILD.bazel b/wpiunits/BUILD.bazel index 7990a454c00..4d127410c79 100644 --- a/wpiunits/BUILD.bazel +++ b/wpiunits/BUILD.bazel @@ -1,7 +1,7 @@ load("@rules_java//java:defs.bzl", "java_binary", "java_library") java_library( - name = "wpiunits", + name = "wpiunits-java", srcs = glob(["src/main/java/**/*.java"]), visibility = ["//visibility:public"], deps = [], @@ -10,7 +10,8 @@ java_library( java_binary( name = "DevMain-Java", srcs = ["src/dev/java/edu/wpi/first/units/DevMain.java"], + main_class = "edu.wpi.first.units.DevMain", deps = [ - "//wpiunits/src/main/java/edu/wpi/first/units:wpiunits", + ":wpiunits-java", ], ) diff --git a/wpiutil/BUILD.bazel b/wpiutil/BUILD.bazel index 5acb6c64cb3..f7a0e1c44fe 100644 --- a/wpiutil/BUILD.bazel +++ b/wpiutil/BUILD.bazel @@ -118,17 +118,17 @@ generate_resources( name = "generate-resources", namespace = "dlt", prefix = "DLT", - resource_files = glob(["resources/*"]), + resource_files = glob(["src/main/native/resources/*"]), ) filegroup( name = "native-srcs", srcs = select({ "@bazel_tools//src/conditions:windows": glob([ - "windows/*.cpp", - "windows/*.h", + "src/main/native/windows/*.cpp", + "src/main/native/windows/*.h", ]), - "@rules_bzlmodrio_toolchains//constraints/combined:is_unix": glob(["unix/*.cpp"]), + "@rules_bzlmodrio_toolchains//constraints/combined:is_unix": glob(["src/main/native/unix/*.cpp"]), }), ) @@ -166,7 +166,7 @@ cc_library( ) java_library( - name = "wpiutil", + name = "wpiutil-java", srcs = glob(["src/main/java/**/*.java"]), visibility = ["//visibility:public"], deps = [ @@ -208,20 +208,21 @@ cc_binary( java_binary( name = "DevMain-Java", srcs = ["src/dev/java/edu/wpi/first/util/DevMain.java"], + main_class = "edu.wpi.first.util.DevMain", deps = [ - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + ":wpiutil-java", ], ) py_binary( name = "datalog", - srcs = ["datalog.py"], + srcs = ["examples/printlog/datalog.py"], tags = ["manual"], ) cc_binary( name = "printlog", - srcs = ["printlog.cpp"], + srcs = ["examples/printlog/printlog.cpp"], deps = [ ":wpiutil.static", ], @@ -229,16 +230,17 @@ cc_binary( cc_binary( name = "writelog", - srcs = ["writelog.cpp"], + srcs = ["examples/writelog/writelog.cpp"], deps = [ ":wpiutil.static", ], ) java_binary( - name = "printlog", - srcs = ["PrintLog.java"], + name = "printlog-java", + srcs = ["src/printlog/java/printlog/PrintLog.java"], + main_class = "printlog.PrintLog", deps = [ - "//wpiutil/src/main/java/edu/wpi/first/util:wpiutil", + ":wpiutil-java", ], ) From 3205b9cb236a5fc714718087b27fbaf8c5ffad76 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 24 Aug 2024 22:06:27 -0400 Subject: [PATCH 17/38] Code review --- .bazelrc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.bazelrc b/.bazelrc index 74d3a783b8d..2e7190cc9d9 100644 --- a/.bazelrc +++ b/.bazelrc @@ -36,8 +36,3 @@ build:remote_user --remote_download_toplevel # This config should be used on CI. It downloads at little as possible to complete the build build:ci --config=remote build:ci --remote_download_minimal - -build --proto_toolchain_for_cc=//:proto_cc_toolchain - -build:linux --per_file_copt=external/com_google_protobuf/...@-Wno-missing-field-initializers,-Wno-deprecated-enum-enum-conversion -build:macos --per_file_copt=external/com_google_protobuf/...@-Wno-deprecated-non-prototype From c62253f8f7b65496933dd888b801dbb0ebd96769 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 25 Aug 2024 03:28:18 -0400 Subject: [PATCH 18/38] Fixup --- .github/workflows/bazel.yml | 2 -- cameraserver/BUILD.bazel | 6 +++--- cscore/BUILD.bazel | 2 +- hal/BUILD.bazel | 4 ++-- ntcore/BUILD.bazel | 6 +++--- shared/bazel/compiler_flags/linux_flags.rc | 2 +- wpilibj/BUILD.bazel | 11 ++--------- wpinet/BUILD.bazel | 4 ++-- wpiutil/BUILD.bazel | 2 +- 9 files changed, 15 insertions(+), 24 deletions(-) diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index 62234c0e068..f65296f40c5 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -74,7 +74,6 @@ jobs: - config: "asan" - config: "ubsan" runs-on: ubuntu-22.04 - container: wpilib/ubuntu-base:22.04 name: "Sanitizer ${{ matrix.config }}" steps: - uses: actions/checkout@v4 @@ -91,7 +90,6 @@ jobs: uses: actions/setup-go@v5 with: go-version: 1.15.x - id: go - name: Install Buildifier run: | diff --git a/cameraserver/BUILD.bazel b/cameraserver/BUILD.bazel index 9f3a3d3c8dd..c0272b26bf4 100644 --- a/cameraserver/BUILD.bazel +++ b/cameraserver/BUILD.bazel @@ -17,14 +17,14 @@ java_library( ) cc_binary( - name = "DevMain-cpp", + name = "DevMain-Cpp", srcs = ["src/dev/native/cpp/main.cpp"], deps = [ ], ) java_binary( - name = "DevMain-java", + name = "DevMain-Java", srcs = ["src/dev/java/edu/wpi/first/cameraserver/DevMain.java"], main_class = "edu.wpi.first.cameraserver.DevMain", deps = [ @@ -32,7 +32,7 @@ java_binary( ) java_binary( - name = "multiCameraServer", + name = "multiCameraServer-java", srcs = ["multiCameraServer/src/main/java/edu/wpi/Main.java"], main_class = "edu.wpi.Main", deps = [ diff --git a/cscore/BUILD.bazel b/cscore/BUILD.bazel index 14059f09851..a2470f8afe1 100644 --- a/cscore/BUILD.bazel +++ b/cscore/BUILD.bazel @@ -11,7 +11,7 @@ java_library( ) java_binary( - name = "DevMain", + name = "DevMain-Java", srcs = ["src/dev/java/edu/wpi/first/cscore/DevMain.java"], main_class = "edu.wpi.first.cscore.DevMain", deps = [ diff --git a/hal/BUILD.bazel b/hal/BUILD.bazel index f79895d4d4e..44a7f0904a0 100644 --- a/hal/BUILD.bazel +++ b/hal/BUILD.bazel @@ -90,7 +90,7 @@ cc_test( ) cc_binary( - name = "DevMain", + name = "DevMain-Cpp", srcs = ["src/dev/native/cpp/main.cpp"], deps = [ ":wpiHal.static", @@ -98,7 +98,7 @@ cc_binary( ) java_binary( - name = "DevMain-java", + name = "DevMain-Java", srcs = ["src/dev/java/edu/wpi/first/hal/DevMain.java"], main_class = "edu.wpi.first.hal.DevMain", deps = [ diff --git a/ntcore/BUILD.bazel b/ntcore/BUILD.bazel index 9205c6725b5..2846c81e35e 100644 --- a/ntcore/BUILD.bazel +++ b/ntcore/BUILD.bazel @@ -64,7 +64,7 @@ java_library( ) cc_test( - name = "ntcore-test", + name = "ntcore-cpp-test", size = "small", srcs = glob([ "src/test/native/**/*.cpp", @@ -83,7 +83,7 @@ cc_test( ) cc_binary( - name = "DevMain-cpp", + name = "DevMain-Cpp", srcs = ["src/dev/native/cpp/main.cpp"], deps = [ ":ntcore.static", @@ -91,7 +91,7 @@ cc_binary( ) java_binary( - name = "DevMain-java", + name = "DevMain-Java", srcs = ["src/dev/java/edu/wpi/first/ntcore/DevMain.java"], main_class = "edu.wpi.first.ntcore.DevMain", deps = [ diff --git a/shared/bazel/compiler_flags/linux_flags.rc b/shared/bazel/compiler_flags/linux_flags.rc index c32d516691f..0a19c1d73d1 100644 --- a/shared/bazel/compiler_flags/linux_flags.rc +++ b/shared/bazel/compiler_flags/linux_flags.rc @@ -11,4 +11,4 @@ build:linux --copt=-Wextra build:linux --copt=-Werror # Not in nativetools -build:linux --copt=-Wno-deprecated-enum-enum-conversion +build:linux --cxxopt=-Wno-deprecated-enum-enum-conversion diff --git a/wpilibj/BUILD.bazel b/wpilibj/BUILD.bazel index a334a90e395..045148ffe0c 100644 --- a/wpilibj/BUILD.bazel +++ b/wpilibj/BUILD.bazel @@ -34,14 +34,14 @@ java_library( ) cc_binary( - name = "DevMain-cpp", + name = "DevMain-Cpp", srcs = ["src/dev/native/cpp/main.cpp"], deps = [ ], ) java_binary( - name = "DevMain-java", + name = "DevMain-Java", srcs = ["src/dev/java/edu/wpi/first/wpilibj/DevMain.java"], main_class = "edu.wpi.first.wpilibj.DevMain", deps = [ @@ -77,10 +77,3 @@ filegroup( ], visibility = ["//visibility:public"], ) - -java_library( - name = "resources", - testonly = True, - resources = glob(["src/test/resources/**"]), - visibility = ["//wpilibj/src/test:__subpackages__"], -) diff --git a/wpinet/BUILD.bazel b/wpinet/BUILD.bazel index 04dbb9ae7c0..894f3e039cf 100644 --- a/wpinet/BUILD.bazel +++ b/wpinet/BUILD.bazel @@ -141,7 +141,7 @@ java_library( ) cc_test( - name = "wpinet-test", + name = "wpinet-cpp-test", size = "small", srcs = glob([ "src/test/native/**/*.cpp", @@ -164,7 +164,7 @@ cc_binary( ) java_binary( - name = "DevMain-Java", + name = "DevMain-java", srcs = ["src/dev/java/edu/wpi/first/net/DevMain.java"], main_class = "edu.wpi.first.net.DevMain", deps = [ diff --git a/wpiutil/BUILD.bazel b/wpiutil/BUILD.bazel index f7a0e1c44fe..07d5a2df13c 100644 --- a/wpiutil/BUILD.bazel +++ b/wpiutil/BUILD.bazel @@ -185,7 +185,7 @@ cc_library( ) cc_test( - name = "wpiutil-test", + name = "wpiutil-cpp-test", size = "small", srcs = glob(["src/test/native/cpp/**"]), linkstatic = True, From 27a07a9fc6162478143097da943d8e24226d27cc Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Tue, 27 Aug 2024 14:07:43 -0400 Subject: [PATCH 19/38] Code review --- hal/BUILD.bazel | 19 ++----------------- wpinet/BUILD.bazel | 4 ++-- wpiutil/BUILD.bazel | 4 ++-- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/hal/BUILD.bazel b/hal/BUILD.bazel index 44a7f0904a0..549c6bfd15e 100644 --- a/hal/BUILD.bazel +++ b/hal/BUILD.bazel @@ -15,26 +15,11 @@ filegroup( visibility = ["//hal:__subpackages__"], ) -ATHENA_SRCS = glob([ - "src/main/native/athena/*.cpp", - "src/main/native/athena/*.h", - "src/main/native/athena/cpp/*.cpp", - "src/main/native/athena/ctre/*.cpp", - "src/main/native/athena/ctre/*.h", - "src/main/native/athena/rev/*.cpp", - "src/main/native/athena/rev/*.h", - "src/main/native/athena/frccansae/*.h", - "src/main/native/athena/mockdata/*.cpp", -]) +ATHENA_SRCS = glob(["src/main/native/athena/**"]) ATHENA_DEPS = ["@bzlmodrio-ni//libraries/cpp/ni:shared"] -SIM_SRCS = glob([ - "src/main/native/sim/*.cpp", - "src/main/native/sim/mockdata/*.cpp", - "src/main/native/sim/*.h", - "src/main/native/sim/mockdata/*.h", -]) +SIM_SRCS = glob(["src/main/native/sim/**"]) SIM_DEPS = [] diff --git a/wpinet/BUILD.bazel b/wpinet/BUILD.bazel index 894f3e039cf..78469e9b40d 100644 --- a/wpinet/BUILD.bazel +++ b/wpinet/BUILD.bazel @@ -88,8 +88,8 @@ filegroup( generate_resources( name = "generate-resources", - namespace = "dlt", - prefix = "DLT", + namespace = "wpi", + prefix = "WPI", resource_files = glob(["src/main/native/resources/*"]), ) diff --git a/wpiutil/BUILD.bazel b/wpiutil/BUILD.bazel index 07d5a2df13c..5c140510c95 100644 --- a/wpiutil/BUILD.bazel +++ b/wpiutil/BUILD.bazel @@ -116,8 +116,8 @@ cc_library( generate_resources( name = "generate-resources", - namespace = "dlt", - prefix = "DLT", + namespace = "wpi", + prefix = "WPI", resource_files = glob(["src/main/native/resources/*"]), ) From fbef3bd1cf1ab88e901f46025b652184bc73e778 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Thu, 29 Aug 2024 17:24:15 -0400 Subject: [PATCH 20/38] Add readme, run debug builds --- .github/workflows/bazel.yml | 31 +++++++++++++++++++++---------- README-Bazel.md | 27 +++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 README-Bazel.md diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index f65296f40c5..6426c3e8649 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -27,8 +27,12 @@ jobs: java-version: 17 architecture: x64 - - name: Build - run: bazel --output_user_root=C:\\bazelroot ${{ matrix.action }} -k ... --config=ci ${{ matrix.config }} --verbose_failures + - name: Build Release + run: bazel --output_user_root=C:\\bazelroot ${{ matrix.action }} -k ... --config=ci -c opt ${{ matrix.config }} --verbose_failures + shell: bash + + - name: Build Debug + run: bazel --output_user_root=C:\\bazelroot ${{ matrix.action }} -k ... --config=ci -c dbg ${{ matrix.config }} --verbose_failures shell: bash build-mac: @@ -36,8 +40,8 @@ jobs: fail-fast: false matrix: include: - - { name: "Mac (native)", os: macos-14, action: "test", config: "--config=macos -c opt", } - - { name: "Mac (roborio)", os: macos-14, action: "build", config: "--config=roborio -c opt", } + - { name: "Mac (native)", os: macos-14, action: "test", config: "--config=macos", } + - { name: "Mac (roborio)", os: macos-14, action: "build", config: "--config=roborio", } name: "${{ matrix.name }}" runs-on: ${{ matrix.os }} @@ -45,8 +49,12 @@ jobs: - uses: actions/checkout@v4 with: { fetch-depth: 0 } - - name: Build - run: bazel ${{ matrix.action }} -k ... --config=ci ${{ matrix.config }} --nojava_header_compilation --verbose_failures + - name: Build Release + run: bazel ${{ matrix.action }} -k ... --config=ci -c opt ${{ matrix.config }} --nojava_header_compilation --verbose_failures + shell: bash + + - name: Build Debug + run: bazel ${{ matrix.action }} -k ... --config=ci -c dbg ${{ matrix.config }} --nojava_header_compilation --verbose_failures shell: bash build-linux: @@ -54,8 +62,8 @@ jobs: fail-fast: false matrix: include: - - { name: "Linux (native)", os: ubuntu-22.04, action: "test", config: "--config=linux -c opt", } - - { name: "Linux (roborio)", os: ubuntu-22.04, action: "build", config: "--config=roborio -c opt", } + - { name: "Linux (native)", os: ubuntu-22.04, action: "test", config: "--config=linux", } + - { name: "Linux (roborio)", os: ubuntu-22.04, action: "build", config: "--config=roborio", } name: "${{ matrix.name }}" runs-on: ${{ matrix.os }} steps: @@ -63,8 +71,11 @@ jobs: with: { fetch-depth: 0 } - uses: bazelbuild/setup-bazelisk@v3 - - name: Build and Test - run: bazel ${{ matrix.action }} ... --config=ci ${{ matrix.config }} -k --verbose_failures + - name: Build and Test Release + run: bazel ${{ matrix.action }} ... --config=ci -c opt ${{ matrix.config }} -k --verbose_failures + + - name: Build and Test Debug + run: bazel ${{ matrix.action }} ... --config=ci -c dbg ${{ matrix.config }} -k --verbose_failures build-sanitizers: strategy: diff --git a/README-Bazel.md b/README-Bazel.md new file mode 100644 index 00000000000..d97cb5d99a9 --- /dev/null +++ b/README-Bazel.md @@ -0,0 +1,27 @@ +# WPILib Bazel Support + +WPILib is normally built with Gradle, but [Bazel](https://www.bazel.build/) can also be used to increase development speed due to the superior caching ability and the ability to use remote caching and remote execution (on select platforms) + + +## Prerequisites +- Install [Bazelisk](https://github.com/bazelbuild/bazelisk/releases) and add it to your path. Bazelisk is a wrapper that will download the correct version of bazel specified in the repository. Note: You can alias/rename the binary to `bazel` if you want to keep the familiar `bazel build` vs `bazelisk build` syntax. +- Java8+. The build will hermetically use java11, but bazel requires some version of the JRE be installed to run. +- Python 3 + +## Building +To build the entire repository, simply run `bazel build //...`. To run all of the unit tests, run `bazel test //...` +Other examples: +- `bazel build //wpimath/...` - Builds every target in the wpimath folder +- `bazel test //wpiutil:wpiutil-cpp-test` - Runs only the cpp test target in the wpiutil folder +- `bazel coverage //wpiutil/...` - (*Nix only) - Runs a code coverage report for both C++ and Java on all the targets under wpiutil + +## User settings +When invoking bazel, it will check if `user.bazelrc` exists for additional, user specified flags. You can use these settings to do things like always ignore buildin a specific folder, or limiting the CPU/RAM usage during a build. +Examples: +- `build --build_tag_filters=-wpi-example` - Do not build any targets tagged with `wpi-example` (Currently all of the targets in wpilibcExamples and wpilibjExamples contain this tag) +- `build -c opt` - Always build optimized targets. The default compiler flags were chosen to build as fast as possible, and thus don't contain many optimizations +- `build -k` - `-k` is analogous to the MAKE flag `--keep-going`, so the build will not stop on the first error. +- ``` + build --local_ram_resources=HOST_RAM*.5 # Don't use more than half my RAM when building + build --local_cpu_resources=HOST_CPUS-1 # Leave one core alone + ``` \ No newline at end of file From 341e7fa709ebcab31430e5991a22734657f0f212 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Thu, 29 Aug 2024 21:14:04 -0400 Subject: [PATCH 21/38] format --- README-Bazel.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README-Bazel.md b/README-Bazel.md index d97cb5d99a9..3eff66f2548 100644 --- a/README-Bazel.md +++ b/README-Bazel.md @@ -24,4 +24,4 @@ Examples: - ``` build --local_ram_resources=HOST_RAM*.5 # Don't use more than half my RAM when building build --local_cpu_resources=HOST_CPUS-1 # Leave one core alone - ``` \ No newline at end of file + ``` From 951ce90283db724b0703ef88184797c5729003ea Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 31 Aug 2024 00:21:51 -0400 Subject: [PATCH 22/38] Remove old language from readme --- README-Bazel.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README-Bazel.md b/README-Bazel.md index 3eff66f2548..2a3bb45b756 100644 --- a/README-Bazel.md +++ b/README-Bazel.md @@ -5,8 +5,6 @@ WPILib is normally built with Gradle, but [Bazel](https://www.bazel.build/) can ## Prerequisites - Install [Bazelisk](https://github.com/bazelbuild/bazelisk/releases) and add it to your path. Bazelisk is a wrapper that will download the correct version of bazel specified in the repository. Note: You can alias/rename the binary to `bazel` if you want to keep the familiar `bazel build` vs `bazelisk build` syntax. -- Java8+. The build will hermetically use java11, but bazel requires some version of the JRE be installed to run. -- Python 3 ## Building To build the entire repository, simply run `bazel build //...`. To run all of the unit tests, run `bazel test //...` From 20afb6e93e536f5a766181aedfe1b2e092c03520 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 31 Aug 2024 12:28:53 -0400 Subject: [PATCH 23/38] Apply suggestions from code review Co-authored-by: David Vo --- hal/BUILD.bazel | 4 ++-- wpilibj/BUILD.bazel | 2 +- wpiunits/BUILD.bazel | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hal/BUILD.bazel b/hal/BUILD.bazel index 549c6bfd15e..5d893e68591 100644 --- a/hal/BUILD.bazel +++ b/hal/BUILD.bazel @@ -38,7 +38,7 @@ filegroup( cc_library( name = "wpiHal.static", - srcs = ["platform-srcs"] + glob( + srcs = [":platform-srcs"] + glob( ["src/main/native/cpp/**"], exclude = ["src/main/native/cpp/jni/**"], ), @@ -54,7 +54,7 @@ cc_library( java_library( name = "hal-java", - srcs = ["//hal:generated_java"] + glob(["src/main/java/**/*.java"]), + srcs = [":generated_java"] + glob(["src/main/java/**/*.java"]), visibility = ["//visibility:public"], deps = [ "//wpiutil:wpiutil-java", diff --git a/wpilibj/BUILD.bazel b/wpilibj/BUILD.bazel index 045148ffe0c..fbef3321f70 100644 --- a/wpilibj/BUILD.bazel +++ b/wpilibj/BUILD.bazel @@ -17,7 +17,7 @@ filegroup( java_library( name = "wpilibj", - srcs = [":generate-version"] + glob(["src/main/java/**/*.java"]) + ["//wpilibj:generated_java"], + srcs = [":generate-version", ":generated_java"] + glob(["src/main/java/**/*.java"]), visibility = ["//visibility:public"], deps = [ "//cameraserver:cameraserver-java", diff --git a/wpiunits/BUILD.bazel b/wpiunits/BUILD.bazel index 4d127410c79..471c8c96a7b 100644 --- a/wpiunits/BUILD.bazel +++ b/wpiunits/BUILD.bazel @@ -1,7 +1,7 @@ load("@rules_java//java:defs.bzl", "java_binary", "java_library") java_library( - name = "wpiunits-java", + name = "wpiunits", srcs = glob(["src/main/java/**/*.java"]), visibility = ["//visibility:public"], deps = [], From 30324d860ff2e4c08d3a0e8139644f86f717b93e Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 31 Aug 2024 12:32:27 -0400 Subject: [PATCH 24/38] Fixup review suggestions --- wpilibj/BUILD.bazel | 2 +- wpimath/BUILD.bazel | 2 +- wpiunits/BUILD.bazel | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wpilibj/BUILD.bazel b/wpilibj/BUILD.bazel index fbef3321f70..8c10b5d35f2 100644 --- a/wpilibj/BUILD.bazel +++ b/wpilibj/BUILD.bazel @@ -26,7 +26,7 @@ java_library( "//ntcore:networktables-java", "//wpimath:wpimath-java", "//wpinet:wpinet-java", - "//wpiunits:wpiunits-java", + "//wpiunits", "//wpiutil:wpiutil-java", "@maven//:org_ejml_ejml_core", "@maven//:org_ejml_ejml_simple", diff --git a/wpimath/BUILD.bazel b/wpimath/BUILD.bazel index 7a7133f4a55..2f650293fdb 100644 --- a/wpimath/BUILD.bazel +++ b/wpimath/BUILD.bazel @@ -12,7 +12,7 @@ java_library( srcs = [":generated_java"] + glob(["src/main/java/**/*.java"]), visibility = ["//visibility:public"], deps = [ - "//wpiunits:wpiunits-java", + "//wpiunits", "//wpiutil:wpiutil-java", "@maven//:com_fasterxml_jackson_core_jackson_annotations", "@maven//:com_fasterxml_jackson_core_jackson_core", diff --git a/wpiunits/BUILD.bazel b/wpiunits/BUILD.bazel index 471c8c96a7b..c0b6896e616 100644 --- a/wpiunits/BUILD.bazel +++ b/wpiunits/BUILD.bazel @@ -12,6 +12,6 @@ java_binary( srcs = ["src/dev/java/edu/wpi/first/units/DevMain.java"], main_class = "edu.wpi.first.units.DevMain", deps = [ - ":wpiunits-java", + ":wpiunits", ], ) From 90967d42b729f7235110226e4c8d2747fc0134a5 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 31 Aug 2024 12:35:03 -0400 Subject: [PATCH 25/38] Buildifier --- cameraserver/BUILD.bazel | 15 --------------- cameraserver/multiCameraServer/BUILD.bazel | 16 ++++++++++++++++ wpilibj/BUILD.bazel | 5 ++++- 3 files changed, 20 insertions(+), 16 deletions(-) create mode 100644 cameraserver/multiCameraServer/BUILD.bazel diff --git a/cameraserver/BUILD.bazel b/cameraserver/BUILD.bazel index c0272b26bf4..542f0f3c961 100644 --- a/cameraserver/BUILD.bazel +++ b/cameraserver/BUILD.bazel @@ -30,18 +30,3 @@ java_binary( deps = [ ], ) - -java_binary( - name = "multiCameraServer-java", - srcs = ["multiCameraServer/src/main/java/edu/wpi/Main.java"], - main_class = "edu.wpi.Main", - deps = [ - ":cameraserver-java", - "//cscore:cscore-java", - "//hal:hal-java", - "//ntcore:networktables-java", - "//wpimath:wpimath-java", - "//wpiutil:wpiutil-java", - "@maven//:com_google_code_gson_gson", - ], -) diff --git a/cameraserver/multiCameraServer/BUILD.bazel b/cameraserver/multiCameraServer/BUILD.bazel new file mode 100644 index 00000000000..470e9c5bce4 --- /dev/null +++ b/cameraserver/multiCameraServer/BUILD.bazel @@ -0,0 +1,16 @@ +load("@rules_java//java:defs.bzl", "java_binary") + +java_binary( + name = "multiCameraServer-java", + srcs = ["src/main/java/edu/wpi/Main.java"], + main_class = "edu.wpi.Main", + deps = [ + "//cameraserver:cameraserver-java", + "//cscore:cscore-java", + "//hal:hal-java", + "//ntcore:networktables-java", + "//wpimath:wpimath-java", + "//wpiutil:wpiutil-java", + "@maven//:com_google_code_gson_gson", + ], +) diff --git a/wpilibj/BUILD.bazel b/wpilibj/BUILD.bazel index 8c10b5d35f2..f0a9359ae91 100644 --- a/wpilibj/BUILD.bazel +++ b/wpilibj/BUILD.bazel @@ -17,7 +17,10 @@ filegroup( java_library( name = "wpilibj", - srcs = [":generate-version", ":generated_java"] + glob(["src/main/java/**/*.java"]), + srcs = [ + ":generate-version", + ":generated_java", + ] + glob(["src/main/java/**/*.java"]), visibility = ["//visibility:public"], deps = [ "//cameraserver:cameraserver-java", From efbef299d6e18ab71ca4bddacfbf6a12275065f9 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 Sep 2024 23:05:36 -0400 Subject: [PATCH 26/38] Fix build after units update; cherry-pick from maven experimental branch --- hal/BUILD.bazel | 2 +- ntcore/BUILD.bazel | 2 +- thirdparty/googletest/BUILD.bazel | 2 +- wpinet/BUILD.bazel | 2 +- wpiunits/BUILD.bazel | 2 +- wpiutil/BUILD.bazel | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hal/BUILD.bazel b/hal/BUILD.bazel index 5d893e68591..340a74c65e0 100644 --- a/hal/BUILD.bazel +++ b/hal/BUILD.bazel @@ -70,7 +70,7 @@ cc_test( ]), deps = [ ":wpiHal.static", - "//thirdparty/googletest", + "//thirdparty/googletest:googletest.static", ], ) diff --git a/ntcore/BUILD.bazel b/ntcore/BUILD.bazel index 2846c81e35e..0e7cea571dd 100644 --- a/ntcore/BUILD.bazel +++ b/ntcore/BUILD.bazel @@ -77,7 +77,7 @@ cc_test( ], deps = [ ":ntcore.static", - "//thirdparty/googletest", + "//thirdparty/googletest:googletest.static", "//wpiutil:wpiutil-testlib", ], ) diff --git a/thirdparty/googletest/BUILD.bazel b/thirdparty/googletest/BUILD.bazel index 6db884b78c9..198ae1e0c2f 100644 --- a/thirdparty/googletest/BUILD.bazel +++ b/thirdparty/googletest/BUILD.bazel @@ -1,7 +1,7 @@ load("@rules_cc//cc:defs.bzl", "cc_library") cc_library( - name = "googletest", + name = "googletest.static", srcs = glob(["src/**"]), hdrs = glob(["include/**"]), includes = ["src/googletest"], diff --git a/wpinet/BUILD.bazel b/wpinet/BUILD.bazel index 78469e9b40d..c6bdebae7a0 100644 --- a/wpinet/BUILD.bazel +++ b/wpinet/BUILD.bazel @@ -150,7 +150,7 @@ cc_test( tags = ["no-asan"], deps = [ ":wpinet.static", - "//thirdparty/googletest", + "//thirdparty/googletest:googletest.static", "//wpiutil:wpiutil-testlib", ], ) diff --git a/wpiunits/BUILD.bazel b/wpiunits/BUILD.bazel index c0b6896e616..d6686308a97 100644 --- a/wpiunits/BUILD.bazel +++ b/wpiunits/BUILD.bazel @@ -2,7 +2,7 @@ load("@rules_java//java:defs.bzl", "java_binary", "java_library") java_library( name = "wpiunits", - srcs = glob(["src/main/java/**/*.java"]), + srcs = glob(["src/main/java/**/*.java"]) + glob(["src/generated/main/java/**/*.java"]), visibility = ["//visibility:public"], deps = [], ) diff --git a/wpiutil/BUILD.bazel b/wpiutil/BUILD.bazel index 5c140510c95..746117f0c63 100644 --- a/wpiutil/BUILD.bazel +++ b/wpiutil/BUILD.bazel @@ -193,7 +193,7 @@ cc_test( deps = [ ":wpiutil.static", ":wpiutil-testlib", - "//thirdparty/googletest", + "//thirdparty/googletest:googletest.static", ], ) From 0faf27e7ee5a2031d6b57e8b2c247a5fe3998871 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Wed, 11 Sep 2024 23:49:55 -0400 Subject: [PATCH 27/38] Merge and fix new third party library --- wpiutil/BUILD.bazel | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/wpiutil/BUILD.bazel b/wpiutil/BUILD.bazel index 746117f0c63..036f1881e1b 100644 --- a/wpiutil/BUILD.bazel +++ b/wpiutil/BUILD.bazel @@ -13,6 +13,16 @@ cc_library( visibility = ["//wpiutil:__subpackages__"], ) +cc_library( + name = "concurrentqueue-headers", + hdrs = glob([ + "src/main/native/thirdparty/concurrentqueue/include/**/*", + ]), + includes = ["src/main/native/thirdparty/concurrentqueue/include"], + strip_include_prefix = "src/main/native/thirdparty/concurrentqueue/include", + visibility = ["//wpiutil:__subpackages__"], +) + cc_library( name = "fmtlib-headers", hdrs = glob([ @@ -151,6 +161,7 @@ cc_library( strip_include_prefix = "src/main/native/include", visibility = ["//visibility:public"], deps = [ + ":concurrentqueue-headers", ":expected-headers", ":fmtlib-headers", ":json-headers", From 1fafe614ad2a46ce99f81829246074f202a2fcb3 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Wed, 11 Sep 2024 23:50:41 -0400 Subject: [PATCH 28/38] Blindly try artifactory endpoint --- .bazelrc | 6 ------ .github/workflows/bazel.yml | 9 +++++++++ .gitignore | 1 + 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.bazelrc b/.bazelrc index 2e7190cc9d9..4958fb1d16a 100644 --- a/.bazelrc +++ b/.bazelrc @@ -23,12 +23,6 @@ build:build_cpp --test_tag_filters=+allwpilib-build-cpp --build_tag_filters=+all build:no_example --test_tag_filters=-wpi-example --build_tag_filters=-wpi-example test:no_example --test_tag_filters=-wpi-example --build_tag_filters=-wpi-example - -build:remote --bes_results_url=https://app.buildbuddy.io/invocation/ -build:remote --bes_backend=grpcs://cloud.buildbuddy.io -build:remote --remote_cache=grpcs://cloud.buildbuddy.io -build:remote --remote_timeout=3600 - # This config should be used locally. It downloads more than the CI version build:remote_user --config=remote build:remote_user --remote_download_toplevel diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index 6426c3e8649..1ef6c9afc1d 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -26,6 +26,9 @@ jobs: distribution: 'zulu' java-version: 17 architecture: x64 + + - name: Set artifactory cache key + run: echo "build:ci --remote_header=https://${{ secrets.ARTIFACTORY_USERNAME }}:${{ secrets.ARTIFACTORY_PASSWORD }}@frcmaven.wpi.edu/artifactory/wpilib-generic-cache-bazel-local" > bazel_auth.rc - name: Build Release run: bazel --output_user_root=C:\\bazelroot ${{ matrix.action }} -k ... --config=ci -c opt ${{ matrix.config }} --verbose_failures @@ -48,6 +51,9 @@ jobs: steps: - uses: actions/checkout@v4 with: { fetch-depth: 0 } + + - name: Set artifactory cache key + run: echo "build:ci --remote_header=https://${{ secrets.ARTIFACTORY_USERNAME }}:${{ secrets.ARTIFACTORY_PASSWORD }}@frcmaven.wpi.edu/artifactory/wpilib-generic-cache-bazel-local" > bazel_auth.rc - name: Build Release run: bazel ${{ matrix.action }} -k ... --config=ci -c opt ${{ matrix.config }} --nojava_header_compilation --verbose_failures @@ -70,6 +76,9 @@ jobs: - uses: actions/checkout@v4 with: { fetch-depth: 0 } - uses: bazelbuild/setup-bazelisk@v3 + + - name: Set artifactory cache key + run: echo "build:ci --remote_header=https://${{ secrets.ARTIFACTORY_USERNAME }}:${{ secrets.ARTIFACTORY_PASSWORD }}@wpilib.jfrog.io/wpilib-generic-cache-bazel-local" > bazel_auth.rc - name: Build and Test Release run: bazel ${{ matrix.action }} ... --config=ci -c opt ${{ matrix.config }} -k --verbose_failures diff --git a/.gitignore b/.gitignore index 333895f9f39..ff4b8ff2265 100644 --- a/.gitignore +++ b/.gitignore @@ -249,6 +249,7 @@ imgui.ini /bazel-* user.bazelrc coverage_report/ +bazel_auth.rc # ctest /Testing/ From e21e104100e0db1f547d4f3a5e9107b884f2644f Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Wed, 11 Sep 2024 23:56:24 -0400 Subject: [PATCH 29/38] Fixup --- .bazelrc | 1 - 1 file changed, 1 deletion(-) diff --git a/.bazelrc b/.bazelrc index 4958fb1d16a..bc9e1013091 100644 --- a/.bazelrc +++ b/.bazelrc @@ -28,5 +28,4 @@ build:remote_user --config=remote build:remote_user --remote_download_toplevel # This config should be used on CI. It downloads at little as possible to complete the build -build:ci --config=remote build:ci --remote_download_minimal From b9e7b82138bdc5abdfd82e874cca714daff8fd83 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Wed, 11 Sep 2024 23:58:53 -0400 Subject: [PATCH 30/38] Forgot to add bazel auth include --- .bazelrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.bazelrc b/.bazelrc index bc9e1013091..4103911d37c 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,3 +1,4 @@ +try-import %workspace%/bazel_auth.rc try-import %workspace%/user.bazelrc common --noenable_bzlmod From 424f06e2424b23df3ab8f46cd914893f4622199c Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Thu, 12 Sep 2024 00:05:28 -0400 Subject: [PATCH 31/38] Try without auth to see what happens --- .github/workflows/bazel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index 1ef6c9afc1d..32f2147f76d 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -78,7 +78,7 @@ jobs: - uses: bazelbuild/setup-bazelisk@v3 - name: Set artifactory cache key - run: echo "build:ci --remote_header=https://${{ secrets.ARTIFACTORY_USERNAME }}:${{ secrets.ARTIFACTORY_PASSWORD }}@wpilib.jfrog.io/wpilib-generic-cache-bazel-local" > bazel_auth.rc + run: echo "build:ci --remote_header=https://wpilib.jfrog.io/wpilib-generic-cache-bazel-local" > bazel_auth.rc - name: Build and Test Release run: bazel ${{ matrix.action }} ... --config=ci -c opt ${{ matrix.config }} -k --verbose_failures From ce489b8130e57f18cae4430b29fe048518e7eb92 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Thu, 12 Sep 2024 00:14:27 -0400 Subject: [PATCH 32/38] Was using the wrong parameter... --- .github/workflows/bazel.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index 32f2147f76d..b1d64ca9e3a 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -28,7 +28,7 @@ jobs: architecture: x64 - name: Set artifactory cache key - run: echo "build:ci --remote_header=https://${{ secrets.ARTIFACTORY_USERNAME }}:${{ secrets.ARTIFACTORY_PASSWORD }}@frcmaven.wpi.edu/artifactory/wpilib-generic-cache-bazel-local" > bazel_auth.rc + run: echo "build:ci --remote_cache=https://frcmaven.wpi.edu/artifactory/wpilib-generic-cache-bazel-local" > bazel_auth.rc - name: Build Release run: bazel --output_user_root=C:\\bazelroot ${{ matrix.action }} -k ... --config=ci -c opt ${{ matrix.config }} --verbose_failures @@ -53,7 +53,7 @@ jobs: with: { fetch-depth: 0 } - name: Set artifactory cache key - run: echo "build:ci --remote_header=https://${{ secrets.ARTIFACTORY_USERNAME }}:${{ secrets.ARTIFACTORY_PASSWORD }}@frcmaven.wpi.edu/artifactory/wpilib-generic-cache-bazel-local" > bazel_auth.rc + run: echo "build:ci --remote_cache=https://frcmaven.wpi.edu/artifactory/wpilib-generic-cache-bazel-local" > bazel_auth.rc - name: Build Release run: bazel ${{ matrix.action }} -k ... --config=ci -c opt ${{ matrix.config }} --nojava_header_compilation --verbose_failures @@ -78,7 +78,7 @@ jobs: - uses: bazelbuild/setup-bazelisk@v3 - name: Set artifactory cache key - run: echo "build:ci --remote_header=https://wpilib.jfrog.io/wpilib-generic-cache-bazel-local" > bazel_auth.rc + run: echo "build:ci --remote_cache=https://wpilib.jfrog.io/artifactory/wpilib-generic-cache-bazel-local" > bazel_auth.rc - name: Build and Test Release run: bazel ${{ matrix.action }} ... --config=ci -c opt ${{ matrix.config }} -k --verbose_failures From c5db8e68151b6d826f3c59b3a0ddd8af6aa43895 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Wed, 18 Sep 2024 23:46:50 -0400 Subject: [PATCH 33/38] Change back to buildbuddy --- .bazelrc | 21 +++++++++++-- .bazelversion | 2 +- .github/actions/setup-build-buddy/action.yml | 27 +++++++++++++++++ .github/workflows/bazel.yml | 31 ++++++++++++++------ wpiutil/BUILD.bazel | 11 +++++++ 5 files changed, 80 insertions(+), 12 deletions(-) create mode 100644 .github/actions/setup-build-buddy/action.yml diff --git a/.bazelrc b/.bazelrc index 4103911d37c..cfc99909ad7 100644 --- a/.bazelrc +++ b/.bazelrc @@ -24,9 +24,26 @@ build:build_cpp --test_tag_filters=+allwpilib-build-cpp --build_tag_filters=+all build:no_example --test_tag_filters=-wpi-example --build_tag_filters=-wpi-example test:no_example --test_tag_filters=-wpi-example --build_tag_filters=-wpi-example +# Build Buddy Cache Setup +build:build_buddy --bes_results_url=https://app.buildbuddy.io/invocation/ +build:build_buddy --bes_backend=grpcs://remote.buildbuddy.io +build:build_buddy --remote_cache=grpcs://remote.buildbuddy.io +build:build_buddy --remote_timeout=3600 + +# Additional suggestions from buildbuddy for speed +build:build_buddy --experimental_remote_cache_compression +build:build_buddy --experimental_remote_cache_compression_threshold=100 +build:build_buddy --noslim_profile +build:build_buddy --experimental_profile_include_target_label +build:build_buddy --experimental_profile_include_primary_output +build:build_buddy --nolegacy_important_outputs + +build:build_buddy_readonly --noremote_upload_local_results + # This config should be used locally. It downloads more than the CI version -build:remote_user --config=remote +build:remote_user --config=build_buddy +build:remote_user --config=build_buddy_readonly build:remote_user --remote_download_toplevel -# This config should be used on CI. It downloads at little as possible to complete the build +build:ci --config=build_buddy build:ci --remote_download_minimal diff --git a/.bazelversion b/.bazelversion index 0ee843cc604..643916c03f1 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -7.2.0 +7.3.1 diff --git a/.github/actions/setup-build-buddy/action.yml b/.github/actions/setup-build-buddy/action.yml new file mode 100644 index 00000000000..c3b8ec3caa5 --- /dev/null +++ b/.github/actions/setup-build-buddy/action.yml @@ -0,0 +1,27 @@ +name: 'Setup BuildBuddy acache' +description: 'Sets up the build buddy cache to be readonly / writing based on the presence of environment variables' + +inputs: + token: + description: 'Build Buddy API token' + +runs: + using: "composite" + steps: + - name: Setup without key + env: + API_KEY: ${{ inputs.token }} + if: ${{ env.API_KEY == '' }} + shell: bash + run: | + echo "No API key secret detected, will setup readonly cache" + echo "build:ci --build_buddy_readonly" > bazel_auth.rc + + - name: Set with key + env: + API_KEY: ${{ inputs.token }} + if: ${{ env.API_KEY != '' }} + shell: bash + run: | + echo "API Key detected!" + echo "build:build_buddy --remote_header=x-buildbuddy-api-key=${{ env.API_KEY }}" > bazel_auth.rc diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index b1d64ca9e3a..98eb166b837 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -26,9 +26,11 @@ jobs: distribution: 'zulu' java-version: 17 architecture: x64 - - - name: Set artifactory cache key - run: echo "build:ci --remote_cache=https://frcmaven.wpi.edu/artifactory/wpilib-generic-cache-bazel-local" > bazel_auth.rc + + - id: Setup_build_buddy + uses: ./.github/actions/setup-build-buddy + with: + token: ${{ secrets.BUILDBUDDY_API_KEY }} - name: Build Release run: bazel --output_user_root=C:\\bazelroot ${{ matrix.action }} -k ... --config=ci -c opt ${{ matrix.config }} --verbose_failures @@ -51,9 +53,11 @@ jobs: steps: - uses: actions/checkout@v4 with: { fetch-depth: 0 } - - - name: Set artifactory cache key - run: echo "build:ci --remote_cache=https://frcmaven.wpi.edu/artifactory/wpilib-generic-cache-bazel-local" > bazel_auth.rc + + - id: Setup_build_buddy + uses: ./.github/actions/setup-build-buddy + with: + token: ${{ secrets.BUILDBUDDY_API_KEY }} - name: Build Release run: bazel ${{ matrix.action }} -k ... --config=ci -c opt ${{ matrix.config }} --nojava_header_compilation --verbose_failures @@ -76,9 +80,11 @@ jobs: - uses: actions/checkout@v4 with: { fetch-depth: 0 } - uses: bazelbuild/setup-bazelisk@v3 - - - name: Set artifactory cache key - run: echo "build:ci --remote_cache=https://wpilib.jfrog.io/artifactory/wpilib-generic-cache-bazel-local" > bazel_auth.rc + + - id: Setup_build_buddy + uses: ./.github/actions/setup-build-buddy + with: + token: ${{ secrets.BUILDBUDDY_API_KEY }} - name: Build and Test Release run: bazel ${{ matrix.action }} ... --config=ci -c opt ${{ matrix.config }} -k --verbose_failures @@ -99,6 +105,12 @@ jobs: - uses: actions/checkout@v4 with: { fetch-depth: 0 } - uses: bazelbuild/setup-bazelisk@v3 + + - id: Setup_build_buddy + uses: ./.github/actions/setup-build-buddy + with: + token: ${{ secrets.BUILDBUDDY_API_KEY }} + - name: Build and Test run: bazel test -k --config=ci --config=linux --config=${{ matrix.config }} //... @@ -110,6 +122,7 @@ jobs: uses: actions/setup-go@v5 with: go-version: 1.15.x + id: go - name: Install Buildifier run: | diff --git a/wpiutil/BUILD.bazel b/wpiutil/BUILD.bazel index 036f1881e1b..d23d218ce49 100644 --- a/wpiutil/BUILD.bazel +++ b/wpiutil/BUILD.bazel @@ -3,6 +3,16 @@ load("@rules_java//java:defs.bzl", "java_binary", "java_library") load("@rules_python//python:defs.bzl", "py_binary") load("//shared/bazel/rules/gen:gen-resources.bzl", "generate_resources") +cc_library( + name = "argparse-headers", + hdrs = glob([ + "src/main/native/thirdparty/argparse/include/**/*", + ]), + includes = ["src/main/native/thirdparty/argparse/include"], + strip_include_prefix = "src/main/native/thirdparty/argparse/include", + visibility = ["//wpiutil:__subpackages__"], +) + cc_library( name = "expected-headers", hdrs = glob([ @@ -161,6 +171,7 @@ cc_library( strip_include_prefix = "src/main/native/include", visibility = ["//visibility:public"], deps = [ + ":argparse-headers", ":concurrentqueue-headers", ":expected-headers", ":fmtlib-headers", From 3499bda4ac3de6df21162aa604016575c3e3cdda Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Thu, 19 Sep 2024 00:19:24 -0400 Subject: [PATCH 34/38] Whoops --- .github/actions/setup-build-buddy/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-build-buddy/action.yml b/.github/actions/setup-build-buddy/action.yml index c3b8ec3caa5..423398a0534 100644 --- a/.github/actions/setup-build-buddy/action.yml +++ b/.github/actions/setup-build-buddy/action.yml @@ -15,7 +15,7 @@ runs: shell: bash run: | echo "No API key secret detected, will setup readonly cache" - echo "build:ci --build_buddy_readonly" > bazel_auth.rc + echo "build:ci --config=build_buddy_readonly" > bazel_auth.rc - name: Set with key env: From 58aa6e07438e3a69b1205974eddf9d25db162d98 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 5 Oct 2024 02:53:56 -0400 Subject: [PATCH 35/38] (finally) transition to wpilibsuite owned libraries --- WORKSPACE | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index baa9b32c584..66e3eaf8e70 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -35,8 +35,8 @@ maven_install( # Download toolchains http_archive( name = "rules_bzlmodrio_toolchains", - sha256 = "cd3ff046427e9c6dbc0c86a458c8cf081b8045fc3fb4265d08c0ebfc17f9cb30", - url = "https://github.com/bzlmodRio/rules_bzlmodRio_toolchains/releases/download/2024-1/rules_bzlmodRio_toolchains-2024-1.tar.gz", + sha256 = "2ef1cafce7f4fd4e909bb5de8b0dc771a934646afd55d5f100ff31f6b500df98", + url = "https://github.com/wpilibsuite/rules_bzlmodRio_toolchains/releases/download/2024-1.bcr1/rules_bzlmodRio_toolchains-2024-1.bcr1.tar.gz", ) load("@rules_bzlmodrio_toolchains//:maven_deps.bzl", "setup_legacy_setup_toolchains_dependencies") @@ -51,7 +51,7 @@ load_toolchains() http_archive( name = "rules_bzlmodrio_jdk", sha256 = "a00d5fa971fbcad8a17b1968cdc5350688397035e90b0cb94e040d375ecd97b4", - url = "https://github.com/bzlmodRio/rules_bzlmodRio_jdk/releases/download/17.0.8.1-1/rules_bzlmodRio_jdk-17.0.8.1-1.tar.gz", + url = "https://github.com/wpilibsuite/rules_bzlmodRio_jdk/releases/download/17.0.8.1-1/rules_bzlmodRio_jdk-17.0.8.1-1.tar.gz", ) load("@rules_bzlmodrio_jdk//:maven_deps.bzl", "setup_legacy_setup_jdk_dependencies") @@ -75,17 +75,10 @@ register_toolchains( setup_legacy_setup_jdk_dependencies() -# Download other dependencies -http_archive( - name = "rules_bazelrio", - sha256 = "0c5a98476ac5b606689863b7b9ef3f7d685c47ce2681e448ca977e8e95de31c1", - url = "https://github.com/bzlmodRio/rules_bazelrio/releases/download/0.0.14/rules_bazelrio-0.0.14.tar.gz", -) - http_archive( name = "bzlmodrio-ni", - sha256 = "02a9b1d9722ad3cc7d55ee31a709938884d981f69634dfe93f92e3986bb7a43f", - url = "https://github.com/bzlmodRio/bzlmodRio-ni/releases/download/2024.2.1/bzlmodRio-ni-2024.2.1.tar.gz", + sha256 = "28abfa366389514669dabf9e71cc723749f650e98a689bf428ec1fc998ca5de9", + url = "https://github.com/wpilibsuite/bzlmodRio-ni/releases/download/2024.2.1.bcr1/bzlmodRio-ni-2024.2.1.bcr1.tar.gz", ) load("@bzlmodrio-ni//:maven_cpp_deps.bzl", "setup_legacy_bzlmodrio_ni_cpp_dependencies") @@ -94,8 +87,8 @@ setup_legacy_bzlmodrio_ni_cpp_dependencies() http_archive( name = "bzlmodrio-opencv", - sha256 = "f61f21220bf3d01d9585af30d23714b774235fe0f5334446745f6eee682a9b14", - url = "https://github.com/bzlmodRio/bzlmodRio-opencv/releases/download/2024.4.8.0-4/bzlmodRio-opencv-2024.4.8.0-4.tar.gz", + sha256 = "5314cce05b49451a46bf3e3140fc401342e53d5f3357612ed4473e59bb616cba", + url = "https://github.com/wpilibsuite/bzlmodRio-opencv/releases/download/2024.4.8.0-4.bcr1/bzlmodRio-opencv-2024.4.8.0-4.bcr1.tar.gz", ) load("@bzlmodrio-opencv//:maven_cpp_deps.bzl", "setup_legacy_bzlmodrio_opencv_cpp_dependencies") From ec5692bbd91cf6115cd1ed254b9fe08092ebd946 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 12 Oct 2024 01:45:04 -0400 Subject: [PATCH 36/38] Update ni libraries --- WORKSPACE | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 66e3eaf8e70..602b2ed4297 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -77,8 +77,8 @@ setup_legacy_setup_jdk_dependencies() http_archive( name = "bzlmodrio-ni", - sha256 = "28abfa366389514669dabf9e71cc723749f650e98a689bf428ec1fc998ca5de9", - url = "https://github.com/wpilibsuite/bzlmodRio-ni/releases/download/2024.2.1.bcr1/bzlmodRio-ni-2024.2.1.bcr1.tar.gz", + sha256 = "197fceac88bf44fb8427d5e000b0083118d3346172dd2ad31eccf83a5e61b3ce", + url = "https://github.com/wpilibsuite/bzlmodRio-ni/releases/download/2025.0.0/bzlmodRio-ni-2025.0.0.tar.gz", ) load("@bzlmodrio-ni//:maven_cpp_deps.bzl", "setup_legacy_bzlmodrio_ni_cpp_dependencies") From 30c32487053d7f7d1c179e46b52d8d18e9a90c18 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 12 Oct 2024 18:06:52 -0400 Subject: [PATCH 37/38] Simplify ntcore --- ntcore/BUILD.bazel | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/ntcore/BUILD.bazel b/ntcore/BUILD.bazel index 0e7cea571dd..1156cff691e 100644 --- a/ntcore/BUILD.bazel +++ b/ntcore/BUILD.bazel @@ -24,17 +24,6 @@ filegroup( visibility = ["//ntcore:__subpackages__"], ) -cc_library( - name = "private_includes", - hdrs = glob([ - "src/main/native/cpp/*.h", - "src/main/native/cpp/net/*.h", - "src/main/native/cpp/net/*.inc", - "src/main/native/cpp/net3/*.h", - ]), - strip_include_prefix = "src/main/native/cpp", -) - cc_library( name = "ntcore.static", srcs = glob( @@ -42,12 +31,14 @@ cc_library( exclude = ["src/main/native/cpp/jni/**"], ) + [":generated_cc_source"], hdrs = glob(["src/main/native/include/**/*"]), - includes = ["src/main/native/include"], + includes = [ + "src/main/native/cpp", + "src/main/native/include", + ], strip_include_prefix = "src/main/native/include", visibility = ["//visibility:public"], deps = [ ":generated_cc_headers", - ":private_includes", "//wpinet:wpinet.static", "//wpiutil:wpiutil.static", ], From e066cda70f533b153a7eafd87ea9629cf8477b01 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 12 Oct 2024 21:31:43 -0400 Subject: [PATCH 38/38] Update repo url --- .bazelrc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.bazelrc b/.bazelrc index cfc99909ad7..051ff924bd8 100644 --- a/.bazelrc +++ b/.bazelrc @@ -47,3 +47,5 @@ build:remote_user --remote_download_toplevel build:ci --config=build_buddy build:ci --remote_download_minimal + +build --build_metadata=REPO_URL=https://github.com/wpilibsuite/allwpilib.git