xmake.lua 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. add_urls("https://github.com/unicorn-engine/unicorn.git")
  5. add_versions("2022.02.13", "c10639fd4658a852049546162d116b123e2b1ec2")
  6. add_deps("cmake")
  7. add_deps("glib")
  8. local archs = {"aarch64", "sparc", "sparc", "riscv64", "arm", "m68k",
  9. "x86_64", "s390x", "mips64", "sparc64", "ppc", "ppc64",
  10. "mipsel", "riscv32", "mips", "mips64el"}
  11. add_configs("arch", {description = "Select unicorn architecture for softmmu.", default = "aarch64", values = archs})
  12. on_load(function (package)
  13. package:add("links", "unicorn")
  14. package:add("links", package:config("arch") .. "-softmmu")
  15. package:add("links", "unicorn-common")
  16. end)
  17. on_install("windows", "macosx", "linux", function (package)
  18. local configs = {
  19. "-DUNICORN_BUILD_TESTS=OFF",
  20. "-DUNICORN_STATIC_MSVCRT=OFF"}
  21. local arch = package:config("arch")
  22. if arch == "x86_64" then
  23. table.insert(configs, "-DUNICORN_ARCH=x86")
  24. elseif arch:startswith("riscv") then
  25. table.insert(configs, "-DUNICORN_ARCH=riscv")
  26. elseif arch:startswith("mips") then
  27. table.insert(configs, "-DUNICORN_ARCH=mips")
  28. elseif arch:startswith("ppc") then
  29. table.insert(configs, "-DUNICORN_ARCH=ppc")
  30. else
  31. table.insert(configs, "-DUNICORN_ARCH=" .. arch)
  32. end
  33. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  34. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  35. import("package.tools.cmake").install(package, configs, {buildir = "build"})
  36. if package:is_plat("windows") then
  37. os.cp("include", package:installdir())
  38. end
  39. os.trycp("build/*.a", package:installdir("lib"))
  40. os.trycp("build/*.lib", package:installdir("lib"))
  41. os.trycp("build/*.dylib", package:installdir("lib"))
  42. os.trycp("build/*.so", package:installdir("lib"))
  43. os.trycp("build/*.dll", package:installdir("bin"))
  44. end)
  45. on_test(function (package)
  46. assert(package:has_cfuncs("uc_open", {includes = "unicorn/unicorn.h"}))
  47. end)