@@ -31,37 +31,34 @@ pub fn build(b: *std.Build) void {
3131 };
3232
3333 // gui build
34- const ngui = b .createModule (.{
34+ const ngui = b .addExecutable (.{
35+ .name = "ngui" ,
3536 .root_source_file = b .path ("src/ngui.zig" ),
3637 .target = target ,
3738 .optimize = optimize ,
3839 .link_libc = true ,
3940 .strip = strip ,
4041 });
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" ));
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" ));
4946
5047 const lvgl_flags = .{
5148 "-std=c11" ,
5249 "-fstack-protector" ,
5350 "-Wformat" ,
5451 "-Wformat-security" ,
5552 } ++ common_cflags ;
56- ngui_exe .addCSourceFiles (.{ .files = lvgl_generic_src , .flags = & lvgl_flags });
53+ ngui .addCSourceFiles (.{ .files = lvgl_generic_src , .flags = & lvgl_flags });
5754
5855 const ngui_cflags = .{
5956 "-std=c11" ,
6057 "-Wshadow" ,
6158 "-Wunused-parameter" ,
6259 "-Werror" ,
6360 } ++ common_cflags ;
64- ngui_exe .addCSourceFiles (.{
61+ ngui .addCSourceFiles (.{
6562 .root = b .path ("src/ui/c" ),
6663 .files = &.{
6764 "ui.c" ,
@@ -72,77 +69,69 @@ pub fn build(b: *std.Build) void {
7269 .flags = & ngui_cflags ,
7370 });
7471
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())" );
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())" );
8279 switch (drv ) {
8380 .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" );
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" );
8885 },
8986 .x11 = > {
90- ngui_exe .addCSourceFiles (.{ .files = lvgl_x11_src , .flags = & lvgl_flags });
91- ngui_exe .addCSourceFiles (.{
87+ ngui .addCSourceFiles (.{ .files = lvgl_x11_src , .flags = & lvgl_flags });
88+ ngui .addCSourceFiles (.{
9289 .files = &.{
9390 "src/ui/c/drv_x11.c" ,
9491 "src/ui/c/mouse_cursor_icon.c" ,
9592 },
9693 .flags = & ngui_cflags ,
9794 });
98- ngui_exe . root_module . addCMacro ("USE_X11" , "1" );
99- ngui_exe .linkSystemLibrary ("X11" );
95+ ngui . defineCMacro ("USE_X11" , "1" );
96+ ngui .linkSystemLibrary ("X11" );
10097 },
10198 .fbev = > {
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" );
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" );
106103 },
107104 }
108105
109106 const ngui_build_step = b .step ("ngui" , "build ngui (nakamochi gui)" );
110- ngui_build_step .dependOn (& b .addInstallArtifact (ngui_exe , .{}).step );
107+ ngui_build_step .dependOn (& b .addInstallArtifact (ngui , .{}).step );
111108
112109 // daemon build
113- const nd = b .createModule (.{
110+ const nd = b .addExecutable (.{
111+ .name = "nd" ,
114112 .root_source_file = b .path ("src/nd.zig" ),
115113 .target = target ,
116114 .optimize = optimize ,
117- .link_libc = true ,
118115 .strip = strip ,
119116 });
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 );
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 );
129122
130123 const nd_build_step = b .step ("nd" , "build nd (nakamochi daemon)" );
131- nd_build_step .dependOn (& b .addInstallArtifact (nd_exe , .{}).step );
124+ nd_build_step .dependOn (& b .addInstallArtifact (nd , .{}).step );
132125
133126 // automated tests
134127 {
135- const mod_tests = b .createModule (.{
128+ const tests = b .addTest (.{
136129 .root_source_file = b .path ("src/test.zig" ),
137130 .target = target ,
138131 .optimize = optimize ,
139132 .link_libc = true ,
133+ .filter = b .option ([]const u8 , "test-filter" , "run tests matching the filter" ),
140134 });
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-
146135 tests .root_module .addImport ("build_options" , buildopts_mod );
147136 tests .root_module .addImport ("nif" , libnif_dep .module ("nif" ));
148137 tests .root_module .addImport ("ini" , libini_dep .module ("ini" ));
@@ -155,53 +144,47 @@ pub fn build(b: *std.Build) void {
155144
156145 // GUI playground
157146 {
158- const guiplay = b .createModule (.{
147+ const guiplay = b .addExecutable (.{
148+ .name = "guiplay" ,
159149 .root_source_file = b .path ("src/test/guiplay.zig" ),
160150 .target = target ,
161151 .optimize = optimize ,
162152 });
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" ) }));
153+ guiplay .root_module .addImport ("comm" , b .createModule (.{ .root_source_file = b .path ("src/comm.zig" ) }));
168154
169155 const guiplay_build_step = b .step ("guiplay" , "build GUI playground" );
170- guiplay_build_step .dependOn (& b .addInstallArtifact (guiplay_exe , .{}).step );
156+ guiplay_build_step .dependOn (& b .addInstallArtifact (guiplay , .{}).step );
171157 guiplay_build_step .dependOn (ngui_build_step );
172158 }
173159
174160 // bitcoind RPC client playground
175161 {
176- const btcrpc = b .createModule (.{
162+ const btcrpc = b .addExecutable (.{
163+ .name = "btcrpc" ,
177164 .root_source_file = b .path ("src/test/btcrpc.zig" ),
178165 .target = target ,
179166 .optimize = optimize ,
180167 .strip = strip ,
181168 });
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" ) }));
169+ btcrpc .root_module .addImport ("bitcoindrpc" , b .createModule (.{ .root_source_file = b .path ("src/bitcoindrpc.zig" ) }));
187170
188171 const btcrpc_build_step = b .step ("btcrpc" , "bitcoind RPC client playground" );
189- btcrpc_build_step .dependOn (& b .addInstallArtifact (btcrpc_exe , .{}).step );
172+ btcrpc_build_step .dependOn (& b .addInstallArtifact (btcrpc , .{}).step );
190173 }
191174
192175 // lnd HTTP API client playground
193176 {
194- const lndhc = b .createModule (.{
177+ const lndhc = b .addExecutable (.{
178+ .name = "lndhc" ,
195179 .root_source_file = b .path ("src/test/lndhc.zig" ),
196180 .target = target ,
197181 .optimize = optimize ,
198182 .strip = strip ,
199183 });
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" ) }));
184+ lndhc .root_module .addImport ("lightning" , b .createModule (.{ .root_source_file = b .path ("src/lightning.zig" ) }));
202185
203186 const lndhc_build_step = b .step ("lndhc" , "lnd HTTP API client playground" );
204- lndhc_build_step .dependOn (& b .addInstallArtifact (lndhc_exe , .{}).step );
187+ lndhc_build_step .dependOn (& b .addInstallArtifact (lndhc , .{}).step );
205188 }
206189
207190 // default build step
@@ -393,7 +376,7 @@ const LVGLLogLevel = enum {
393376 none ,
394377
395378 /// returns default mode based on the compiler optimization flags.
396- fn default (mode : std.builtin.OptimizeMode ) @This () {
379+ fn default (mode : std.builtin.Mode ) @This () {
397380 return switch (mode ) {
398381 .Debug = > .warn ,
399382 .ReleaseSafe = > .warn ,
@@ -444,7 +427,7 @@ const VersionStep = struct {
444427 return & vstep .step ;
445428 }
446429
447- fn make (step : * std.Build.Step , _ : std.Build.Step.MakeOptions ) anyerror ! void {
430+ fn make (step : * std.Build.Step , _ : * std.Progress.Node ) anyerror ! void {
448431 const self : * @This () = @fieldParentPtr ("step" , step );
449432 const semver = try self .eval ();
450433 std .log .info ("build version: {any}" , .{semver });
0 commit comments