Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## What version of Zig to use

`0.17.0-dev.1936+5a625d5f3`
`0.17.0`

## Getting Started With MicroZig

Expand Down
2 changes: 1 addition & 1 deletion build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Note: This should be changed if you fork microzig!
.fingerprint = 0x605a83a849186d0f,
.version = "0.17.11",
.minimum_zig_version = "0.17.0-dev.1936+5a625d5f3",
.minimum_zig_version = "0.17.0",
.dependencies = .{
.@"build-internals" = .{ .path = "build-internals" },
.core = .{ .path = "core" },
Expand Down
13 changes: 11 additions & 2 deletions tools/printer/tests/test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var buf: [1024]u8 = undefined;
pub fn main(init: std.process.Init) !void {
const gpa = init.gpa;
const io = init.io;
const arena = init.arena.allocator();

const args = try init.minimal.args.toSlice(init.arena.allocator());
if (args.len != 3)
Expand All @@ -29,8 +30,16 @@ pub fn main(init: std.process.Init) !void {
const test_data_raw = try std.Io.Dir.cwd().readFileAllocOptions(io, test_data_path, gpa, .limited(1_000_000), .@"1", 0);
defer gpa.free(test_data_raw);

const test_data = try std.zon.parse.fromSliceAlloc(common.Data, gpa, test_data_raw, null, .{});
defer std.zon.parse.free(gpa, test_data);
var diags: std.zon.parse.Diagnostics = undefined;
const test_data = std.zon.parse.fromSlice(common.Data, .{
.gpa = gpa,
.arena = arena,
.source = test_data_raw,
.diagnostics = &diags,
}) catch |err| switch (err) {
error.ParseZon => diags.fatal(test_data_path),
else => |e| return e,
};

var debug_info = try printer.DebugInfo.init(gpa, elf);
defer debug_info.deinit(gpa);
Expand Down
2 changes: 1 addition & 1 deletion tools/printer/tests/test_program.dwarf32.zon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.{ .zig_version = "0.17.0-dev.1936+5a625d5f3", .tests = .{
.{ .zig_version = "0.17.0", .tests = .{
.{ .address = 16941056, .expected = .{
.line = 163,
.column = 33,
Expand Down
2 changes: 1 addition & 1 deletion tools/printer/tests/test_program.dwarf64.zon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.{ .zig_version = "0.17.0-dev.1936+5a625d5f3", .tests = .{
.{ .zig_version = "0.17.0", .tests = .{
.{ .address = 16969728, .expected = .{
.line = 163,
.column = 33,
Expand Down
8 changes: 4 additions & 4 deletions tools/regz/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
},
.dependencies = .{
.libxml2 = .{
.url = "git+https://github.com/allyourcodebase/libxml2#f7bab883c713fa60f33cbf5e562696c529812967",
.hash = "libxml2-2.15.1-2-qHdjhjJXAAADBouSraVVXa-w--J3KeGvrpVuaW01KpT2",
.url = "git+https://github.com/allyourcodebase/libxml2?ref=zig-0.17.0#5963151267de6ab21b4abcc9fe5164eadc63a4a4",
.hash = "libxml2-2.15.1-2-qHdjhkFXAADYDyUYdBuZ63gfHidJSauXYKrIuUK2QPGE",
},
.virtual_io = .{ .path = "../../modules/virtual-io" },
.zqlite = .{
.url = "git+https://github.com/mattnite/zqlite.zig#48509708f7c965b3f0b5b29ec3d0f56c4a6fb32a",
.hash = "zqlite-0.0.1-RWLaY4Q-nAAkr-6kmFrU59kWxesGyFzgXMHJDAxwgLEA",
.url = "git+https://github.com/mattnite/zqlite.zig?ref=zig-0.17.0#4c3116c42d1abf721735e8d48b9f7bebaddfbd6c",
.hash = "zqlite-0.0.1-RWLaY5M-nADM7IT75xD-2DxZnqPJsqEDSUZ4wA6_zOPy",
},
},
}
41 changes: 24 additions & 17 deletions tools/regz/src/Database.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2098,9 +2098,20 @@ fn cleanup_unused_enums(db: *Database) !void {
, .{});
}

pub fn apply_patch(db: *Database, zon_text: [:0]const u8, diags: *std.zon.parse.Diagnostics) !void {
const patches = try std.zon.parse.fromSliceAlloc([]const Patch, db.gpa, zon_text, diags, .{});
defer std.zon.parse.free(db.gpa, patches);
pub fn apply_patch(db: *Database, zon_text: [:0]const u8, arena: std.mem.Allocator) !void {
var diags: std.zon.parse.Diagnostics = undefined;
const patches = std.zon.parse.fromSlice([]const Patch, .{
.gpa = db.gpa,
.arena = arena,
.diagnostics = &diags,
.source = zon_text,
}) catch |err| switch (err) {
error.ParseZon => {
diags.log("in-memory");
return error.Explained;
},
else => |e| return e,
};

for (patches) |patch| {
switch (patch) {
Expand Down Expand Up @@ -2289,14 +2300,12 @@ test "add_enum_and_apply patch creates enum and applies to fields" {
\\}
;

var diags: std.zon.parse.Diagnostics = .{};
defer diags.deinit(allocator);
var arena = std.heap.ArenaAllocator.init(allocator);
defer arena.deinit();

try db.apply_patch(patch_zon, &diags);
try db.apply_patch(patch_zon, arena.allocator());

// Verify the enum was created
var arena = std.heap.ArenaAllocator.init(allocator);
defer arena.deinit();
const enum_info = try db.get_enum_by_name(arena.allocator(), struct_id, "TestMode");
try std.testing.expectEqual(@as(u8, 2), enum_info.size_bits);

Expand Down Expand Up @@ -2349,20 +2358,21 @@ test "add_enum_and_apply patch with empty apply_to list" {
\\}
;

var diags: std.zon.parse.Diagnostics = .{};
defer diags.deinit(allocator);
var arena = std.heap.ArenaAllocator.init(allocator);
defer arena.deinit();

try db.apply_patch(patch_zon, &diags);
try db.apply_patch(patch_zon, arena.allocator());

// Verify the enum was created
var arena = std.heap.ArenaAllocator.init(allocator);
defer arena.deinit();

const enum_info = try db.get_enum_by_name(arena.allocator(), struct_id, "UnusedEnum");
try std.testing.expectEqual(@as(u8, 4), enum_info.size_bits);
}

test "add_enum_and_apply patch with invalid field reference" {
const allocator = std.testing.allocator;
var arena: std.heap.ArenaAllocator = .init(allocator);
defer arena.deinit();

var db = try Database.create(allocator);
defer db.destroy();
Expand Down Expand Up @@ -2393,9 +2403,6 @@ test "add_enum_and_apply patch with invalid field reference" {
\\}
;

var diags: std.zon.parse.Diagnostics = .{};
defer diags.deinit(allocator);

const result = db.apply_patch(patch_zon, &diags);
const result = db.apply_patch(patch_zon, arena.allocator());
try std.testing.expectError(error.MissingEntity, result);
}
11 changes: 1 addition & 10 deletions tools/regz/src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,7 @@ fn main_impl(init: std.process.Init) anyerror!void {
const patch = try std.Io.Dir.cwd().readFileAllocOptions(io, patch_path, gpa, .unlimited, .@"1", 0);
defer gpa.free(patch);

var diags: std.zon.parse.Diagnostics = .{};
defer diags.deinit(db.gpa);

db.apply_patch(patch, &diags) catch |err| {
if (err == error.ParseZon) {
std.log.err("Failed to parse zon patch file '{s}': {f}", .{ patch_path, diags });
}

return err;
};
try db.apply_patch(patch, init.arena.allocator());
}

// arch dependent stuff
Expand Down
4 changes: 2 additions & 2 deletions website/content/docs/getting-started.smd
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ The main change is in your `build.zig`, where the board target should be

## Let's Begin

Quickly check that you have Zig master. You should see something like
`0.17.0-dev.1936+5a625d5f3` by running `zig version`.
Quickly check that you have the right version of Zig. You should see something
like `0.17.0` by running `zig version`.

Assuming you've initialized a zig project with `zig init`, or have set one up
yourself, you can add microzig as a dependency with the following command:
Expand Down
Loading