xmake.lua 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package("flex")
  2. set_kind("library", {headeronly = true})
  3. set_homepage("https://github.com/westes/flex/")
  4. set_license("BSD-2-Clause")
  5. add_versions("2.6.4", "e87aae032bf07c26f85ac0ed3250998c37621d95f8bd748b31f15b33c45ee995")
  6. if on_source then
  7. on_source(function (package)
  8. if not package:is_plat("windows", "mingw", "msys") then
  9. package:add("urls", "https://github.com/westes/flex/releases/download/v$(version)/flex-$(version).tar.gz")
  10. end
  11. end)
  12. elseif not is_plat("windows", "mingw", "msys") then
  13. add_urls("https://github.com/westes/flex/releases/download/v$(version)/flex-$(version).tar.gz")
  14. end
  15. on_load("macosx", "linux", "bsd", "windows", "@msys", function (package)
  16. if package:is_plat("windows") then
  17. package:add("deps", "winflexbison", {private = true})
  18. elseif package:is_plat("linux") then
  19. package:add("deps", "m4")
  20. end
  21. if is_subhost("msys") and xmake:version():ge("2.9.7") then
  22. package:add("deps", "pacman::flex", {private = true, configs = {msystem = "msys"}})
  23. end
  24. if not package:is_cross() then
  25. package:addenv("PATH", "bin")
  26. end
  27. -- https://github.com/Seifert69/DikuMUD3/issues/70#issuecomment-1100932157
  28. -- Don't link libfl.so
  29. package:add("links", "")
  30. end)
  31. on_install("@msys", function (package)
  32. -- https://github.com/msys2/MSYS2-packages/issues/1911
  33. if package:is_library() then
  34. local msys_dir = os.getenv("MINGW_PREFIX")
  35. local header = path.join(path.directory(msys_dir), "usr/include/FlexLexer.h")
  36. os.vcp(header, package:installdir("include"))
  37. end
  38. end)
  39. on_install("windows", function (package)
  40. os.cp(path.join(package:dep("winflexbison"):installdir(), "*"), package:installdir())
  41. os.rm(path.join(package:installdir(), "bin", "bison.exe"))
  42. end)
  43. on_install("macosx", "linux", "bsd", function (package)
  44. local configs = {}
  45. table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
  46. table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
  47. if package:is_debug() then
  48. table.insert(configs, "--enable-debug")
  49. end
  50. import("package.tools.autoconf").install(package, configs)
  51. end)
  52. on_test(function (package)
  53. if not package:is_cross() then
  54. os.vrun("flex -h")
  55. end
  56. if package:is_library() then
  57. assert(package:has_cxxincludes("FlexLexer.h"))
  58. end
  59. end)