@@ -5,6 +5,7 @@ pub fn build(b: *std.Build) void {
55 const target = b .standardTargetOptions (.{});
66 const optimize = b .standardOptimizeOption (.{});
77
8+ const linkage = b .option (std .builtin .LinkMode , "linkage" , "Link mode" ) orelse .static ;
89 const strip = b .option (bool , "strip" , "Omit debug information" );
910 const pic = b .option (bool , "pie" , "Produce Position Independent Code" );
1011
@@ -30,16 +31,19 @@ pub fn build(b: *std.Build) void {
3031 const exclude_compressors_dfast_and_up = b .option (bool , "exclude-compressors-dfast-and-up" , "" ) orelse false ;
3132 const exclude_compressors_greedy_and_up = b .option (bool , "exclude-compressors-greedy-and-up" , "" ) orelse false ;
3233
33- const zstd = b .addStaticLibrary (.{
34+ const zstd = b .addLibrary (.{
35+ .linkage = linkage ,
3436 .name = "zstd" ,
35- .target = target ,
36- .optimize = optimize ,
37- .strip = strip ,
38- .pic = pic ,
39- .link_libc = true ,
37+ .root_module = b .createModule (.{
38+ .target = target ,
39+ .optimize = optimize ,
40+ .strip = strip ,
41+ .pic = pic ,
42+ .link_libc = true ,
43+ }),
4044 });
4145 b .installArtifact (zstd );
42- zstd .addCSourceFiles (.{ .root = upstream .path ("lib" ), .files = common_sources });
46+ zstd .root_module . addCSourceFiles (.{ .root = upstream .path ("lib" ), .files = common_sources });
4347 // zstd does not install into its own subdirectory. :(
4448 zstd .installHeader (upstream .path ("lib/zstd.h" ), "zstd.h" );
4549 zstd .installHeader (upstream .path ("lib/zdict.h" ), "zdict.h" );
@@ -54,7 +58,7 @@ pub fn build(b: *std.Build) void {
5458
5559 if (target .result .cpu .arch == .x86_64 ) {
5660 if (decompression ) {
57- zstd .addAssemblyFile (upstream .path ("lib/decompress/huf_decompress_amd64.S" ));
61+ zstd .root_module . addAssemblyFile (upstream .path ("lib/decompress/huf_decompress_amd64.S" ));
5862 }
5963 } else {
6064 zstd .root_module .addCMacro ("ZSTD_DISABLE_ASM" , "" );
@@ -101,8 +105,10 @@ pub fn build(b: *std.Build) void {
101105 for (examples ) | name | {
102106 const exe = b .addExecutable (.{
103107 .name = name ,
104- .target = target ,
105- .optimize = optimize ,
108+ .root_module = b .createModule (.{
109+ .target = target ,
110+ .optimize = optimize ,
111+ }),
106112 });
107113 exe .addCSourceFile (.{ .file = upstream .path (b .fmt ("examples/{s}.c" , .{name })) });
108114 exe .addIncludePath (upstream .path ("examples/common.c" ));
0 commit comments