1- const std = @import ("std" );
2- const compile_flagz = @import ("compile_flagz" );
3- const config = @import ("config" );
4- const builtin = @import ("builtin" );
1+ const STD = @import ("std" );
2+ const COMPILE_FLAGZ = @import ("compile_flagz" );
3+ const CONFIG = @import ("config" );
4+ const BUILTIN = @import ("builtin" );
55
6- pub fn build (b : * std .Build ) ! void {
7- if (builtin .zig_version .minor < 15 ) {
6+ pub fn build (b : * STD .Build ) ! void {
7+ if (BUILTIN .zig_version .minor < 15 ) {
88 @compileError ("Zig >= v0.15.1 is required..." );
99 }
1010
11- const target = b .standardTargetOptions (.{});
12- const optimize = b .standardOptimizeOption (.{});
13- const compiler_flags = [_ ][]const u8 { "-std=c++23" , "-Wall" , "-Werror" , "-Wextra" };
11+ const TARGET = b .standardTargetOptions (.{});
12+ const OPTIMIZE = b .standardOptimizeOption (.{});
13+ const COMPILER_FLAGS = [_ ][]const u8 { "-std=c++23" , "-Wall" , "-Werror" , "-Wextra" };
1414
1515 // dependencies
16- const dep_gtest = b .dependency ("googletest" , .{});
16+ const DEP_GTEST = b .dependency ("googletest" , .{});
1717
1818 // cli
19- const cpplings_cli = b .addExecutable (.{ .name = "cpplings_cli" , .root_module = b .createModule (.{
20- .target = target ,
21- .optimize = optimize ,
19+ const CPPLINGS_CLI = b .addExecutable (.{ .name = "cpplings_cli" , .root_module = b .createModule (.{
20+ .target = TARGET ,
21+ .optimize = OPTIMIZE ,
2222 .root_source_file = b .path ("src/main.zig" ),
2323 }) });
2424
25- b .installArtifact (cpplings_cli );
25+ b .installArtifact (CPPLINGS_CLI );
2626
27- const cpplings_cli_step = b .step ("run" , "Run cpplings cli" );
28- const cpplings_cli_cmd = b .addRunArtifact (cpplings_cli );
29- cpplings_cli_step .dependOn (& cpplings_cli_cmd .step );
30- cpplings_cli_cmd .step .dependOn (b .getInstallStep ());
27+ const CPPLINGS_CLI_STEP = b .step ("run" , "Run cpplings cli" );
28+ const CPPLINGS_CLI_CMD = b .addRunArtifact (CPPLINGS_CLI );
29+ CPPLINGS_CLI_STEP .dependOn (& CPPLINGS_CLI_CMD .step );
30+ CPPLINGS_CLI_CMD .step .dependOn (b .getInstallStep ());
3131
3232 // exercises
33- const cpplings = b .addExecutable (.{
34- .name = "cpplings " ,
33+ const CPPLIGNS_EXERCISE = b .addExecutable (.{
34+ .name = "CPPLIGNS_EXERCISE " ,
3535 .root_module = b .createModule (.{
36- .target = target ,
37- .optimize = optimize ,
36+ .target = TARGET ,
37+ .optimize = OPTIMIZE ,
3838 .link_libc = true ,
3939 .link_libcpp = true ,
4040 }),
4141 });
4242
4343 if (b .args ) | args | {
4444 if (args .len > 0 ) {
45- const exercise_filenames = args ;
45+ const EXERCISE_FILENAMES = args ;
4646
47- cpplings .root_module .addCSourceFiles (.{ .flags = & compiler_flags , .files = exercise_filenames });
47+ CPPLIGNS_EXERCISE .root_module .addCSourceFiles (.{ .flags = & COMPILER_FLAGS , .files = EXERCISE_FILENAMES });
4848
49- cpplings .root_module .addIncludePath (b .path ("include" ));
50- cpplings .root_module .linkLibrary (dep_gtest .artifact ("gtest" ));
51- cpplings .root_module .linkLibrary (dep_gtest .artifact ("gtest_main" ));
49+ CPPLIGNS_EXERCISE .root_module .addIncludePath (b .path ("include" ));
50+ CPPLIGNS_EXERCISE .root_module .linkLibrary (DEP_GTEST .artifact ("gtest" ));
51+ CPPLIGNS_EXERCISE .root_module .linkLibrary (DEP_GTEST .artifact ("gtest_main" ));
5252
53- b .installArtifact (cpplings );
53+ b .installArtifact (CPPLIGNS_EXERCISE );
5454 }
5555 }
5656
57- const cpplings_run_exercise_step = b .step ("exercises" , "Build and run cpplings exercise" );
58- const cpplings_run_exercise_cmd = b .addRunArtifact (cpplings );
59- cpplings_run_exercise_step .dependOn (& cpplings_run_exercise_cmd .step );
60- cpplings_run_exercise_cmd .step .dependOn (b .getInstallStep ());
57+ const CPPLINGS_RUN_EXERCISE_STEP = b .step ("exercises" , "Build and run cppligns_exercise exercise" );
58+ const CPPLINGS_RUN_EXERCISE_CMD = b .addRunArtifact (CPPLIGNS_EXERCISE );
59+ CPPLINGS_RUN_EXERCISE_STEP .dependOn (& CPPLINGS_RUN_EXERCISE_CMD .step );
60+ CPPLINGS_RUN_EXERCISE_CMD .step .dependOn (b .getInstallStep ());
6161
6262 if (b .args ) | args | {
6363 if (args .len > 0 ) {
64- cpplings_run_exercise_cmd .addArgs (args );
64+ CPPLINGS_RUN_EXERCISE_CMD .addArgs (args );
6565 }
6666 }
6767
6868 // create compile flags generator
69- var cflags = compile_flagz .addCompileFlags (b );
69+ var cflags = COMPILE_FLAGZ .addCompileFlags (b );
7070 cflags .addIncludePath (b .path ("include" ));
7171 cflags .addIncludePath (b .path ("src" ));
72- cflags .addIncludePath (dep_gtest .path ("include" ));
72+ cflags .addIncludePath (DEP_GTEST .path ("include" ));
7373
7474 // TODO: automate libcc path
7575 // $ clang++ -E -x c++ - -v < /dev/null
@@ -81,6 +81,6 @@ pub fn build(b: *std.Build) !void {
8181 cflags .addIncludePath (.{ .cwd_relative = "/nix/store/fbfcll570w9vimfbh41f9b4rrwnp33f3-clang-wrapper-19.1.7/resource-root/include" });
8282 cflags .addIncludePath (.{ .cwd_relative = "/nix/store/gf3wh0x0rzb1dkx0wx1jvmipydwfzzd5-glibc-2.40-66-dev/include" });
8383
84- const cflags_step = b .step ("compile-flags" , "Generate compile_flags.txt for C/C++ IDE support" );
85- cflags_step .dependOn (& cflags .step );
84+ const CFLAGS_STEP = b .step ("compile-flags" , "Generate compile_flags.txt for C/C++ IDE support" );
85+ CFLAGS_STEP .dependOn (& cflags .step );
8686}
0 commit comments