diff --git a/README.md b/README.md index 7095fae..299c16f 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ 8-bit emulator experiments in Zig. +> NOTE: no longer works with Zig 0.13.0, instead use the Zig nightly version + ## Usage ### Arcade Machines: diff --git a/emus/build.zig b/emus/build.zig index b189145..0e60bb3 100644 --- a/emus/build.zig +++ b/emus/build.zig @@ -75,20 +75,25 @@ const EmuOptions = struct { }; fn addEmulator(b: *Build, opts: EmuOptions) void { - const exe = b.addExecutable(.{ - .name = opts.name, + const mod = b.createModule(.{ .root_source_file = b.path(opts.src), .target = opts.target, .optimize = opts.optimize, + .imports = &.{ + .{ .name = "chipz", .module = opts.mod_chipz }, + .{ .name = "host", .module = opts.mod_host }, + .{ .name = "sokol", .module = opts.mod_sokol }, + }, }); if (opts.model != .NONE) { const options = b.addOptions(); options.addOption(Model, "model", opts.model); - exe.root_module.addOptions("build_options", options); + mod.addOptions("build_options", options); } - exe.root_module.addImport("chipz", opts.mod_chipz); - exe.root_module.addImport("host", opts.mod_host); - exe.root_module.addImport("sokol", opts.mod_sokol); + const exe = b.addExecutable(.{ + .name = opts.name, + .root_module = mod, + }); b.installArtifact(exe); const run_cmd = b.addRunArtifact(exe); diff --git a/tests/build.zig b/tests/build.zig index 09ef6ab..692717b 100644 --- a/tests/build.zig +++ b/tests/build.zig @@ -22,11 +22,15 @@ pub fn build(b: *Build, opts: Options) void { inline for (tests) |name| { const exe = b.addExecutable(.{ .name = name, - .root_source_file = b.path(b.fmt("{s}/{s}.zig", .{ opts.src_dir, name })), - .target = opts.target, - .optimize = opts.optimize, + .root_module = b.createModule(.{ + .root_source_file = b.path(b.fmt("{s}/{s}.zig", .{ opts.src_dir, name })), + .target = opts.target, + .optimize = opts.optimize, + .imports = &.{ + .{ .name = "chipz", .module = opts.mod_chipz }, + }, + }), }); - exe.root_module.addImport("chipz", opts.mod_chipz); b.installArtifact(exe); const run = b.addRunArtifact(exe); @@ -46,11 +50,15 @@ pub fn build(b: *Build, opts: Options) void { inline for (unit_tests) |name| { const unit_test = b.addTest(.{ .name = name ++ ".test", - .root_source_file = b.path(b.fmt("{s}/{s}.test.zig", .{ opts.src_dir, name })), - .target = opts.target, + .root_module = b.createModule(.{ + .root_source_file = b.path(b.fmt("{s}/{s}.test.zig", .{ opts.src_dir, name })), + .target = opts.target, + .imports = &.{ + .{ .name = "chipz", .module = opts.mod_chipz }, + }, + }), }); b.installArtifact(unit_test); // install an exe for debugging - unit_test.root_module.addImport("chipz", opts.mod_chipz); const run_unit_test = b.addRunArtifact(unit_test); test_step.dependOn(&run_unit_test.step); } diff --git a/tools/build.zig b/tools/build.zig index 49526b7..801d44d 100644 --- a/tools/build.zig +++ b/tools/build.zig @@ -31,9 +31,11 @@ const ToolOptions = struct { fn buildTool(b: *Build, options: ToolOptions) void { const exe = b.addExecutable(.{ .name = options.name, - .root_source_file = b.path(options.src), - .target = options.target, - .optimize = options.optimize, + .root_module = b.createModule(.{ + .root_source_file = b.path(options.src), + .target = options.target, + .optimize = options.optimize, + }), }); b.installArtifact(exe);