Skip to content

Commit 27307e0

Browse files
authored
"Regz Wizard" -> Sorcerer (ZigEmbeddedGroup#716)
1 parent ef42935 commit 27307e0

15 files changed

Lines changed: 1180 additions & 317 deletions

.github/workflows/tools-regz-wizard.yml

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

build.zig

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const std = @import("std");
22
const Build = std.Build;
33
const LazyPath = Build.LazyPath;
4+
const assert = std.debug.assert;
45

56
const internals = @import("build-internals");
67
pub const Target = internals.Target;
@@ -138,25 +139,35 @@ fn generate_release_steps(b: *Build) void {
138139
}
139140
}
140141

141-
pub const PortSelect = blk: {
142-
var fields: []const std.builtin.Type.StructField = &.{};
143-
for (port_list) |port| {
144-
fields = fields ++ [_]std.builtin.Type.StructField{.{
145-
.name = port.name,
146-
.type = bool,
147-
.default_value_ptr = @as(*const anyopaque, @ptrCast(&false)),
148-
.is_comptime = false,
149-
.alignment = @alignOf(bool),
150-
}};
142+
pub const PortSelect = struct {
143+
esp: bool = false,
144+
gd32: bool = false,
145+
atsam: bool = false,
146+
avr: bool = false,
147+
nrf5x: bool = false,
148+
lpc: bool = false,
149+
mcx: bool = false,
150+
rp2xxx: bool = false,
151+
stm32: bool = false,
152+
ch32v: bool = false,
153+
154+
pub const all: PortSelect = blk: {
155+
var ret: PortSelect = undefined;
156+
for (@typeInfo(PortSelect).@"struct".fields) |field| {
157+
@field(ret, field.name) = true;
158+
}
159+
160+
break :blk ret;
161+
};
162+
163+
comptime {
164+
// assumes fields are in the same order as the port list
165+
for (port_list, @typeInfo(PortSelect).@"struct".fields) |port_entry, field| {
166+
assert(std.mem.eql(u8, port_entry.name, field.name));
167+
const default_value_ptr: *const bool = @ptrCast(field.default_value_ptr);
168+
assert(false == default_value_ptr.*);
169+
}
151170
}
152-
break :blk @Type(.{
153-
.@"struct" = .{
154-
.layout = .auto,
155-
.fields = fields,
156-
.decls = &.{},
157-
.is_tuple = false,
158-
},
159-
});
160171
};
161172

162173
// Don't know if this is required but it doesn't hurt either.

tools/regz-wizard/build.zig

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

tools/regz-wizard/build.zig.zon

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

tools/regz-wizard/src/VirtualFilesystem.zig

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

tools/regz-wizard/src/main.zig

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

tools/sorcerer/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Sorcerer

0 commit comments

Comments
 (0)