@@ -4,7 +4,7 @@ pub fn build(b: *std.Build) void {
4
4
const target = b .standardTargetOptions (.{});
5
5
const optimize = b .standardOptimizeOption (.{});
6
6
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 ;
8
8
const strip = b .option (bool , "strip" , "Omit debug information" );
9
9
const pic = b .option (bool , "pie" , "Produce Position Independent Code" );
10
10
@@ -35,35 +35,34 @@ pub fn build(b: *std.Build) void {
35
35
36
36
const upstream = b .dependency ("capstone" , .{});
37
37
38
- const capstone = std . Build . Step . Compile . create ( b , .{
38
+ const capstone = b . addLibrary ( .{
39
39
.name = "capstone" ,
40
- .kind = .lib ,
41
- .linkage = if (shared ) .dynamic else .static ,
42
- .root_module = .{
40
+ .linkage = linkage ,
41
+ .root_module = b .createModule (.{
43
42
.target = target ,
44
43
.optimize = optimize ,
45
44
.pic = pic ,
46
45
.strip = strip ,
47
46
.link_libc = true ,
48
- },
47
+ }) ,
49
48
});
50
49
b .installArtifact (capstone );
51
50
capstone .addIncludePath (upstream .path ("include" ));
52
51
capstone .installHeadersDirectory (upstream .path ("include/capstone" ), "capstone" , .{});
53
52
capstone .installHeader (upstream .path ("include/platform.h" ), "capstone/platform.h" );
54
53
capstone .addCSourceFiles (.{ .root = upstream .path ("" ), .files = common_sources });
55
54
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" , "" );
62
61
63
62
var it = supported_architectures .iterator ();
64
63
while (it .next ()) | key | {
65
64
// 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 ()}), "" );
67
66
capstone .addCSourceFiles (.{
68
67
.root = upstream .path (b .fmt ("arch/{s}" , .{key .subdirectory ()})),
69
68
.files = key .sources (),
0 commit comments