Skip to content

Commit e9519cb

Browse files
committed
Revert tool/build changes per review
1 parent bf21028 commit e9519cb

10 files changed

Lines changed: 52 additions & 52 deletions

File tree

sim/aviron/build.zig

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pub fn build(b: *Build) !void {
7373

7474
const run_cmd = b.addRunArtifact(aviron_exe);
7575
run_cmd.step.dependOn(b.getInstallStep());
76-
76+
run_cmd.addPassthruArgs();
7777
run_step.dependOn(&run_cmd.step);
7878

7979
const avr_target = b.resolveTargetQuery(avr_target_query);
@@ -156,7 +156,7 @@ fn add_test_suite(
156156
// Scan the testsuite directory for files. Based on the extension, either load or compile them.
157157
// Files in testsuite.avr-gcc will be compiled with avr-gcc and have the output copied to
158158
// this directory.
159-
var walkdir = try b.build_root.handle.openDir(io, "testsuite", .{ .iterate = true });
159+
var walkdir = try b.root.root_dir.handle.openDir(io, "testsuite", .{ .iterate = true });
160160
defer walkdir.close(io);
161161

162162
var walker = try walkdir.walk(b.allocator);
@@ -192,8 +192,7 @@ fn add_test_suite(
192192
};
193193

194194
const ext = std.fs.path.extension(entry.basename);
195-
const action: FileAction = inline for (@typeInfo(@TypeOf(extension_to_action)).@"struct".fields) |field| {
196-
const field_name = field.name;
195+
const action: FileAction = inline for (@typeInfo(@TypeOf(extension_to_action)).@"struct".field_names) |field_name| {
197196
const action: FileAction = @field(extension_to_action, field_name);
198197

199198
if (std.mem.eql(u8, ext, "." ++ field_name))
@@ -332,10 +331,12 @@ fn add_test_suite_update(
332331
b: *Build,
333332
invoke_step: *Build.Step,
334333
) !void {
335-
const avr_gcc: Build.LazyPath = .{ .cwd_relative = try b.findProgram(&.{"avr-gcc"}, &.{}) };
334+
const avr_gcc = b.findProgramLazy(.{
335+
.names = &.{"avr-gcc"},
336+
});
336337

337338
const io = b.graph.io;
338-
var walkdir = try b.build_root.handle.openDir(io, "testsuite.avr-gcc", .{ .iterate = true });
339+
var walkdir = try b.root.root_dir.handle.openDir(io, "testsuite.avr-gcc", .{ .iterate = true });
339340
defer walkdir.close(io);
340341

341342
var walker = try walkdir.walk(b.allocator);
@@ -363,8 +364,7 @@ fn add_test_suite_update(
363364
};
364365

365366
const ext = std.fs.path.extension(entry.basename);
366-
const action: FileAction = inline for (@typeInfo(@TypeOf(extension_to_action)).@"struct".fields) |field| {
367-
const field_name = field.name;
367+
const action: FileAction = inline for (@typeInfo(@TypeOf(extension_to_action)).@"struct".field_names) |field_name| {
368368
const action: FileAction = @field(extension_to_action, field_name);
369369
if (std.mem.eql(u8, ext, "." ++ field_name))
370370
break action;

tools/linter/build.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub fn build(b: *std.Build) void {
1818
b.installArtifact(exe);
1919

2020
const run_cmd = b.addRunArtifact(exe);
21-
21+
run_cmd.addPassthruArgs();
2222
run_cmd.step.dependOn(b.getInstallStep());
2323

2424
const run_step = b.step("run", "Run the app");

tools/regz/build.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub fn build(b: *Build) !void {
6767
b.installArtifact(regz);
6868

6969
const run_cmd = b.addRunArtifact(regz);
70-
70+
run_cmd.addPassthruArgs();
7171
run_cmd.step.dependOn(b.getInstallStep());
7272

7373
const run_step = b.step("run", "Run the app");

tools/regz/src/Database.zig

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,9 @@ pub const Access = enum {
364364
pub const default = .read_write;
365365

366366
pub fn to_string(access: Access) []const u8 {
367-
return inline for (@typeInfo(Access).@"enum".fields) |field| {
368-
if (@field(Access, field.name) == access)
369-
break field.name;
367+
return inline for (@typeInfo(Access).@"enum".field_names) |field_name| {
368+
if (@field(Access, field_name) == access)
369+
break field_name;
370370
} else unreachable;
371371
}
372372
};
@@ -383,14 +383,14 @@ fn gen_field_list(comptime T: type, opts: struct { prefix: ?[]const u8 = null })
383383
var buf: [4096]u8 = undefined;
384384
var fbs: std.Io.Writer = .fixed(&buf);
385385

386-
inline for (@typeInfo(T).@"struct".fields, 0..) |field, i| {
386+
inline for (@typeInfo(T).@"struct".field_names, 0..) |field_name, i| {
387387
if (i != 0)
388388
fbs.writeAll(", ") catch unreachable;
389389

390390
if (opts.prefix) |prefix|
391391
fbs.print("{s}.", .{prefix}) catch unreachable;
392392

393-
fbs.print("{s}", .{field.name}) catch unreachable;
393+
fbs.print("{s}", .{field_name}) catch unreachable;
394394
}
395395

396396
const buf_copy = buf;
@@ -423,9 +423,9 @@ fn gen_sql_table_impl(comptime name: []const u8, comptime T: type) ![:0]const u8
423423
var primary_key_found = T.sql_opts.primary_key == null;
424424

425425
const info = @typeInfo(T);
426-
inline for (info.@"struct".fields) |field| {
426+
inline for (info.@"struct".field_names) |field_name| {
427427
if (T.sql_opts.primary_key) |primary_key| {
428-
if (std.mem.eql(u8, primary_key.name, field.name))
428+
if (std.mem.eql(u8, primary_key.name, field_name))
429429
primary_key_found = true;
430430
}
431431
}
@@ -434,21 +434,21 @@ fn gen_sql_table_impl(comptime name: []const u8, comptime T: type) ![:0]const u8
434434

435435
try fbs.print("CREATE TABLE {s} (\n", .{name});
436436
var first = true;
437-
inline for (info.@"struct".fields) |field| {
437+
inline for (info.@"struct".field_names, info.@"struct".field_types) |field_name, field_type| {
438438
if (first) {
439439
first = false;
440440
} else {
441441
try fbs.writeAll(",\n");
442442
}
443-
try fbs.print(" {s}", .{field.name});
444-
try fbs.print(" {s}", .{zig_type_to_sql_type(field.type)});
443+
try fbs.print(" {s}", .{field_name});
444+
try fbs.print(" {s}", .{zig_type_to_sql_type(field_type)});
445445

446-
const field_type_info = @typeInfo(field.type);
446+
const field_type_info = @typeInfo(field_type);
447447
if (field_type_info != .optional)
448448
try fbs.writeAll(" NOT NULL");
449449

450450
if (T.sql_opts.primary_key) |primary_key| {
451-
if (std.mem.eql(u8, primary_key.name, field.name)) {
451+
if (std.mem.eql(u8, primary_key.name, field_name)) {
452452
try fbs.writeAll(" PRIMARY KEY");
453453

454454
if (primary_key.autoincrement)
@@ -474,9 +474,9 @@ fn gen_sql_table_impl(comptime name: []const u8, comptime T: type) ![:0]const u8
474474
for (T.sql_opts.foreign_keys) |foreign_key| {
475475
try fbs.writeAll(",\n");
476476

477-
const field_type = for (@typeInfo(T).@"struct".fields) |field| {
478-
if (std.mem.eql(u8, field.name, foreign_key.name))
479-
break field.type;
477+
const field_type = for (@typeInfo(T).@"struct".field_names, @typeInfo(T).@"struct".field_types) |field_name, field_type| {
478+
if (std.mem.eql(u8, field_name, foreign_key.name))
479+
break field_type;
480480
} else unreachable;
481481

482482
try fbs.print(" FOREIGN KEY ({s}) REFERENCES {s}(id) ON DELETE {s} ON UPDATE {s}\n", .{
@@ -776,31 +776,31 @@ pub fn get_device_id_by_name(db: *Database, name: []const u8) !?DeviceID {
776776
fn scan_row(comptime T: type, allocator: Allocator, row: zqlite.Row) !T {
777777
var entry: T = undefined;
778778
const info = @typeInfo(T).@"struct";
779-
inline for (info.fields, 0..) |field, i| {
780-
if (@typeInfo(field.type) == .@"enum") {
781-
if (@hasDecl(field.type, "to_string"))
782-
@field(entry, field.name) = std.meta.stringToEnum(field.type, row.text(i)) orelse return error.Unknown
779+
inline for (info.field_names, info.field_types, 0..) |field_name, field_type, i| {
780+
if (@typeInfo(field_type) == .@"enum") {
781+
if (@hasDecl(field_type, "to_string"))
782+
@field(entry, field_name) = std.meta.stringToEnum(field_type, row.text(i)) orelse return error.Unknown
783783
else
784-
@field(entry, field.name) = @enumFromInt(row.int(i));
785-
} else if (@typeInfo(field.type) == .int) {
786-
@field(entry, field.name) = @intCast(row.int(i));
787-
} else switch (field.type) {
784+
@field(entry, field_name) = @enumFromInt(row.int(i));
785+
} else if (@typeInfo(field_type) == .int) {
786+
@field(entry, field_name) = @intCast(row.int(i));
787+
} else switch (field_type) {
788788
[]const u8 => {
789-
@field(entry, field.name) = try allocator.dupe(u8, row.text(i));
789+
@field(entry, field_name) = try allocator.dupe(u8, row.text(i));
790790
},
791791
?[]const u8 => {
792-
@field(entry, field.name) = if (row.nullableText(i)) |text| try allocator.dupe(u8, text) else null;
792+
@field(entry, field_name) = if (row.nullableText(i)) |text| try allocator.dupe(u8, text) else null;
793793
},
794794
?u64, ?u16, ?u8 => {
795-
@field(entry, field.name) = if (row.nullableInt(i)) |value| @intCast(value) else null;
795+
@field(entry, field_name) = if (row.nullableInt(i)) |value| @intCast(value) else null;
796796
},
797797
?StructID, ?EnumID => {
798-
@field(entry, field.name) = if (row.nullableInt(i)) |value| @enumFromInt(value) else null;
798+
@field(entry, field_name) = if (row.nullableInt(i)) |value| @enumFromInt(value) else null;
799799
},
800800
?Access => {
801-
@field(entry, field.name) = if (row.nullableText(i)) |text| (std.meta.stringToEnum(Access, text) orelse return error.Unknown) else null;
801+
@field(entry, field_name) = if (row.nullableText(i)) |text| (std.meta.stringToEnum(Access, text) orelse return error.Unknown) else null;
802802
},
803-
else => @compileError(std.fmt.comptimePrint("unhandled column type: {s}", .{@typeName(field.type)})),
803+
else => @compileError(std.fmt.comptimePrint("unhandled column type: {s}", .{@typeName(field_type)})),
804804
}
805805
}
806806

tools/regz/src/VirtualFilesystem.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ fn operate(userdata: ?*anyopaque, op: std.Io.Operation) std.Io.Cancelable!std.Io
108108
.file_read_streaming => unreachable,
109109
.device_io_control => unreachable,
110110
.net_receive => unreachable,
111+
.net_read => unreachable,
111112
};
112113
}
113114

@@ -378,7 +379,6 @@ pub fn io(vfs: *VirtualFilesystem) std.Io {
378379
.netConnectUnix = std.Io.failingNetConnectUnix,
379380
.netSocketCreatePair = std.Io.failingNetSocketCreatePair,
380381
.netSend = std.Io.failingNetSend,
381-
.netRead = std.Io.failingNetRead,
382382

383383
.netWrite = std.Io.failingNetWrite,
384384
.netWriteFile = std.Io.failingNetWriteFile,

tools/regz/src/arch.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ pub const Arch = enum {
5252
pub const default = .unknown;
5353

5454
pub fn to_string(arch: Arch) []const u8 {
55-
return inline for (@typeInfo(Arch).@"enum".fields) |field| {
56-
if (@field(Arch, field.name) == arch)
57-
break field.name;
55+
return inline for (@typeInfo(Arch).@"enum".field_names) |field_name| {
56+
if (@field(Arch, field_name) == arch)
57+
break field_name;
5858
} else unreachable;
5959
}
6060

tools/regz/src/arch/arm.zig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ const system_interrupts = struct {
5353
pub fn load_system_interrupts(db: *Database, device_id: DeviceID, arch: Arch) !void {
5454
assert(arch.is_arm());
5555

56-
inline for (@typeInfo(Arch).@"enum".fields) |field| {
57-
const field_name = field.name;
56+
inline for (@typeInfo(Arch).@"enum".field_names) |field_name| {
5857
if (arch == @field(Arch, field_name)) {
5958
if (@hasDecl(system_interrupts, field_name)) {
6059
for (@field(system_interrupts, field_name)) |interrupt| {

tools/regz/src/svd.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ const Context = struct {
3333
) !RegisterProperties {
3434
const register_props = try RegisterProperties.parse(node);
3535
var base_register_props = ctx.register_props.get(from) orelse unreachable;
36-
inline for (@typeInfo(RegisterProperties).@"struct".fields) |field| {
37-
if (@field(register_props, field.name)) |value|
38-
@field(base_register_props, field.name) = value;
36+
inline for (@typeInfo(RegisterProperties).@"struct".field_names) |field_name| {
37+
if (@field(register_props, field_name)) |value|
38+
@field(base_register_props, field_name) = value;
3939
}
4040

4141
return base_register_props;

tools/regz/src/targetdb.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ fn parse_isa_to_arch(isa: []const u8) Arch {
2424
const lower = std.ascii.lowerString(&buf, isa);
2525

2626
// Try to match against all Arch enum values
27-
inline for (@typeInfo(Arch).@"enum".fields) |field| {
28-
if (std.mem.eql(u8, lower, field.name)) {
29-
return @field(Arch, field.name);
27+
inline for (@typeInfo(Arch).@"enum".field_names) |field_name| {
28+
if (std.mem.eql(u8, lower, field_name)) {
29+
return @field(Arch, field_name);
3030
}
3131
}
3232

tools/sorcerer/build.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub fn build(b: *std.Build) void {
6363
b.installArtifact(cli_exe);
6464

6565
const run_cli_cmd = b.addRunArtifact(cli_exe);
66-
66+
run_cli_cmd.addPassthruArgs();
6767
run_cli_cmd.step.dependOn(b.getInstallStep());
6868

6969
const run_cli_step = b.step("run-cli", "Run the CLI tool");
@@ -152,6 +152,7 @@ pub fn build(b: *std.Build) void {
152152
b.installArtifact(exe);
153153

154154
const run_cmd = b.addRunArtifact(exe);
155+
run_cmd.addPassthruArgs();
155156

156157
// I only want the path to the register schema file, not the lazy path,
157158
// because I want to be able to refresh it with `zig build` while sorcerer

0 commit comments

Comments
 (0)