@@ -4,7 +4,7 @@ pub fn build(b: *std.Build) void {
44 const target = b .standardTargetOptions (.{});
55 const optimize = b .standardOptimizeOption (.{});
66
7- const shared = b .option (bool , "shared " , "Build as a shared library " ) orelse false ;
7+ const linkage = b .option (std . builtin . LinkMode , "linkage " , "How the library shall be linked " ) orelse .static ;
88 const strip = b .option (bool , "strip" , "Omit debug information" );
99 const pic = b .option (bool , "pie" , "Produce Position Independent Code" );
1010
@@ -35,35 +35,34 @@ pub fn build(b: *std.Build) void {
3535
3636 const upstream = b .dependency ("capstone" , .{});
3737
38- const capstone = std . Build . Step . Compile . create ( b , .{
38+ const capstone = b . addLibrary ( .{
3939 .name = "capstone" ,
40- .kind = .lib ,
41- .linkage = if (shared ) .dynamic else .static ,
42- .root_module = .{
40+ .linkage = linkage ,
41+ .root_module = b .createModule (.{
4342 .target = target ,
4443 .optimize = optimize ,
4544 .pic = pic ,
4645 .strip = strip ,
4746 .link_libc = true ,
48- },
47+ }) ,
4948 });
5049 b .installArtifact (capstone );
5150 capstone .addIncludePath (upstream .path ("include" ));
5251 capstone .installHeadersDirectory (upstream .path ("include/capstone" ), "capstone" , .{});
5352 capstone .installHeader (upstream .path ("include/platform.h" ), "capstone/platform.h" );
5453 capstone .addCSourceFiles (.{ .root = upstream .path ("" ), .files = common_sources });
5554
56- if (build_diet ) capstone .defineCMacro ("CAPSTONE_DIET" , null );
57- if (use_default_alloc ) capstone .defineCMacro ("CAPSTONE_USE_SYS_DYN_MEM" , null );
58- if (x86_reduce ) capstone .defineCMacro ("CAPSTONE_X86_REDUCE" , null );
59- if (x86_att_disable ) capstone .defineCMacro ("CAPSTONE_X86_ATT_DISABLE" , null );
60- if (osx_kernel_support ) capstone .defineCMacro ("CAPSTONE_HAS_OSXKERNEL" , null );
61- if (optimize == .Debug ) capstone .defineCMacro ("CAPSTONE_DEBUG" , null );
55+ if (build_diet ) capstone .root_module . addCMacro ("CAPSTONE_DIET" , "" );
56+ if (use_default_alloc ) capstone .root_module . addCMacro ("CAPSTONE_USE_SYS_DYN_MEM" , "" );
57+ if (x86_reduce ) capstone .root_module . addCMacro ("CAPSTONE_X86_REDUCE" , "" );
58+ if (x86_att_disable ) capstone .root_module . addCMacro ("CAPSTONE_X86_ATT_DISABLE" , "" );
59+ if (osx_kernel_support ) capstone .root_module . addCMacro ("CAPSTONE_HAS_OSXKERNEL" , "" );
60+ if (optimize == .Debug ) capstone .root_module . addCMacro ("CAPSTONE_DEBUG" , "" );
6261
6362 var it = supported_architectures .iterator ();
6463 while (it .next ()) | key | {
6564 // std.log.info("Enabling CAPSTONE_HAS_{s}", .{key.macroName()});
66- capstone .defineCMacro (b .fmt ("CAPSTONE_HAS_{s}" , .{key .macroName ()}), null );
65+ capstone .root_module . addCMacro (b .fmt ("CAPSTONE_HAS_{s}" , .{key .macroName ()}), "" );
6766 capstone .addCSourceFiles (.{
6867 .root = upstream .path (b .fmt ("arch/{s}" , .{key .subdirectory ()})),
6968 .files = key .sources (),
0 commit comments