Skip to content

Commit 7c02553

Browse files
committed
Initial Commit
0 parents  commit 7c02553

File tree

5 files changed

+189
-0
lines changed

5 files changed

+189
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
zig-out/**
2+
zig-cache/**

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2024 SoraTenshi <[email protected]>
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# capstone
2+
This just enables to use [capstone](https://github.com/capstone-engine/capstone) as a Dependency for the Zig build system.

build.zig

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
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+
}

build.zig.zon

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.{
2+
.name = "capstone",
3+
.version = "5.0.1",
4+
5+
.dependencies = .{
6+
.capstone = .{
7+
.url = "https://github.com/capstone-engine/capstone/archive/refs/tags/5.0.1.tar.gz",
8+
.hash = "12203db27899cf191689d4c4a37497e0bfb5e9e185ac8bb968792c5d138d64a75119",
9+
},
10+
},
11+
12+
.paths = .{
13+
"LICENSE",
14+
"README.md",
15+
"build.zig",
16+
"build.zig.zon",
17+
},
18+
}

0 commit comments

Comments
 (0)