Skip to content

Commit d0e9ed6

Browse files
star-hengxingstd-microblock
authored andcommitted
Add xmake support
1 parent a33de08 commit d0e9ed6

File tree

3 files changed

+159
-1
lines changed

3 files changed

+159
-1
lines changed

.github/workflows/build.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
paths-ignore:
9+
- 'README.md'
10+
11+
jobs:
12+
windows:
13+
strategy:
14+
matrix:
15+
os: [windows-2022, ubuntu-24.04]
16+
build_type: [debug, release]
17+
18+
runs-on: ${{ matrix.os }}
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Setup xmake
25+
uses: xmake-io/github-action-setup-xmake@v1
26+
with:
27+
xmake-version: '2.9.8'
28+
actions-cache-folder: '.xmake-cache'
29+
actions-cache-key: ${{ matrix.os }}
30+
package-cache: true
31+
package-cache-key: ${{ matrix.os }}-${{ matrix.build_type }}
32+
# build-cache: true
33+
# build-cache-key: ${{ matrix.os }}-${{ matrix.build_type }}
34+
35+
- name: Xmake configure
36+
run: |
37+
xmake config --yes --mode=${{ matrix.build_type }}
38+
39+
- name: Build
40+
run: |
41+
xmake build --verbose --diagnosis --all

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@
3434

3535
cmake-*
3636
/build*
37-
.cache
37+
.cache
38+
39+
.xmake/

xmake.lua

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
set_xmakever("2.9.8")
2+
3+
set_allowedplats("windows", "linux")
4+
5+
add_rules("mode.debug", "mode.release", "mode.releasedbg")
6+
set_allowedmodes("debug", "release", "releasedbg")
7+
8+
set_languages("c++23")
9+
set_encodings("utf-8")
10+
11+
add_requires("zasm edd30ff31d5a1d5f68002a61dca0ebf6e3c10ed0")
12+
13+
target("blook")
14+
set_kind("static")
15+
add_files("src/*.cpp")
16+
if is_plat("windows") then
17+
add_files("src/platform/windows/*.cpp")
18+
elseif is_plat("linux") then
19+
add_files("src/platform/linux/*.cpp")
20+
end
21+
add_includedirs("include", {public = true})
22+
23+
add_packages("zasm", {public = true})
24+
25+
target("blook-dll-hijack-codegen")
26+
set_enabled(is_plat("windows"))
27+
set_kind("binary")
28+
add_files("src/platform/windows/codegen/DllHijackCodegen.cpp")
29+
30+
target("blook-test")
31+
set_default(false)
32+
set_kind("binary")
33+
if is_plat("windows") then
34+
add_files("src/tests/test_windows.cpp")
35+
elseif is_plat("linux") then
36+
add_files("src/tests/test_linux.cpp")
37+
end
38+
39+
if is_plat("windows") then
40+
add_syslinks("user32", "advapi32")
41+
end
42+
add_deps("blook")
43+
44+
add_tests("default")
45+
46+
package("zasm")
47+
set_homepage("https://github.com/zyantific/zasm")
48+
set_description("x86-64 Assembler based on Zydis")
49+
50+
set_urls("https://github.com/zyantific/zasm.git")
51+
52+
add_versions("2025.03.02", "c239a78b51c1b0060296193174d78b802f02a618")
53+
add_versions("2024.05.14", "bea8af2c68f0cbe8a02e93ab79a8b5c596d2b232")
54+
add_versions("2023.06.21", "19a642518eccbb1740865642eaf3ce79d5d5b884")
55+
56+
add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
57+
58+
on_load(function (package)
59+
local map = {
60+
["2025.03.02"] = "4.1.0",
61+
["2024.05.14"] = "4.1.0",
62+
["2023.06.21"] = "4.0.0",
63+
}
64+
local zydis_version = map[package:version()]
65+
if zydis_version then
66+
package:add("deps", "zydis " .. zydis_version)
67+
else
68+
package:add("deps", "zydis")
69+
end
70+
end)
71+
72+
on_install("!wasm and !iphoneos", function (package)
73+
local src_include
74+
if package:version() and package:version():lt("2024.05.14") then
75+
src_include = [[
76+
add_files("src/zasm/**.cpp")
77+
add_includedirs("include", "src/zasm/src")
78+
add_headerfiles("include/(**.hpp)")
79+
]]
80+
else
81+
src_include = [[
82+
add_files("zasm/**.cpp")
83+
add_includedirs("zasm/include")
84+
add_headerfiles("zasm/include/(**.hpp)")
85+
]]
86+
end
87+
88+
io.writefile("xmake.lua", format([[
89+
add_rules("mode.debug", "mode.release")
90+
add_requires("zydis v4.0.0")
91+
target("zasm")
92+
set_kind("$(kind)")
93+
set_languages("c++17")
94+
%s
95+
if is_plat("windows") then
96+
add_cxxflags("/bigobj", "/MP", "/W3", "/permissive-")
97+
if is_kind("shared") then
98+
add_rules("utils.symbols.export_all", {export_classes = true})
99+
end
100+
end
101+
add_packages("zydis")
102+
]], src_include))
103+
import("package.tools.xmake").install(package)
104+
end)
105+
106+
on_test(function (package)
107+
assert(package:check_cxxsnippets({test = [[
108+
#include <zasm/serialization/serializer.hpp>
109+
#include <zasm/zasm.hpp>
110+
using namespace zasm;
111+
void test() {
112+
Program program(MachineMode::AMD64);
113+
}
114+
]]}, {configs = {languages = "c++17"}}))
115+
end)

0 commit comments

Comments
 (0)