|
@@ -1,51 +1,57 @@
|
|
|
package("unicorn")
|
|
|
set_homepage("http://www.unicorn-engine.org")
|
|
|
- set_description("Unicorn CPU emulator framework (ARM, AArch64, M68K, Mips, Sparc, PowerPC, RiscV, S390x, X86)")
|
|
|
+ set_description("Unicorn CPU emulator framework (ARM, AArch64, M68K, Mips, Sparc, PowerPC, RiscV, S390x, TriCore, X86)")
|
|
|
+ set_license("GPL-2.0")
|
|
|
|
|
|
- add_urls("https://github.com/unicorn-engine/unicorn.git")
|
|
|
- add_versions("2022.02.13", "c10639fd4658a852049546162d116b123e2b1ec2")
|
|
|
+ add_urls("https://github.com/unicorn-engine/unicorn/archive/refs/tags/$(version).tar.gz",
|
|
|
+ "https://github.com/unicorn-engine/unicorn.git")
|
|
|
+
|
|
|
+ add_versions("2.1.1", "8740b03053162c1ace651364c4c5e31859eeb6c522859aa00cb4c31fa9cbbed2")
|
|
|
|
|
|
add_deps("cmake")
|
|
|
add_deps("glib")
|
|
|
|
|
|
- local archs = {"aarch64", "sparc", "sparc", "riscv64", "arm", "m68k",
|
|
|
- "x86_64", "s390x", "mips64", "sparc64", "ppc", "ppc64",
|
|
|
- "mipsel", "riscv32", "mips", "mips64el"}
|
|
|
- add_configs("arch", {description = "Select unicorn architecture for softmmu.", default = "aarch64", values = archs})
|
|
|
+ if is_plat("linux", "bsd") then
|
|
|
+ add_syslinks("pthread", "m")
|
|
|
+ end
|
|
|
+
|
|
|
+ add_configs("logging", {description = "Enable logging", default = false, type = "boolean"})
|
|
|
+ add_configs("tracer", {description = "Trace unicorn execution", default = false, type = "boolean"})
|
|
|
+ add_configs("archs", {description = "Enabled unicorn architectures", default = {"x86", "aarch64"}, type = "table"})
|
|
|
|
|
|
on_load(function (package)
|
|
|
- package:add("links", "unicorn")
|
|
|
- package:add("links", package:config("arch") .. "-softmmu")
|
|
|
- package:add("links", "unicorn-common")
|
|
|
+ if package:is_plat("windows") and package:config("shared") then
|
|
|
+ package:add("defines", "UNICORN_SHARED")
|
|
|
+ end
|
|
|
end)
|
|
|
|
|
|
- on_install("windows", "macosx", "linux", function (package)
|
|
|
- local configs = {
|
|
|
- "-DUNICORN_BUILD_TESTS=OFF",
|
|
|
- "-DUNICORN_STATIC_MSVCRT=OFF"}
|
|
|
- local arch = package:config("arch")
|
|
|
- if arch == "x86_64" then
|
|
|
- table.insert(configs, "-DUNICORN_ARCH=x86")
|
|
|
- elseif arch:startswith("riscv") then
|
|
|
- table.insert(configs, "-DUNICORN_ARCH=riscv")
|
|
|
- elseif arch:startswith("mips") then
|
|
|
- table.insert(configs, "-DUNICORN_ARCH=mips")
|
|
|
- elseif arch:startswith("ppc") then
|
|
|
- table.insert(configs, "-DUNICORN_ARCH=ppc")
|
|
|
- else
|
|
|
- table.insert(configs, "-DUNICORN_ARCH=" .. arch)
|
|
|
- end
|
|
|
- table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
|
|
|
+ on_install("windows|!arm64", "macosx", "linux", "cross", function (package)
|
|
|
+ io.replace("CMakeLists.txt", "if(UNICORN_INSTALL AND NOT MSVC)", "if(1)", {plain = true})
|
|
|
+
|
|
|
+ local configs = {"-DUNICORN_BUILD_TESTS=OFF"}
|
|
|
+ table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
|
|
|
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
|
|
|
- import("package.tools.cmake").install(package, configs, {buildir = "build"})
|
|
|
+ table.insert(configs, "-DUNICORN_LOGGING=" .. (package:config("logging") and "ON" or "OFF"))
|
|
|
+ table.insert(configs, "-DUNICORN_TRACER=" .. (package:config("tracer") and "ON" or "OFF"))
|
|
|
+
|
|
|
+ local archs = table.concat(package:config("archs"), ";")
|
|
|
+ table.insert(configs, "-DUNICORN_ARCH=" .. archs)
|
|
|
+ import("package.tools.cmake").install(package, configs)
|
|
|
+
|
|
|
+ if package:config("shared") then
|
|
|
+ os.tryrm(package:installdir("lib/unicorn.lib"))
|
|
|
+ os.rm(package:installdir("lib/*.a"))
|
|
|
+ end
|
|
|
+
|
|
|
if package:is_plat("windows") then
|
|
|
- os.cp("include", package:installdir())
|
|
|
+ if package:config("shared") then
|
|
|
+ io.replace(package:installdir("include/unicorn/unicorn.h"), "__declspec(dllexport)", "__declspec(dllimport)", {plain = true})
|
|
|
+ end
|
|
|
+ if package:is_debug() then
|
|
|
+ local dir = package:installdir(package:config("shared") and "bin" or "lib")
|
|
|
+ os.trycp(path.join(package:buildir(), "unicorn.pdb"), dir)
|
|
|
+ end
|
|
|
end
|
|
|
- os.trycp("build/*.a", package:installdir("lib"))
|
|
|
- os.trycp("build/*.lib", package:installdir("lib"))
|
|
|
- os.trycp("build/*.dylib", package:installdir("lib"))
|
|
|
- os.trycp("build/*.so", package:installdir("lib"))
|
|
|
- os.trycp("build/*.dll", package:installdir("bin"))
|
|
|
end)
|
|
|
|
|
|
on_test(function (package)
|