xmake.lua 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package("asmjit")
  2. set_homepage("https://asmjit.com/")
  3. set_description("AsmJit is a lightweight library for machine code generation written in C++ language.")
  4. set_license("zlib")
  5. add_urls("https://github.com/asmjit/asmjit.git")
  6. add_versions("2024.03.09", "268bce7952883dec5015ae539906e9e9d7fb65a0")
  7. add_versions("2022.01.18", "9a92d2f97260749f6f29dc93e53c743448f0137a")
  8. add_versions("2021.06.27", "d02235b83434943b52a6d7c57118205c5082de08")
  9. add_deps("cmake")
  10. if is_plat("linux") then
  11. add_syslinks("rt")
  12. end
  13. on_load("windows", "macosx", "linux", function (package)
  14. if not package:config("shared") then
  15. package:add("defines", "ASMJIT_STATIC")
  16. end
  17. end)
  18. on_install("windows", "macosx", "linux", function (package)
  19. local configs = {}
  20. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  21. table.insert(configs, "-DASMJIT_STATIC=" .. (package:config("shared") and "OFF" or "ON"))
  22. import("package.tools.cmake").install(package, configs)
  23. end)
  24. on_test(function (package)
  25. assert(package:check_cxxsnippets({test = [[
  26. typedef int (*Func)(void);
  27. void test() {
  28. using namespace asmjit;
  29. JitRuntime rt;
  30. CodeHolder code;
  31. code.init(rt.environment());
  32. x86::Assembler a(&code);
  33. a.mov(x86::eax, 1); // Emits 'mov eax, 1' - moves one to 'eax' register.
  34. a.ret(); // Emits 'ret' - returns from a function.
  35. Func fn;
  36. rt.add(&fn, &code);
  37. int result = fn();
  38. rt.release(fn);
  39. return;
  40. }
  41. ]]}, {configs = {languages = "c++17"}, includes = "asmjit/asmjit.h"}))
  42. end)