xmake.lua 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package("winflexbison")
  2. set_kind("binary")
  3. set_homepage("https://github.com/lexxmark/winflexbison")
  4. set_description("Win flex-bison is a windows port the Flex (the fast lexical analyser) and Bison (GNU parser generator)")
  5. set_license("GPL")
  6. set_urls("https://github.com/lexxmark/winflexbison/archive/refs/tags/$(version).tar.gz",
  7. "https://github.com/lexxmark/winflexbison.git")
  8. add_versions("v2.5.25", "8e1b71e037b524ba3f576babb0cf59182061df1f19cd86112f085a882560f60b")
  9. add_configs("flex", {description = "Enable flex", default = true, type = "boolean"})
  10. add_configs("bison", {description = "Enable bison", default = true, type = "boolean"})
  11. add_deps("cmake")
  12. on_load(function (package)
  13. -- we always set it, because flex may be modified as library
  14. -- by add_deps("winflexbison", {kind = "library"})
  15. package:addenv("PATH", "bin")
  16. end)
  17. on_install("windows", function (package)
  18. local mode = (package:debug() and "Debug" or "Release")
  19. local configs = {}
  20. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. mode)
  21. import("package.tools.cmake").build(package, configs)
  22. os.cp("custom_build_rules", package:installdir("bin"))
  23. os.cp(path.join("bin", mode, "*"), package:installdir("bin"))
  24. if package:config("flex") then
  25. os.cp("flex/src/FlexLexer.h", package:installdir("include"))
  26. os.cp(path.join(package:installdir("bin"), "win_flex.exe"), path.join(package:installdir("bin"), "flex.exe"))
  27. end
  28. if package:config("bison") then
  29. os.cp(path.join(package:installdir("bin"), "win_bison.exe"), path.join(package:installdir("bin"), "bison.exe"))
  30. end
  31. end)
  32. on_test(function (package)
  33. if package:config("bison") then
  34. os.vrun("bison.exe -h")
  35. end
  36. if package:config("flex") then
  37. os.vrun("flex.exe -h")
  38. if not package:is_binary() then
  39. assert(package:has_cxxincludes("FlexLexer.h"))
  40. end
  41. end
  42. end)