|
| 1 | +const std = @import("std"); |
| 2 | +const builtin = @import("builtin"); |
| 3 | + |
| 4 | +pub fn build(b: *std.Build) void { |
| 5 | + const target = b.standardTargetOptions(.{}); |
| 6 | + const optimize = b.standardOptimizeOption(.{}); |
| 7 | + |
| 8 | + const upstream = b.dependency("capstone", .{}); |
| 9 | + const lib = b.addSharedLibrary(.{ |
| 10 | + .name = "capstone", |
| 11 | + .target = target, |
| 12 | + .optimize = optimize, |
| 13 | + }); |
| 14 | + |
| 15 | + lib.linkLibC(); |
| 16 | + lib.addIncludePath(upstream.path("include")); |
| 17 | + lib.addCSourceFiles(.{ |
| 18 | + .root = upstream.path(""), |
| 19 | + .files = &.{ |
| 20 | + "Mapping.c", |
| 21 | + "MCInst.c", |
| 22 | + "cs.c", |
| 23 | + "MCInstrDesc.c", |
| 24 | + "utils.c", |
| 25 | + "SStream.c", |
| 26 | + "MCRegisterInfo.c", |
| 27 | + |
| 28 | + "cstool/cstool_evm.c", |
| 29 | + "cstool/cstool_systemz.c", |
| 30 | + "cstool/getopt.c", |
| 31 | + "cstool/cstool_arm64.c", |
| 32 | + "cstool/cstool_tricore.c", |
| 33 | + "cstool/cstool_powerpc.c", |
| 34 | + "cstool/cstool_mips.c", |
| 35 | + "cstool/cstool_x86.c", |
| 36 | + "cstool/cstool_mos65xx.c", |
| 37 | + "cstool/cstool_bpf.c", |
| 38 | + "cstool/cstool.c", |
| 39 | + "cstool/cstool_riscv.c", |
| 40 | + "cstool/cstool_sparc.c", |
| 41 | + "cstool/cstool_m68k.c", |
| 42 | + "cstool/cstool_xcore.c", |
| 43 | + "cstool/cstool_sh.c", |
| 44 | + "cstool/cstool_tms320c64x.c", |
| 45 | + "cstool/cstool_arm.c", |
| 46 | + "cstool/cstool_wasm.c", |
| 47 | + "cstool/cstool_m680x.c", |
| 48 | + |
| 49 | + "arch/PowerPC/PPCModule.c", |
| 50 | + "arch/PowerPC/PPCMapping.c", |
| 51 | + "arch/PowerPC/PPCDisassembler.c", |
| 52 | + "arch/PowerPC/PPCInstPrinter.c", |
| 53 | + "arch/X86/X86IntelInstPrinter.c", |
| 54 | + "arch/X86/X86DisassemblerDecoder.c", |
| 55 | + "arch/X86/X86InstPrinterCommon.c", |
| 56 | + "arch/X86/X86Mapping.c", |
| 57 | + "arch/X86/X86Disassembler.c", |
| 58 | + "arch/X86/X86Module.c", |
| 59 | + "arch/X86/X86ATTInstPrinter.c", |
| 60 | + "arch/M680X/M680XInstPrinter.c", |
| 61 | + "arch/M680X/M680XDisassembler.c", |
| 62 | + "arch/M680X/M680XModule.c", |
| 63 | + "arch/TMS320C64x/TMS320C64xModule.c", |
| 64 | + "arch/TMS320C64x/TMS320C64xInstPrinter.c", |
| 65 | + "arch/TMS320C64x/TMS320C64xMapping.c", |
| 66 | + "arch/TMS320C64x/TMS320C64xDisassembler.c", |
| 67 | + "arch/XCore/XCoreDisassembler.c", |
| 68 | + "arch/XCore/XCoreMapping.c", |
| 69 | + "arch/XCore/XCoreInstPrinter.c", |
| 70 | + "arch/XCore/XCoreModule.c", |
| 71 | + "arch/MOS65XX/MOS65XXDisassembler.c", |
| 72 | + "arch/MOS65XX/MOS65XXModule.c", |
| 73 | + "arch/BPF/BPFDisassembler.c", |
| 74 | + "arch/BPF/BPFMapping.c", |
| 75 | + "arch/BPF/BPFInstPrinter.c", |
| 76 | + "arch/BPF/BPFModule.c", |
| 77 | + "arch/Sparc/SparcInstPrinter.c", |
| 78 | + "arch/Sparc/SparcMapping.c", |
| 79 | + "arch/Sparc/SparcDisassembler.c", |
| 80 | + "arch/Sparc/SparcModule.c", |
| 81 | + "arch/WASM/WASMModule.c", |
| 82 | + "arch/WASM/WASMInstPrinter.c", |
| 83 | + "arch/WASM/WASMDisassembler.c", |
| 84 | + "arch/WASM/WASMMapping.c", |
| 85 | + "arch/Mips/MipsInstPrinter.c", |
| 86 | + "arch/Mips/MipsDisassembler.c", |
| 87 | + "arch/Mips/MipsMapping.c", |
| 88 | + "arch/Mips/MipsModule.c", |
| 89 | + "arch/SystemZ/SystemZInstPrinter.c", |
| 90 | + "arch/SystemZ/SystemZDisassembler.c", |
| 91 | + "arch/SystemZ/SystemZMCTargetDesc.c", |
| 92 | + "arch/SystemZ/SystemZModule.c", |
| 93 | + "arch/SystemZ/SystemZMapping.c", |
| 94 | + "arch/RISCV/RISCVMapping.c", |
| 95 | + "arch/RISCV/RISCVDisassembler.c", |
| 96 | + "arch/RISCV/RISCVInstPrinter.c", |
| 97 | + "arch/RISCV/RISCVModule.c", |
| 98 | + "arch/SH/SHInstPrinter.c", |
| 99 | + "arch/SH/SHModule.c", |
| 100 | + "arch/SH/SHDisassembler.c", |
| 101 | + "arch/ARM/ARMInstPrinter.c", |
| 102 | + "arch/ARM/ARMMapping.c", |
| 103 | + "arch/ARM/ARMDisassembler.c", |
| 104 | + "arch/ARM/ARMModule.c", |
| 105 | + "arch/M68K/M68KInstPrinter.c", |
| 106 | + "arch/M68K/M68KModule.c", |
| 107 | + "arch/M68K/M68KDisassembler.c", |
| 108 | + "arch/AArch64/AArch64BaseInfo.c", |
| 109 | + "arch/AArch64/AArch64Module.c", |
| 110 | + "arch/AArch64/AArch64InstPrinter.c", |
| 111 | + "arch/AArch64/AArch64Mapping.c", |
| 112 | + "arch/AArch64/AArch64Disassembler.c", |
| 113 | + "arch/TriCore/TriCoreModule.c", |
| 114 | + "arch/TriCore/TriCoreInstPrinter.c", |
| 115 | + "arch/TriCore/TriCoreMapping.c", |
| 116 | + "arch/TriCore/TriCoreDisassembler.c", |
| 117 | + "arch/EVM/EVMModule.c", |
| 118 | + "arch/EVM/EVMInstPrinter.c", |
| 119 | + "arch/EVM/EVMMapping.c", |
| 120 | + "arch/EVM/EVMDisassembler.c", |
| 121 | + }, |
| 122 | + .flags = &.{ |
| 123 | + // For now, let's just add all of them lol |
| 124 | + "-DCAPSTONE_HAS_ARM", |
| 125 | + "-DCAPSTONE_HAS_ARM64", |
| 126 | + "-DCAPSTONE_HAS_MIPS", |
| 127 | + "-DCAPSTONE_HAS_POWERPC", |
| 128 | + "-DCAPSTONE_HAS_X86", |
| 129 | + "-DCAPSTONE_HAS_SPARC", |
| 130 | + "-DCAPSTONE_HAS_SYSZ", |
| 131 | + "-DCAPSTONE_HAS_XCORE", |
| 132 | + "-DCAPSTONE_HAS_M68K", |
| 133 | + "-DCAPSTONE_HAS_TMS320C64X", |
| 134 | + "-DCAPSTONE_HAS_M680X", |
| 135 | + "-DCAPSTONE_HAS_EVM", |
| 136 | + "-DCAPSTONE_HAS_WASM", |
| 137 | + "-DCAPSTONE_HAS_MOS65XX", |
| 138 | + "-DCAPSTONE_HAS_BPF", |
| 139 | + "-DCAPSTONE_HAS_RISCV", |
| 140 | + "-DCAPSTONE_HAS_SH", |
| 141 | + "-DCAPSTONE_HAS_TRICORE", |
| 142 | + }, |
| 143 | + }); |
| 144 | + |
| 145 | + lib.installHeadersDirectory(upstream.path("include"), "", .{}); |
| 146 | + |
| 147 | + b.installArtifact(lib); |
| 148 | +} |
0 commit comments