Skip to content

Commit d19a320

Browse files
authored
add unicorn (#1012)
* Update xmake.lua * Update xmake.lua * add unicorn * Update xmake.lua * Update xmake.lua * improve unicorn
1 parent a9f7fd3 commit d19a320

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

packages/p/python/xmake.lua

+6-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,12 @@ package("python")
9797
os.cp("libs/*", package:installdir("lib"))
9898
os.cp("*", package:installdir())
9999
local python = path.join(package:installdir("bin"), "python.exe")
100-
os.vrunv(python, {"-m", "pip", "install", "--upgrade", "--force-reinstall", "pip"})
100+
if package:version():eq("3.9.10") then
101+
-- https://github.com/xmake-io/xmake-repo/issues/1013
102+
os.vrunv(python, {"-m", "pip", "install", "--upgrade", "--force-reinstall", "pip==21.3.1"})
103+
else
104+
os.vrunv(python, {"-m", "pip", "install", "--upgrade", "--force-reinstall", "pip"})
105+
end
101106
os.vrunv(python, {"-m", "pip", "install", "wheel"})
102107
end)
103108

packages/u/unicorn/xmake.lua

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package("unicorn")
2+
set_homepage("http://www.unicorn-engine.org")
3+
set_description("Unicorn CPU emulator framework (ARM, AArch64, M68K, Mips, Sparc, PowerPC, RiscV, S390x, X86)")
4+
5+
add_urls("https://github.com/unicorn-engine/unicorn.git")
6+
add_versions("2022.02.13", "c10639fd4658a852049546162d116b123e2b1ec2")
7+
8+
add_deps("cmake")
9+
add_deps("glib")
10+
11+
local archs = {"aarch64", "sparc", "sparc", "riscv64", "arm", "m68k",
12+
"x86_64", "s390x", "mips64", "sparc64", "ppc", "ppc64",
13+
"mipsel", "riscv32", "mips", "mips64el"}
14+
add_configs("arch", {description = "Select unicorn architecture for softmmu.", default = "aarch64", values = archs})
15+
16+
on_load(function (package)
17+
package:add("links", "unicorn")
18+
package:add("links", package:config("arch") .. "-softmmu")
19+
package:add("links", "unicorn-common")
20+
end)
21+
22+
on_install("windows", "macosx", "linux", function (package)
23+
local configs = {
24+
"-DUNICORN_BUILD_TESTS=OFF",
25+
"-DUNICORN_STATIC_MSVCRT=OFF"}
26+
local arch = package:config("arch")
27+
if arch == "x86_64" then
28+
table.insert(configs, "-DUNICORN_ARCH=x86")
29+
elseif arch:startswith("riscv") then
30+
table.insert(configs, "-DUNICORN_ARCH=riscv")
31+
elseif arch:startswith("mips") then
32+
table.insert(configs, "-DUNICORN_ARCH=mips")
33+
elseif arch:startswith("ppc") then
34+
table.insert(configs, "-DUNICORN_ARCH=ppc")
35+
else
36+
table.insert(configs, "-DUNICORN_ARCH=" .. arch)
37+
end
38+
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
39+
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
40+
import("package.tools.cmake").install(package, configs, {buildir = "build"})
41+
if package:is_plat("windows") then
42+
os.cp("include", package:installdir())
43+
end
44+
os.trycp("build/*.a", package:installdir("lib"))
45+
os.trycp("build/*.lib", package:installdir("lib"))
46+
os.trycp("build/*.dylib", package:installdir("lib"))
47+
os.trycp("build/*.so", package:installdir("lib"))
48+
os.trycp("build/*.dll", package:installdir("bin"))
49+
end)
50+
51+
on_test(function (package)
52+
assert(package:has_cfuncs("uc_open", {includes = "unicorn/unicorn.h"}))
53+
end)

0 commit comments

Comments
 (0)