xmake.lua 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package("flex")
  2. set_kind("binary")
  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. if is_subhost("msys") then
  16. add_deps("pacman::flex")
  17. end
  18. on_load("macosx", "linux", "bsd", "windows", function (package)
  19. if package:is_plat("windows") then
  20. package:add("deps", "winflexbison", {private = true})
  21. elseif package:is_plat("linux") then
  22. package:add("deps", "m4")
  23. end
  24. -- we always set it, because flex may be modified as library
  25. -- by add_deps("flex", {kind = "library"})
  26. package:addenv("PATH", "bin")
  27. if package:is_library() then
  28. package:set("kind", "library", {headeronly = true})
  29. end
  30. end)
  31. on_install("@msys", function (package)
  32. end)
  33. on_install("windows", function (package)
  34. os.cp(path.join(package:dep("winflexbison"):installdir(), "*"), package:installdir())
  35. os.rm(path.join(package:installdir(), "bin", "bison.exe"))
  36. end)
  37. on_install("macosx", "linux", "bsd", "android", "iphoneos", "cross", function (package)
  38. import("package.tools.autoconf").install(package)
  39. end)
  40. on_test(function (package)
  41. if not package:is_cross() then
  42. os.vrun("flex -h")
  43. end
  44. if package:is_library() then
  45. assert(package:has_cxxincludes("FlexLexer.h"))
  46. end
  47. end)