xmake.lua 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package("bison")
  2. set_kind("binary")
  3. set_homepage("https://www.gnu.org/software/bison/")
  4. set_description("A general-purpose parser generator.")
  5. set_license("GPL-3.0")
  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://ftp.gnu.org/gnu/bison/bison-$(version).tar.gz",
  10. "https://mirrors.ustc.edu.cn/gnu/bison/bison-$(version).tar.gz",
  11. "https://mirror.csclub.uwaterloo.ca/gnu/bison/bison-$(version).tar.gz")
  12. end
  13. end)
  14. elseif not is_plat("windows", "mingw", "msys") then
  15. add_urls("https://ftp.gnu.org/gnu/bison/bison-$(version).tar.gz",
  16. "https://mirrors.ustc.edu.cn/gnu/bison/bison-$(version).tar.gz",
  17. "https://mirror.csclub.uwaterloo.ca/gnu/bison/bison-$(version).tar.gz")
  18. end
  19. add_versions("3.7.4", "fbabc7359ccd8b4b36d47bfe37ebbce44805c052526d5558b95eda125d1677e2")
  20. add_versions("3.7.6", "69dc0bb46ea8fc307d4ca1e0b61c8c355eb207d0b0c69f4f8462328e74d7b9ea")
  21. add_versions("3.8.2", "06c9e13bdf7eb24d4ceb6b59205a4f67c2c7e7213119644430fe82fbd14a0abb")
  22. on_load("macosx", "linux", "bsd", "windows", "@msys", function (package)
  23. if package:is_plat("windows") then
  24. package:add("deps", "winflexbison", {private = true})
  25. elseif package:is_plat("linux", "bsd") then
  26. package:add("deps", "m4")
  27. end
  28. -- we always set it, because bison may be modified as library
  29. -- by add_deps("bison", {kind = "library"})
  30. package:addenv("PATH", "bin")
  31. if package:is_library() then
  32. package:set("kind", "library", {headeronly = true})
  33. end
  34. if is_subhost("msys") and xmake:version():ge("2.9.7") then
  35. package:add("deps", "pacman::bison", {configs = {msystem = "msys"}})
  36. end
  37. end)
  38. on_install("@msys", function (package) 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", "flex.exe"))
  42. os.rm(path.join(package:installdir(), "include", "FlexLexer.h"))
  43. end)
  44. on_install("macosx", "linux", "bsd", "android", "iphoneos", "cross", function (package)
  45. import("package.tools.autoconf").install(package)
  46. os.rm(package:installdir("share", "doc"))
  47. end)
  48. on_test(function (package)
  49. if not package:is_cross() then
  50. os.vrun("bison -h")
  51. end
  52. end)