Microzig Generation 2 Build Interface (#26)

* Drops microzig dependency
* Starts to port to MicroZig Build Gen 2
* Drops CI

---------

Co-authored-by: Felix "xq" Queißner <git@random-projects.net>
wch-ch32v003
Felix Queißner 1 year ago committed by GitHub
parent 081683a451
commit 597843c4c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,19 +0,0 @@
name: Build
on:
push:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
optimize: [Debug, ReleaseSmall, ReleaseFast, ReleaseSafe]
steps:
- uses: actions/checkout@v2
- uses: goto-bus-stop/setup-zig@v2.1.1
with:
version: 0.11.0
- name: Build
run: zig build install "-Doptimize=${{matrix.optimize}}"

@ -1,32 +1,84 @@
const std = @import("std");
const microzig = @import("microzig");
pub const boards = @import("src/boards.zig");
pub const chips = @import("src/chips.zig");
fn path(comptime suffix: []const u8) std.Build.LazyPath {
return .{
.cwd_relative = comptime ((std.fs.path.dirname(@src().file) orelse ".") ++ suffix),
};
}
pub fn build(b: *std.build.Builder) void {
const optimize = b.standardOptimizeOption(.{});
inline for (@typeInfo(boards).Struct.decls) |decl| {
const exe = microzig.addEmbeddedExecutable(b, .{
.name = @field(boards, decl.name).name ++ ".minimal",
.source_file = .{
.path = "test/programs/minimal.zig",
const hal = .{
.source_file = path("/src/hals/ATmega328P.zig"),
};
pub const chips = struct {
pub const atmega328p = .{
.preferred_format = .hex,
.chip = .{
.name = "ATmega328P",
.url = "https://www.microchip.com/en-us/product/atmega328p",
.cpu = .avr5,
.register_definition = .{
.json = path("/src/chips/ATmega328P.json"),
},
.memory_regions = &.{
.{ .offset = 0x000000, .length = 32 * 1024, .kind = .flash },
.{ .offset = 0x800100, .length = 2048, .kind = .ram },
},
},
.backing = .{ .board = @field(boards, decl.name) },
.optimize = optimize,
});
exe.installArtifact(b);
}
.hal = hal,
};
};
inline for (@typeInfo(chips).Struct.decls) |decl| {
const exe = microzig.addEmbeddedExecutable(b, .{
.name = @field(chips, decl.name).name ++ ".minimal",
.source_file = .{
.path = "test/programs/minimal.zig",
pub const boards = struct {
pub const arduino = struct {
pub const nano = .{
.preferred_format = .hex,
.chip = chips.atmega328p.chip,
.hal = hal,
.board = .{
.name = "Arduino Nano",
.url = "https://docs.arduino.cc/hardware/nano",
.source_file = path("/src/boards/arduino_nano.zig"),
},
.backing = .{ .chip = @field(chips, decl.name) },
.optimize = optimize,
});
exe.installArtifact(b);
}
};
pub const uno_rev3 = .{
.preferred_format = .hex,
.chip = chips.atmega328p.chip,
.hal = hal,
.board = .{
.name = "Arduino Uno",
.url = "https://docs.arduino.cc/hardware/uno-rev3",
.source_file = path("/src/boards/arduino_uno.zig"),
},
};
};
};
pub fn build(b: *std.build.Builder) void {
_ = b;
// const optimize = b.standardOptimizeOption(.{});
// inline for (@typeInfo(boards).Struct.decls) |decl| {
// const exe = microzig.addEmbeddedExecutable(b, .{
// .name = @field(boards, decl.name).name ++ ".minimal",
// .source_file = .{
// .path = "test/programs/minimal.zig",
// },
// .backing = .{ .board = @field(boards, decl.name) },
// .optimize = optimize,
// });
// exe.installArtifact(b);
// }
// inline for (@typeInfo(chips).Struct.decls) |decl| {
// const exe = microzig.addEmbeddedExecutable(b, .{
// .name = @field(chips, decl.name).name ++ ".minimal",
// .source_file = .{
// .path = "test/programs/minimal.zig",
// },
// .backing = .{ .chip = @field(chips, decl.name) },
// .optimize = optimize,
// });
// exe.installArtifact(b);
// }
}

@ -1,10 +1,5 @@
.{
.name = "microzig-espressif-esp",
.version = "0.1.0",
.dependencies = .{
.microzig = .{
.url = "https://github.com/ZigEmbeddedGroup/microzig/archive/0b3be0a4cc7e6d45714cb09961efc771e364723c.tar.gz",
.hash = "1220ada6d01db7b3d0aa8642df89b1af9ee71b681438249e9a7efb2275fc4cf32152",
},
},
.dependencies = .{},
}

@ -5,15 +5,3 @@ const chips = @import("chips.zig");
fn root_dir() []const u8 {
return std.fs.path.dirname(@src().file) orelse unreachable;
}
pub const arduino_nano = micro.Board{
.name = "Arduino Nano",
.source = .{ .path = root_dir() ++ "/boards/arduino_nano.zig" },
.chip = chips.atmega328p,
};
pub const arduino_uno = micro.Board{
.name = "Arduino Uno",
.source = .{ .path = root_dir() ++ "/boards/arduino_uno.zig" },
.chip = chips.atmega328p,
};

@ -6,12 +6,3 @@ const MemoryRegion = micro.MemoryRegion;
fn root_dir() []const u8 {
return std.fs.path.dirname(@src().file) orelse ".";
}
pub const atmega328p = Chip.from_standard_paths(root_dir(), .{
.name = "ATmega328P",
.cpu = micro.cpus.avr5,
.memory_regions = &.{
MemoryRegion{ .offset = 0x000000, .length = 32 * 1024, .kind = .flash },
MemoryRegion{ .offset = 0x800100, .length = 2048, .kind = .ram },
},
});

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save