@@ -31,34 +31,37 @@ pub fn build(b: *std.Build) void {
3131 };
3232
3333 // gui build
34- const ngui = b .addExecutable (.{
35- .name = "ngui" ,
34+ const ngui = b .createModule (.{
3635 .root_source_file = b .path ("src/ngui.zig" ),
3736 .target = target ,
3837 .optimize = optimize ,
3938 .link_libc = true ,
4039 .strip = strip ,
4140 });
42- ngui .pie = true ;
43- ngui .root_module .addImport ("build_options" , buildopts_mod );
44- ngui .addIncludePath (b .path ("lib" ));
45- ngui .addIncludePath (b .path ("src/ui/c" ));
41+ const ngui_exe = b .addExecutable (.{
42+ .name = "ngui" ,
43+ .root_module = ngui ,
44+ });
45+ ngui_exe .pie = true ;
46+ ngui_exe .root_module .addImport ("build_options" , buildopts_mod );
47+ ngui_exe .addIncludePath (b .path ("lib" ));
48+ ngui_exe .addIncludePath (b .path ("src/ui/c" ));
4649
4750 const lvgl_flags = .{
4851 "-std=c11" ,
4952 "-fstack-protector" ,
5053 "-Wformat" ,
5154 "-Wformat-security" ,
5255 } ++ common_cflags ;
53- ngui .addCSourceFiles (.{ .files = lvgl_generic_src , .flags = & lvgl_flags });
56+ ngui_exe .addCSourceFiles (.{ .files = lvgl_generic_src , .flags = & lvgl_flags });
5457
5558 const ngui_cflags = .{
5659 "-std=c11" ,
5760 "-Wshadow" ,
5861 "-Wunused-parameter" ,
5962 "-Werror" ,
6063 } ++ common_cflags ;
61- ngui .addCSourceFiles (.{
64+ ngui_exe .addCSourceFiles (.{
6265 .root = b .path ("src/ui/c" ),
6366 .files = &.{
6467 "ui.c" ,
@@ -69,69 +72,77 @@ pub fn build(b: *std.Build) void {
6972 .flags = & ngui_cflags ,
7073 });
7174
72- ngui .root_module .addCMacro ("NM_DISP_HOR" , b .fmt ("{d}" , .{disp_horiz }));
73- ngui .root_module .addCMacro ("NM_DISP_VER" , b .fmt ("{d}" , .{disp_vert }));
74- ngui . defineCMacro ("LV_CONF_INCLUDE_SIMPLE" , "1" );
75- ngui . defineCMacro ("LV_LOG_LEVEL" , lvgl_loglevel .text ());
76- ngui . defineCMacro ("LV_TICK_CUSTOM" , "1" );
77- ngui . defineCMacro ("LV_TICK_CUSTOM_INCLUDE" , "\" lv_custom_tick.h\" " );
78- ngui . defineCMacro ("LV_TICK_CUSTOM_SYS_TIME_EXPR" , "(nm_get_curr_tick())" );
75+ ngui_exe .root_module .addCMacro ("NM_DISP_HOR" , b .fmt ("{d}" , .{disp_horiz }));
76+ ngui_exe .root_module .addCMacro ("NM_DISP_VER" , b .fmt ("{d}" , .{disp_vert }));
77+ ngui_exe . root_module . addCMacro ("LV_CONF_INCLUDE_SIMPLE" , "1" );
78+ ngui_exe . root_module . addCMacro ("LV_LOG_LEVEL" , lvgl_loglevel .text ());
79+ ngui_exe . root_module . addCMacro ("LV_TICK_CUSTOM" , "1" );
80+ ngui_exe . root_module . addCMacro ("LV_TICK_CUSTOM_INCLUDE" , "\" lv_custom_tick.h\" " );
81+ ngui_exe . root_module . addCMacro ("LV_TICK_CUSTOM_SYS_TIME_EXPR" , "(nm_get_curr_tick())" );
7982 switch (drv ) {
8083 .sdl2 = > {
81- ngui .addCSourceFiles (.{ .files = lvgl_sdl2_src , .flags = & lvgl_flags });
82- ngui .addCSourceFile (.{ .file = b .path ("src/ui/c/drv_sdl2.c" ), .flags = & ngui_cflags });
83- ngui . defineCMacro ("USE_SDL" , "1" );
84- ngui .linkSystemLibrary ("SDL2" );
84+ ngui_exe .addCSourceFiles (.{ .files = lvgl_sdl2_src , .flags = & lvgl_flags });
85+ ngui_exe .addCSourceFile (.{ .file = b .path ("src/ui/c/drv_sdl2.c" ), .flags = & ngui_cflags });
86+ ngui_exe . root_module . addCMacro ("USE_SDL" , "1" );
87+ ngui_exe .linkSystemLibrary ("SDL2" );
8588 },
8689 .x11 = > {
87- ngui .addCSourceFiles (.{ .files = lvgl_x11_src , .flags = & lvgl_flags });
88- ngui .addCSourceFiles (.{
90+ ngui_exe .addCSourceFiles (.{ .files = lvgl_x11_src , .flags = & lvgl_flags });
91+ ngui_exe .addCSourceFiles (.{
8992 .files = &.{
9093 "src/ui/c/drv_x11.c" ,
9194 "src/ui/c/mouse_cursor_icon.c" ,
9295 },
9396 .flags = & ngui_cflags ,
9497 });
95- ngui . defineCMacro ("USE_X11" , "1" );
96- ngui .linkSystemLibrary ("X11" );
98+ ngui_exe . root_module . addCMacro ("USE_X11" , "1" );
99+ ngui_exe .linkSystemLibrary ("X11" );
97100 },
98101 .fbev = > {
99- ngui .addCSourceFiles (.{ .files = lvgl_fbev_src , .flags = & lvgl_flags });
100- ngui .addCSourceFile (.{ .file = b .path ("src/ui/c/drv_fbev.c" ), .flags = & ngui_cflags });
101- ngui . defineCMacro ("USE_FBDEV" , "1" );
102- ngui . defineCMacro ("USE_EVDEV" , "1" );
102+ ngui_exe .addCSourceFiles (.{ .files = lvgl_fbev_src , .flags = & lvgl_flags });
103+ ngui_exe .addCSourceFile (.{ .file = b .path ("src/ui/c/drv_fbev.c" ), .flags = & ngui_cflags });
104+ ngui_exe . root_module . addCMacro ("USE_FBDEV" , "1" );
105+ ngui_exe . root_module . addCMacro ("USE_EVDEV" , "1" );
103106 },
104107 }
105108
106109 const ngui_build_step = b .step ("ngui" , "build ngui (nakamochi gui)" );
107- ngui_build_step .dependOn (& b .addInstallArtifact (ngui , .{}).step );
110+ ngui_build_step .dependOn (& b .addInstallArtifact (ngui_exe , .{}).step );
108111
109112 // daemon build
110- const nd = b .addExecutable (.{
111- .name = "nd" ,
113+ const nd = b .createModule (.{
112114 .root_source_file = b .path ("src/nd.zig" ),
113115 .target = target ,
114116 .optimize = optimize ,
117+ .link_libc = true ,
115118 .strip = strip ,
116119 });
117- nd .pie = true ;
118- nd .root_module .addImport ("build_options" , buildopts_mod );
119- nd .root_module .addImport ("nif" , libnif_dep .module ("nif" ));
120- nd .root_module .addImport ("ini" , libini_dep .module ("ini" ));
121- nd .linkLibrary (libnif );
120+ const nd_exe = b .addExecutable (.{
121+ .name = "nd" ,
122+ .root_module = nd ,
123+ });
124+ nd_exe .pie = true ;
125+ nd_exe .root_module .addImport ("build_options" , buildopts_mod );
126+ nd_exe .root_module .addImport ("nif" , libnif_dep .module ("nif" ));
127+ nd_exe .root_module .addImport ("ini" , libini_dep .module ("ini" ));
128+ nd_exe .linkLibrary (libnif );
122129
123130 const nd_build_step = b .step ("nd" , "build nd (nakamochi daemon)" );
124- nd_build_step .dependOn (& b .addInstallArtifact (nd , .{}).step );
131+ nd_build_step .dependOn (& b .addInstallArtifact (nd_exe , .{}).step );
125132
126133 // automated tests
127134 {
128- const tests = b .addTest (.{
135+ const mod_tests = b .createModule (.{
129136 .root_source_file = b .path ("src/test.zig" ),
130137 .target = target ,
131138 .optimize = optimize ,
132139 .link_libc = true ,
133- .filter = b .option ([]const u8 , "test-filter" , "run tests matching the filter" ),
134140 });
141+ const tests = b .addTest (.{
142+ .root_module = mod_tests ,
143+ .filters = &.{b .option ([]const u8 , "test-filter" , "run tests matching the filter" ) orelse "" },
144+ });
145+
135146 tests .root_module .addImport ("build_options" , buildopts_mod );
136147 tests .root_module .addImport ("nif" , libnif_dep .module ("nif" ));
137148 tests .root_module .addImport ("ini" , libini_dep .module ("ini" ));
@@ -144,47 +155,53 @@ pub fn build(b: *std.Build) void {
144155
145156 // GUI playground
146157 {
147- const guiplay = b .addExecutable (.{
148- .name = "guiplay" ,
158+ const guiplay = b .createModule (.{
149159 .root_source_file = b .path ("src/test/guiplay.zig" ),
150160 .target = target ,
151161 .optimize = optimize ,
152162 });
153- guiplay .root_module .addImport ("comm" , b .createModule (.{ .root_source_file = b .path ("src/comm.zig" ) }));
163+ const guiplay_exe = b .addExecutable (.{
164+ .name = "guiplay" ,
165+ .root_module = guiplay ,
166+ });
167+ guiplay_exe .root_module .addImport ("comm" , b .createModule (.{ .root_source_file = b .path ("src/comm.zig" ) }));
154168
155169 const guiplay_build_step = b .step ("guiplay" , "build GUI playground" );
156- guiplay_build_step .dependOn (& b .addInstallArtifact (guiplay , .{}).step );
170+ guiplay_build_step .dependOn (& b .addInstallArtifact (guiplay_exe , .{}).step );
157171 guiplay_build_step .dependOn (ngui_build_step );
158172 }
159173
160174 // bitcoind RPC client playground
161175 {
162- const btcrpc = b .addExecutable (.{
163- .name = "btcrpc" ,
176+ const btcrpc = b .createModule (.{
164177 .root_source_file = b .path ("src/test/btcrpc.zig" ),
165178 .target = target ,
166179 .optimize = optimize ,
167180 .strip = strip ,
168181 });
169- btcrpc .root_module .addImport ("bitcoindrpc" , b .createModule (.{ .root_source_file = b .path ("src/bitcoindrpc.zig" ) }));
182+ const btcrpc_exe = b .addExecutable (.{
183+ .name = "btcrpc" ,
184+ .root_module = btcrpc ,
185+ });
186+ btcrpc_exe .root_module .addImport ("bitcoindrpc" , b .createModule (.{ .root_source_file = b .path ("src/bitcoindrpc.zig" ) }));
170187
171188 const btcrpc_build_step = b .step ("btcrpc" , "bitcoind RPC client playground" );
172- btcrpc_build_step .dependOn (& b .addInstallArtifact (btcrpc , .{}).step );
189+ btcrpc_build_step .dependOn (& b .addInstallArtifact (btcrpc_exe , .{}).step );
173190 }
174191
175192 // lnd HTTP API client playground
176193 {
177- const lndhc = b .addExecutable (.{
178- .name = "lndhc" ,
194+ const lndhc = b .createModule (.{
179195 .root_source_file = b .path ("src/test/lndhc.zig" ),
180196 .target = target ,
181197 .optimize = optimize ,
182198 .strip = strip ,
183199 });
184- lndhc .root_module .addImport ("lightning" , b .createModule (.{ .root_source_file = b .path ("src/lightning.zig" ) }));
200+ const lndhc_exe = b .addExecutable (.{ .name = "lndhc" , .root_module = lndhc });
201+ lndhc_exe .root_module .addImport ("lightning" , b .createModule (.{ .root_source_file = b .path ("src/lightning.zig" ) }));
185202
186203 const lndhc_build_step = b .step ("lndhc" , "lnd HTTP API client playground" );
187- lndhc_build_step .dependOn (& b .addInstallArtifact (lndhc , .{}).step );
204+ lndhc_build_step .dependOn (& b .addInstallArtifact (lndhc_exe , .{}).step );
188205 }
189206
190207 // default build step
@@ -376,7 +393,7 @@ const LVGLLogLevel = enum {
376393 none ,
377394
378395 /// returns default mode based on the compiler optimization flags.
379- fn default (mode : std.builtin.Mode ) @This () {
396+ fn default (mode : std.builtin.OptimizeMode ) @This () {
380397 return switch (mode ) {
381398 .Debug = > .warn ,
382399 .ReleaseSafe = > .warn ,
@@ -427,7 +444,7 @@ const VersionStep = struct {
427444 return & vstep .step ;
428445 }
429446
430- fn make (step : * std.Build.Step , _ : * std.Progress.Node ) anyerror ! void {
447+ fn make (step : * std.Build.Step , _ : std.Build.Step.MakeOptions ) anyerror ! void {
431448 const self : * @This () = @fieldParentPtr ("step" , step );
432449 const semver = try self .eval ();
433450 std .log .info ("build version: {any}" , .{semver });
0 commit comments