xmake.lua 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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") 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") 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", 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. -- we always set it, because flex may be modified as library
  22. -- by add_deps("flex", {kind = "library"})
  23. package:addenv("PATH", "bin")
  24. if package:is_library() then
  25. package:set("kind", "library", {headeronly = true})
  26. end
  27. end)
  28. on_install("windows", function (package)
  29. os.cp(path.join(package:dep("winflexbison"):installdir(), "*"), package:installdir())
  30. os.rm(path.join(package:installdir(), "bin", "bison.exe"))
  31. end)
  32. on_install("macosx", "linux", "bsd", "android", "iphoneos", "cross", function (package)
  33. import("package.tools.autoconf").install(package)
  34. end)
  35. on_test(function (package)
  36. if not package:is_cross() then
  37. os.vrun("flex -h")
  38. end
  39. if package:is_library() then
  40. assert(package:has_cxxincludes("FlexLexer.h"))
  41. end
  42. end)