xmake.lua 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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", "http://ftpmirror.gnu.org/gnu/bison/bison-$(version).tar.gz",
  10. "http://ftp.gnu.org/gnu/bison/bison-$(version).tar.gz")
  11. end
  12. end)
  13. elseif not is_plat("windows", "mingw", "msys") then
  14. add_urls("http://ftpmirror.gnu.org/gnu/bison/bison-$(version).tar.gz",
  15. "http://ftp.gnu.org/gnu/bison/bison-$(version).tar.gz")
  16. end
  17. add_versions("3.7.4", "fbabc7359ccd8b4b36d47bfe37ebbce44805c052526d5558b95eda125d1677e2")
  18. add_versions("3.7.6", "69dc0bb46ea8fc307d4ca1e0b61c8c355eb207d0b0c69f4f8462328e74d7b9ea")
  19. add_versions("3.8.2", "06c9e13bdf7eb24d4ceb6b59205a4f67c2c7e7213119644430fe82fbd14a0abb")
  20. on_load("macosx", "linux", "bsd", "windows", "@msys", function (package)
  21. if package:is_plat("windows") then
  22. package:add("deps", "winflexbison", {private = true})
  23. elseif package:is_plat("linux", "bsd") then
  24. package:add("deps", "m4")
  25. end
  26. -- we always set it, because bison may be modified as library
  27. -- by add_deps("bison", {kind = "library"})
  28. package:addenv("PATH", "bin")
  29. if package:is_library() then
  30. package:set("kind", "library", {headeronly = true})
  31. end
  32. if is_subhost("msys") and xmake:version():ge("2.9.7") then
  33. package:add("deps", "pacman::bison", {configs = {msystem = "msys"}})
  34. end
  35. end)
  36. on_install("@msys", function (package) end)
  37. on_install("windows", function (package)
  38. os.cp(path.join(package:dep("winflexbison"):installdir(), "*"), package:installdir())
  39. os.rm(path.join(package:installdir(), "bin", "flex.exe"))
  40. os.rm(path.join(package:installdir(), "include", "FlexLexer.h"))
  41. end)
  42. on_install("macosx", "linux", "bsd", "android", "iphoneos", "cross", function (package)
  43. import("package.tools.autoconf").install(package)
  44. os.rm(package:installdir("share", "doc"))
  45. end)
  46. on_test(function (package)
  47. if not package:is_cross() then
  48. os.vrun("bison -h")
  49. end
  50. end)