From a9c3ae56907ad8949325dfb7e532a038e5d6ec77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20=22xq=22=20Quei=C3=9Fner?= Date: Mon, 25 Sep 2023 18:41:49 +0200 Subject: [PATCH] Enables all packages, with no examples if defunct. --- .github/workflows/build.yml | 6 +-- gigadevice-gd32/build.zig | 76 ++++++++-------------------------- microchip-atmega/build.zig | 2 +- stmicro-stm32/build.zig | 81 ++++++++++--------------------------- 4 files changed, 43 insertions(+), 122 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 08208de..720973f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,9 +17,9 @@ jobs: - espressif-esp - nxp-lpc - microchip-atmega - # TODO: - gigadevice-gd32 - # TODO: - nordic-nrf5x - # TODO: - stmicro-stm32 + - gigadevice-gd32 + - nordic-nrf5x + - stmicro-stm32 os: - windows-latest - macos-latest diff --git a/gigadevice-gd32/build.zig b/gigadevice-gd32/build.zig index 4064772..b7a2e4c 100644 --- a/gigadevice-gd32/build.zig +++ b/gigadevice-gd32/build.zig @@ -1,75 +1,27 @@ const std = @import("std"); -const rp2040 = @import("rp2040"); -const stm32 = @import("stm32"); -const lpc = @import("lpc"); const gd32 = @import("gd32"); -const nrf5x = @import("nrf5x"); -const esp = @import("esp"); -const atmega = @import("atmega"); + +const available_examples = [_]Example{ + // .{ .name = "gd32vf103xb", .target = gd32.chips.gd32vf103xb, .file = "src/blinky.zig" }, + // .{ .name = "gd32vf103x8", .target = gd32.chips.gd32vf103x8, .file = "src/blinky.zig" }, + // .{ .name = "sipeed-longan_nano", .target = gd32.boards.sipeed.longan_nano, .file = "src/blinky.zig" }, +}; pub fn build(b: *std.Build) void { const microzig = @import("microzig").init(b, "microzig"); - const optimize = b.standardOptimizeOption(.{}); - - const TargetDesc = struct { - target: @import("microzig").Target, - name: []const u8, - }; - - const available_targets = [_]TargetDesc{ - // RP2040 - .{ .name = "pico", .target = rp2040.boards.raspberry_pi.pico }, - .{ .name = "rp2040-eth", .target = rp2040.boards.waveshare.rp2040_eth }, - .{ .name = "rp2040-plus-4m", .target = rp2040.boards.waveshare.rp2040_plus_4m }, - .{ .name = "rp2040-plus-16m", .target = rp2040.boards.waveshare.rp2040_plus_16m }, - .{ .name = "rp2040-matrix", .target = rp2040.boards.waveshare.rp2040_matrix }, - - // STM32 - .{ .name = "stm32f103x8", .target = stm32.chips.stm32f103x8 }, - .{ .name = "stm32f303vc", .target = stm32.chips.stm32f303vc }, - .{ .name = "stm32f407vg", .target = stm32.chips.stm32f407vg }, - .{ .name = "stm32f429zit6u", .target = stm32.chips.stm32f429zit6u }, - .{ .name = "stm32f3discovery", .target = stm32.boards.stm32f3discovery }, - .{ .name = "stm32f4discovery", .target = stm32.boards.stm32f4discovery }, - .{ .name = "stm3240geval", .target = stm32.boards.stm3240geval }, - .{ .name = "stm32f429idiscovery", .target = stm32.boards.stm32f429idiscovery }, - - // NXP LPC - .{ .name = "lpc176x5x", .target = lpc.chips.lpc176x5x }, - .{ .name = "mbed-lpc1768", .target = lpc.boards.mbed.lpc1768 }, + const optimize = .ReleaseSmall; // The others are not really an option on AVR - // GigaDevice GD32 - .{ .name = "gd32vf103xb", .target = gd32.chips.gd32vf103xb }, - .{ .name = "gd32vf103x8", .target = gd32.chips.gd32vf103x8 }, - .{ .name = "sipeed-longan_nano", .target = gd32.boards.sipeed.longan_nano }, - - // Nordic Nrf5x - .{ .name = "nrf52832", .target = nrf5x.chips.nrf52832 }, - .{ .name = "nrf52840", .target = nrf5x.chips.nrf52840 }, - .{ .name = "nrf52840-dongle", .target = nrf5x.boards.nordic.nRF52840_Dongle }, // TODO: Add support for DFU files! - - // RISC-V Espressif ESP - .{ .name = "esp32-c3", .target = esp.chips.esp32_c3 }, // TODO: Add support for Espressif Update Binaries - - // Microchip ATmega - // TODO: Fix compiler bugs - // - https://github.com/ziglang/zig/issues/17219 - // .{ .name = "atmega328p", .target = atmega.chips.atmega328p }, - // .{ .name = "arduino-nano", .target = atmega.boards.arduino.nano }, - // .{ .name = "arduino-uno-rev3", .target = atmega.boards.arduino.uno_rev3 }, - }; - - for (available_targets) |dest| { + for (available_examples) |example| { // `addFirmware` basically works like addExecutable, but takes a // `microzig.Target` for target instead of a `std.zig.CrossTarget`. // // The target will convey all necessary information on the chip, // cpu and potentially the board as well. const firmware = microzig.addFirmware(b, .{ - .name = b.fmt("empty-{s}", .{dest.name}), - .target = dest.target, + .name = example.name, + .target = example.target, .optimize = optimize, - .source_file = .{ .path = "src/empty.zig" }, + .source_file = .{ .path = example.file }, }); // `installFirmware()` is the MicroZig pendant to `Build.installArtifact()` @@ -82,3 +34,9 @@ pub fn build(b: *std.Build) void { microzig.installFirmware(b, firmware, .{ .format = .elf }); } } + +const Example = struct { + target: @import("microzig").Target, + name: []const u8, + file: []const u8, +}; diff --git a/microchip-atmega/build.zig b/microchip-atmega/build.zig index 4eba0c2..6459450 100644 --- a/microchip-atmega/build.zig +++ b/microchip-atmega/build.zig @@ -2,7 +2,7 @@ const std = @import("std"); const atmega = @import("atmega"); const available_examples = [_]Example{ - .{ .name = "arduino-nano_blinky", .target = atmega.boards.arduino.nano, .file = "src/blinky.zig" }, + // TODO: .{ .name = "arduino-nano_blinky", .target = atmega.boards.arduino.nano, .file = "src/blinky.zig" }, }; pub fn build(b: *std.Build) void { diff --git a/stmicro-stm32/build.zig b/stmicro-stm32/build.zig index 4064772..26bbda7 100644 --- a/stmicro-stm32/build.zig +++ b/stmicro-stm32/build.zig @@ -1,75 +1,32 @@ const std = @import("std"); -const rp2040 = @import("rp2040"); const stm32 = @import("stm32"); -const lpc = @import("lpc"); -const gd32 = @import("gd32"); -const nrf5x = @import("nrf5x"); -const esp = @import("esp"); -const atmega = @import("atmega"); + +const available_examples = [_]Example{ + // TODO: .{ .name = "stm32f103x8", .target = stm32.chips.stm32f103x8, .file = "src/blinky.zig" }, + // TODO: .{ .name = "stm32f303vc", .target = stm32.chips.stm32f303vc, .file = "src/blinky.zig" }, + // TODO: .{ .name = "stm32f407vg", .target = stm32.chips.stm32f407vg, .file = "src/blinky.zig" }, + // TODO: .{ .name = "stm32f429zit6u", .target = stm32.chips.stm32f429zit6u, .file = "src/blinky.zig" }, + // TODO: .{ .name = "stm32f3discovery", .target = stm32.boards.stm32f3discovery, .file = "src/blinky.zig" }, + // TODO: .{ .name = "stm32f4discovery", .target = stm32.boards.stm32f4discovery, .file = "src/blinky.zig" }, + // TODO: .{ .name = "stm3240geval", .target = stm32.boards.stm3240geval, .file = "src/blinky.zig" }, + // TODO: .{ .name = "stm32f429idiscovery", .target = stm32.boards.stm32f429idiscovery, .file = "src/blinky.zig" }, +}; pub fn build(b: *std.Build) void { const microzig = @import("microzig").init(b, "microzig"); - const optimize = b.standardOptimizeOption(.{}); - - const TargetDesc = struct { - target: @import("microzig").Target, - name: []const u8, - }; - - const available_targets = [_]TargetDesc{ - // RP2040 - .{ .name = "pico", .target = rp2040.boards.raspberry_pi.pico }, - .{ .name = "rp2040-eth", .target = rp2040.boards.waveshare.rp2040_eth }, - .{ .name = "rp2040-plus-4m", .target = rp2040.boards.waveshare.rp2040_plus_4m }, - .{ .name = "rp2040-plus-16m", .target = rp2040.boards.waveshare.rp2040_plus_16m }, - .{ .name = "rp2040-matrix", .target = rp2040.boards.waveshare.rp2040_matrix }, - - // STM32 - .{ .name = "stm32f103x8", .target = stm32.chips.stm32f103x8 }, - .{ .name = "stm32f303vc", .target = stm32.chips.stm32f303vc }, - .{ .name = "stm32f407vg", .target = stm32.chips.stm32f407vg }, - .{ .name = "stm32f429zit6u", .target = stm32.chips.stm32f429zit6u }, - .{ .name = "stm32f3discovery", .target = stm32.boards.stm32f3discovery }, - .{ .name = "stm32f4discovery", .target = stm32.boards.stm32f4discovery }, - .{ .name = "stm3240geval", .target = stm32.boards.stm3240geval }, - .{ .name = "stm32f429idiscovery", .target = stm32.boards.stm32f429idiscovery }, - - // NXP LPC - .{ .name = "lpc176x5x", .target = lpc.chips.lpc176x5x }, - .{ .name = "mbed-lpc1768", .target = lpc.boards.mbed.lpc1768 }, + const optimize = .ReleaseSmall; // The others are not really an option on AVR - // GigaDevice GD32 - .{ .name = "gd32vf103xb", .target = gd32.chips.gd32vf103xb }, - .{ .name = "gd32vf103x8", .target = gd32.chips.gd32vf103x8 }, - .{ .name = "sipeed-longan_nano", .target = gd32.boards.sipeed.longan_nano }, - - // Nordic Nrf5x - .{ .name = "nrf52832", .target = nrf5x.chips.nrf52832 }, - .{ .name = "nrf52840", .target = nrf5x.chips.nrf52840 }, - .{ .name = "nrf52840-dongle", .target = nrf5x.boards.nordic.nRF52840_Dongle }, // TODO: Add support for DFU files! - - // RISC-V Espressif ESP - .{ .name = "esp32-c3", .target = esp.chips.esp32_c3 }, // TODO: Add support for Espressif Update Binaries - - // Microchip ATmega - // TODO: Fix compiler bugs - // - https://github.com/ziglang/zig/issues/17219 - // .{ .name = "atmega328p", .target = atmega.chips.atmega328p }, - // .{ .name = "arduino-nano", .target = atmega.boards.arduino.nano }, - // .{ .name = "arduino-uno-rev3", .target = atmega.boards.arduino.uno_rev3 }, - }; - - for (available_targets) |dest| { + for (available_examples) |example| { // `addFirmware` basically works like addExecutable, but takes a // `microzig.Target` for target instead of a `std.zig.CrossTarget`. // // The target will convey all necessary information on the chip, // cpu and potentially the board as well. const firmware = microzig.addFirmware(b, .{ - .name = b.fmt("empty-{s}", .{dest.name}), - .target = dest.target, + .name = example.name, + .target = example.target, .optimize = optimize, - .source_file = .{ .path = "src/empty.zig" }, + .source_file = .{ .path = example.file }, }); // `installFirmware()` is the MicroZig pendant to `Build.installArtifact()` @@ -82,3 +39,9 @@ pub fn build(b: *std.Build) void { microzig.installFirmware(b, firmware, .{ .format = .elf }); } } + +const Example = struct { + target: @import("microzig").Target, + name: []const u8, + file: []const u8, +};