xmake.lua 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package("swig")
  2. set_kind("binary")
  3. set_homepage("http://swig.org/")
  4. set_description("SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages.")
  5. set_license("GPL-3.0")
  6. if is_host("windows") then
  7. add_urls("https://sourceforge.net/projects/swig/files/swigwin/swigwin-$(version)/swigwin-$(version).zip")
  8. add_versions("4.0.2", "daadb32f19fe818cb9b0015243233fc81584844c11a48436385e87c050346559")
  9. add_versions("4.1.1", "2ec3107e24606db535d77ef3dbf246dc6eccbf1d5c868dce365d7f7fb19a1a51")
  10. else
  11. add_urls("https://sourceforge.net/projects/swig/files/swig/swig-$(version)/swig-$(version).tar.gz")
  12. add_versions("4.0.2", "d53be9730d8d58a16bf0cbd1f8ac0c0c3e1090573168bfa151b01eb47fa906fc")
  13. add_versions("4.1.1", "2af08aced8fcd65cdb5cc62426768914bedc735b1c250325203716f78e39ac9b")
  14. end
  15. on_load("@macosx", "@linux", function (package)
  16. if package:version():ge("4.1") then
  17. package:add("deps", "pcre2", {host = true})
  18. else
  19. package:add("deps", "pcre", {host = true})
  20. end
  21. end)
  22. on_fetch(function (package, opt)
  23. if opt.system then
  24. return package:find_tool("swig")
  25. end
  26. end)
  27. on_install("@windows", function (package)
  28. os.cp("*|Doc|Examples", package:installdir())
  29. package:addenv("PATH", ".")
  30. end)
  31. on_install("@macosx", "@linux", function (package)
  32. local configs = {}
  33. if package:version():ge("4.1") then
  34. local pcre2 = package:dep("pcre2")
  35. if pcre2 and not pcre2:is_system() then
  36. table.insert(configs, "--with-pcre2-prefix=" .. pcre2:installdir())
  37. end
  38. else
  39. local pcre = package:dep("pcre")
  40. if pcre and not pcre:is_system() then
  41. table.insert(configs, "--with-pcre-prefix=" .. pcre:installdir())
  42. end
  43. end
  44. import("package.tools.autoconf").install(package, configs)
  45. end)
  46. on_test(function (package)
  47. os.vrun("swig -version")
  48. end)