|
| 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