@@ -9,23 +9,20 @@ pub fn build(b: *std.Build) void {
99 const target = b .standardTargetOptions (.{});
1010 const optimize = b .standardOptimizeOption (.{});
1111
12- // add library
13- const lib = b .addStaticLibrary (.{
14- .name = "ocispec" ,
15- // In this case the main source file is merely a path, however, in more
16- // complicated build scripts, this could be a generated file.
17- .root_source_file = b .path ("src/distribution/lib.zig" ),
18- .target = target ,
19- .optimize = optimize ,
20- .single_threaded = false ,
21- });
22-
23- b .installArtifact (lib );
24-
2512 const oci_spec_module = b .addModule ("ocispec" , .{
2613 .root_source_file = b .path ("src/lib.zig" ),
2714 });
2815
16+ // Library object for documentation generation
17+ const lib = b .addObject (.{
18+ .name = "ocispec" ,
19+ .root_module = b .createModule (.{
20+ .root_source_file = b .path ("src/lib.zig" ),
21+ .target = target ,
22+ .optimize = optimize ,
23+ }),
24+ });
25+
2926 // step generate docs
3027 const install_docs = b .addInstallDirectory (.{
3128 .source_dir = lib .getEmittedDocs (),
@@ -46,36 +43,37 @@ pub fn build(b: *std.Build) void {
4643 }) | example_name | {
4744 const example = b .addExecutable (.{
4845 .name = example_name ,
49- .root_source_file = b .path (b .fmt ("examples/{s}.zig" , .{example_name })),
50- .target = target ,
51- .optimize = optimize ,
46+ .root_module = b .createModule (.{
47+ .root_source_file = b .path (b .fmt ("examples/{s}.zig" , .{example_name })),
48+ .target = target ,
49+ .optimize = optimize ,
50+ }),
5251 });
5352
5453 example .root_module .addImport ("ocispec" , oci_spec_module );
5554 b .installArtifact (example );
5655 }
5756
5857 // step run tests
59- const lib_unit_tests = b .addTest (.{
60- // Assuming this needs to be the same root file as the library,
61- // since it's the library we're building tests for?
58+ const test_module = b .createModule (.{
6259 .root_source_file = b .path ("tests/lib.zig" ),
6360 .target = target ,
6461 .optimize = optimize ,
6562 });
66- lib_unit_tests .root_module .addImport ("ocispec" , oci_spec_module );
63+ test_module .addImport ("ocispec" , oci_spec_module );
64+ const lib_unit_tests = b .addTest (.{
65+ .root_module = test_module ,
66+ });
6767
6868 const run_lib_unit_tests = b .addRunArtifact (lib_unit_tests );
6969
7070 const test_step = b .step ("test" , "Run unit tests" );
7171 test_step .dependOn (& run_lib_unit_tests .step );
7272
73- // step generate code cov
73+ // step generate code coverage
7474 const cov_step = b .step ("cov" , "Generate code coverage" );
75-
7675 const cov_run = b .addSystemCommand (&.{ "kcov" , "--clean" , "--include-pattern=src/" , ".coverage/" });
7776 cov_run .addArtifactArg (lib_unit_tests );
78-
7977 cov_step .dependOn (& cov_run .step );
8078
8179 // step check formatting
0 commit comments