diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index af331b9679..e2cdf81c2a 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -56,10 +56,11 @@ jobs: fail-fast: false 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: "Linux (native)", os: ubuntu-24.04, container: "wpilib/ubuntu-base:22.04", action: "test", config: "--config=linux", } + - { name: "Linux (systemcore)", os: ubuntu-24.04, container: "wpilib/ubuntu-base:22.04", action: "build", config: "--config=systemcore", } name: "${{ matrix.name }}" runs-on: ${{ matrix.os }} + container: ${{ matrix.container }} steps: - uses: actions/checkout@v4 with: { fetch-depth: 0 } diff --git a/glass/BUILD.bazel b/glass/BUILD.bazel new file mode 100644 index 0000000000..0ebb5b7de9 --- /dev/null +++ b/glass/BUILD.bazel @@ -0,0 +1,66 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") +load("//shared/bazel/rules/gen:gen-resources.bzl", "generate_resources") +load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file") + +cc_library( + name = "libglass", + srcs = glob(["src/lib/native/cpp/**/*.cpp"]), + hdrs = glob(["src/lib/native/include/**"]), + strip_include_prefix = "src/lib/native/include", + tags = [ + "wpi-cpp-gui", + ], + visibility = ["//visibility:public"], + deps = [ + "//fieldImages", + "//wpigui", + "//wpimath:wpimath.static", + "//wpiutil:wpiutil.static", + ], +) + +cc_library( + name = "libglassnt", + srcs = glob(["src/libnt/native/cpp/*.cpp"]), + hdrs = glob(["src/libnt/native/include/**/*.h"]), + strip_include_prefix = "src/libnt/native/include", + tags = [ + "wpi-cpp-gui", + ], + visibility = ["//visibility:public"], + deps = [ + ":libglass", + "//ntcore:ntcore.static", + ], +) + +generate_version_file( + name = "generate-version", + output_file = "WPILibVersion.cpp", + template = "src/app/generate/WPILibVersion.cpp.in", +) + +generate_resources( + name = "generate-resources", + namespace = "glass", + prefix = "GLASS", + resource_files = glob(["src/app/native/resources/*"]), +) + +cc_binary( + name = "glassApp", + srcs = [ + ":generate-resources", + ":generate-version", + ] + glob(["src/app/native/cpp/**"]), + linkopts = select({ + "@bazel_tools//src/conditions:windows": ["-SUBSYSTEM:WINDOWS"], + "//conditions:default": [], + }), + tags = [ + "wpi-cpp-gui", + ], + deps = [ + ":libglassnt", + ], +) diff --git a/outlineviewer/BUILD.bazel b/outlineviewer/BUILD.bazel new file mode 100644 index 0000000000..d711d876b9 --- /dev/null +++ b/outlineviewer/BUILD.bazel @@ -0,0 +1,40 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary") +load("//shared/bazel/rules/gen:gen-resources.bzl", "generate_resources") +load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file") + +generate_resources( + name = "generate-resources", + namespace = "ov", + prefix = "OV", + resource_files = glob(["src/main/native/resources/*"]), +) + +generate_version_file( + name = "generate-version", + output_file = "WPILibVersion.cpp", + template = "src/main/generate/WPILibVersion.cpp.in", +) + +cc_binary( + name = "outlineviewer", + srcs = glob(["src/main/native/cpp/*"]) + [ + ":generate-resources", + ":generate-version", + ], + linkopts = select({ + "@bazel_tools//src/conditions:windows": ["-SUBSYSTEM:WINDOWS"], + "//conditions:default": [], + }), + 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": [], + }), + deps = [ + "//glass:libglass", + "//glass:libglassnt", + ], +) diff --git a/shared/bazel/rules/objectivec_rules.bzl b/shared/bazel/rules/objectivec_rules.bzl new file mode 100644 index 0000000000..05d674fa3c --- /dev/null +++ b/shared/bazel/rules/objectivec_rules.bzl @@ -0,0 +1,37 @@ +load("@rules_cc//cc:defs.bzl", "objc_library") + +# These flags are added to match the current native-utils flags in https://github.com/wpilibsuite/native-utils/blob/d8555ca479438c9c08b4a2400a58f280fec90c3f/src/main/java/edu/wpi/first/nativeutils/WPINativeUtilsExtension.java +OBJC_COMPILER_FLAGS = [ + "-stdlib=libc++", + "-fPIC", +] + +def wpilib_objc_library( + name, + srcs = [], + deps = [], + copts = None, + is_cpp = True, + include_arc = True, + **kwargs): + """ + Helper macro for defining . + + Args: + is_cpp: If this is a C++ library. Specifying this will add additional C++ specific compiler flags + include_arc: If true, this will add compiler flags for ARC (Automatic Reference Counting) + """ + copts = copts or [] + if is_cpp: + copts.append("-std=c++20") + if include_arc: + copts += ["-fobjc-weak", "-fobjc-arc"] + + objc_library( + name = name, + srcs = srcs, + copts = copts + OBJC_COMPILER_FLAGS, + target_compatible_with = ["@platforms//os:osx"], + deps = deps, + **kwargs + ) diff --git a/simulation/halsim_ds_socket/BUILD.bazel b/simulation/halsim_ds_socket/BUILD.bazel new file mode 100644 index 0000000000..f11e9f6e64 --- /dev/null +++ b/simulation/halsim_ds_socket/BUILD.bazel @@ -0,0 +1,44 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") + +cc_library( + name = "headers", + hdrs = glob(["src/main/native/include/**"]), + includes = ["src/main/native/include"], +) + +cc_library( + name = "halsim_ds_socket", + srcs = glob(["src/main/native/cpp/**"]), + 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 = [ + ":headers", + "//hal:wpiHal.static", + "//wpinet:wpinet.static", + ], +) + +cc_test( + name = "halsim_ds_socket-test", + size = "small", + srcs = glob([ + "src/test/native/**/*.cpp", + "src/test/native/**/*.h", + ]), + deps = [ + "//simulation/halsim_ds_socket", + "//thirdparty/googletest:googletest.static", + ], +) + +cc_binary( + name = "DevMain-Cpp", + srcs = ["src/dev/native/cpp/main.cpp"], + deps = [ + ":halsim_ds_socket", + ], +) diff --git a/simulation/halsim_gui/BUILD.bazel b/simulation/halsim_gui/BUILD.bazel new file mode 100644 index 0000000000..40e9fc79c7 --- /dev/null +++ b/simulation/halsim_gui/BUILD.bazel @@ -0,0 +1,51 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") + +cc_library( + name = "halsim_gui", + srcs = glob([ + "src/main/native/cpp/*", + "src/main/native/include/*.h", + ]), + includes = ["src/main/native/include"], + 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:libglassnt", + "//hal:wpiHal.static", + ], +) + +cc_test( + name = "halsim_gui-test", + size = "small", + srcs = glob([ + "src/test/native/**/*.cpp", + "src/test/native/**/*.h", + ]), + tags = [ + "no-asan", + "wpi-cpp-gui", + ], + deps = [ + ":halsim_gui", + "//thirdparty/googletest:googletest.static", + ], +) + +cc_binary( + name = "DevMain-Cpp", + srcs = ["src/dev/native/cpp/main.cpp"], + tags = [ + "wpi-cpp-gui", + ], + deps = [ + ":halsim_gui", + ], +) diff --git a/simulation/halsim_ws_client/BUILD.bazel b/simulation/halsim_ws_client/BUILD.bazel new file mode 100644 index 0000000000..49948187ec --- /dev/null +++ b/simulation/halsim_ws_client/BUILD.bazel @@ -0,0 +1,27 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") + +cc_library( + name = "halsim_ws_client", + srcs = glob([ + "src/main/native/cpp/*.cpp", + "src/main/native/include/*.h", + ]), + includes = ["src/main/native/include"], + 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 = [ + "//simulation/halsim_ws_core", + ], +) + +cc_binary( + name = "DevMain-Cpp", + srcs = ["src/dev/native/cpp/main.cpp"], + deps = [ + ":halsim_ws_client", + ], +) diff --git a/simulation/halsim_ws_core/BUILD.bazel b/simulation/halsim_ws_core/BUILD.bazel new file mode 100644 index 0000000000..93cbcc3bad --- /dev/null +++ b/simulation/halsim_ws_core/BUILD.bazel @@ -0,0 +1,22 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + +cc_library( + name = "halsim_ws_core", + srcs = glob(["src/main/native/cpp/*.cpp"]), + hdrs = glob([ + "src/main/native/include/*.h", + "src/main/native/include/*.inc", + ]), + strip_include_prefix = "src/main/native/include", + 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 = [ + "//hal:wpiHal.static", + "//wpinet:wpinet.static", + "//wpiutil:wpiutil.static", + ], +) diff --git a/simulation/halsim_ws_server/BUILD.bazel b/simulation/halsim_ws_server/BUILD.bazel new file mode 100644 index 0000000000..34840b6a0e --- /dev/null +++ b/simulation/halsim_ws_server/BUILD.bazel @@ -0,0 +1,51 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") + +cc_library( + name = "headers", + hdrs = glob(["src/main/native/include/**"]), + includes = ["src/main/native/include"], +) + +cc_library( + name = "halsim_ws_server", + srcs = glob(["src/main/native/cpp/**"]), + 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 = [ + ":headers", + "//simulation/halsim_ws_core", + ], +) + +cc_library( + name = "test_headers", + srcs = glob(["src/test/native/include/*.h"]), + includes = ["src/test/native/include"], + strip_include_prefix = "src/test/native/include", +) + +cc_test( + name = "halsim_ws_server-test", + size = "small", + srcs = glob(["src/test/native/**/*.cpp"]), + tags = [ + "no-asan", + ], + deps = [ + ":halsim_ws_server", + ":test_headers", + "//thirdparty/googletest:googletest.static", + ], +) + +cc_binary( + name = "DevMain-Cpp", + srcs = ["src/dev/native/cpp/main.cpp"], + deps = [ + ":halsim_ws_server", + ], +) diff --git a/simulation/halsim_xrp/BUILD.bazel b/simulation/halsim_xrp/BUILD.bazel new file mode 100644 index 0000000000..000a60fc50 --- /dev/null +++ b/simulation/halsim_xrp/BUILD.bazel @@ -0,0 +1,25 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") + +cc_library( + name = "halsim_xrp", + srcs = glob([ + "src/main/native/cpp/*", + "src/main/native/include/*.h", + ]), + includes = ["src/main/native/include"], + 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 = [ + "//simulation/halsim_ws_core", + "//xrpVendordep:xrp-cpp", + ], +) + +cc_binary( + name = "DevMain-Cpp", + srcs = ["src/dev/native/cpp/main.cpp"], +) diff --git a/sysid/BUILD.bazel b/sysid/BUILD.bazel new file mode 100644 index 0000000000..4372fdfb70 --- /dev/null +++ b/sysid/BUILD.bazel @@ -0,0 +1,59 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") +load("//shared/bazel/rules/gen:gen-resources.bzl", "generate_resources") +load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file") + +generate_version_file( + name = "generate-version", + output_file = "WPILibVersion.cpp", + template = "src/main/generate/WPILibVersion.cpp.in", + visibility = ["//sysid:__subpackages__"], +) + +generate_resources( + name = "generate-resources", + namespace = "sysid", + prefix = "SYSID", + resource_files = glob(["src/main/native/resources/*"]), +) + +cc_library( + name = "sysid-lib", + srcs = glob( + ["src/main/native/cpp/**/*.cpp"], + exclude = ["src/main/native/cpp/Main.cpp"], + ) + [ + ":generate-resources", + ":generate-version", + ], + hdrs = glob(["src/main/native/include/**"]), + strip_include_prefix = "src/main/native/include", + visibility = ["//sysid:__subpackages__"], + deps = [ + "//datalog:datalog.static", + "//glass:libglass", + "//wpinet:wpinet.static", + ], +) + +cc_binary( + name = "sysid", + srcs = ["src/main/native/cpp/Main.cpp"], + linkopts = select({ + "@bazel_tools//src/conditions:windows": ["-SUBSYSTEM:WINDOWS"], + "//conditions:default": [], + }), + deps = ["sysid-lib"], +) + +cc_test( + name = "sysid-test", + size = "medium", + srcs = glob(["src/test/native/cpp/**"]), + tags = [ + "no-asan", + ], + deps = [ + ":sysid-lib", + "//thirdparty/googletest:googletest.static", + ], +) diff --git a/thirdparty/imgui_suite/BUILD.bazel b/thirdparty/imgui_suite/BUILD.bazel new file mode 100644 index 0000000000..3e4bf54263 --- /dev/null +++ b/thirdparty/imgui_suite/BUILD.bazel @@ -0,0 +1,360 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") +load("@rules_python//python:defs.bzl", "py_binary") +load("//shared/bazel/rules:objectivec_rules.bzl", "wpilib_objc_library") + +cc_library( + name = "gl3w", + srcs = ["generated/gl3w/src/gl3w.c"], + hdrs = [ + "generated/gl3w/include/GL/gl3w.h", + "generated/gl3w/include/GL/glcorearb.h", + "generated/gl3w/include/KHR/khrplatform.h", + ], + includes = [ + "generated/gl3w/include", + ], + strip_include_prefix = "generated/gl3w/include", +) + +cc_library( + name = "fonts", + srcs = glob(["generated/fonts/src/**"]), + hdrs = glob(["generated/fonts/include/**"]), + includes = ["generated/fonts/include"], + deps = [ + ":imgui", + ], +) + +py_binary( + name = "gl3w_gen", + srcs = ["gl3w/gl3w_gen.py"], + target_compatible_with = select({ + "@rules_bzlmodrio_toolchains//constraints/is_roborio:roborio": ["@platforms//:incompatible"], + "@rules_bzlmodrio_toolchains//constraints/is_systemcore:systemcore": ["@platforms//:incompatible"], + "//conditions:default": [], + }), +) + +#---------------------------------------- +# GLFW +#---------------------------------------- + +COMMON_SOURCES = [ + "glfw/src/internal.h", + "glfw/src/platform.h", + "glfw/src/mappings.h", + "glfw/src/context.c", + "glfw/src/init.c", + "glfw/src/input.c", + "glfw/src/monitor.c", + "glfw/src/platform.c", + "glfw/src/vulkan.c", + "glfw/src/window.c", + "glfw/src/egl_context.c", + "glfw/src/osmesa_context.c", + "glfw/src/null_platform.h", + "glfw/src/null_joystick.h", + "glfw/src/null_init.c", + "glfw/src/null_monitor.c", + "glfw/src/null_window.c", + "glfw/src/null_joystick.c", +] + [ +] + +############################ +# Linux +############################ + +LINUX_DEFINES = ["_GLFW_X11"] + +LINUX_LINKOPTS = [] + +LINUX_SOURCES = COMMON_SOURCES + [ + "glfw/src/posix_time.h", + "glfw/src/posix_thread.h", + "glfw/src/posix_module.c", + "glfw/src/posix_time.c", + "glfw/src/posix_thread.c", + "glfw/src/x11_platform.h", + "glfw/src/xkb_unicode.h", + "glfw/src/x11_init.c", + "glfw/src/x11_monitor.c", + "glfw/src/x11_window.c", + "glfw/src/xkb_unicode.c", + "glfw/src/glx_context.c", + "glfw/src/linux_joystick.h", + "glfw/src/linux_joystick.c", + "glfw/src/posix_poll.h", + "glfw/src/posix_poll.c", +] + +############################ +# Windows +############################ + +WINDOWS_DEFINES = [ + "_GLFW_WIN32", + "GLFW_INVALID_CODEPOINT", +] + +WINDOWS_LINKOPTS = [ + "-DEFAULTLIB:user32.lib", + "-DEFAULTLIB:gdi32.lib", + "-DEFAULTLIB:shell32.lib", +] + +WINDOWS_SOURCES = COMMON_SOURCES + [ + "glfw/src/win32_time.h", + "glfw/src/win32_thread.h", + "glfw/src/win32_module.c", + "glfw/src/win32_time.c", + "glfw/src/win32_thread.c", + "glfw/src/win32_platform.h", + "glfw/src/win32_joystick.h", + "glfw/src/win32_init.c", + "glfw/src/win32_joystick.c", + "glfw/src/win32_monitor.c", + "glfw/src/win32_window.c", + "glfw/src/wgl_context.c", +] + +############################ +# Mac +############################ +DARWIN_DEFINES = [ + "_GLFW_COCOA", + "_GLFW_NSGL", + "_GLFW_NO_DLOAD_WINMM", + "_GLFW_USE_OPENGL", +] + +DARWIN_LINKOPTS = [] + +DARWIN_SOURCES = COMMON_SOURCES + [ + "glfw/src/cocoa_time.h", + "glfw/src/cocoa_time.c", + "glfw/src/posix_thread.h", + "glfw/src/posix_module.c", + "glfw/src/posix_thread.c", + "glfw/src/cocoa_platform.h", + "glfw/src/cocoa_joystick.h", + "glfw/src/cocoa_init.m", + "glfw/src/cocoa_joystick.m", + "glfw/src/cocoa_monitor.m", + "glfw/src/cocoa_window.m", + "glfw/src/nsgl_context.m", +] + +cc_library( + name = "glfw_hdrs", + hdrs = [ + "glfw/include/GLFW/glfw3.h", + "glfw/include/GLFW/glfw3native.h", + ], + includes = [ + "glfw/include", + ], + strip_include_prefix = "glfw/include", +) + +cc_library( + name = "glfw_src", + srcs = select({ + "@bazel_tools//src/conditions:windows": WINDOWS_SOURCES, + "@rules_bzlmodrio_toolchains//constraints/combined:is_linux": LINUX_SOURCES, + }), + defines = select({ + "@bazel_tools//src/conditions:windows": WINDOWS_DEFINES, + "@rules_bzlmodrio_toolchains//constraints/combined:is_linux": LINUX_DEFINES, + }), + tags = ["manual"], + deps = [ + ":glfw_hdrs", + ], +) + +wpilib_objc_library( + name = "glfw_src_darwin", + srcs = DARWIN_SOURCES, + copts = [ + "-fno-objc-arc", + "-Wno-unused-parameter", + "-Wno-sign-compare", + "-Wno-unused-command-line-argument", + ], + defines = DARWIN_DEFINES + ["GLFW_INVALID_CODEPOINT"], + include_arc = False, + is_cpp = False, + deps = [ + ":glfw_hdrs", + ], +) + +cc_library( + name = "glfw", + linkopts = select({ + "@bazel_tools//src/conditions:darwin": DARWIN_LINKOPTS, + "@bazel_tools//src/conditions:windows": WINDOWS_LINKOPTS, + "@rules_bzlmodrio_toolchains//constraints/combined:is_linux": LINUX_LINKOPTS, + }), + linkstatic = True, + target_compatible_with = select({ + "@rules_bzlmodrio_toolchains//constraints/is_roborio:roborio": ["@platforms//:incompatible"], + "//conditions:default": [], + }), + visibility = ["//thirdparty/imgui_suite:__subpackages__"], + deps = [":glfw_hdrs"] + select({ + "@bazel_tools//src/conditions:darwin": [":glfw_src_darwin"], + "@bazel_tools//src/conditions:windows": [":glfw_src"], + "@rules_bzlmodrio_toolchains//constraints/combined:is_linux": [":glfw_src"], + }), +) + +#---------------------------------------- +# IMGUI +#---------------------------------------- +IMGUI_COMMON_SOURCES = glob(["imgui/cpp/*.cpp"]) + [ + "imgui/cpp/misc/cpp/imgui_stdlib.cpp", +] + +IMGUI_COMMON_HEADERS = glob(["imgui/include/*.h"]) + [ + "imgui/include/misc/cpp/imgui_stdlib.h", +] + +########################### +# Linux +########################### +IMGUI_LINUX_SRCS = [ + "imgui/cpp/backends/imgui_impl_glfw.cpp", + "imgui/cpp/backends/imgui_impl_opengl2.cpp", + "imgui/cpp/backends/imgui_impl_opengl3.cpp", +] + +IMGUI_LINUX_HDRS = [ + "imgui/include/backends/imgui_impl_glfw.h", + "imgui/include/backends/imgui_impl_opengl2.h", + "imgui/include/backends/imgui_impl_opengl3.h", + "imgui/include/backends/imgui_impl_opengl3_loader.h", +] + +########################### +# OSX +########################### +IMGUI_DARWIN_SRCS = [ + "imgui/cpp/backends/imgui_impl_glfw.cpp", + "imgui/cpp/backends/imgui_impl_metal.mm", +] + +IMGUI_DARWIN_HDRS = [ + "imgui/include/backends/imgui_impl_glfw.h", + "imgui/include/backends/imgui_impl_metal.h", +] + +########################### +# Windows +########################### +IMGUI_WIN_SRCS = [ + "imgui/cpp/backends/imgui_impl_glfw.cpp", + "imgui/cpp/backends/imgui_impl_dx11.cpp", +] + +IMGUI_WIN_HDRS = [ + "imgui/include/backends/imgui_impl_glfw.h", + "imgui/include/backends/imgui_impl_dx11.h", +] + +cc_library( + name = "imgui_src", + srcs = IMGUI_COMMON_SOURCES + select({ + "@bazel_tools//src/conditions:windows": IMGUI_WIN_SRCS, + "@rules_bzlmodrio_toolchains//constraints/combined:is_linux": IMGUI_LINUX_SRCS, + }), + hdrs = IMGUI_COMMON_HEADERS + select({ + "@bazel_tools//src/conditions:windows": IMGUI_WIN_HDRS, + "@rules_bzlmodrio_toolchains//constraints/combined:is_linux": IMGUI_LINUX_HDRS, + }), + includes = [ + "imgui/include", + "imgui/include/backends", + "imgui/include/misc/cpp", + ], + linkstatic = True, + strip_include_prefix = "imgui/include", + tags = ["manual"], + visibility = ["//thirdparty/imgui_suite:__subpackages__"], + deps = [ + ":glfw", + ], +) + +wpilib_objc_library( + name = "imgui_src_darwin", + srcs = IMGUI_COMMON_SOURCES + IMGUI_DARWIN_SRCS, + hdrs = IMGUI_COMMON_HEADERS + IMGUI_DARWIN_HDRS, + include_arc = False, + includes = [ + "imgui/include", + "imgui/include/backends", + "imgui/include/misc/cpp", + ], + deps = [ + ":glfw", + ], +) + +cc_library( + name = "imgui", + visibility = ["//thirdparty/imgui_suite:__subpackages__"], + deps = select({ + "@bazel_tools//src/conditions:darwin": [":imgui_src_darwin"], + "@bazel_tools//src/conditions:windows": [":imgui_src"], + "@rules_bzlmodrio_toolchains//constraints/combined:is_linux": [":imgui_src"], + }), +) + +#---------------------------------------- +# IMPLOT +#---------------------------------------- + +cc_library( + name = "implot", + srcs = glob(["implot/cpp/**"]), + hdrs = glob(["implot/include/**"]), + includes = ["implot/include"], + linkstatic = True, + strip_include_prefix = "implot/include", + visibility = ["//thirdparty/imgui_suite:__subpackages__"], + deps = [ + "//thirdparty/imgui_suite:imgui", + ], +) + +#---------------------------------- +# STB +#---------------------------------- + +cc_library( + name = "stb", + srcs = glob(["stb/cpp/**"]), + hdrs = glob(["stb/include/**"]), + linkstatic = True, + strip_include_prefix = "stb/include", + visibility = ["//visibility:public"], +) + +######################################### +# IMGUI suite +######################################### +cc_library( + name = "imgui_suite", + linkstatic = True, + visibility = ["//visibility:public"], + deps = [ + ":fonts", + ":gl3w", + ":imgui", + ":implot", + ":stb", + ], +) diff --git a/wpigui/BUILD.bazel b/wpigui/BUILD.bazel new file mode 100644 index 0000000000..fcaefac228 --- /dev/null +++ b/wpigui/BUILD.bazel @@ -0,0 +1,54 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") +load("//shared/bazel/rules:objectivec_rules.bzl", "wpilib_objc_library") + +WIN_SRCS = glob(["src/main/native/directx11/**/*.cpp"]) + +LINUX_SRCS = glob(["src/main/native/opengl3/**/*.cpp"]) + +MAC_SRCS = glob(["src/main/native/metal/**/*.mm"]) + +cc_library( + name = "headers", + hdrs = glob(["src/main/native/include/**/*"]), + strip_include_prefix = "src/main/native/include", +) + +wpilib_objc_library( + name = "wpigui-mac", + srcs = MAC_SRCS, + sdk_frameworks = [ + "Metal", + "MetalKit", + "Cocoa", + "IOKit", + "CoreFoundation", + "CoreVideo", + "QuartzCore", + ], + deps = [ + ":headers", + "//thirdparty/imgui_suite", + ], +) + +cc_library( + name = "wpigui", + srcs = glob(["src/main/native/cpp/**/*.cpp"]) + + select({ + "@bazel_tools//src/conditions:darwin": [], + "@bazel_tools//src/conditions:windows": WIN_SRCS, + "@rules_bzlmodrio_toolchains//constraints/combined:is_linux": LINUX_SRCS, + }), + strip_include_prefix = "include", + tags = [ + "wpi-cpp-gui", + ], + visibility = ["//visibility:public"], + deps = [ + ":headers", + "//thirdparty/imgui_suite", + ] + select({ + "@bazel_tools//src/conditions:darwin": [":wpigui-mac"], + "//conditions:default": [], + }), +)