|
|
@ -11,18 +11,16 @@ pub fn build(b: *std.Build) void {
|
|
|
|
const inver = b.option([]const u8, "version", "semantic version of the build; must match git tag when available");
|
|
|
|
const inver = b.option([]const u8, "version", "semantic version of the build; must match git tag when available");
|
|
|
|
|
|
|
|
|
|
|
|
const buildopts = b.addOptions();
|
|
|
|
const buildopts = b.addOptions();
|
|
|
|
|
|
|
|
const buildopts_mod = buildopts.createModule();
|
|
|
|
buildopts.addOption(DriverTarget, "driver", drv);
|
|
|
|
buildopts.addOption(DriverTarget, "driver", drv);
|
|
|
|
const semver_step = VersionStep.create(b, buildopts, inver);
|
|
|
|
const semver_step = VersionStep.create(b, buildopts, inver);
|
|
|
|
buildopts.step.dependOn(semver_step);
|
|
|
|
buildopts.step.dependOn(semver_step);
|
|
|
|
|
|
|
|
|
|
|
|
// network interface (nif) standalone library used by the daemon and tests.
|
|
|
|
// network interface (nif) standalone library used by the daemon and tests.
|
|
|
|
const libnif_dep = b.anonymousDependency("lib/nif", @import("lib/nif/build.zig"), .{
|
|
|
|
const libnif_dep = b.lazyDependency("nif", .{ .target = target, .optimize = optimize }) orelse return;
|
|
|
|
.target = target,
|
|
|
|
|
|
|
|
.optimize = optimize,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
const libnif = libnif_dep.artifact("nif");
|
|
|
|
const libnif = libnif_dep.artifact("nif");
|
|
|
|
// ini file format parser
|
|
|
|
// ini file format parser
|
|
|
|
const libini = b.addModule("ini", .{ .source_file = .{ .path = "lib/ini/src/ini.zig" } });
|
|
|
|
const libini_dep = b.lazyDependency("ini", .{ .target = target, .optimize = optimize }) orelse return;
|
|
|
|
|
|
|
|
|
|
|
|
const common_cflags = .{
|
|
|
|
const common_cflags = .{
|
|
|
|
"-Wall",
|
|
|
|
"-Wall",
|
|
|
@ -35,16 +33,16 @@ pub fn build(b: *std.Build) void {
|
|
|
|
// gui build
|
|
|
|
// gui build
|
|
|
|
const ngui = b.addExecutable(.{
|
|
|
|
const ngui = b.addExecutable(.{
|
|
|
|
.name = "ngui",
|
|
|
|
.name = "ngui",
|
|
|
|
.root_source_file = .{ .path = "src/ngui.zig" },
|
|
|
|
.root_source_file = b.path("src/ngui.zig"),
|
|
|
|
.target = target,
|
|
|
|
.target = target,
|
|
|
|
.optimize = optimize,
|
|
|
|
.optimize = optimize,
|
|
|
|
.link_libc = true,
|
|
|
|
.link_libc = true,
|
|
|
|
|
|
|
|
.strip = strip,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
ngui.pie = true;
|
|
|
|
ngui.pie = true;
|
|
|
|
ngui.strip = strip;
|
|
|
|
ngui.root_module.addImport("build_options", buildopts_mod);
|
|
|
|
ngui.addOptions("build_options", buildopts);
|
|
|
|
ngui.addIncludePath(b.path("lib"));
|
|
|
|
ngui.addIncludePath(.{ .path = "lib" });
|
|
|
|
ngui.addIncludePath(b.path("src/ui/c"));
|
|
|
|
ngui.addIncludePath(.{ .path = "src/ui/c" });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const lvgl_flags = .{
|
|
|
|
const lvgl_flags = .{
|
|
|
|
"-std=c11",
|
|
|
|
"-std=c11",
|
|
|
@ -52,7 +50,7 @@ pub fn build(b: *std.Build) void {
|
|
|
|
"-Wformat",
|
|
|
|
"-Wformat",
|
|
|
|
"-Wformat-security",
|
|
|
|
"-Wformat-security",
|
|
|
|
} ++ common_cflags;
|
|
|
|
} ++ common_cflags;
|
|
|
|
ngui.addCSourceFiles(lvgl_generic_src, &lvgl_flags);
|
|
|
|
ngui.addCSourceFiles(.{ .files = lvgl_generic_src, .flags = &lvgl_flags });
|
|
|
|
|
|
|
|
|
|
|
|
const ngui_cflags = .{
|
|
|
|
const ngui_cflags = .{
|
|
|
|
"-std=c11",
|
|
|
|
"-std=c11",
|
|
|
@ -60,39 +58,46 @@ pub fn build(b: *std.Build) void {
|
|
|
|
"-Wunused-parameter",
|
|
|
|
"-Wunused-parameter",
|
|
|
|
"-Werror",
|
|
|
|
"-Werror",
|
|
|
|
} ++ common_cflags;
|
|
|
|
} ++ common_cflags;
|
|
|
|
ngui.addCSourceFiles(&.{
|
|
|
|
ngui.addCSourceFiles(.{
|
|
|
|
"src/ui/c/ui.c",
|
|
|
|
.root = b.path("src/ui/c"),
|
|
|
|
"src/ui/c/lv_font_courierprimecode_14.c",
|
|
|
|
.files = &.{
|
|
|
|
"src/ui/c/lv_font_courierprimecode_16.c",
|
|
|
|
"ui.c",
|
|
|
|
"src/ui/c/lv_font_courierprimecode_24.c",
|
|
|
|
"lv_font_courierprimecode_14.c",
|
|
|
|
}, &ngui_cflags);
|
|
|
|
"lv_font_courierprimecode_16.c",
|
|
|
|
|
|
|
|
"lv_font_courierprimecode_24.c",
|
|
|
|
ngui.defineCMacroRaw(b.fmt("NM_DISP_HOR={}", .{disp_horiz}));
|
|
|
|
},
|
|
|
|
ngui.defineCMacroRaw(b.fmt("NM_DISP_VER={}", .{disp_vert}));
|
|
|
|
.flags = &ngui_cflags,
|
|
|
|
ngui.defineCMacro("LV_CONF_INCLUDE_SIMPLE", null);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ngui.root_module.addCMacro("NM_DISP_HOR", b.fmt("{d}", .{disp_horiz}));
|
|
|
|
|
|
|
|
ngui.root_module.addCMacro("NM_DISP_VER", b.fmt("{d}", .{disp_vert}));
|
|
|
|
|
|
|
|
ngui.defineCMacro("LV_CONF_INCLUDE_SIMPLE", "1");
|
|
|
|
ngui.defineCMacro("LV_LOG_LEVEL", lvgl_loglevel.text());
|
|
|
|
ngui.defineCMacro("LV_LOG_LEVEL", lvgl_loglevel.text());
|
|
|
|
ngui.defineCMacro("LV_TICK_CUSTOM", "1");
|
|
|
|
ngui.defineCMacro("LV_TICK_CUSTOM", "1");
|
|
|
|
ngui.defineCMacro("LV_TICK_CUSTOM_INCLUDE", "\"lv_custom_tick.h\"");
|
|
|
|
ngui.defineCMacro("LV_TICK_CUSTOM_INCLUDE", "\"lv_custom_tick.h\"");
|
|
|
|
ngui.defineCMacro("LV_TICK_CUSTOM_SYS_TIME_EXPR", "(nm_get_curr_tick())");
|
|
|
|
ngui.defineCMacro("LV_TICK_CUSTOM_SYS_TIME_EXPR", "(nm_get_curr_tick())");
|
|
|
|
switch (drv) {
|
|
|
|
switch (drv) {
|
|
|
|
.sdl2 => {
|
|
|
|
.sdl2 => {
|
|
|
|
ngui.addCSourceFiles(lvgl_sdl2_src, &lvgl_flags);
|
|
|
|
ngui.addCSourceFiles(.{ .files = lvgl_sdl2_src, .flags = &lvgl_flags });
|
|
|
|
ngui.addCSourceFile(.{ .file = .{ .path = "src/ui/c/drv_sdl2.c" }, .flags = &ngui_cflags });
|
|
|
|
ngui.addCSourceFile(.{ .file = b.path("src/ui/c/drv_sdl2.c"), .flags = &ngui_cflags });
|
|
|
|
ngui.defineCMacro("USE_SDL", "1");
|
|
|
|
ngui.defineCMacro("USE_SDL", "1");
|
|
|
|
ngui.linkSystemLibrary("SDL2");
|
|
|
|
ngui.linkSystemLibrary("SDL2");
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.x11 => {
|
|
|
|
.x11 => {
|
|
|
|
ngui.addCSourceFiles(lvgl_x11_src, &lvgl_flags);
|
|
|
|
ngui.addCSourceFiles(.{ .files = lvgl_x11_src, .flags = &lvgl_flags });
|
|
|
|
ngui.addCSourceFiles(&.{
|
|
|
|
ngui.addCSourceFiles(.{
|
|
|
|
|
|
|
|
.files = &.{
|
|
|
|
"src/ui/c/drv_x11.c",
|
|
|
|
"src/ui/c/drv_x11.c",
|
|
|
|
"src/ui/c/mouse_cursor_icon.c",
|
|
|
|
"src/ui/c/mouse_cursor_icon.c",
|
|
|
|
}, &ngui_cflags);
|
|
|
|
},
|
|
|
|
|
|
|
|
.flags = &ngui_cflags,
|
|
|
|
|
|
|
|
});
|
|
|
|
ngui.defineCMacro("USE_X11", "1");
|
|
|
|
ngui.defineCMacro("USE_X11", "1");
|
|
|
|
ngui.linkSystemLibrary("X11");
|
|
|
|
ngui.linkSystemLibrary("X11");
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.fbev => {
|
|
|
|
.fbev => {
|
|
|
|
ngui.addCSourceFiles(lvgl_fbev_src, &lvgl_flags);
|
|
|
|
ngui.addCSourceFiles(.{ .files = lvgl_fbev_src, .flags = &lvgl_flags });
|
|
|
|
ngui.addCSourceFile(.{ .file = .{ .path = "src/ui/c/drv_fbev.c" }, .flags = &ngui_cflags });
|
|
|
|
ngui.addCSourceFile(.{ .file = b.path("src/ui/c/drv_fbev.c"), .flags = &ngui_cflags });
|
|
|
|
ngui.defineCMacro("USE_FBDEV", "1");
|
|
|
|
ngui.defineCMacro("USE_FBDEV", "1");
|
|
|
|
ngui.defineCMacro("USE_EVDEV", "1");
|
|
|
|
ngui.defineCMacro("USE_EVDEV", "1");
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -104,15 +109,15 @@ pub fn build(b: *std.Build) void {
|
|
|
|
// daemon build
|
|
|
|
// daemon build
|
|
|
|
const nd = b.addExecutable(.{
|
|
|
|
const nd = b.addExecutable(.{
|
|
|
|
.name = "nd",
|
|
|
|
.name = "nd",
|
|
|
|
.root_source_file = .{ .path = "src/nd.zig" },
|
|
|
|
.root_source_file = b.path("src/nd.zig"),
|
|
|
|
.target = target,
|
|
|
|
.target = target,
|
|
|
|
.optimize = optimize,
|
|
|
|
.optimize = optimize,
|
|
|
|
|
|
|
|
.strip = strip,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
nd.pie = true;
|
|
|
|
nd.pie = true;
|
|
|
|
nd.strip = strip;
|
|
|
|
nd.root_module.addImport("build_options", buildopts_mod);
|
|
|
|
nd.addOptions("build_options", buildopts);
|
|
|
|
nd.root_module.addImport("nif", libnif_dep.module("nif"));
|
|
|
|
nd.addModule("nif", libnif_dep.module("nif"));
|
|
|
|
nd.root_module.addImport("ini", libini_dep.module("ini"));
|
|
|
|
nd.addModule("ini", libini);
|
|
|
|
|
|
|
|
nd.linkLibrary(libnif);
|
|
|
|
nd.linkLibrary(libnif);
|
|
|
|
|
|
|
|
|
|
|
|
const nd_build_step = b.step("nd", "build nd (nakamochi daemon)");
|
|
|
|
const nd_build_step = b.step("nd", "build nd (nakamochi daemon)");
|
|
|
@ -121,15 +126,15 @@ pub fn build(b: *std.Build) void {
|
|
|
|
// automated tests
|
|
|
|
// automated tests
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const tests = b.addTest(.{
|
|
|
|
const tests = b.addTest(.{
|
|
|
|
.root_source_file = .{ .path = "src/test.zig" },
|
|
|
|
.root_source_file = b.path("src/test.zig"),
|
|
|
|
.target = target,
|
|
|
|
.target = target,
|
|
|
|
.optimize = optimize,
|
|
|
|
.optimize = optimize,
|
|
|
|
.link_libc = true,
|
|
|
|
.link_libc = true,
|
|
|
|
.filter = b.option([]const u8, "test-filter", "run tests matching the filter"),
|
|
|
|
.filter = b.option([]const u8, "test-filter", "run tests matching the filter"),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
tests.addOptions("build_options", buildopts);
|
|
|
|
tests.root_module.addImport("build_options", buildopts_mod);
|
|
|
|
tests.addModule("nif", libnif_dep.module("nif"));
|
|
|
|
tests.root_module.addImport("nif", libnif_dep.module("nif"));
|
|
|
|
tests.addModule("ini", libini);
|
|
|
|
tests.root_module.addImport("ini", libini_dep.module("ini"));
|
|
|
|
tests.linkLibrary(libnif);
|
|
|
|
tests.linkLibrary(libnif);
|
|
|
|
|
|
|
|
|
|
|
|
const run_tests = b.addRunArtifact(tests);
|
|
|
|
const run_tests = b.addRunArtifact(tests);
|
|
|
@ -141,11 +146,11 @@ pub fn build(b: *std.Build) void {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const guiplay = b.addExecutable(.{
|
|
|
|
const guiplay = b.addExecutable(.{
|
|
|
|
.name = "guiplay",
|
|
|
|
.name = "guiplay",
|
|
|
|
.root_source_file = .{ .path = "src/test/guiplay.zig" },
|
|
|
|
.root_source_file = b.path("src/test/guiplay.zig"),
|
|
|
|
.target = target,
|
|
|
|
.target = target,
|
|
|
|
.optimize = optimize,
|
|
|
|
.optimize = optimize,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
guiplay.addModule("comm", b.createModule(.{ .source_file = .{ .path = "src/comm.zig" } }));
|
|
|
|
guiplay.root_module.addImport("comm", b.createModule(.{ .root_source_file = b.path("src/comm.zig") }));
|
|
|
|
|
|
|
|
|
|
|
|
const guiplay_build_step = b.step("guiplay", "build GUI playground");
|
|
|
|
const guiplay_build_step = b.step("guiplay", "build GUI playground");
|
|
|
|
guiplay_build_step.dependOn(&b.addInstallArtifact(guiplay, .{}).step);
|
|
|
|
guiplay_build_step.dependOn(&b.addInstallArtifact(guiplay, .{}).step);
|
|
|
@ -156,12 +161,12 @@ pub fn build(b: *std.Build) void {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const btcrpc = b.addExecutable(.{
|
|
|
|
const btcrpc = b.addExecutable(.{
|
|
|
|
.name = "btcrpc",
|
|
|
|
.name = "btcrpc",
|
|
|
|
.root_source_file = .{ .path = "src/test/btcrpc.zig" },
|
|
|
|
.root_source_file = b.path("src/test/btcrpc.zig"),
|
|
|
|
.target = target,
|
|
|
|
.target = target,
|
|
|
|
.optimize = optimize,
|
|
|
|
.optimize = optimize,
|
|
|
|
|
|
|
|
.strip = strip,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
btcrpc.strip = strip;
|
|
|
|
btcrpc.root_module.addImport("bitcoindrpc", b.createModule(.{ .root_source_file = b.path("src/bitcoindrpc.zig") }));
|
|
|
|
btcrpc.addModule("bitcoindrpc", b.createModule(.{ .source_file = .{ .path = "src/bitcoindrpc.zig" } }));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const btcrpc_build_step = b.step("btcrpc", "bitcoind RPC client playground");
|
|
|
|
const btcrpc_build_step = b.step("btcrpc", "bitcoind RPC client playground");
|
|
|
|
btcrpc_build_step.dependOn(&b.addInstallArtifact(btcrpc, .{}).step);
|
|
|
|
btcrpc_build_step.dependOn(&b.addInstallArtifact(btcrpc, .{}).step);
|
|
|
@ -171,12 +176,12 @@ pub fn build(b: *std.Build) void {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const lndhc = b.addExecutable(.{
|
|
|
|
const lndhc = b.addExecutable(.{
|
|
|
|
.name = "lndhc",
|
|
|
|
.name = "lndhc",
|
|
|
|
.root_source_file = .{ .path = "src/test/lndhc.zig" },
|
|
|
|
.root_source_file = b.path("src/test/lndhc.zig"),
|
|
|
|
.target = target,
|
|
|
|
.target = target,
|
|
|
|
.optimize = optimize,
|
|
|
|
.optimize = optimize,
|
|
|
|
|
|
|
|
.strip = strip,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
lndhc.strip = strip;
|
|
|
|
lndhc.root_module.addImport("lightning", b.createModule(.{ .root_source_file = b.path("src/lightning.zig") }));
|
|
|
|
lndhc.addModule("lightning", b.createModule(.{ .source_file = .{ .path = "src/lightning.zig" } }));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const lndhc_build_step = b.step("lndhc", "lnd HTTP API client playground");
|
|
|
|
const lndhc_build_step = b.step("lndhc", "lnd HTTP API client playground");
|
|
|
|
lndhc_build_step.dependOn(&b.addInstallArtifact(lndhc, .{}).step);
|
|
|
|
lndhc_build_step.dependOn(&b.addInstallArtifact(lndhc, .{}).step);
|
|
|
@ -423,7 +428,7 @@ const VersionStep = struct {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn make(step: *std.Build.Step, _: *std.Progress.Node) anyerror!void {
|
|
|
|
fn make(step: *std.Build.Step, _: *std.Progress.Node) anyerror!void {
|
|
|
|
const self = @fieldParentPtr(VersionStep, "step", step);
|
|
|
|
const self: *@This() = @fieldParentPtr("step", step);
|
|
|
|
const semver = try self.eval();
|
|
|
|
const semver = try self.eval();
|
|
|
|
std.log.info("build version: {any}", .{semver});
|
|
|
|
std.log.info("build version: {any}", .{semver});
|
|
|
|
self.buildopts.addOption(std.SemanticVersion, "semver", semver);
|
|
|
|
self.buildopts.addOption(std.SemanticVersion, "semver", semver);
|
|
|
@ -460,7 +465,7 @@ const VersionStep = struct {
|
|
|
|
const matchTag = self.b.fmt("{s}*.*.*", .{prefix});
|
|
|
|
const matchTag = self.b.fmt("{s}*.*.*", .{prefix});
|
|
|
|
const cmd = [_][]const u8{ git, "-C", self.b.pathFromRoot("."), "describe", "--match", matchTag, "--tags", "--abbrev=8" };
|
|
|
|
const cmd = [_][]const u8{ git, "-C", self.b.pathFromRoot("."), "describe", "--match", matchTag, "--tags", "--abbrev=8" };
|
|
|
|
var code: u8 = undefined;
|
|
|
|
var code: u8 = undefined;
|
|
|
|
const git_describe = self.b.execAllowFail(&cmd, &code, .Ignore) catch return null;
|
|
|
|
const git_describe = self.b.runAllowFail(&cmd, &code, .Ignore) catch return null;
|
|
|
|
const repotag = std.mem.trim(u8, git_describe, " \n\r")[prefix.len..];
|
|
|
|
const repotag = std.mem.trim(u8, git_describe, " \n\r")[prefix.len..];
|
|
|
|
return std.SemanticVersion.parse(repotag) catch |err| ret: {
|
|
|
|
return std.SemanticVersion.parse(repotag) catch |err| ret: {
|
|
|
|
std.log.err("unparsable git tag semver '{s}': {any}", .{ repotag, err });
|
|
|
|
std.log.err("unparsable git tag semver '{s}': {any}", .{ repotag, err });
|
|
|
|