Catchup to changes introduced by ziglang/zig#14498 (#101)

wch-ch32v003
Philipp Wendel 2 years ago committed by GitHub
parent e1c1466d9e
commit e63558330b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -29,4 +29,4 @@ jobs:
version: master
- name: Build tests
run: zig build -Drelease-small
run: zig build -Doptimize=ReleaseSmall

@ -10,7 +10,10 @@ const chips = microzig.chips;
const Backing = microzig.Backing;
pub fn build(b: *std.build.Builder) !void {
const mode = b.standardReleaseOptions();
// Standard optimization options allow the person running `zig build -Doptimize=...` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not
// set a preferred release mode, allowing the user to decide how to optimize.
const optimize = b.standardOptimizeOption(.{});
const test_step = b.step("test", "Builds and runs the library test suite");
@ -52,11 +55,10 @@ pub fn build(b: *std.build.Builder) !void {
b.fmt("test-{s}-{s}.elf", .{ tst.name, cfg.name }),
tst.source,
cfg.backing,
.{},
.{.optimize = optimize },
);
if (filter == null or exe.inner.target.cpu_arch.? == filter.?) {
exe.inner.setBuildMode(mode);
exe.inner.install();
test_step.dependOn(&exe.inner.step);

@ -32,6 +32,7 @@ pub const BuildOptions = struct {
// a hal package is a package with ergonomic wrappers for registers for a
// given mcu, it's only dependency can be microzig
hal_package_path: ?std.build.FileSource = null,
optimize: std.builtin.OptimizeMode = std.builtin.OptimizeMode.Debug,
};
pub const EmbeddedExecutable = struct {
@ -56,10 +57,6 @@ pub const EmbeddedExecutable = struct {
});
}
pub fn setBuildMode(exe: *EmbeddedExecutable, mode: std.builtin.Mode) void {
exe.inner.setBuildMode(mode);
}
pub fn install(exe: *EmbeddedExecutable) void {
exe.inner.install();
}
@ -177,7 +174,7 @@ pub fn addEmbeddedExecutable(
};
var exe = EmbeddedExecutable{
.inner = builder.addExecutable(name, root_path ++ "core/microzig.zig"),
.inner = builder.addExecutable(.{ .name = name, .root_source_file = .{ .path = root_path ++ "core/microzig.zig" }, .target = chip.cpu.target, .optimize = options.optimize }),
.app_packages = std.ArrayList(Pkg).init(builder.allocator),
};
@ -186,7 +183,6 @@ pub fn addEmbeddedExecutable(
// might not be true for all machines (Pi Pico), but
// for the HAL it's true (it doesn't know the concept of threading)
exe.inner.single_threaded = true;
exe.inner.setTarget(chip.cpu.target);
const linkerscript = LinkerScriptStep.create(builder, chip) catch unreachable;
exe.inner.setLinkerScriptPath(.{ .generated = &linkerscript.generated_file });

Loading…
Cancel
Save