Skip to content

Commit dc8cea5

Browse files
authored
Merge pull request #145 from robbielyman/zig-0.14
feat(build): update to latest Zig
2 parents 0e9e4f3 + f89fb28 commit dc8cea5

File tree

15 files changed

+194
-288
lines changed

15 files changed

+194
-288
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ __pycache__/
77
.lock-waf*
88
.cache/
99
config.log
10-
zig-cache/
10+
.zig-cache/
1111
zig-out/
1212
lua/core/.DS_Store
1313
lua/.DS_Store

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ brew install freetype2 harfbuzz ncurses
4646

4747
alternatively to install with homebrew, do
4848
```bash
49-
brew tap ryleelyman/seamstress
50-
brew install seamstress
49+
brew tap robbielyman/seamstress
50+
brew install seamstress@1
5151
```
5252

5353
on linux, additional requirements include `alsa`.
@@ -65,8 +65,9 @@ and will not work as expected if you move only the binary to a different folder.
6565
## building from source
6666

6767

68-
building seamstress from source requires version 0.11.0 of [zig](https://github.com/ziglang/zig).
68+
building seamstress from source requires the latest stable version of [zig](https://github.com/ziglang/zig).
6969
the easiest way to get zig is to download a binary from [here](https://ziglang.org/download/) and add it to your PATH.
70+
(be sure that you do not choose a download from the "master" section.)
7071
seamstress follows releases of zig.
7172
to build seamstress, install the dependencies listed above (as well as `pkg-config`) and invoke
7273

build.zig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ pub fn build(b: *std.Build) void {
3434
exe.linkSystemLibrary("SDL2");
3535
exe.linkSystemLibrary("SDL2_image");
3636
exe.linkSystemLibrary("SDL2_ttf");
37-
const zig_lua = b.dependency("Lua", .{
37+
const lua_wrapper = b.dependency("lua_wrapper", .{
3838
.target = target,
3939
.optimize = optimize,
4040
});
41-
exe.root_module.addImport("ziglua", zig_lua.module("ziglua"));
42-
exe.linkSystemLibrary("lua");
41+
exe.root_module.addImport("lua_wrapper", lua_wrapper.module("lua_wrapper"));
42+
// exe.linkSystemLibrary("lua");
4343

44-
const zig_link = b.dependency("link", .{
44+
const zig_link = b.dependency("abl_link", .{
4545
.target = target,
4646
.optimize = optimize,
4747
});
@@ -51,9 +51,9 @@ pub fn build(b: *std.Build) void {
5151
switch (target.result.os.tag) {
5252
.macos => {
5353
exe.addLibraryPath(.{ .cwd_relative = "/opt/homebrew/opt/readline/lib" });
54-
exe.addLibraryPath(.{ .cwd_relative = "/usr/local/opt/readline/lib" });
54+
// exe.addLibraryPath(.{ .cwd_relative = "/usr/local/opt/readline/lib" });
5555
exe.addSystemIncludePath(.{ .cwd_relative = "/opt/homebrew/opt/readline/include" });
56-
exe.addSystemIncludePath(.{ .cwd_relative = "/usr/local/opt/readline/include" });
56+
// exe.addSystemIncludePath(.{ .cwd_relative = "/usr/local/opt/readline/include" });
5757
},
5858
else => {},
5959
}

build.zig.zon

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@
66
"build.zig",
77
"build.zig.zon",
88
},
9-
.name = "seamstress",
10-
.version = "1.4.5",
9+
.name = .seamstress,
10+
.fingerprint = 0xddf04d098cc31c65,
11+
.version = "1.4.7",
1112
.dependencies = .{
12-
.Lua = .{
13-
.url = "git+https://github.com/natecraddock/ziglua#d853aa9450ae568a39ea02d7082e85bafc33f735",
14-
.hash = "1220affeb3fe37ef09411b5a213b5fdf9bb6568e9913bade204694648983a8b2776d",
13+
.abl_link = .{
14+
.url = "git+https://github.com/robbielyman/zig-abl_link#c4fb74acb59662910833fd5cdca40f1c4bd8be0c",
15+
.hash = "abl_link-3.1.1-kE5CL1FYAAAEILPom95ZVqlks0UezAKHuS2PuorYsCUF",
1516
},
16-
.link = .{
17-
.url = "git+https://github.com/ryleelyman/zig-abl_link#bca725468f88ef073cabc6da03696ceaa0af19c7",
18-
.hash = "12205b92ab3c432ed67f84896ad0c4f89e1a3c3934bc9a34c16e98952eee717761ac",
17+
.lua_wrapper = .{
18+
.url = "git+https://github.com/natecraddock/ziglua#7bfb3c2b87220cdc89ef01cc99a200dad7a28e50",
19+
.hash = "lua_wrapper-0.1.0-OyMC27fOBAAU3E2ueB-EWGSgsuCFQZL83pT0nQJ1ufOI",
1920
},
2021
},
2122
}

src/clock.zig

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -340,21 +340,11 @@ fn reschedule_sync_events() void {
340340
}
341341

342342
pub fn stop() void {
343-
const event = .{
344-
.Clock_Transport = .{
345-
.transport = .Stop,
346-
},
347-
};
348-
events.post(event);
343+
events.post(.{ .Clock_Transport = .{ .transport = .Stop } });
349344
}
350345

351346
pub fn start() void {
352-
const event = .{
353-
.Clock_Transport = .{
354-
.transport = .Start,
355-
},
356-
};
357-
events.post(event);
347+
events.post(.{ .Clock_Transport = .{ .transport = .Start } });
358348
}
359349

360350
pub fn reset(beat: f64) void {

src/input.zig

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,7 @@ fn inner() !void {
8989
continue;
9090
}
9191
_ = c.add_history(c_line);
92-
const event = .{ .Exec_Code_Line = .{
93-
.line = line,
94-
.allocator = allocator,
95-
} };
96-
events.post(event);
92+
events.post(.{ .Exec_Code_Line = .{ .line = line, .allocator = allocator } });
9793
}
9894
events.post(.{ .Quit = {} });
9995
}
@@ -124,13 +120,7 @@ fn bare_input_run() !void {
124120
quit = true;
125121
continue;
126122
}
127-
const event = .{
128-
.Exec_Code_Line = .{
129-
.line = line,
130-
.allocator = allocator,
131-
},
132-
};
133-
events.post(event);
123+
events.post(.{ .Exec_Code_Line = .{ .line = line, .allocator = allocator } });
134124
}
135125
events.post(.{ .Quit = {} });
136126
}

src/main.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const socket = @import("socket.zig");
1313
const watcher = @import("watcher.zig");
1414
const create = @import("create.zig");
1515

16-
const VERSION = .{ .major = 1, .minor = 4, .patch = 6 };
16+
const VERSION: std.SemanticVersion = .{ .major = 1, .minor = 4, .patch = 7 };
1717

1818
pub const std_options: std.Options = .{
1919
.log_level = .info,
@@ -29,7 +29,7 @@ pub fn main() !void {
2929
var go_again = true;
3030
timer = try std.time.Timer.start();
3131

32-
var loc_buf = [_]u8{0} ** std.fs.MAX_PATH_BYTES;
32+
var loc_buf = [_]u8{0} ** std.fs.max_path_bytes;
3333
const location = try std.fs.selfExeDirPath(&loc_buf);
3434

3535
const option = try args.parse(location);
@@ -94,7 +94,7 @@ pub fn main() !void {
9494
const height = try std.fmt.parseUnsigned(u16, args.height, 10);
9595
const assets_path = try std.fs.path.join(allocator, &.{ location, "..", "share", "seamstress", "resources" });
9696
defer allocator.free(assets_path);
97-
var assets_buf = [_]u8{0} ** std.fs.MAX_PATH_BYTES;
97+
var assets_buf = [_]u8{0} ** std.fs.max_path_bytes;
9898
const assets = try std.fs.realpath(assets_path, &assets_buf);
9999
try screen.init(width, height, assets);
100100
defer screen.deinit();
@@ -122,7 +122,7 @@ fn print_version() !void {
122122
var bw = std.io.bufferedWriter(stdout_file);
123123
const stdout = bw.writer();
124124
try stdout.print("SEAMSTRESS\n", .{});
125-
try stdout.print("seamstress version: {d}.{d}.{d}\n", VERSION);
125+
try stdout.print("seamstress version: {d}.{d}.{d}\n", .{ VERSION.major, VERSION.minor, VERSION.patch });
126126
try bw.flush();
127127
}
128128

src/metros.zig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ const Metro = struct {
3737
self.thread = null;
3838
}
3939
fn bang(self: *Metro) void {
40-
const event = .{ .Metro = .{ .id = self.id, .stage = self.stage } };
41-
events.post(event);
40+
events.post(.{ .Metro = .{ .id = self.id, .stage = self.stage } });
4241
}
4342
fn init(self: *Metro, delta: u64, count: i64) !void {
4443
self.delta = delta;

src/midi.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ fn add_devices() !void {
160160
input: bool,
161161
output: bool,
162162
};
163-
var is_active: [32]Is_Active = .{.{ .input = false, .output = false }} ** 32;
163+
const initial: Is_Active = .{ .input = false, .output = false };
164+
var is_active: [32]Is_Active = .{initial} ** 32;
164165
const in_count = c.rtmidi_get_port_count(midi_in_counter);
165166
for (0..in_count) |i| {
166167
var len: c_int = 256;

src/monome.zig

Lines changed: 14 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,7 @@ pub fn add(name: []const u8, dev_type: []const u8, port: i32) void {
138138
if (std.mem.eql(u8, n, name)) {
139139
if (device.connected == true) return;
140140
device.connected = true;
141-
const event = .{
142-
.Monome_Add = .{
143-
.dev = device,
144-
},
145-
};
146-
events.post(event);
141+
events.post(.{ .Monome_Add = .{ .dev = device } });
147142
device.set_port();
148143
return;
149144
}
@@ -159,10 +154,7 @@ pub fn add(name: []const u8, dev_type: []const u8, port: i32) void {
159154
device.m_type = .Arc;
160155
device.quads = 4;
161156
device.connected = true;
162-
const event = .{
163-
.Monome_Add = .{ .dev = device },
164-
};
165-
events.post(event);
157+
events.post(.{ .Monome_Add = .{ .dev = device } });
166158
device.set_port();
167159
} else {
168160
device.m_type = .Grid;
@@ -179,12 +171,7 @@ pub fn remove(name: []const u8) void {
179171
const n = device.name orelse continue;
180172
if (std.mem.eql(u8, n, name)) {
181173
device.connected = false;
182-
const event = .{
183-
.Monome_Remove = .{
184-
.id = device.id,
185-
},
186-
};
187-
events.post(event);
174+
events.post(.{ .Monome_Remove = .{ .id = device.id } });
188175
return;
189176
}
190177
}
@@ -270,10 +257,7 @@ fn handle_size(
270257
device.quads = @intCast(@divExact(argv[0].*.i * argv[1].*.i, 64));
271258
if (!device.connected) {
272259
device.connected = true;
273-
const event = .{
274-
.Monome_Add = .{ .dev = device },
275-
};
276-
events.post(event);
260+
events.post(.{ .Monome_Add = .{ .dev = device } });
277261
}
278262
return 0;
279263
}
@@ -291,15 +275,7 @@ fn handle_grid_key(
291275
_ = types;
292276
_ = path;
293277
const device: *Monome = @ptrCast(@alignCast(user_data orelse return 1));
294-
const event = .{
295-
.Grid_Key = .{
296-
.id = device.id,
297-
.x = argv[0].*.i,
298-
.y = argv[1].*.i,
299-
.state = argv[2].*.i,
300-
},
301-
};
302-
events.post(event);
278+
events.post(.{ .Grid_Key = .{ .id = device.id, .x = argv[0].*.i, .y = argv[1].*.i, .state = argv[2].*.i } });
303279
return 0;
304280
}
305281

@@ -316,14 +292,7 @@ fn handle_arc_key(
316292
_ = types;
317293
_ = path;
318294
const device: *Monome = @ptrCast(@alignCast(user_data orelse return 1));
319-
const event = .{
320-
.Arc_Key = .{
321-
.id = device.id,
322-
.ring = argv[0].*.i,
323-
.state = argv[1].*.i,
324-
},
325-
};
326-
events.post(event);
295+
events.post(.{ .Arc_Key = .{ .id = device.id, .ring = argv[0].*.i, .state = argv[1].*.i } });
327296
return 0;
328297
}
329298

@@ -340,14 +309,7 @@ fn handle_delta(
340309
_ = types;
341310
_ = path;
342311
const device: *Monome = @ptrCast(@alignCast(user_data orelse return 1));
343-
const event = .{
344-
.Arc_Encoder = .{
345-
.id = device.id,
346-
.ring = argv[0].*.i,
347-
.delta = argv[1].*.i,
348-
},
349-
};
350-
events.post(event);
312+
events.post(.{ .Arc_Encoder = .{ .id = device.id, .ring = argv[0].*.i, .delta = argv[1].*.i } });
351313
return 0;
352314
}
353315

@@ -364,15 +326,12 @@ fn handle_tilt(
364326
_ = types;
365327
_ = path;
366328
const device: *Monome = @ptrCast(@alignCast(user_data orelse return 1));
367-
const event = .{
368-
.Grid_Tilt = .{
369-
.id = device.id,
370-
.sensor = argv[0].*.i,
371-
.x = argv[1].*.i,
372-
.y = argv[2].*.i,
373-
.z = argv[3].*.i,
374-
},
375-
};
376-
events.post(event);
329+
events.post(.{ .Grid_Tilt = .{
330+
.id = device.id,
331+
.sensor = argv[0].*.i,
332+
.x = argv[1].*.i,
333+
.y = argv[2].*.i,
334+
.z = argv[3].*.i,
335+
} });
377336
return 0;
378337
}

0 commit comments

Comments
 (0)