mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
494 lines
12 KiB
Python
494 lines
12 KiB
Python
load("@rules_cc//cc:defs.bzl", "cc_library")
|
|
load("@rules_pkg//:mappings.bzl", "pkg_files")
|
|
load("@rules_pkg//:pkg.bzl", "pkg_zip")
|
|
load("@rules_python//python:defs.bzl", "py_binary")
|
|
load("//shared/bazel/rules:cc_rules.bzl", "wpilib_cc_library", "wpilib_cc_static_library")
|
|
load("//shared/bazel/rules:objectivec_rules.bzl", "wpilib_objc_library")
|
|
load("//shared/bazel/rules:packaging.bzl", "package_minimal_cc_project")
|
|
|
|
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({
|
|
"@platforms//os:windows": WINDOWS_SOURCES,
|
|
"@rules_bzlmodrio_toolchains//constraints/combined:is_linux": LINUX_SOURCES,
|
|
}),
|
|
defines = select({
|
|
"@platforms//os:windows": WINDOWS_DEFINES,
|
|
"@rules_bzlmodrio_toolchains//constraints/combined:is_linux": LINUX_DEFINES,
|
|
}),
|
|
linkopts = select({
|
|
"@platforms//os:windows": WINDOWS_LINKOPTS,
|
|
"@rules_bzlmodrio_toolchains//constraints/combined:is_linux": LINUX_LINKOPTS,
|
|
}),
|
|
target_compatible_with = select({
|
|
"@platforms//os:windows": [],
|
|
"@rules_bzlmodrio_toolchains//constraints/combined:is_linux": [],
|
|
"//conditions:default": ["@platforms//:incompatible"],
|
|
}),
|
|
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,
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
":glfw_hdrs",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "glfw",
|
|
linkopts = select({
|
|
"@platforms//os:osx": DARWIN_LINKOPTS,
|
|
"@platforms//os: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": [],
|
|
}),
|
|
deps = [":glfw_hdrs"] + select({
|
|
"@platforms//os:osx": [":glfw_src_darwin"],
|
|
"@platforms//os: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({
|
|
"@platforms//os:windows": IMGUI_WIN_SRCS,
|
|
"@rules_bzlmodrio_toolchains//constraints/combined:is_linux": IMGUI_LINUX_SRCS,
|
|
}),
|
|
hdrs = IMGUI_COMMON_HEADERS + select({
|
|
"@platforms//os: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",
|
|
target_compatible_with = select({
|
|
"@platforms//os:windows": [],
|
|
"@rules_bzlmodrio_toolchains//constraints/combined:is_linux": [],
|
|
"//conditions:default": ["@platforms//:incompatible"],
|
|
}),
|
|
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",
|
|
],
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
":glfw",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "imgui",
|
|
deps = select({
|
|
"@platforms//os:osx": [":imgui_src_darwin"],
|
|
"@platforms//os: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",
|
|
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",
|
|
)
|
|
|
|
#########################################
|
|
# IMGUI suite
|
|
#########################################
|
|
wpilib_cc_library(
|
|
name = "imgui_suite",
|
|
hdrs_pkg_root = None,
|
|
linkstatic = True,
|
|
srcs_pkg_root = None,
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
":fonts",
|
|
":gl3w",
|
|
":imgui",
|
|
":implot",
|
|
":stb",
|
|
],
|
|
)
|
|
|
|
wpilib_cc_static_library(
|
|
name = "static/imguiSuite",
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
":imgui_suite",
|
|
],
|
|
)
|
|
|
|
pkg_files(
|
|
name = "glfw-hdrs-pkg",
|
|
srcs = glob(["glfw/include/**"]),
|
|
strip_prefix = "glfw/include",
|
|
)
|
|
|
|
pkg_files(
|
|
name = "imgui-hdrs-pkg",
|
|
srcs = glob(["imgui/include/**"]),
|
|
strip_prefix = "imgui/include",
|
|
)
|
|
|
|
pkg_files(
|
|
name = "implot-hdrs-pkg",
|
|
srcs = glob(["implot/include/**"]),
|
|
strip_prefix = "implot/include",
|
|
)
|
|
|
|
pkg_files(
|
|
name = "stb-hdrs-pkg",
|
|
srcs = glob(["stb/include/**"]),
|
|
strip_prefix = "stb/include",
|
|
)
|
|
|
|
pkg_files(
|
|
name = "generated-fonts-hdrs-pkg",
|
|
srcs = glob(["generated/fonts/include/**"]),
|
|
strip_prefix = "generated/fonts/include/",
|
|
)
|
|
|
|
pkg_files(
|
|
name = "generated-gl3w-hdrs-pkg",
|
|
srcs = glob(["generated/gl3w/include/**"]),
|
|
strip_prefix = "generated/gl3w/include/",
|
|
)
|
|
|
|
pkg_zip(
|
|
name = "imguiSuite-hdrs-zip",
|
|
srcs = [
|
|
"generated-fonts-hdrs-pkg",
|
|
"generated-gl3w-hdrs-pkg",
|
|
"glfw-hdrs-pkg",
|
|
"imgui-hdrs-pkg",
|
|
"implot-hdrs-pkg",
|
|
"stb-hdrs-pkg",
|
|
"//:license_pkg_files",
|
|
],
|
|
tags = [
|
|
"manual",
|
|
],
|
|
)
|
|
|
|
pkg_files(
|
|
name = "glfw-srcs-pkg",
|
|
srcs = glob(["glfw/src/**"]),
|
|
strip_prefix = "glfw/src",
|
|
)
|
|
|
|
pkg_files(
|
|
name = "imgui-srcs-pkg",
|
|
srcs = glob(["imgui/cpp/**"]),
|
|
strip_prefix = "imgui/cpp",
|
|
)
|
|
|
|
pkg_files(
|
|
name = "implot-srcs-pkg",
|
|
srcs = glob(["implot/cpp/**"]),
|
|
strip_prefix = "implot/cpp",
|
|
)
|
|
|
|
pkg_files(
|
|
name = "stb-srcs-pkg",
|
|
srcs = glob(["stb/cpp/**"]),
|
|
strip_prefix = "stb/cpp",
|
|
)
|
|
|
|
pkg_files(
|
|
name = "generated-fonts-srcs-pkg",
|
|
srcs = glob(["generated/fonts/src/**"]),
|
|
strip_prefix = "generated/fonts/src/",
|
|
)
|
|
|
|
pkg_files(
|
|
name = "generated-gl3w-srcs-pkg",
|
|
srcs = glob(["generated/gl3w/src/**"]),
|
|
strip_prefix = "generated/gl3w/src/",
|
|
)
|
|
|
|
pkg_zip(
|
|
name = "imguiSuite-srcs-zip",
|
|
srcs = [
|
|
"generated-fonts-srcs-pkg",
|
|
"generated-gl3w-srcs-pkg",
|
|
"glfw-srcs-pkg",
|
|
"imgui-srcs-pkg",
|
|
"implot-srcs-pkg",
|
|
"stb-srcs-pkg",
|
|
"//:license_pkg_files",
|
|
],
|
|
tags = [
|
|
"manual",
|
|
],
|
|
)
|
|
|
|
package_minimal_cc_project(
|
|
name = "imguiSuite",
|
|
maven_artifact_name = "imguiSuite-cpp",
|
|
maven_group_id = "edu.wpi.first.thirdparty.imguiSuite",
|
|
)
|