Files
allwpilib/simulation/halsim_gui/BUILD.bazel
Thad House 6e5171cd8f [hal] Use MrcLib to talk to DS (#8858)
Using MrcLib on the robot is going to be the plan for the future, to
make things easier.

MrcLib is how sim is supported going forward. The desktop version of
mrclib can act as a robot server.

This is set up where the mrclib interface is in shared code. On robot,
that is the only backend used. On desktop, a default sim backend is
used. However, the sim plugin can switch that to the real robot backend,
so the robot code will exactly look like a real robot.
2026-06-06 12:15:17 -07:00

188 lines
5.3 KiB
Python

load("@allwpilib_pip_deps//:requirements.bzl", "requirement")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_test")
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library", "wpilib_cc_shared_library", "wpilib_cc_static_library")
load("//shared/bazel/rules:packaging.bzl", "package_default_cc_project")
load("//shared/bazel/rules:publishing.bzl", "host_architectures")
load("//shared/bazel/rules/robotpy:pytest_util.bzl", "robotpy_py_test")
load("//simulation/halsim_gui:robotpy_pybind_build_info.bzl", "define_pybind_library", "halsim_gui_ext_extension")
wpilib_cc_library(
name = "halsim_gui",
srcs = glob([
"src/main/native/cpp/*",
"src/main/native/include/**/*.hpp",
]),
include_license_files = True,
includes = ["src/main/native/include"],
linkopts = [
"-lm",
],
tags = [
"wpi-cpp-gui",
],
target_compatible_with = select({
"@rules_bzlmodrio_toolchains//constraints/is_roborio:roborio": ["@platforms//:incompatible"],
"@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
deps = [
"//glass:glassnt",
"//hal:wpiHal",
],
)
wpilib_cc_library(
name = "halsim_gui_static",
srcs = glob([
"src/main/native/cpp/*",
"src/main/native/include/**/*.hpp",
]),
copts = [
"-DHALSIM_InitExtension=HALSIM_InitExtension_GUI",
],
include_license_files = True,
includes = ["src/main/native/include"],
linkopts = [
"-lm",
],
tags = [
"wpi-cpp-gui",
],
target_compatible_with = select({
"@rules_bzlmodrio_toolchains//constraints/is_roborio:roborio": ["@platforms//:incompatible"],
"@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
deps = [
"//glass:glassnt",
"//hal:wpiHal",
],
)
wpilib_cc_shared_library(
name = "shared/halsim_gui",
additional_linker_inputs = select({
"@platforms//os:osx": [
"//thirdparty/imgui_suite:glfw_src_darwin",
"//thirdparty/imgui_suite:imgui_src_darwin",
"//wpigui:wpigui-mac",
],
"//conditions:default": [],
}),
dynamic_deps = [
"//hal:shared/wpiHal",
"//wpimath:shared/wpimath",
"//datalog:shared/datalog",
"//ntcore:shared/ntcore",
],
user_link_flags = select({
"@platforms//os:osx": [
"-Wl,-force_load,$(location //thirdparty/imgui_suite:glfw_src_darwin)",
"-Wl,-force_load,$(location //thirdparty/imgui_suite:imgui_src_darwin)",
"-Wl,-force_load,$(location //wpigui:wpigui-mac)",
"-framework",
"Metal",
"-framework",
"MetalKit",
"-framework",
"Cocoa",
"-framework",
"IOKit",
"-framework",
"CoreFoundation",
"-framework",
"CoreVideo",
"-framework",
"QuartzCore",
],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
deps = [
":halsim_gui",
],
)
wpilib_cc_static_library(
name = "static/halsim_gui",
static_deps = [
"//hal:static/wpiHal",
"//wpimath:static/wpimath",
"//datalog:static/datalog",
"//ntcore:static/ntcore",
"//glass:static/glassnt",
],
visibility = ["//visibility:public"],
deps = [
":halsim_gui_static",
],
)
cc_test(
name = "halsim_gui-test",
size = "small",
srcs = glob(["src/test/native/**/*.cpp"]),
tags = [
"no-asan",
"wpi-cpp-gui",
],
deps = [
":halsim_gui",
"//thirdparty/googletest",
],
)
cc_binary(
name = "DevMain-Cpp",
srcs = ["src/dev/native/cpp/main.cpp"],
tags = [
"wpi-cpp-gui",
],
deps = [
":halsim_gui",
],
)
package_default_cc_project(
name = "halsim_gui",
architectures = host_architectures,
maven_artifact_name = "halsim_gui",
maven_group_id = "org.wpilib.halsim",
)
PKG_CONFIG_DEPS = [
"//datalog:native/datalog/robotpy-native-datalog.pc",
"//datalog:robotpy-wpilog.generated_pkgcfg_files",
"//hal:native/wpihal/robotpy-native-mrclib.pc",
"//hal:native/wpihal/robotpy-native-wpihal.pc",
"//hal:robotpy-hal.generated_pkgcfg_files",
"//ntcore:native/ntcore/robotpy-native-ntcore.pc",
"//ntcore:pyntcore.generated_pkgcfg_files",
"//wpimath:native/wpimath/robotpy-native-wpimath.pc",
"//wpimath:robotpy-wpimath.generated_pkgcfg_files",
"//wpinet:native/wpinet/robotpy-native-wpinet.pc",
"//wpinet:robotpy-wpinet.generated_pkgcfg_files",
"//wpiutil:native/wpiutil/robotpy-native-wpiutil.pc",
"//wpiutil:robotpy-wpiutil.generated_pkgcfg_files",
]
halsim_gui_ext_extension(
srcs = glob(["src/main/python/halsim_gui/_ext/**/*.cpp"]),
)
define_pybind_library(
name = "robotpy-halsim-gui",
pkgcfgs = PKG_CONFIG_DEPS,
)
robotpy_py_test(
"python_tests",
srcs = glob(["src/test/python/**/*.py"]),
deps = [
":robotpy-halsim-gui",
requirement("pytest"),
],
)