|
| 1 | +load("@rules_cc//cc:cc_library.bzl", "cc_library") |
| 2 | +load("@rules_cc//cc:objc_library.bzl", "objc_library") |
| 3 | + |
| 4 | +cc_library( |
| 5 | + name = "glfw-headers", |
| 6 | + hdrs = [ |
| 7 | + "include/GLFW/glfw3.h", |
| 8 | + "include/GLFW/glfw3native.h", |
| 9 | + ], |
| 10 | + includes = ["include"], |
| 11 | + visibility = [ |
| 12 | + "//visibility:private", |
| 13 | + ], |
| 14 | +) |
| 15 | + |
| 16 | +COMMON_HDRS = [ |
| 17 | + "include/GLFW/glfw3.h", |
| 18 | + "include/GLFW/glfw3native.h", |
| 19 | + "src/internal.h", |
| 20 | + "src/mappings.h", |
| 21 | + "src/null_joystick.h", |
| 22 | + "src/null_platform.h", |
| 23 | + "src/xkb_unicode.h", |
| 24 | + "src/platform.h", |
| 25 | +] |
| 26 | + |
| 27 | +COMMON_SRCS = [ |
| 28 | + "src/context.c", |
| 29 | + "src/egl_context.c", |
| 30 | + "src/init.c", |
| 31 | + "src/input.c", |
| 32 | + "src/osmesa_context.c", |
| 33 | + "src/monitor.c", |
| 34 | + "src/null_init.c", |
| 35 | + "src/null_window.c", |
| 36 | + "src/null_monitor.c", |
| 37 | + "src/null_joystick.c", |
| 38 | + "src/vulkan.c", |
| 39 | + "src/window.c", |
| 40 | + "src/xkb_unicode.c", |
| 41 | + "src/platform.c", |
| 42 | +] |
| 43 | + |
| 44 | +DARWIN_HDRS = [ |
| 45 | + "src/cocoa_joystick.h", |
| 46 | + "src/cocoa_platform.h", |
| 47 | + "src/cocoa_time.h", |
| 48 | + "src/posix_thread.h", |
| 49 | + "src/wl_platform.h", |
| 50 | +] |
| 51 | + |
| 52 | +DARWIN_SRCS = [ |
| 53 | + "src/cocoa_init.m", |
| 54 | + "src/cocoa_time.c", |
| 55 | + "src/cocoa_joystick.m", |
| 56 | + "src/cocoa_monitor.m", |
| 57 | + "src/cocoa_window.m", |
| 58 | + "src/nsgl_context.m", |
| 59 | + "src/posix_module.c", |
| 60 | + "src/posix_poll.c", |
| 61 | + "src/posix_thread.c", |
| 62 | +] |
| 63 | + |
| 64 | +LINUX_HDRS = [ |
| 65 | + "src/linux_joystick.h", |
| 66 | + "src/posix_poll.h", |
| 67 | + "src/posix_thread.h", |
| 68 | + "src/posix_time.h", |
| 69 | + "src/x11_platform.h", |
| 70 | +] |
| 71 | + |
| 72 | +LINUX_SRCS = [ |
| 73 | + "src/glx_context.c", |
| 74 | + "src/linux_joystick.c", |
| 75 | + "src/posix_module.c", |
| 76 | + "src/posix_poll.c", |
| 77 | + "src/posix_thread.c", |
| 78 | + "src/posix_time.c", |
| 79 | + "src/x11_init.c", |
| 80 | + "src/x11_monitor.c", |
| 81 | + "src/x11_window.c", |
| 82 | +] |
| 83 | + |
| 84 | +WIN32_SRCS = [ |
| 85 | + "src/win32_init.c", |
| 86 | + "src/win32_joystick.c", |
| 87 | + "src/win32_module.c", |
| 88 | + "src/win32_monitor.c", |
| 89 | + "src/win32_thread.c", |
| 90 | + "src/win32_time.c", |
| 91 | + "src/win32_window.c", |
| 92 | + "src/wgl_context.c", |
| 93 | +] |
| 94 | + |
| 95 | +WIN32_HDRS = [ |
| 96 | + "src/win32_joystick.h", |
| 97 | + "src/win32_platform.h", |
| 98 | + "src/win32_thread.h", |
| 99 | + "src/win32_time.h", |
| 100 | +] |
| 101 | + |
| 102 | +objc_library( |
| 103 | + name = "glfw-cocoa", |
| 104 | + srcs = COMMON_SRCS + DARWIN_SRCS, |
| 105 | + hdrs = COMMON_HDRS + DARWIN_HDRS, |
| 106 | + copts = [ |
| 107 | + "-fno-objc-arc", |
| 108 | + ], |
| 109 | + defines = [ |
| 110 | + "_GLFW_COCOA", |
| 111 | + "GLFW_INVALID_CODEPOINT", |
| 112 | + ], |
| 113 | + linkopts = [ |
| 114 | + "-framework OpenGL", |
| 115 | + "-framework Cocoa", |
| 116 | + "-framework IOKit", |
| 117 | + "-framework CoreFoundation", |
| 118 | + ], |
| 119 | + target_compatible_with = ["@platforms//os:macos"], |
| 120 | + visibility = ["//visibility:private"], |
| 121 | +) |
| 122 | + |
| 123 | +cc_library( |
| 124 | + name = "glfw-linux", |
| 125 | + srcs = COMMON_SRCS + LINUX_SRCS, |
| 126 | + hdrs = COMMON_HDRS + LINUX_HDRS, |
| 127 | + defines = ["_GLFW_X11"], |
| 128 | + target_compatible_with = ["@platforms//os:linux"], |
| 129 | + visibility = ["//visibility:private"], |
| 130 | + deps = [ |
| 131 | + "@libx11", |
| 132 | + "@libxcursor", |
| 133 | + "@libxi", |
| 134 | + "@libxinerama", |
| 135 | + "@libxrandr", |
| 136 | + ], |
| 137 | +) |
| 138 | + |
| 139 | +cc_library( |
| 140 | + name = "glfw-windows", |
| 141 | + srcs = COMMON_SRCS + WIN32_SRCS, |
| 142 | + hdrs = COMMON_HDRS + WIN32_HDRS, |
| 143 | + defines = ["_GLFW_WIN32"], |
| 144 | + linkopts = [ |
| 145 | + "-DEFAULTLIB:user32.lib", |
| 146 | + "-DEFAULTLIB:gdi32.lib", |
| 147 | + "-DEFAULTLIB:shell32.lib", |
| 148 | + ], |
| 149 | + target_compatible_with = ["@platforms//os:windows"], |
| 150 | + visibility = ["//visibility:private"], |
| 151 | +) |
| 152 | + |
| 153 | +cc_library( |
| 154 | + name = "glfw", |
| 155 | + visibility = ["//visibility:public"], |
| 156 | + deps = select({ |
| 157 | + "@platforms//os:linux": [ |
| 158 | + ":glfw-headers", |
| 159 | + ":glfw-linux", |
| 160 | + ], |
| 161 | + "@platforms//os:macos": [ |
| 162 | + ":glfw-cocoa", |
| 163 | + ":glfw-headers", |
| 164 | + ], |
| 165 | + "@platforms//os:windows": [ |
| 166 | + "glfw-windows", |
| 167 | + ":glfw-headers", |
| 168 | + ], |
| 169 | + }), |
| 170 | +) |
0 commit comments