2
0

xmake.lua 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package("opencc")
  2. set_homepage("https://github.com/BYVoid/OpenCC")
  3. set_description("Conversion between Traditional and Simplified Chinese.")
  4. set_urls("https://github.com/BYVoid/OpenCC/archive/ver.$(version).zip")
  5. add_versions("1.1.2", "b4a53564d0de446bf28c8539a8a17005a3e2b1877647b68003039e77f8f7d9c2")
  6. add_patches("1.1.2", path.join(os.scriptdir(), "patches", "1.1.2", "fix-static.patch"), "a51b58d5d092a057461bc8c7661546cde5c39af3c1f4438abc1d89e1a1df7122")
  7. add_deps("cmake", {kind = "binary"})
  8. if not is_plat("bsd") then
  9. add_deps("python 3.x", {kind = "binary"})
  10. end
  11. on_load(function (package)
  12. if package:is_plat("linux", "mingw") and not package:config("shared") then
  13. package:add("links", "opencc", "marisa")
  14. end
  15. if not package:config("shared") then
  16. package:add("defines", "Opencc_BUILT_AS_STATIC")
  17. end
  18. package:addenv("PATH", "bin")
  19. end)
  20. on_install("windows", "mingw@windows,msys", "linux", "macosx", "bsd", function (package)
  21. local configs = {"-DBUILD_DOCUMENTATION=OFF", "-DENABLE_GTEST=OFF"}
  22. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  23. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  24. import("package.tools.cmake").install(package, configs)
  25. end)
  26. on_test("windows", "mingw@windows,msys", "linux", "macosx", "bsd", function (package)
  27. assert(package:has_cfuncs("opencc_open", {includes = "opencc/opencc.h"}))
  28. assert(package:check_cxxsnippets({test = [[
  29. void test() {
  30. opencc::Config config;
  31. }
  32. ]]}, {includes = {"opencc/Config.hpp"}}))
  33. end)