Skip to content

Commit 47cba9b

Browse files
authored
[email protected] This change adds Windows support
1 parent 9cff6eb commit 47cba9b

File tree

6 files changed

+238
-1
lines changed

6 files changed

+238
-1
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module(
2+
name = "glfw",
3+
version = "3.4.0.bcr.1",
4+
bazel_compatibility = [">=7.2.1"],
5+
compatibility_level = 0,
6+
)
7+
8+
bazel_dep(name = "apple_support", version = "1.24.5")
9+
bazel_dep(name = "libx11", version = "1.8.12.bcr.4")
10+
bazel_dep(name = "libxcursor", version = "1.2.3")
11+
bazel_dep(name = "libxi", version = "1.8.2")
12+
bazel_dep(name = "libxinerama", version = "1.1.5")
13+
bazel_dep(name = "libxrandr", version = "1.5.4")
14+
bazel_dep(name = "platforms", version = "1.0.0")
15+
bazel_dep(name = "rules_cc", version = "0.2.14")
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
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+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module(
2+
name = "glfw",
3+
version = "3.4.0.bcr.1",
4+
bazel_compatibility = [">=7.2.1"],
5+
compatibility_level = 0,
6+
)
7+
8+
bazel_dep(name = "apple_support", version = "1.24.5")
9+
bazel_dep(name = "libx11", version = "1.8.12.bcr.4")
10+
bazel_dep(name = "libxcursor", version = "1.2.3")
11+
bazel_dep(name = "libxi", version = "1.8.2")
12+
bazel_dep(name = "libxinerama", version = "1.1.5")
13+
bazel_dep(name = "libxrandr", version = "1.5.4")
14+
bazel_dep(name = "platforms", version = "1.0.0")
15+
bazel_dep(name = "rules_cc", version = "0.2.14")
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
matrix:
2+
linux_platform: ["ubuntu2004", "ubuntu2004_arm64", "ubuntu2204", "ubuntu2404", "debian11"]
3+
osx_platform: ["macos", "macos_arm64"]
4+
bazel: [7.x, 8.x, rolling]
5+
6+
tasks:
7+
verify_linux_targets:
8+
name: Verify linux build and test targets
9+
platform: ${{ linux_platform }}
10+
bazel: ${{ bazel }}
11+
build_targets:
12+
- '@glfw//:glfw'
13+
verify_osx_targets:
14+
name: Verify osx build and test targets
15+
platform: ${{ osx_platform }}
16+
bazel: ${{ bazel }}
17+
build_targets:
18+
- '@glfw//:glfw'
19+
build_flags:
20+
- "--repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1"
21+
verify_windows_targets:
22+
name: Verify windows build and test targets
23+
platform: windows
24+
bazel: ${{ bazel }}
25+
build_targets:
26+
- '@glfw//:glfw'
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"integrity": "sha256-tewASycS/Qjohh3CcUKPBId1IAot9xnM9XUUO6dJo+k=",
3+
"patch_strip": 0,
4+
"overlay": {
5+
"BUILD.bazel": "sha256-VW0GQUc410TBzNMn9kj+Ijk5q2ucCP7my1uY2OE6itk=",
6+
"MODULE.bazel": "sha256-WuNK5p7atvi8ZWICPRm97cqsfxyZCc2/l7QtZMKPxJ0="
7+
},
8+
"strip_prefix": "glfw-3.4",
9+
"url": "https://github.com/glfw/glfw/releases/download/3.4/glfw-3.4.zip"
10+
}

modules/glfw/metadata.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"versions": [
2020
"3.3.9",
2121
"3.3.9.bcr.1",
22-
"3.4.0"
22+
"3.4.0",
23+
"3.4.0.bcr.1"
2324
],
2425
"yanked_versions": {}
2526
}

0 commit comments

Comments
 (0)