diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index a2f0c381d6f..8949d6b055d 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -57,6 +57,7 @@ jobs: matrix: include: - { name: "Linux (native)", os: ubuntu-24.04, action: "test", config: "--config=linux", } + - { name: "Linux (systemcore)", os: ubuntu-24.04, action: "build", config: "--config=systemcore", } name: "${{ matrix.name }}" runs-on: ${{ matrix.os }} steps: diff --git a/.styleguide b/.styleguide index feb5dc3e00e..a23842e2f53 100644 --- a/.styleguide +++ b/.styleguide @@ -14,6 +14,7 @@ modifiableFileExclude { thirdparty/ \.patch$ gradlew + BUILD.bazel } generatedFileExclude { diff --git a/WORKSPACE b/WORKSPACE index eb731acfd2a..7362421731f 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -13,6 +13,7 @@ load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps") rules_jvm_external_deps() load("@rules_jvm_external//:defs.bzl", "maven_install") +load("@rules_jvm_external//:specs.bzl", "maven") maven_artifacts = [ "org.ejml:ejml-simple:0.43.1", @@ -21,6 +22,72 @@ maven_artifacts = [ "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.artifact( + "org.junit.jupiter", + "junit-jupiter", + "5.10.1", + testonly = True, + ), + maven.artifact( + "org.junit.platform", + "junit-platform-console", + "1.10.1", + testonly = True, + ), + maven.artifact( + "org.junit.platform", + "junit-platform-launcher", + "1.10.1", + testonly = True, + ), + maven.artifact( + "org.junit.platform", + "junit-platform-reporting", + "1.10.1", + testonly = True, + ), + maven.artifact( + "com.google.code.gson", + "gson", + "2.10.1", + testonly = False, + ), + maven.artifact( + "org.hamcrest", + "hamcrest-all", + "1.3", + testonly = True, + ), + maven.artifact( + "com.googlecode.junit-toolbox", + "junit-toolbox", + "2.4", + testonly = True, + ), + maven.artifact( + "org.apache.ant", + "ant", + "1.10.12", + testonly = True, + ), + maven.artifact( + "org.apache.ant", + "ant-junit", + "1.10.12", + testonly = True, + ), + maven.artifact( + "org.mockito", + "mockito-core", + "4.1.0", + testonly = True, + ), + maven.artifact( + "com.google.testing.compile", + "compile-testing", + "0.21.0", + testonly = True, + ), ] maven_install( diff --git a/apriltag/BUILD.bazel b/apriltag/BUILD.bazel index ea1ef1abe00..3544d27ef0a 100644 --- a/apriltag/BUILD.bazel +++ b/apriltag/BUILD.bazel @@ -1,6 +1,8 @@ load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") -load("@rules_java//java:defs.bzl", "java_binary", "java_library") +load("@rules_java//java:defs.bzl", "java_binary") load("@rules_python//python:defs.bzl", "py_binary") +load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test") +load("//shared/bazel/rules:jni_rules.bzl", "wpilib_jni_cc_library", "wpilib_jni_java_library") load("//shared/bazel/rules/gen:gen-resources.bzl", "generate_resources") cc_library( @@ -59,9 +61,20 @@ cc_library( ], ) -java_library( +wpilib_jni_cc_library( + name = "apriltagjni", + srcs = glob(["src/main/native/cpp/jni/**"]), + java_dep = ":apriltag-java", + visibility = ["//visibility:public"], + deps = [ + ":apriltag.static", + ], +) + +wpilib_jni_java_library( name = "apriltag-java", srcs = glob(["src/main/java/**/*.java"]), + native_libs = [":apriltagjni"], resource_strip_prefix = "apriltag/src/main/native/resources", resources = glob(["src/main/native/resources/**"]), visibility = ["//visibility:public"], @@ -88,6 +101,20 @@ cc_test( ], ) +wpilib_java_junit5_test( + name = "apriltag-java-test", + srcs = glob(["src/test/java/**/*.java"]), + resource_strip_prefix = "apriltag/src/test/resources", + resources = glob(["src/test/resources/**"]), + deps = [ + ":apriltag-java", + "//wpimath:wpimath-java", + "//wpiutil:wpiutil-java", + "@bzlmodrio-opencv//libraries/java/opencv", + "@maven//:com_fasterxml_jackson_core_jackson_databind", + ], +) + cc_binary( name = "DevMain-Cpp", srcs = ["src/dev/native/cpp/main.cpp"], diff --git a/cscore/BUILD.bazel b/cscore/BUILD.bazel index d40fb4d2fd9..1c0ac8d9b7c 100644 --- a/cscore/BUILD.bazel +++ b/cscore/BUILD.bazel @@ -1,5 +1,7 @@ load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test", "objc_library") -load("@rules_java//java:defs.bzl", "java_binary", "java_library") +load("@rules_java//java:defs.bzl", "java_binary") +load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test") +load("//shared/bazel/rules:jni_rules.bzl", "wpilib_jni_cc_library", "wpilib_jni_java_library") WIN_SRCS = glob([ "src/main/native/windows/**/*.cpp", @@ -71,9 +73,20 @@ cc_library( }), ) -java_library( +wpilib_jni_cc_library( + name = "cscorejni", + srcs = glob(["src/main/native/cpp/jni/**"]), + java_dep = ":cscore-java", + visibility = ["//visibility:public"], + deps = [ + ":cscore.static", + ], +) + +wpilib_jni_java_library( name = "cscore-java", srcs = glob(["src/main/java/**/*.java"]), + native_libs = [":cscorejni"], visibility = ["//visibility:public"], deps = [ "//wpiutil:wpiutil-java", @@ -91,6 +104,15 @@ cc_test( ], ) +wpilib_java_junit5_test( + name = "cscore-java-test", + srcs = glob(["src/test/java/**/*.java"]), + deps = [ + ":cscore-java", + "//wpiutil:wpiutil-java", + ], +) + cc_binary( name = "DevMain-Cpp", srcs = ["src/dev/native/cpp/main.cpp"], diff --git a/epilogue-processor/BUILD.bazel b/epilogue-processor/BUILD.bazel index a9a8e083ab4..290132009d0 100644 --- a/epilogue-processor/BUILD.bazel +++ b/epilogue-processor/BUILD.bazel @@ -1,4 +1,5 @@ load("@rules_java//java:defs.bzl", "java_library", "java_plugin") +load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test") java_library( name = "processor", @@ -20,3 +21,15 @@ java_plugin( ":processor", ], ) + +wpilib_java_junit5_test( + name = "processor-test", + srcs = glob(["src/test/java/**/*.java"]), + plugins = [ + ":plugin", + ], + deps = [ + ":processor", + "@maven//:com_google_testing_compile_compile_testing", + ], +) diff --git a/epilogue-runtime/BUILD.bazel b/epilogue-runtime/BUILD.bazel index 05db6b75270..6e02a5dfcb8 100644 --- a/epilogue-runtime/BUILD.bazel +++ b/epilogue-runtime/BUILD.bazel @@ -1,4 +1,5 @@ load("@rules_java//java:defs.bzl", "java_library") +load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test") java_library( name = "epilogue", @@ -10,3 +11,12 @@ java_library( "//wpiutil:wpiutil-java", ], ) + +wpilib_java_junit5_test( + name = "epilogue-test", + srcs = glob(["src/test/java/**/*.java"]), + deps = [ + ":epilogue", + "//wpiutil:wpiutil-java", + ], +) diff --git a/fieldImages/BUILD.bazel b/fieldImages/BUILD.bazel index b5cfc82cfa4..e006e9ef83c 100644 --- a/fieldImages/BUILD.bazel +++ b/fieldImages/BUILD.bazel @@ -1,5 +1,6 @@ load("@rules_cc//cc:defs.bzl", "cc_library") load("@rules_java//java:defs.bzl", "java_library") +load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test") load("//shared/bazel/rules/gen:gen-resources.bzl", "generate_resources") generate_resources( @@ -29,3 +30,11 @@ java_library( "@maven//:com_fasterxml_jackson_core_jackson_databind", ], ) + +wpilib_java_junit5_test( + name = "fieldImages-test", + srcs = glob(["src/test/java/**/*.java"]), + deps = [ + ":fieldImages-java", + ], +) diff --git a/hal/BUILD.bazel b/hal/BUILD.bazel index 6f8097b070f..2a1c00a1fc6 100644 --- a/hal/BUILD.bazel +++ b/hal/BUILD.bazel @@ -1,5 +1,7 @@ load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") -load("@rules_java//java:defs.bzl", "java_binary", "java_library") +load("@rules_java//java:defs.bzl", "java_binary") +load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test") +load("//shared/bazel/rules:jni_rules.bzl", "wpilib_jni_cc_library", "wpilib_jni_java_library") cc_library( name = "generated_cc_headers", @@ -31,23 +33,14 @@ filegroup( visibility = ["//hal:__subpackages__"], ) -ATHENA_SRCS = glob(["src/main/native/athena/**"]) - -ATHENA_DEPS = ["@bzlmodrio-ni//libraries/cpp/ni:shared"] +SYSTEMCORE_SRCS = glob(["src/main/native/systemcore/**"]) SIM_SRCS = glob(["src/main/native/sim/**"]) -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, + "@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": SYSTEMCORE_SRCS, "//conditions:default": SIM_SRCS, }), ) @@ -67,17 +60,28 @@ cc_library( visibility = ["//visibility:public"], deps = [ ":generated_cc_headers", - ":mrc_cc_headers", ":generated_mrc_cc_headers", + ":mrc_cc_headers", "//ntcore:ntcore.static", "//wpinet:wpinet.static", "//wpiutil:wpiutil.static", - ] + HAL_DEPS, + ], +) + +wpilib_jni_cc_library( + name = "wpiHaljni", + srcs = glob(["src/main/native/cpp/jni/**"]), + java_dep = ":hal-java", + visibility = ["//visibility:public"], + deps = [ + ":wpiHal.static", + ], ) -java_library( +wpilib_jni_java_library( name = "hal-java", srcs = [":generated_java"] + glob(["src/main/java/**/*.java"]), + native_libs = [":wpiHaljni"], visibility = ["//visibility:public"], deps = [ "//ntcore:networktables-java", @@ -99,6 +103,14 @@ cc_test( ], ) +wpilib_java_junit5_test( + name = "hal-java-test", + srcs = glob(["src/test/java/**/*.java"]), + deps = [ + ":hal-java", + ], +) + cc_binary( name = "DevMain-Cpp", srcs = ["src/dev/native/cpp/main.cpp"], diff --git a/ntcore/BUILD.bazel b/ntcore/BUILD.bazel index 1156cff691e..9b020297c59 100644 --- a/ntcore/BUILD.bazel +++ b/ntcore/BUILD.bazel @@ -1,5 +1,7 @@ load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") -load("@rules_java//java:defs.bzl", "java_binary", "java_library") +load("@rules_java//java:defs.bzl", "java_binary") +load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test") +load("//shared/bazel/rules:jni_rules.bzl", "wpilib_jni_cc_library", "wpilib_jni_java_library") cc_library( name = "generated_cc_headers", @@ -18,6 +20,12 @@ filegroup( visibility = ["//ntcore:__subpackages__"], ) +filegroup( + name = "generated_jni", + srcs = glob(["src/generated/main/native/cpp/jni/**"]), + visibility = ["//ntcore:__subpackages__"], +) + filegroup( name = "generated_java", srcs = glob(["src/generated/main/java/**/*.java"]), @@ -44,9 +52,20 @@ cc_library( ], ) -java_library( +wpilib_jni_cc_library( + name = "ntcorejni", + srcs = glob(["src/main/native/cpp/jni/**"]) + [":generated_jni"], + java_dep = ":networktables-java", + visibility = ["//visibility:public"], + deps = [ + ":ntcore.static", + ], +) + +wpilib_jni_java_library( name = "networktables-java", srcs = glob(["src/main/java/**/*.java"]) + [":generated_java"], + native_libs = [":ntcorejni"], visibility = ["//visibility:public"], deps = [ "//wpiutil:wpiutil-java", @@ -73,6 +92,16 @@ cc_test( ], ) +wpilib_java_junit5_test( + name = "ntcore-java-test", + srcs = glob(["src/test/java/**/*.java"]), + tags = ["exclusive"], + deps = [ + ":networktables-java", + "//wpiutil:wpiutil-java", + ], +) + cc_binary( name = "DevMain-Cpp", srcs = ["src/dev/native/cpp/main.cpp"], diff --git a/shared/bazel/rules/BUILD.bazel b/shared/bazel/rules/BUILD.bazel new file mode 100644 index 00000000000..e69de29bb2d diff --git a/shared/bazel/rules/java_rules.bzl b/shared/bazel/rules/java_rules.bzl new file mode 100644 index 00000000000..b712c0cb7c1 --- /dev/null +++ b/shared/bazel/rules/java_rules.bzl @@ -0,0 +1,35 @@ +load("@rules_java//java:defs.bzl", "java_binary") + +def wpilib_java_junit5_test( + name, + deps = [], + runtime_deps = [], + args = [], + tags = [], + package = "edu", + **kwargs): + """ + Convenience helper to make a junit5 test + """ + junit_deps = [ + "@maven//:org_junit_jupiter_junit_jupiter_api", + "@maven//:org_junit_jupiter_junit_jupiter_params", + "@maven//:org_junit_jupiter_junit_jupiter_engine", + ] + + junit_runtime_deps = [ + "@maven//:org_junit_platform_junit_platform_console", + ] + + # TODO - replace with java_test once shared libraries are hooked up. + java_binary( + name = name, + deps = deps + junit_deps, + runtime_deps = runtime_deps + junit_runtime_deps, + args = args + ["--select-package", package], + main_class = "org.junit.platform.console.ConsoleLauncher", + use_testrunner = False, + testonly = True, + tags = tags + ["no-roborio", "no-bionic", "no-raspbian", "allwpilib-build-java", "no-asan", "no-tsan", "no-ubsan"], + **kwargs + ) diff --git a/shared/bazel/rules/jni_rules.bzl b/shared/bazel/rules/jni_rules.bzl new file mode 100644 index 00000000000..dfc23dbb481 --- /dev/null +++ b/shared/bazel/rules/jni_rules.bzl @@ -0,0 +1,101 @@ +load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain") +load("@rules_cc//cc:defs.bzl", "cc_library") +load("@rules_java//java:defs.bzl", "java_library") + +def _jni_headers_impl(ctx): + include_dir = ctx.actions.declare_directory(ctx.attr.name + ".h") + native_headers_jar = ctx.attr.lib[JavaInfo].outputs.native_headers + args = ["xf", native_headers_jar.path, "-d", include_dir.path] + + ctx.actions.run( + inputs = [native_headers_jar], + tools = [ctx.executable._zipper], + outputs = [include_dir], + executable = ctx.executable._zipper.path, + arguments = args, + ) + + cc_toolchain = find_cpp_toolchain(ctx) + feature_configuration = cc_common.configure_features( + ctx = ctx, + cc_toolchain = cc_toolchain, + requested_features = ctx.features, + unsupported_features = ctx.disabled_features, + ) + compilation_context, _ = cc_common.compile( + name = ctx.attr.name, + actions = ctx.actions, + feature_configuration = feature_configuration, + cc_toolchain = cc_toolchain, + public_hdrs = [include_dir], + quote_includes = [include_dir.path], + ) + cc_info_with_jni = cc_common.merge_cc_infos( + direct_cc_infos = [ + CcInfo(compilation_context = compilation_context), + ctx.attr.jni[CcInfo], + ], + ) + + return [ + DefaultInfo(files = depset([include_dir])), + cc_info_with_jni, + ] + +_jni_headers = rule( + implementation = _jni_headers_impl, + attrs = { + "jni": attr.label(mandatory = True), + "lib": attr.label( + mandatory = True, + providers = [JavaInfo], + ), + "_cc_toolchain": attr.label(default = Label("@bazel_tools//tools/cpp:current_cc_toolchain")), + "_zipper": attr.label( + executable = True, + cfg = "exec", + default = Label("@bazel_tools//tools/zip:zipper"), + ), + }, + fragments = ["cpp"], + incompatible_use_toolchain_transition = True, + provides = [CcInfo], + toolchains = ["@bazel_tools//tools/cpp:toolchain_type"], +) + +def wpilib_jni_java_library( + name, + native_libs = [], + **java_library_args): + tags = java_library_args.pop("tags", default = None) + visibility = java_library_args.pop("visibility", default = None) + testonly = java_library_args.pop("testonly", default = None) + headers_name = name + ".hdrs" + java_library( + name = name, + visibility = visibility, + testonly = testonly, + **java_library_args + ) + + jni = "@rules_bzlmodrio_toolchains//jni" + _jni_headers( + name = headers_name, + tags = ["manual"], + jni = jni, + lib = ":" + name, + testonly = testonly, + visibility = visibility, + ) + +def wpilib_jni_cc_library( + name, + deps = [], + java_dep = None, + **kwargs): + jni = "@rules_bzlmodrio_toolchains//jni" + cc_library( + name = name + ".static", + deps = [jni, java_dep + ".hdrs"] + deps, + **kwargs + ) diff --git a/wpilibNewCommands/BUILD.bazel b/wpilibNewCommands/BUILD.bazel index 6add11137ad..37b063dd5bf 100644 --- a/wpilibNewCommands/BUILD.bazel +++ b/wpilibNewCommands/BUILD.bazel @@ -1,5 +1,6 @@ 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:java_rules.bzl", "wpilib_java_junit5_test") cc_library( name = "generated_cc_headers", @@ -67,6 +68,23 @@ cc_test( ], ) +wpilib_java_junit5_test( + name = "wpilibNewCommands-java-test", + srcs = glob(["**/*.java"]), + resource_strip_prefix = "wpilibNewCommands/src/test/resources", + resources = glob(["src/test/resources/**"]), + deps = [ + ":wpilibNewCommands-java", + "//hal:hal-java", + "//ntcore:networktables-java", + "//wpilibj", + "//wpimath:wpimath-java", + "//wpiunits", + "//wpiutil:wpiutil-java", + "@maven//:org_mockito_mockito_core", + ], +) + cc_binary( name = "DevMain-Cpp", srcs = ["src/dev/native/cpp/main.cpp"], diff --git a/wpilibj/BUILD.bazel b/wpilibj/BUILD.bazel index f0a9359ae91..e5b8b0dd993 100644 --- a/wpilibj/BUILD.bazel +++ b/wpilibj/BUILD.bazel @@ -1,5 +1,6 @@ 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_junit5_test") load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file") generate_version_file( @@ -36,6 +37,21 @@ java_library( ], ) +wpilib_java_junit5_test( + name = "wpilibj-java-test", + srcs = glob(["src/test/java/**/*.java"]), + resource_strip_prefix = "wpilibj/src/test/resources", + resources = glob(["src/test/resources/**"]), + deps = [ + ":wpilibj", + "//hal:hal-java", + "//ntcore:networktables-java", + "//wpimath:wpimath-java", + "//wpiunits", + "//wpiutil:wpiutil-java", + ], +) + cc_binary( name = "DevMain-Cpp", srcs = ["src/dev/native/cpp/main.cpp"], diff --git a/wpimath/BUILD.bazel b/wpimath/BUILD.bazel index 7979a8ba1cb..d6763b68dec 100644 --- a/wpimath/BUILD.bazel +++ b/wpimath/BUILD.bazel @@ -1,6 +1,8 @@ load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") -load("@rules_java//java:defs.bzl", "java_binary", "java_library") +load("@rules_java//java:defs.bzl", "java_binary") load("@rules_python//python:defs.bzl", "py_binary") +load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test") +load("//shared/bazel/rules:jni_rules.bzl", "wpilib_jni_cc_library", "wpilib_jni_java_library") filegroup( name = "generated_java", @@ -78,9 +80,20 @@ cc_library( ], ) -java_library( +wpilib_jni_cc_library( + name = "wpimathjni", + srcs = glob(["src/main/native/cpp/jni/**"]), + java_dep = ":wpimath-java", + visibility = ["//visibility:public"], + deps = [ + ":wpimath.static", + ], +) + +wpilib_jni_java_library( name = "wpimath-java", srcs = [":generated_java"] + glob(["src/main/java/**/*.java"]), + native_libs = [":wpimathjni"], visibility = ["//visibility:public"], deps = [ "//wpiunits", @@ -121,6 +134,19 @@ cc_test( ], ) +wpilib_java_junit5_test( + name = "wpimath-java-test", + srcs = glob(["src/test/java/**/*.java"]), + deps = [ + ":wpimath-java", + "//wpiunits", + "//wpiutil:wpiutil-java", + "@maven//:org_ejml_ejml_core", + "@maven//:org_ejml_ejml_simple", + "@maven//:us_hebi_quickbuf_quickbuf_runtime", + ], +) + cc_binary( name = "DevMain-Cpp", srcs = ["src/dev/native/cpp/main.cpp"], diff --git a/wpinet/BUILD.bazel b/wpinet/BUILD.bazel index c6bdebae7a0..8a56e0b3459 100644 --- a/wpinet/BUILD.bazel +++ b/wpinet/BUILD.bazel @@ -1,5 +1,7 @@ load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") -load("@rules_java//java:defs.bzl", "java_binary", "java_library") +load("@rules_java//java:defs.bzl", "java_binary") +load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test") +load("//shared/bazel/rules:jni_rules.bzl", "wpilib_jni_cc_library", "wpilib_jni_java_library") load("//shared/bazel/rules/gen:gen-resources.bzl", "generate_resources") WIN_UV_SRCS = glob([ @@ -131,9 +133,23 @@ cc_library( ], ) -java_library( +wpilib_jni_cc_library( + name = "wpinetjni", + srcs = glob([ + "src/main/native/cpp/jni/**", + "src/main/native/cpp/**/*.h", + ]), + java_dep = ":wpinet-java", + visibility = ["//visibility:public"], + deps = [ + ":wpinet.static", + ], +) + +wpilib_jni_java_library( name = "wpinet-java", srcs = glob(["src/main/java/**/*.java"]), + native_libs = [":wpinetjni"], visibility = ["//visibility:public"], deps = [ "//wpiutil:wpiutil-java", @@ -155,6 +171,14 @@ cc_test( ], ) +wpilib_java_junit5_test( + name = "wpinet-java-test", + srcs = glob(["src/test/java/**/*.java"]), + deps = [ + ":wpinet-java", + ], +) + cc_binary( name = "DevMain-Cpp", srcs = ["src/dev/native/cpp/main.cpp"], diff --git a/wpiunits/BUILD.bazel b/wpiunits/BUILD.bazel index d6686308a97..d6609a4f00f 100644 --- a/wpiunits/BUILD.bazel +++ b/wpiunits/BUILD.bazel @@ -1,4 +1,5 @@ load("@rules_java//java:defs.bzl", "java_binary", "java_library") +load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test") java_library( name = "wpiunits", @@ -7,6 +8,14 @@ java_library( deps = [], ) +wpilib_java_junit5_test( + name = "wpiunits-test", + srcs = glob(["src/test/java/**/*.java"]), + deps = [ + ":wpiunits", + ], +) + java_binary( name = "DevMain-Java", srcs = ["src/dev/java/edu/wpi/first/units/DevMain.java"], diff --git a/wpiutil/BUILD.bazel b/wpiutil/BUILD.bazel index 928fa4e8f3d..646858441c5 100644 --- a/wpiutil/BUILD.bazel +++ b/wpiutil/BUILD.bazel @@ -1,6 +1,8 @@ load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") -load("@rules_java//java:defs.bzl", "java_binary", "java_library") +load("@rules_java//java:defs.bzl", "java_binary") load("@rules_python//python:defs.bzl", "py_binary") +load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test") +load("//shared/bazel/rules:jni_rules.bzl", "wpilib_jni_cc_library", "wpilib_jni_java_library") load("//shared/bazel/rules/gen:gen-resources.bzl", "generate_resources") cc_library( @@ -224,9 +226,20 @@ cc_library( }), ) -java_library( +wpilib_jni_cc_library( + name = "wpiutiljni", + srcs = glob(["src/main/native/cpp/jni/**"]), + java_dep = ":wpiutil-java", + visibility = ["//visibility:public"], + deps = [ + ":wpiutil.static", + ], +) + +wpilib_jni_java_library( name = "wpiutil-java", srcs = glob(["src/main/java/**/*.java"]), + native_libs = [":wpiutiljni"], visibility = ["//visibility:public"], deps = [ "@maven//:com_fasterxml_jackson_core_jackson_annotations", @@ -268,6 +281,14 @@ cc_test( ], ) +wpilib_java_junit5_test( + name = "wpiutil-java-test", + srcs = glob(["src/test/java/**/*.java"]), + deps = [ + ":wpiutil-java", + ], +) + cc_binary( name = "DevMain-Cpp", srcs = ["src/dev/native/cpp/main.cpp"],