microzig icon indicating copy to clipboard operation
microzig copied to clipboard

Expand EmbeddedExecutable

Open ikskuh opened this issue 1 year ago • 3 comments

Expose common functions like install() and setBuildMode(), also installRaw()

ikskuh avatar Jul 27 '22 09:07 ikskuh

I also use:

addCSourceFile
addIncludeDir
addSystemIncludeDir
want_lto

I currently just use exe.inner I don't know if we need to wrap all of those.

kuon avatar Aug 02 '22 03:08 kuon

Implemented in #77

r4gus avatar Sep 14 '22 21:09 r4gus

I just had to do the following:

    var buf: [100]u8 = .{0} ** 100;
    const date = std.fmt.bufPrint(
        &buf,
        "{d}",
        .{std.time.timestamp()},
    ) catch unreachable;
    const options = b.addOptions();
    options.addOption([]const u8, "date", date);
    exe.inner.addOptions("compile_info", options);

    exe.addPackage(.{ .name = "compile_info", .source = options.getSource() });

To be able to do

const date = @import("compile_info").date;

So I think #77 should be extended with addOptions and the code would then look like:

    var buf: [100]u8 = .{0} ** 100;
    const date = std.fmt.bufPrint(
        &buf,
        "{d}",
        .{std.time.timestamp()},
    ) catch unreachable;
    const options = b.addOptions();
    options.addOption([]const u8, "date", date);

    exe.addOptions("compile_info", options); // this should be implemented

    // addPackage should not be needed

kuon avatar Sep 14 '22 21:09 kuon