xmake.lua 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package("melon")
  2. set_homepage("http://doc.melonc.io")
  3. set_description("A generic cross-platform C library that includes many commonly used components and frameworks, and a new scripting language interpreter. It currently supports C99 and Aspect-Oriented Programming (AOP).")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://github.com/Water-Melon/Melon.git")
  6. add_versions("2025.01.18", "9df92922ab384295380d4414493e69983671dbf5")
  7. if is_plat("windows") then
  8. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  9. end
  10. on_check("mingw", function (package)
  11. if is_subhost("macosx") then
  12. raise("package(melon) is unsupported on Mac OS X subhost.")
  13. end
  14. local msystem = os.getenv("MSYSTEM")
  15. if msystem then
  16. if msystem ~= "CLANG64" or msystem ~= "CLANGARM64" then
  17. raise("package(melon) is unsupported on MinGW64/UCRT64. Use CLANG64/CLANGARM64 Shell.")
  18. end
  19. end
  20. end)
  21. on_install("!android", function (package)
  22. if package:is_plat("windows") then
  23. for _, file in ipairs(os.files("src/*.c")) do
  24. io.replace(file, "!defined(MSVC)", "0", {plain = true})
  25. io.replace(file, "defined(MSVC)", "1", {plain = true})
  26. end
  27. for _, file in ipairs(os.files("include/*.h")) do
  28. io.replace(file, "!defined(MSVC)", "0", {plain = true})
  29. io.replace(file, "defined(MSVC)", "1", {plain = true})
  30. end
  31. end
  32. local home = package:installdir()
  33. io.replace("src/mln_path.c", "MLN_ROOT", [["]] .. path.join(home, "bin"):gsub([[\]], [[\\]]) .. [["]], {plain = true})
  34. io.replace("src/mln_path.c", "MLN_NULL", [["]] .. path.join(home, "bin"):gsub([[\]], [[\\]]) .. [["]], {plain = true})
  35. io.replace("src/mln_path.c", "MLN_LANG_LIB", [["]] .. path.join(home, "lib"):gsub([[\]], [[\\]]) .. [["]], {plain = true})
  36. io.replace("src/mln_path.c", "MLN_LANG_DYLIB", [["]] .. path.join(home, "lib"):gsub([[\]], [[\\]]) .. [["]], {plain = true})
  37. io.writefile("xmake.lua", [[
  38. add_rules("mode.debug", "mode.release")
  39. target("melon")
  40. if is_plat("windows") then
  41. set_languages("c11")
  42. else
  43. set_languages("gnu99")
  44. end
  45. set_kind("$(kind)")
  46. add_files("src/*.c")
  47. add_headerfiles("include/*.h")
  48. add_includedirs("include")
  49. if is_plat("linux", "bsd") then
  50. add_syslinks("dl", "pthread")
  51. end
  52. if is_plat("windows", "mingw") then
  53. add_syslinks("ws2_32")
  54. end
  55. ]])
  56. import("package.tools.xmake").install(package)
  57. end)
  58. on_test(function (package)
  59. assert(package:has_cfuncs("mln_aes_init", {includes = "mln_aes.h"}))
  60. end)