From fcb68ad0e2160d80f87dd6f3c6136ae476e7d2c8 Mon Sep 17 00:00:00 2001 From: biom4st3r <37042156+biom4st3r@users.noreply.github.com> Date: Tue, 9 Jul 2024 14:30:45 -0500 Subject: [PATCH] Updated to zig 0.13.0 (#198) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Updated to latest zig * feat(flake): update zig to 0.13.0 and add zls This also disable diffs for flake.lock to not not polute the git diff output too much * feat(build): Update dependencies to support 0.13.0 * feat(build): disable broken examples * feat(ci): Update zig to 0.13.0 * feat(rp2040): Update pio tokenizer tests to 0.13.0 * feat(build): Fix uses of deprecated std.zig.CrossTarget * feat(rezg): Fix uses of deprecated std.mem.{tokenize,slice} * feat(rp2040): Fix uses of depreacted std.rand * feat(readme): Update zig version --------- Co-authored-by: Maciej 'vesim' KuliƄski --- .envrc | 5 +- .gitattributes | 1 + .github/workflows/build.yml | 2 +- .github/workflows/deploy.yml | 2 +- .gitignore | 1 + README.md | 2 +- bsp/espressif/esp/build.zig | 2 +- bsp/microchip/atsam/build.zig | 2 +- bsp/raspberrypi/rp2040/build.zig | 10 +- .../src/hal/pio/assembler/tokenizer.zig | 28 +-- bsp/raspberrypi/rp2040/src/hal/random.zig | 10 +- bsp/stmicro/stm32/build.zig | 8 +- build.zig.zon | 7 +- build/build.zig | 7 +- build/definitions/build.zig | 2 +- core/build.zig | 24 +- examples/espressif/esp/build.zig | 2 +- examples/gigadevice/gd32/build.zig | 13 +- examples/microchip/atsam/build.zig | 2 +- examples/microchip/avr/build.zig | 2 +- examples/nordic/nrf5x/build.zig | 2 +- examples/nxp/lpc/build.zig | 2 +- examples/raspberrypi/rp2040/build.zig | 2 +- examples/raspberrypi/rp2040/src/tiles.zig | 2 +- examples/stmicro/stm32/build.zig | 7 +- flake.lock | 235 ++++++++++++++++-- flake.nix | 7 +- tools/regz/build.zig | 16 +- tools/regz/build.zig.zon | 4 +- tools/regz/src/Database.zig | 6 +- tools/regz/src/atdf.zig | 2 +- tools/regz/src/gen.zig | 10 +- tools/regz/src/regzon.zig | 4 +- tools/regz/src/svd.zig | 4 +- tools/uf2/build.zig | 10 +- 35 files changed, 324 insertions(+), 121 deletions(-) diff --git a/.envrc b/.envrc index 4cc700c..e7dc9cb 100644 --- a/.envrc +++ b/.envrc @@ -1,2 +1,3 @@ -# use_nix -use_flake +if has nix; then + use flake +fi \ No newline at end of file diff --git a/.gitattributes b/.gitattributes index 0cb064a..96af9e5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ *.zig text=auto eol=lf +flake.lock -diff diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4de3db2..a1183b0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,7 +25,7 @@ jobs: - name: Setup Zig uses: goto-bus-stop/setup-zig@v2 with: - version: 0.12.0 + version: 0.13.0 - name: Build run: zig build -Doptimize=ReleaseSmall diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6e2697f..1122bd0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -23,7 +23,7 @@ jobs: - name: Setup Zig uses: goto-bus-stop/setup-zig@v2 with: - version: 0.12.0 + version: 0.13.0 - name: Extract version run: echo "MICROZIG_VERSION=$(zig build package -- get-version)" >> $GITHUB_ENV diff --git a/.gitignore b/.gitignore index c081f1d..8de4d7a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ zig-out/ zig-cache/ +.zig-cache/ microzig-deploy/ .DS_Store .gdbinit diff --git a/README.md b/README.md index 392d588..d6d1e70 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## What version of Zig to use -Zig 0.12.0 +Zig 0.13.0 ## Getting Started With MicroZig diff --git a/bsp/espressif/esp/build.zig b/bsp/espressif/esp/build.zig index 463b3d8..b9d2577 100644 --- a/bsp/espressif/esp/build.zig +++ b/bsp/espressif/esp/build.zig @@ -10,7 +10,7 @@ fn path(comptime suffix: []const u8) std.Build.LazyPath { const esp_riscv = .{ .name = "Espressif RISC-V", .root_source_file = path("/src/cpus/espressif-riscv.zig"), - .target = std.zig.CrossTarget{ + .target = std.Target.Query{ .cpu_arch = .riscv32, .cpu_model = .{ .explicit = &std.Target.riscv.cpu.generic_rv32 }, .cpu_features_add = std.Target.riscv.featureSet(&.{ diff --git a/bsp/microchip/atsam/build.zig b/bsp/microchip/atsam/build.zig index 55406e9..ec0e8fa 100644 --- a/bsp/microchip/atsam/build.zig +++ b/bsp/microchip/atsam/build.zig @@ -19,7 +19,7 @@ pub const chips = struct { .url = "https://www.microchip.com/en-us/product/ATSAMD51J19A", .cpu = MicroZig.cpus.cortex_m4, .register_definition = .{ - .atdf = .{ .path = build_root ++ "/src/chips/ATSAMD51J19A.atdf" }, + .atdf = .{ .cwd_relative = build_root ++ "/src/chips/ATSAMD51J19A.atdf" }, }, .memory_regions = &.{ .{ .kind = .flash, .offset = 0x00000000, .length = 512 * 1024 }, // Embedded Flash diff --git a/bsp/raspberrypi/rp2040/build.zig b/bsp/raspberrypi/rp2040/build.zig index 7b2e3c1..c507706 100644 --- a/bsp/raspberrypi/rp2040/build.zig +++ b/bsp/raspberrypi/rp2040/build.zig @@ -12,9 +12,9 @@ const build_root = root(); pub fn build(b: *Build) !void { const unit_tests = b.addTest(.{ - .root_source_file = .{ .path = "src/hal.zig" }, + .root_source_file = b.path("src/hal.zig"), }); - unit_tests.addIncludePath(.{ .path = "src/hal/pio/assembler" }); + unit_tests.addIncludePath(b.path("src/hal/pio/assembler")); const unit_tests_run = b.addRunArtifact(unit_tests); const test_step = b.step("test", "Run platform agnostic unit tests"); @@ -119,7 +119,7 @@ pub const BootROM = union(enum) { }; const linker_script = .{ - .path = build_root ++ "/rp2040.ld", + .cwd_relative = build_root ++ "/rp2040.ld", }; const hal = .{ @@ -188,8 +188,8 @@ pub fn get_bootrom(mz: *MicroZig, rom: BootROM) Stage2Bootloader { .root_source_file = null, }); //rom_exe.linkage = .static; - rom_exe.setLinkerScript(.{ .path = build_root ++ "/src/bootroms/shared/stage2.ld" }); - rom_exe.addAssemblyFile(.{ .path = rom_path }); + rom_exe.setLinkerScript(.{ .cwd_relative = build_root ++ "/src/bootroms/shared/stage2.ld" }); + rom_exe.addAssemblyFile(.{ .cwd_relative = rom_path }); rom_exe.entry = .{ .symbol_name = "_stage2_boot" }; break :blk rom_exe; diff --git a/bsp/raspberrypi/rp2040/src/hal/pio/assembler/tokenizer.zig b/bsp/raspberrypi/rp2040/src/hal/pio/assembler/tokenizer.zig index bf6a458..4a3aedb 100644 --- a/bsp/raspberrypi/rp2040/src/hal/pio/assembler/tokenizer.zig +++ b/bsp/raspberrypi/rp2040/src/hal/pio/assembler/tokenizer.zig @@ -481,7 +481,7 @@ pub const Tokenizer = struct { }; } - const directives = std.ComptimeStringMap(*const fn (*Tokenizer, u32, *?Diagnostics) TokenizeError!Token, .{ + const directives = std.StaticStringMap(*const fn (*Tokenizer, u32, *?Diagnostics) TokenizeError!Token).initComptime(.{ .{ "program", get_program }, .{ "define", get_define }, .{ "origin", get_origin }, @@ -527,7 +527,7 @@ pub const Tokenizer = struct { fn get_jmp(self: *Tokenizer, diags: *?Diagnostics) TokenizeError!Token.Instruction.Payload { const Condition = Token.Instruction.Jmp.Condition; - const conditions = std.ComptimeStringMap(Condition, .{ + const conditions = std.StaticStringMap(Condition).initComptime(.{ .{ "!x", .x_is_zero }, .{ "x--", .x_dec }, .{ "!y", .y_is_zero }, @@ -828,7 +828,7 @@ pub const Tokenizer = struct { }; } - const instructions = std.ComptimeStringMap(*const fn (*Tokenizer, *?Diagnostics) TokenizeError!Token.Instruction.Payload, .{ + const instructions = std.StaticStringMap(*const fn (*Tokenizer, *?Diagnostics) TokenizeError!Token.Instruction.Payload).initComptime(.{ .{ "nop", get_nop }, .{ "jmp", get_jmp }, .{ "wait", get_wait }, @@ -1588,7 +1588,7 @@ test "tokenize.instr.jmp.value" { test "tokenize.instr.jmp.conditions" { const Condition = Token.Instruction.Jmp.Condition; - const cases = std.ComptimeStringMap(Condition, .{ + const cases = std.StaticStringMap(Condition).initComptime(.{ .{ "!x", .x_is_zero }, .{ "x--", .x_dec }, .{ "!y", .y_is_zero }, @@ -1598,9 +1598,7 @@ test "tokenize.instr.jmp.conditions" { .{ "!osre", .osre_not_empty }, }); - inline for (cases.kvs) |case| { - const op = case.key; - const cond = case.value; + inline for (comptime cases.keys(), comptime cases.values()) |op, cond| { const tokens = try bounded_tokenize(comptime std.fmt.comptimePrint("jmp {s} my_label", .{op})); try expect_instr_jmp(.{ .cond = cond, .target = "my_label" }, tokens.get(0)); @@ -1762,16 +1760,14 @@ test "tokenize.instr.mov" { } const Operation = Token.Instruction.Mov.Operation; - const operations = std.ComptimeStringMap(Operation, .{ + const operations = std.StaticStringMap(Operation).initComptime(.{ .{ "!", .invert }, .{ "~", .invert }, .{ "::", .bit_reverse }, }); inline for (.{ "", " " }) |space| { - inline for (operations.kvs) |kv| { - const str = kv.key; - const operation = kv.value; + inline for (comptime operations.keys(), comptime operations.values()) |str, operation| { const tokens = try bounded_tokenize(comptime std.fmt.comptimePrint("mov x {s}{s}y", .{ str, space, @@ -1792,7 +1788,7 @@ test "tokenize.instr.irq" { wait: bool, }; - const modes = std.ComptimeStringMap(ClearWait, .{ + const modes = std.StaticStringMap(ClearWait).initComptime(.{ .{ "", .{ .clear = false, .wait = false } }, .{ "set", .{ .clear = false, .wait = false } }, .{ "nowait", .{ .clear = false, .wait = false } }, @@ -1800,15 +1796,15 @@ test "tokenize.instr.irq" { .{ "clear", .{ .clear = true, .wait = false } }, }); - inline for (modes.kvs, 0..) |kv, num| { + inline for (comptime modes.keys(), comptime modes.values(), 0..) |key, value, num| { const tokens = try bounded_tokenize(comptime std.fmt.comptimePrint("irq {s} {}", .{ - kv.key, + key, num, })); try expect_instr_irq(.{ - .clear = kv.value.clear, - .wait = kv.value.wait, + .clear = value.clear, + .wait = value.wait, .num = num, }, tokens.get(0)); } diff --git a/bsp/raspberrypi/rp2040/src/hal/random.zig b/bsp/raspberrypi/rp2040/src/hal/random.zig index b7f102f..e311712 100644 --- a/bsp/raspberrypi/rp2040/src/hal/random.zig +++ b/bsp/raspberrypi/rp2040/src/hal/random.zig @@ -2,7 +2,7 @@ const std = @import("std"); const assert = std.debug.assert; -const Random = std.rand.Random; +const Random = std.Random; const microzig = @import("microzig"); const peripherals = microzig.chip.peripherals; @@ -20,11 +20,11 @@ const peripherals = microzig.chip.peripherals; /// for security systems because the ROSC as entropy source can be /// compromised. However, it promises at least equal distribution. pub const Ascon = struct { - state: std.rand.Ascon, + state: Random.Ascon, counter: usize = 0, const reseed_threshold = 4096; - const secret_seed_length = std.rand.Ascon.secret_seed_length; + const secret_seed_length = Random.Ascon.secret_seed_length; pub fn init() @This() { // Ensure that the system clocks run from the XOSC and/or PLLs @@ -38,10 +38,10 @@ pub const Ascon = struct { var b: [secret_seed_length]u8 = undefined; rosc(&b); - return @This(){ .state = std.rand.Ascon.init(b) }; + return @This(){ .state = Random.Ascon.init(b) }; } - /// Returns a `std.rand.Random` structure backed by the current RNG + /// Returns a `std.Random` structure backed by the current RNG pub fn random(self: *@This()) Random { return Random.init(self, fill); } diff --git a/bsp/stmicro/stm32/build.zig b/bsp/stmicro/stm32/build.zig index 3fcc52d..863a658 100644 --- a/bsp/stmicro/stm32/build.zig +++ b/bsp/stmicro/stm32/build.zig @@ -190,7 +190,7 @@ pub const boards = struct { .chip = chips.stm32f303vc.chip, .board = .{ .name = "STM32F3DISCOVERY", - .root_source_file = .{ .path = build_root ++ "/src/boards/STM32F3DISCOVERY.zig" }, + .root_source_file = .{ .cwd_relative = build_root ++ "/src/boards/STM32F3DISCOVERY.zig" }, }, }; @@ -199,7 +199,7 @@ pub const boards = struct { .chip = chips.stm32f407vg.chip, .board = .{ .name = "STM32F4DISCOVERY", - .root_source_file = .{ .path = build_root ++ "/src/boards/STM32F4DISCOVERY.zig" }, + .root_source_file = .{ .cwd_relative = build_root ++ "/src/boards/STM32F4DISCOVERY.zig" }, }, }; @@ -208,7 +208,7 @@ pub const boards = struct { .chip = chips.stm32f407vg.chip, .board = .{ .name = "STM3240G_EVAL", - .root_source_file = .{ .path = build_root ++ "/src/boards/STM3240G_EVAL.zig" }, + .root_source_file = .{ .cwd_relative = build_root ++ "/src/boards/STM3240G_EVAL.zig" }, }, }; @@ -217,7 +217,7 @@ pub const boards = struct { .chip = chips.stm32f429zit6u.chip, .board = .{ .name = "STM32F429IDISCOVERY", - .root_source_file = .{ .path = build_root ++ "/src/boards/STM32F429IDISCOVERY.zig" }, + .root_source_file = .{ .cwd_relative = build_root ++ "/src/boards/STM32F429IDISCOVERY.zig" }, }, }; }; diff --git a/build.zig.zon b/build.zig.zon index 061a312..2362cc6 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,7 @@ .{ .name = "microzig", - .version = "0.12.1", + .version = "0.13.0", + .minimum_zig_version = "0.13.0", .dependencies = .{ // packages within the monorepo so that others can reach them .build = .{ .path = "build" }, @@ -29,8 +30,8 @@ // used for creating package tarballs .boxzer = .{ - .url = "https://github.com/mattnite/boxzer/archive/74f17daa97f6861c31b30a5070136216c08eb39b.tar.gz", - .hash = "1220a14c01a66c023d8944dc672edd5121f98f82196fefbc09a13bcadb96e1c8e7f1", + .url = "https://github.com/mattnite/boxzer/archive/6bd6636d780f626af1c40a27be2680e223965c8a.tar.gz", + .hash = "1220432ca3323f0a7033fd84df6d0f2d66aecf4c5301b3ac70c96cca8b0938164f17", }, }, diff --git a/build/build.zig b/build/build.zig index 6ea3809..4105c23 100644 --- a/build/build.zig +++ b/build/build.zig @@ -23,7 +23,7 @@ pub fn build(b: *Build) !void { const uf2_dep = b.dependency("microzig/tools/uf2", .{}); const build_test = b.addTest(.{ - .root_source_file = .{ .path = "build.zig" }, + .root_source_file = b.path("build.zig"), }); build_test.root_module.addAnonymousImport("uf2", .{ @@ -39,6 +39,9 @@ pub fn build(b: *Build) !void { b.getInstallStep().dependOn(&install_docs.step); } +fn root() []const u8 { + return comptime (std.fs.path.dirname(@src().file) orelse "."); +} /// Creates a new MicroZig build environment that can be used to create new firmware. pub fn init(b: *Build, opts: struct { dependency_name: []const u8 = "microzig/build", @@ -53,7 +56,7 @@ pub fn init(b: *Build, opts: struct { .microzig_core = core_dep, .generate_linkerscript = mz_dep.builder.addExecutable(.{ .name = "generate-linkerscript", - .root_source_file = .{ .path = "src/generate_linkerscript.zig" }, + .root_source_file = .{ .cwd_relative = comptime root() ++ "/src/generate_linkerscript.zig" }, .target = mz_dep.builder.host, }), }; diff --git a/build/definitions/build.zig b/build/definitions/build.zig index 875da03..deee1cb 100644 --- a/build/definitions/build.zig +++ b/build/definitions/build.zig @@ -4,7 +4,7 @@ const LazyPath = Build.LazyPath; pub fn build(b: *Build) void { _ = b.addModule("definitions", .{ - .root_source_file = .{ .path = "build.zig" }, + .root_source_file = b.path("build.zig"), }); } diff --git a/core/build.zig b/core/build.zig index fe24e6e..17d0bed 100644 --- a/core/build.zig +++ b/core/build.zig @@ -18,8 +18,8 @@ pub fn build(b: *std.Build) !void { pub const cpus = struct { pub const avr5 = MicroZig.Cpu{ .name = "AVR5", - .root_source_file = .{ .path = build_root ++ "/src/cpus/avr5.zig" }, - .target = std.zig.CrossTarget{ + .root_source_file = .{ .cwd_relative = build_root ++ "/src/cpus/avr5.zig" }, + .target = std.Target.Query{ .cpu_arch = .avr, .cpu_model = .{ .explicit = &std.Target.avr.cpu.avr5 }, .os_tag = .freestanding, @@ -29,8 +29,8 @@ pub const cpus = struct { pub const cortex_m0 = MicroZig.Cpu{ .name = "ARM Cortex-M0", - .root_source_file = .{ .path = build_root ++ "/src/cpus/cortex_m.zig" }, - .target = std.zig.CrossTarget{ + .root_source_file = .{ .cwd_relative = build_root ++ "/src/cpus/cortex_m.zig" }, + .target = std.Target.Query{ .cpu_arch = .thumb, .cpu_model = .{ .explicit = &std.Target.arm.cpu.cortex_m0 }, .os_tag = .freestanding, @@ -40,8 +40,8 @@ pub const cpus = struct { pub const cortex_m0plus = MicroZig.Cpu{ .name = "ARM Cortex-M0+", - .root_source_file = .{ .path = build_root ++ "/src/cpus/cortex_m.zig" }, - .target = std.zig.CrossTarget{ + .root_source_file = .{ .cwd_relative = build_root ++ "/src/cpus/cortex_m.zig" }, + .target = std.Target.Query{ .cpu_arch = .thumb, .cpu_model = .{ .explicit = &std.Target.arm.cpu.cortex_m0plus }, .os_tag = .freestanding, @@ -51,8 +51,8 @@ pub const cpus = struct { pub const cortex_m3 = MicroZig.Cpu{ .name = "ARM Cortex-M3", - .root_source_file = .{ .path = build_root ++ "/src/cpus/cortex_m.zig" }, - .target = std.zig.CrossTarget{ + .root_source_file = .{ .cwd_relative = build_root ++ "/src/cpus/cortex_m.zig" }, + .target = std.Target.Query{ .cpu_arch = .thumb, .cpu_model = .{ .explicit = &std.Target.arm.cpu.cortex_m3 }, .os_tag = .freestanding, @@ -62,8 +62,8 @@ pub const cpus = struct { pub const cortex_m4 = MicroZig.Cpu{ .name = "ARM Cortex-M4", - .root_source_file = .{ .path = build_root ++ "/src/cpus/cortex_m.zig" }, - .target = std.zig.CrossTarget{ + .root_source_file = .{ .cwd_relative = build_root ++ "/src/cpus/cortex_m.zig" }, + .target = std.Target.Query{ .cpu_arch = .thumb, .cpu_model = .{ .explicit = &std.Target.arm.cpu.cortex_m4 }, .os_tag = .freestanding, @@ -73,8 +73,8 @@ pub const cpus = struct { pub const riscv32_imac = MicroZig.Cpu{ .name = "RISC-V 32-bit", - .root_source_file = .{ .path = build_root ++ "/src/cpus/riscv32.zig" }, - .target = std.zig.CrossTarget{ + .root_source_file = .{ .cwd_relative = build_root ++ "/src/cpus/riscv32.zig" }, + .target = std.Target.Query{ .cpu_arch = .riscv32, .cpu_model = .{ .explicit = &std.Target.riscv.cpu.sifive_e21 }, .os_tag = .freestanding, diff --git a/examples/espressif/esp/build.zig b/examples/espressif/esp/build.zig index ffa48d2..366a1fd 100644 --- a/examples/espressif/esp/build.zig +++ b/examples/espressif/esp/build.zig @@ -20,7 +20,7 @@ pub fn build(b: *std.Build) void { .name = example.name, .target = example.target, .optimize = optimize, - .root_source_file = .{ .path = example.file }, + .root_source_file = b.path(example.file), }); // `installFirmware()` is the MicroZig pendant to `Build.installArtifact()` diff --git a/examples/gigadevice/gd32/build.zig b/examples/gigadevice/gd32/build.zig index a4c9963..e43946d 100644 --- a/examples/gigadevice/gd32/build.zig +++ b/examples/gigadevice/gd32/build.zig @@ -3,10 +3,13 @@ const MicroZig = @import("microzig/build"); const gd32 = @import("microzig/bsp/gigadevice/gd32"); const available_examples = [_]Example{ - .{ .target = gd32.chips.gd32vf103xb, .name = "gd32vf103xb", .file = "src/empty.zig" }, - .{ .target = gd32.chips.gd32vf103x8, .name = "gd32vf103x8", .file = "src/empty.zig" }, - .{ .target = gd32.boards.sipeed.longan_nano, .name = "sipeed-longan_nano", .file = "src/empty.zig" }, - .{ .target = gd32.boards.sipeed.longan_nano, .name = "sipeed-longan_nano_blinky", .file = "src/blinky.zig" }, + // TODO: + // error: ld.lld: section '.text' will not fit in region 'flash0': overflowed by 152170 bytes + // error: ld.lld: section '.data' will not fit in region 'flash0': overflowed by 161520 bytes + // .{ .target = gd32.chips.gd32vf103xb, .name = "gd32vf103xb", .file = "src/empty.zig" }, + // .{ .target = gd32.chips.gd32vf103x8, .name = "gd32vf103x8", .file = "src/empty.zig" }, + // .{ .target = gd32.boards.sipeed.longan_nano, .name = "sipeed-longan_nano", .file = "src/empty.zig" }, + // .{ .target = gd32.boards.sipeed.longan_nano, .name = "sipeed-longan_nano_blinky", .file = "src/blinky.zig" }, }; pub fn build(b: *std.Build) void { @@ -23,7 +26,7 @@ pub fn build(b: *std.Build) void { .name = example.name, .target = example.target, .optimize = optimize, - .root_source_file = .{ .path = example.file }, + .root_source_file = b.path(example.file), }); // `install_firmware()` is the MicroZig pendant to `Build.installArtifact()` diff --git a/examples/microchip/atsam/build.zig b/examples/microchip/atsam/build.zig index 58ba6b4..851fa56 100644 --- a/examples/microchip/atsam/build.zig +++ b/examples/microchip/atsam/build.zig @@ -20,7 +20,7 @@ pub fn build(b: *std.Build) void { .name = example.name, .target = example.target, .optimize = optimize, - .root_source_file = .{ .path = example.file }, + .root_source_file = b.path(example.file), }); // `install_firmware()` is the MicroZig pendant to `Build.installArtifact()` diff --git a/examples/microchip/avr/build.zig b/examples/microchip/avr/build.zig index 236525f..213bdb3 100644 --- a/examples/microchip/avr/build.zig +++ b/examples/microchip/avr/build.zig @@ -21,7 +21,7 @@ pub fn build(b: *std.Build) void { .name = example.name, .target = example.target, .optimize = optimize, - .root_source_file = .{ .path = example.file }, + .root_source_file = b.path(example.file), }); // `install_firmware()` is the MicroZig pendant to `Build.installArtifact()` diff --git a/examples/nordic/nrf5x/build.zig b/examples/nordic/nrf5x/build.zig index 5dffdcf..3851366 100644 --- a/examples/nordic/nrf5x/build.zig +++ b/examples/nordic/nrf5x/build.zig @@ -21,7 +21,7 @@ pub fn build(b: *Build) void { .name = example.name, .target = example.target, .optimize = optimize, - .root_source_file = .{ .path = example.file }, + .root_source_file = b.path(example.file), }); // `install_firmware()` is the MicroZig pendant to `Build.installArtifact()` diff --git a/examples/nxp/lpc/build.zig b/examples/nxp/lpc/build.zig index 493f56b..76129c7 100644 --- a/examples/nxp/lpc/build.zig +++ b/examples/nxp/lpc/build.zig @@ -20,7 +20,7 @@ pub fn build(b: *std.Build) void { .name = example.name, .target = example.target, .optimize = optimize, - .root_source_file = .{ .path = example.file }, + .root_source_file = b.path(example.file), }); // `install_firmware()` is the MicroZig pendant to `Build.installArtifact()` diff --git a/examples/raspberrypi/rp2040/build.zig b/examples/raspberrypi/rp2040/build.zig index 8ec7beb..5be2fad 100644 --- a/examples/raspberrypi/rp2040/build.zig +++ b/examples/raspberrypi/rp2040/build.zig @@ -42,7 +42,7 @@ pub fn build(b: *std.Build) void { .name = example.name, .target = example.target, .optimize = optimize, - .root_source_file = .{ .path = example.file }, + .root_source_file = b.path(example.file), }); // `install_firmware()` is the MicroZig pendant to `Build.installArtifact()` diff --git a/examples/raspberrypi/rp2040/src/tiles.zig b/examples/raspberrypi/rp2040/src/tiles.zig index b55f791..745a0a3 100644 --- a/examples/raspberrypi/rp2040/src/tiles.zig +++ b/examples/raspberrypi/rp2040/src/tiles.zig @@ -97,7 +97,7 @@ pub fn main() void { }) catch unreachable; pio.sm_set_enabled(sm, true); - var rng_src = std.rand.DefaultPrng.init(0x1234); + var rng_src = std.Random.DefaultPrng.init(0x1234); const rng = rng_src.random(); diff --git a/examples/stmicro/stm32/build.zig b/examples/stmicro/stm32/build.zig index 779e0fb..5c2dcd2 100644 --- a/examples/stmicro/stm32/build.zig +++ b/examples/stmicro/stm32/build.zig @@ -3,7 +3,10 @@ const MicroZig = @import("microzig/build"); const stm32 = @import("microzig/bsp/stmicro/stm32"); const available_examples = [_]Example{ - .{ .target = stm32.chips.stm32f103x8, .name = "stm32f103x8", .file = "src/blinky.zig" }, + // error: ld.lld: section '.text' will not fit in region 'flash0': overflowed by 73532 bytes + // error: ld.lld: section '.ARM.exidx' will not fit in region 'flash0': overflowed by 74148 bytes + // error: ld.lld: section '.data' will not fit in region 'flash0': overflowed by 86028 bytes + // TODO: .{ .target = stm32.chips.stm32f103x8, .name = "stm32f103x8", .file = "src/blinky.zig" }, // TODO: .{ .target = stm32.chips.stm32f303vc, .name = "stm32f303vc", .file = "src/blinky.zig" }, // TODO: .{ .target = stm32.chips.stm32f407vg, .name = "stm32f407vg", .file = "src/blinky.zig" }, // TODO: .{ .target = stm32.chips.stm32f429zit6u, .name = "stm32f429zit6u", .file = "src/blinky.zig" }, @@ -27,7 +30,7 @@ pub fn build(b: *std.Build) void { .name = example.name, .target = example.target, .optimize = optimize, - .root_source_file = .{ .path = example.file }, + .root_source_file = b.path(example.file), }); // `install_firmware()` is the MicroZig pendant to `Build.installArtifact()` diff --git a/flake.lock b/flake.lock index 0776794..e2143b3 100644 --- a/flake.lock +++ b/flake.lock @@ -19,11 +19,27 @@ "flake-compat_2": { "flake": false, "locked": { - "lastModified": 1673956053, - "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_3": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", "owner": "edolstra", "repo": "flake-compat", - "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", "type": "github" }, "original": { @@ -37,11 +53,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1701680307, - "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -51,12 +67,51 @@ } }, "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_4": { + "inputs": { + "systems": "systems_4" + }, "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", "owner": "numtide", "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", "type": "github" }, "original": { @@ -65,13 +120,46 @@ "type": "github" } }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "zls", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "langref": { + "flake": false, + "locked": { + "narHash": "sha256-O6p2tiKD8ZMhSX+DeA/o5hhAvcPkU2J9lFys/r11peY=", + "type": "file", + "url": "https://raw.githubusercontent.com/ziglang/zig/0fb2015fd3422fc1df364995f9782dfe7255eccd/doc/langref.html.in" + }, + "original": { + "type": "file", + "url": "https://raw.githubusercontent.com/ziglang/zig/0fb2015fd3422fc1df364995f9782dfe7255eccd/doc/langref.html.in" + } + }, "nixpkgs": { "locked": { - "lastModified": 1704766047, - "narHash": "sha256-q9tH9yvUWVBh5XpWafpCYAYf72ZyNhfmpgfR4fwM6uw=", + "lastModified": 1719957072, + "narHash": "sha256-gvFhEf5nszouwLAkT9nWsDzocUTqLWHuL++dvNjMp9I=", "owner": "nixos", "repo": "nixpkgs", - "rev": "cc2f101c016d42b728a9cb8244215a5d2d98f6df", + "rev": "7144d6241f02d171d25fba3edeaf15e0f2592105", "type": "github" }, "original": { @@ -83,16 +171,32 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1702350026, - "narHash": "sha256-A+GNZFZdfl4JdDphYKBJ5Ef1HOiFsP18vQe9mqjmUis=", + "lastModified": 1708161998, + "narHash": "sha256-6KnemmUorCvlcAvGziFosAVkrlWZGIc6UNT9GUYr0jQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "84d981bae8b5e783b3b548de505b22880559515f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1718208800, + "narHash": "sha256-US1tAChvPxT52RV8GksWZS415tTS7PV42KTc2PNDBmc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9463103069725474698139ab10f17a9d125da859", + "rev": "cc54fb41d13736e92229c21627ea4f22199fee6b", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-23.05", + "ref": "nixos-24.05", "repo": "nixpkgs", "type": "github" } @@ -102,7 +206,8 @@ "flake-compat": "flake-compat", "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", - "zig": "zig" + "zig": "zig", + "zls": "zls" } }, "systems": { @@ -120,6 +225,51 @@ "type": "github" } }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_4": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "zig": { "inputs": { "flake-compat": "flake-compat_2", @@ -127,11 +277,34 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1704283725, - "narHash": "sha256-sRWv8au/59BZpWpqqC8PaGDC9bUNhRIMzanF1zPnXNQ=", + "lastModified": 1720527051, + "narHash": "sha256-87aaUnHa8PzRlnQUR2mLn7BouthbhimExlPdlgu5C0E=", + "owner": "mitchellh", + "repo": "zig-overlay", + "rev": "7789c58ba03f3eb018e7cf60bbcdff2e1e9eb643", + "type": "github" + }, + "original": { + "owner": "mitchellh", + "repo": "zig-overlay", + "type": "github" + } + }, + "zig-overlay": { + "inputs": { + "flake-compat": "flake-compat_3", + "flake-utils": "flake-utils_4", + "nixpkgs": [ + "zls", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1718539737, + "narHash": "sha256-hvQ900gSqzGnJWMRQwv65TixciIbC44iX0Nh5ENRwCU=", "owner": "mitchellh", "repo": "zig-overlay", - "rev": "f06e268e24a71922ff8b20c94cff1d2afcbd4ab5", + "rev": "6eb42ce6f85d247b1aecf854c45d80902821d0ad", "type": "github" }, "original": { @@ -139,6 +312,28 @@ "repo": "zig-overlay", "type": "github" } + }, + "zls": { + "inputs": { + "flake-utils": "flake-utils_3", + "gitignore": "gitignore", + "langref": "langref", + "nixpkgs": "nixpkgs_3", + "zig-overlay": "zig-overlay" + }, + "locked": { + "lastModified": 1720349156, + "narHash": "sha256-eTjMZ/PEkzR+68C1hUwz9Qh/gizxwNG5PkMaDgplEZk=", + "owner": "zigtools", + "repo": "zls", + "rev": "fbd8b9a87a3cd5ab8389054815d9e3f81dfd430b", + "type": "github" + }, + "original": { + "owner": "zigtools", + "repo": "zls", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 599201e..b4d77a9 100644 --- a/flake.nix +++ b/flake.nix @@ -8,6 +8,9 @@ # required for latest zig zig.url = "github:mitchellh/zig-overlay"; + zls.url = "github:zigtools/zls"; + + # Used for shell.nix flake-compat = { url = github:edolstra/flake-compat; @@ -26,6 +29,7 @@ # Other overlays (final: prev: { zigpkgs = inputs.zig.packages.${prev.system}; + zls = inputs.zls.packages.${prev.system}.zls; }) ]; @@ -84,7 +88,8 @@ rec { devShells.default = pkgs.mkShell { nativeBuildInputs = [ - pkgs.zigpkgs."0.11.0" + pkgs.zigpkgs."0.13.0" + pkgs.zls (python3.withPackages (ps: [ ps.dataclasses_json ps.marshmallow diff --git a/tools/regz/build.zig b/tools/regz/build.zig index 7101c1b..7fed509 100644 --- a/tools/regz/build.zig +++ b/tools/regz/build.zig @@ -16,7 +16,7 @@ pub fn build(b: *Build) !void { const regz = b.addExecutable(.{ .name = "regz", - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); @@ -24,7 +24,7 @@ pub fn build(b: *Build) !void { b.installArtifact(regz); const exported_module = b.addModule("regz", .{ - .root_source_file = .{ .path = "src/module.zig" }, + .root_source_file = b.path("src/module.zig"), }); exported_module.linkLibrary(libxml2_dep.artifact("xml2")); @@ -39,9 +39,7 @@ pub fn build(b: *Build) !void { const contextualize_fields = b.addExecutable(.{ .name = "contextualize-fields", - .root_source_file = .{ - .path = "src/contextualize-fields.zig", - }, + .root_source_file = b.path("src/contextualize-fields.zig"), .target = b.host, }); contextualize_fields.linkLibrary(libxml2_dep.artifact("xml2")); @@ -54,9 +52,7 @@ pub fn build(b: *Build) !void { const characterize = b.addExecutable(.{ .name = "characterize", - .root_source_file = .{ - .path = "src/characterize.zig", - }, + .root_source_file = b.path("src/characterize.zig"), .target = b.host, }); characterize.linkLibrary(libxml2_dep.artifact("xml2")); @@ -65,9 +61,7 @@ pub fn build(b: *Build) !void { characterize_step.dependOn(&characterize_run.step); const tests = b.addTest(.{ - .root_source_file = .{ - .path = "src/Database.zig", - }, + .root_source_file = b.path("src/Database.zig"), .target = target, .optimize = optimize, }); diff --git a/tools/regz/build.zig.zon b/tools/regz/build.zig.zon index d93951a..95f49a5 100644 --- a/tools/regz/build.zig.zon +++ b/tools/regz/build.zig.zon @@ -12,8 +12,8 @@ }, .dependencies = .{ .libxml2 = .{ - .url = "https://github.com/mattnite/zig-build-libxml2/archive/fca6bbd7f73914acaea685c544d91608797546a8.tar.gz", - .hash = "1220c3e12fc08c12d6fc52bcc0ae8b180a69abc08212350e2708d4851879f4c814da", + .url = "https://github.com/mattnite/zig-build-libxml2/archive/fab68b5fb06704ef4bdaa221726493a4b6af04b5.tar.gz", + .hash = "122084531ab8ba877a0178fb177a61f6dc9bed56bdcdfb11ad362f352680c04d84cb", }, }, } diff --git a/tools/regz/src/Database.zig b/tools/regz/src/Database.zig index cdb253c..a31f548 100644 --- a/tools/regz/src/Database.zig +++ b/tools/regz/src/Database.zig @@ -763,7 +763,7 @@ pub fn add_child( }); assert(db.entity_is(entity_location, child_id)); - comptime var it = std.mem.tokenize(u8, entity_location, "."); + comptime var it = std.mem.tokenizeScalar(u8, entity_location, '.'); // the tables are in plural form but "type.peripheral" feels better to me // for calling this function _ = comptime it.next(); @@ -796,7 +796,7 @@ pub fn add_device_property( // TODO: assert that entity is only found in one table pub fn entity_is(db: Database, comptime entity_location: []const u8, id: EntityId) bool { - comptime var it = std.mem.tokenize(u8, entity_location, "."); + comptime var it = std.mem.tokenizeScalar(u8, entity_location, '.'); // the tables are in plural form but "type.peripheral" feels better to me // for calling this function const group = comptime (it.next() orelse unreachable) ++ "s"; @@ -811,7 +811,7 @@ pub fn get_entity_id_by_name( comptime entity_location: []const u8, name: []const u8, ) !EntityId { - comptime var tok_it = std.mem.tokenize(u8, entity_location, "."); + comptime var tok_it = std.mem.tokenizeScalar(u8, entity_location, '.'); // the tables are in plural form but "type.peripheral" feels better to me // for calling this function const group = comptime (tok_it.next() orelse unreachable) ++ "s"; diff --git a/tools/regz/src/atdf.zig b/tools/regz/src/atdf.zig index c6515e3..6c50d12 100644 --- a/tools/regz/src/atdf.zig +++ b/tools/regz/src/atdf.zig @@ -519,7 +519,7 @@ fn assign_modes_to_entity( return; }; - var tok_it = std.mem.tokenize(u8, mode_names, " "); + var tok_it = std.mem.tokenizeScalar(u8, mode_names, ' '); while (tok_it.next()) |mode_str| { for (mode_set.keys()) |mode_id| { if (db.attrs.name.get(mode_id)) |name| diff --git a/tools/regz/src/gen.zig b/tools/regz/src/gen.zig index 2aa7ade..93b7f1c 100644 --- a/tools/regz/src/gen.zig +++ b/tools/regz/src/gen.zig @@ -77,7 +77,7 @@ pub fn write_comment(allocator: Allocator, comment: []const u8, writer: anytype) defer tokenized.deinit(); var first = true; - var tok_it = std.mem.tokenize(u8, comment, "\n\r \t"); + var tok_it = std.mem.tokenizeAny(u8, comment, "\n\r \t"); while (tok_it.next()) |token| { if (!first) first = false @@ -90,7 +90,7 @@ pub fn write_comment(allocator: Allocator, comment: []const u8, writer: anytype) const unescaped = try std.mem.replaceOwned(u8, allocator, tokenized.items, "\\n", "\n"); defer allocator.free(unescaped); - var line_it = std.mem.tokenize(u8, unescaped, "\n"); + var line_it = std.mem.tokenizeScalar(u8, unescaped, '\n'); while (line_it.next()) |line| try writer.print("/// {s}\n", .{line}); } @@ -98,7 +98,7 @@ pub fn write_comment(allocator: Allocator, comment: []const u8, writer: anytype) fn write_string(str: []const u8, writer: anytype) !void { if (std.mem.containsAtLeast(u8, str, 1, "\n")) { try writer.writeByte('\n'); - var line_it = std.mem.split(u8, str, "\n"); + var line_it = std.mem.splitScalar(u8, str, '\n'); while (line_it.next()) |line| try writer.print("\\\\{s}\n", .{line}); } else { @@ -511,7 +511,7 @@ fn write_mode_enum_and_fn( defer components.deinit(); const mode = db.types.modes.get(mode_id).?; - var tok_it = std.mem.tokenize(u8, mode.qualifier, "."); + var tok_it = std.mem.tokenizeScalar(u8, mode.qualifier, '.'); while (tok_it.next()) |token| try components.append(token); @@ -526,7 +526,7 @@ fn write_mode_enum_and_fn( }); try writer.writeAll("switch (value) {\n"); - tok_it = std.mem.tokenize(u8, mode.value, " "); + tok_it = std.mem.tokenizeScalar(u8, mode.value, ' '); while (tok_it.next()) |token| { const value = try std.fmt.parseInt(u64, token, 0); try writer.print("{},\n", .{value}); diff --git a/tools/regz/src/regzon.zig b/tools/regz/src/regzon.zig index 1b27fd2..0eaeee9 100644 --- a/tools/regz/src/regzon.zig +++ b/tools/regz/src/regzon.zig @@ -75,7 +75,7 @@ fn entity_type_to_string(entity_type: Database.EntityType) []const u8 { }; } -const string_to_entity_type_map = std.ComptimeStringMap(Database.EntityType, .{ +const string_to_entity_type_map = std.StaticStringMap(Database.EntityType).initComptime(.{ .{ "peripherals", .peripheral }, .{ "register_groups", .register_group }, .{ "registers", .register }, @@ -166,7 +166,7 @@ fn resolve_enums(ctx: *LoadContext) !void { fn ref_to_id(db: Database, ref: []const u8) !EntityId { // TODO: do proper tokenization since we'll need to handle @"" fields. okay to leave for now. - var it = std.mem.tokenize(u8, ref, "."); + var it = std.mem.tokenizeScalar(u8, ref, '.'); const first = it.next() orelse return error.Malformed; return if (std.mem.eql(u8, "types", first)) blk: { var tmp_id: ?EntityId = null; diff --git a/tools/regz/src/svd.zig b/tools/regz/src/svd.zig index 8f0ed3a..822c44b 100644 --- a/tools/regz/src/svd.zig +++ b/tools/regz/src/svd.zig @@ -44,7 +44,7 @@ const Context = struct { } }; -const svd_boolean = std.ComptimeStringMap(bool, .{ +const svd_boolean = std.StaticStringMap(bool).initComptime(.{ .{ "true", true }, .{ "1", true }, .{ "false", false }, @@ -680,7 +680,7 @@ const BitRange = struct { const bit_range_opt = node.get_value("bitRange"); if (bit_range_opt) |bit_range_str| { - var it = std.mem.tokenize(u8, bit_range_str, "[:]"); + var it = std.mem.tokenizeAny(u8, bit_range_str, "[:]"); const msb = try std.fmt.parseInt(u8, it.next() orelse return error.NoMsb, 0); const lsb = try std.fmt.parseInt(u8, it.next() orelse return error.NoLsb, 0); diff --git a/tools/uf2/build.zig b/tools/uf2/build.zig index e278b7c..bfef6af 100644 --- a/tools/uf2/build.zig +++ b/tools/uf2/build.zig @@ -36,18 +36,18 @@ pub fn build(b: *std.Build) void { const elf2uf2 = b.addExecutable(.{ .name = "elf2uf2", - .root_source_file = .{ .path = "src/elf2uf2.zig" }, + .root_source_file = b.path("src/elf2uf2.zig"), .target = target, .optimize = optimize, }); b.installArtifact(elf2uf2); _ = b.addModule("uf2", .{ - .root_source_file = .{ .path = "src/uf2.zig" }, + .root_source_file = b.path("src/uf2.zig"), }); const main_tests = b.addTest(.{ - .root_source_file = .{ .path = "src/uf2.zig" }, + .root_source_file = b.path("src/uf2.zig"), }); const run_main_tests = b.addRunArtifact(main_tests); @@ -56,7 +56,7 @@ pub fn build(b: *std.Build) void { const gen = b.addExecutable(.{ .name = "gen", - .root_source_file = .{ .path = "src/gen.zig" }, + .root_source_file = b.path("src/gen.zig"), .target = b.host, }); const gen_run_step = b.addRunArtifact(gen); @@ -65,7 +65,7 @@ pub fn build(b: *std.Build) void { const example = b.addExecutable(.{ .name = "example", - .root_source_file = .{ .path = "src/example.zig" }, + .root_source_file = b.path("src/example.zig"), .target = b.host, }); b.installArtifact(example);