Skip to content

Commit 11887ff

Browse files
authored
Upgrade from 0.15.2 to Zig 0.16.0 (#21)
* This is more annoying than I thought it would be. Will pick this up again tomorrow * These are breaking changes, unfortunately. 2 tests still failing, working on fixing those. Writergate wasn't too bad it seems. * Removed undefined memory from hook mask. Seems the compiler's behavior changed and exposed that undefined behavior * Adding change log, updating build agents to zig 0.16, getting started upgrading examples * Finalize upgrade
1 parent 4323070 commit 11887ff

22 files changed

Lines changed: 152 additions & 195 deletions

File tree

.github/workflows/tests-ubuntu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: (Z) Install Zig
2121
uses: mlugg/setup-zig@v2
2222
with:
23-
version: 0.15.1
23+
version: 0.16.0
2424

2525
- name: Run tests
2626
shell: bash

.github/workflows/tests-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: (Z) Install Zig
2121
uses: mlugg/setup-zig@v2
2222
with:
23-
version: 0.15.1
23+
version: 0.16.0
2424

2525
- name: ▶️ Run tests
2626
shell: pwsh

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
zig-out/
22
.zig-cache/
3+
zig-pkg/
34

45
__pycache__/
56

CHANGELOG.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,27 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [2.0.0] - 2025-05-21
8+
9+
## [v3.0.0] - 2026-05-08
10+
11+
Upgrade from Zig 0.15.2 to Zig 0.16.0 across library and examples.
12+
13+
### Changed
14+
15+
- Upgraded `zig-luajit-build` dependency from 1.1.6 to 1.1.8 to adopt Zig 0.16.0 changes.
16+
- Changed API for `Lua.dump()`, `Lua.load()` and all `prettyPrint()` functions to adopt new `std.Io.Reader` and
17+
`std.Io.Writer` interfaces. All references to the now deleted `std.io.AnyReader` and `std.io.AnyWriter` are removed.
18+
- Changed API for `HookMask` struct, it is now zeroed by default instead of containing uninitialized memory.
19+
- Updated all example programs to 0.16.0 and removed unnecessary README.md files in the examples directory.
20+
21+
22+
## [v2.0.0] - 2025-05-21
923

1024
### Fixed
1125

1226
- Corrected a logic error causing the `Lua.checkArgument()` function to incorrectly error on a passing condition.
1327
- Refer to [bug: checkArgument has inverse logic #17](https://github.com/sackosoft/zig-luajit/issues/17)
1428

15-
[2.0.0]: https://github.com/sackosoft/zig-luajit/compare/v1.5.4...v2.0.0
16-
[1.5.4]: https://github.com/sackosoft/zig-luajit/releases/tag/v1.5.4
29+
[v2.0.0]: https://github.com/sackosoft/zig-luajit/compare/v2.0.1...v3.0.0
30+
[v2.0.0]: https://github.com/sackosoft/zig-luajit/compare/v1.5.4...v2.0.0
31+
[v1.5.4]: https://github.com/sackosoft/zig-luajit/releases/tag/v1.5.4

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ checks in `Debug` and `ReleaseSafe` builds and provides full test coverage of th
2525

2626
## Zig Version
2727

28-
The `main` branch targets the latest stable Zig version. Currently `0.15.1`.
28+
The `main` branch targets the latest stable Zig version. Currently `0.16.0`.
2929

3030
For other Zig versions look for branches with the named version.
3131

@@ -353,3 +353,4 @@ can be found in the [COPYRIGHT](./COPYRIGHT.md) file.
353353

354354
This project was inspired by [natecraddock/ziglua](https://github.com/natecraddock/ziglua) which provides great
355355
functionality if you're looking to use Lua runtimes other than LuaJIT!
356+

build.zig.zon

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
.{
22
.name = .luajit,
33
.fingerprint = 0xda4bba66d285c19c,
4-
.version = "2.1.0",
4+
.version = "3.0.0",
55
.dependencies = .{
66
.luajit_build = .{
7-
.url = "git+https://github.com/sackosoft/zig-luajit-build#1664f2be707feccf4191fb8c6c6dff9ac2bd6edb",
8-
.hash = "luajit_build-1.1.6-HFjoU9xAAAANlxEGfin2P8D_sVc-AHtqKC6Fg8WWztZN",
7+
.url = "git+https://github.com/sackosoft/zig-luajit-build#83801ee5c76938eb8704de6ae667437e63744588",
8+
.hash = "luajit_build-1.1.8-HFjoU8lBAABZOIYvsm0OATsjlN0Fye4QYA86RuTy6uzl",
99
},
1010
},
1111
.paths = .{

examples/README.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,14 @@
11
# Examples
22

3-
Unless otherwise noted, the `build.zig` files are functionally the same between them.
4-
5-
## Basic Examples
6-
73
Inspired by this [Lua C API "Cheat Sheet"](https://www.codingwiththomas.com/blog/a-lua-c-api-cheat-sheet).
84

5+
0. [A simple Read-Evaluate-Print-Loop (REPL)](./simple-repl)
96
1. [Run Lua code from Zig](./example-01_run-lua)
107
2. [Lua variables in Zig, and vice versa](./example-02_variables)
118
3. [Lua functions in Zig](./example-03_lua-functions)
129
4. [Zig functions in Lua](./example-04_zig-functions)
1310
5. [Zig structs (userdata) in Lua](./example-05_userdata)
1411
6. [Lua tables in Zig](./example-06_lua-tables)
1512

16-
## Miscellaneous
17-
18-
- [Simple REPL](./simple-repl)
19-
20-
## Userdata, in-depth
2113

22-
Based on [Programming in Lua, chapter 28](https://www.lua.org/pil/28.html).
2314

24-
(To-do)

examples/example-01_run-lua/README.md

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

examples/example-01_run-lua/src/main.zig

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,9 @@ const std = @import("std");
55
const print = std.debug.print;
66
const Lua = @import("luajit").Lua;
77

8-
pub fn main() !void {
9-
// Boilerplate
10-
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
11-
defer _ = gpa.deinit();
12-
13-
const allocator = gpa.allocator();
14-
const lua = try Lua.init(allocator);
8+
pub fn main(init: std.process.Init) !void {
9+
const lua = try Lua.init(init.gpa);
1510
defer lua.deinit();
16-
// End boilerplate
1711

1812
lua.openBaseLib();
1913

examples/example-02_variables/README.md

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

0 commit comments

Comments
 (0)