Skip to content

Commit e600133

Browse files
committed
Switch to zig 0.14
1 parent 74d4cea commit e600133

File tree

5 files changed

+35
-90
lines changed

5 files changed

+35
-90
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Setup Zig
1414
run: |
1515
sudo apt install xz-utils
16-
sudo sh -c 'wget -c https://pkg.machengine.org/zig/zig-linux-x86_64-0.14.0-dev.1911+3bf89f55c.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
16+
sudo sh -c 'wget -c https://ziglang.org/download/0.14.0/zig-linux-x86_64-0.14.0.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
1717
- name: build
1818
run: zig build
1919
x86_64-windows:
@@ -26,10 +26,10 @@ jobs:
2626
- name: Setup Zig
2727
run: |
2828
$ProgressPreference = 'SilentlyContinue'
29-
Invoke-WebRequest -Uri "https://pkg.machengine.org/zig/zig-windows-x86_64-0.14.0-dev.1911+3bf89f55c.zip" -OutFile "C:\zig.zip"
29+
Invoke-WebRequest -Uri "https://ziglang.org/download/0.14.0/zig-windows-x86_64-0.14.0.zip" -OutFile "C:\zig.zip"
3030
cd C:\
3131
7z x zig.zip
32-
Add-Content $env:GITHUB_PATH "C:\zig-windows-x86_64-0.14.0-dev.1911+3bf89f55c\"
32+
Add-Content $env:GITHUB_PATH "C:\zig-windows-x86_64-0.14.0\"
3333
- name: build
3434
run: zig build
3535
x86_64-macos:
@@ -42,7 +42,7 @@ jobs:
4242
- name: Setup Zig
4343
run: |
4444
brew install xz
45-
sudo sh -c 'wget -c https://pkg.machengine.org/zig/zig-macos-x86_64-0.14.0-dev.1911+3bf89f55c.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
45+
sudo sh -c 'wget -c https://ziglang.org/download/0.14.0/zig-macos-x86_64-0.14.0.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
4646
- name: build
4747
run: zig build
4848
env:

.github/workflows/ci.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

build.zig

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const std = @import("std");
2+
const Step = std.Build.Step;
23

34
pub fn build(b: *std.Build) void {
45
const target = b.standardTargetOptions(.{});
@@ -37,7 +38,9 @@ pub fn build(b: *std.Build) void {
3738
// To maintain the relative paths inside the files in src/
3839
lib.installHeadersDirectory(b.path("include/GLFW"), "include/GLFW", .{});
3940
}
40-
// GLFW headers depend on these headers, so they must be distributed too.
41+
//
42+
// Header packaging for easy cross compilation
43+
//
4144
if (b.lazyDependency("vulkan_headers", .{
4245
.target = target,
4346
.optimize = optimize,
@@ -60,7 +63,7 @@ pub fn build(b: *std.Build) void {
6063
}
6164
}
6265

63-
if (target.result.isDarwin()) {
66+
if (target.result.os.tag.isDarwin()) {
6467
// MacOS: this must be defined for macOS 13.3 and older.
6568
lib.root_module.addCMacro("__kernel_ptr_semantics", "");
6669

@@ -74,8 +77,12 @@ pub fn build(b: *std.Build) void {
7477
}
7578
}
7679

77-
const include_src_flag = "-Isrc";
78-
80+
//
81+
// Source files
82+
//
83+
lib.addCSourceFiles(.{
84+
.files = &base_sources,
85+
});
7986
switch (target.result.os.tag) {
8087
.windows => {
8188
lib.linkSystemLibrary("gdi32");
@@ -90,14 +97,9 @@ pub fn build(b: *std.Build) void {
9097
lib.linkSystemLibrary("GLESv3");
9198
}
9299

93-
const flags = [_][]const u8{ "-D_GLFW_WIN32", include_src_flag };
94-
lib.addCSourceFiles(.{
95-
.files = &base_sources,
96-
.flags = &flags,
97-
});
100+
lib.root_module.addCMacro("_GLFW_WIN32", "1");
98101
lib.addCSourceFiles(.{
99102
.files = &windows_sources,
100-
.flags = &flags,
101103
});
102104
},
103105
.macos => {
@@ -126,44 +128,35 @@ pub fn build(b: *std.Build) void {
126128
lib.linkFramework("OpenGL");
127129
}
128130

129-
const flags = [_][]const u8{ "-D_GLFW_COCOA", include_src_flag };
130-
lib.addCSourceFiles(.{
131-
.files = &base_sources,
132-
.flags = &flags,
133-
});
131+
lib.root_module.addCMacro("_GLFW_COCOA", "1");
134132
lib.addCSourceFiles(.{
135133
.files = &macos_sources,
136-
.flags = &flags,
137134
});
138135
},
139136

140137
// everything that isn't windows or mac is linux :P
141138
else => {
142-
var sources = std.BoundedArray([]const u8, 64).init(0) catch unreachable;
143-
var flags = std.BoundedArray([]const u8, 16).init(0) catch unreachable;
144-
145-
sources.appendSlice(&base_sources) catch unreachable;
146-
sources.appendSlice(&linux_sources) catch unreachable;
139+
lib.addCSourceFiles(.{
140+
.files = &linux_sources,
141+
});
147142

148143
if (use_x11) {
149-
sources.appendSlice(&linux_x11_sources) catch unreachable;
150-
flags.append("-D_GLFW_X11") catch unreachable;
144+
lib.root_module.addCMacro("_GLFW_X11", "1");
145+
lib.addCSourceFiles(.{
146+
.files = &linux_x11_sources,
147+
});
151148
}
152149

153150
if (use_wl) {
154-
lib.root_module.addCMacro("WL_MARSHAL_FLAG_DESTROY", "1");
155-
156-
sources.appendSlice(&linux_wl_sources) catch unreachable;
157-
flags.append("-D_GLFW_WAYLAND") catch unreachable;
158-
flags.append("-Wno-implicit-function-declaration") catch unreachable;
151+
lib.root_module.addCMacro("_GLFW_WAYLAND", "1");
152+
153+
lib.addCSourceFiles(.{
154+
.files = &linux_wl_sources,
155+
.flags = &.{
156+
"-Wno-implicit-function-declaration",
157+
},
158+
});
159159
}
160-
161-
flags.append(include_src_flag) catch unreachable;
162-
163-
lib.addCSourceFiles(.{
164-
.files = sources.slice(),
165-
.flags = flags.slice(),
166-
});
167160
},
168161
}
169162
b.installArtifact(lib);

build.zig.zon

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.{
2-
.name = "glfw",
2+
.name = .glfw,
33
.version = "0.0.0",
4+
.fingerprint = 0x3bbe0a5c521e9047,
45
.paths = .{
56
"include/",
67
"src/",

verify.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
git diff $(git merge-base master upstream/master)..master \
4+
git diff upstream/master \
55
--diff-filter=d \
66
':(exclude)README.md' \
77
':(exclude)build.zig' \

0 commit comments

Comments
 (0)