Просмотр исходного кода

Add winflexbison (windows support for bison and flex) (#1004)

Jérôme Leclercq 3 лет назад
Родитель
Сommit
48871df589
3 измененных файлов с 56 добавлено и 4 удалено
  1. 11 2
      packages/b/bison/xmake.lua
  2. 11 2
      packages/f/flex/xmake.lua
  3. 34 0
      packages/w/winflexbison/xmake.lua

+ 11 - 2
packages/b/bison/xmake.lua

@@ -5,15 +5,24 @@ package("bison")
     set_description("A general-purpose parser generator.")
     set_license("GPL-3.0")
 
-    add_urls("http://ftp.gnu.org/gnu/bison/bison-$(version).tar.gz")
+    if not is_plat("windows") then
+        add_urls("http://ftp.gnu.org/gnu/bison/bison-$(version).tar.gz")
+    end
+
     add_versions("3.7.4", "fbabc7359ccd8b4b36d47bfe37ebbce44805c052526d5558b95eda125d1677e2")
     add_versions("3.7.6", "69dc0bb46ea8fc307d4ca1e0b61c8c355eb207d0b0c69f4f8462328e74d7b9ea")
     add_versions("3.8.2", "06c9e13bdf7eb24d4ceb6b59205a4f67c2c7e7213119644430fe82fbd14a0abb")
 
-    if is_plat("linux", "bsd") then
+    if is_plat("windows") then
+        add_deps("winflexbison")
+    elseif is_plat("linux", "bsd") then
         add_deps("m4")
     end
 
+    on_install("windows", function (package)
+        -- nothing to do, winflexbison does everything
+    end)
+
     on_install("macosx", "linux", "bsd", function (package)
         import("package.tools.autoconf").install(package)
         os.rm(package:installdir("share", "doc"))

+ 11 - 2
packages/f/flex/xmake.lua

@@ -4,13 +4,22 @@ package("flex")
     set_homepage("https://github.com/westes/flex/")
     set_license("BSD-2-Clause")
 
-    add_urls("https://github.com/westes/flex/releases/download/v$(version)/flex-$(version).tar.gz")
+    if not is_plat("windows") then
+        add_urls("https://github.com/westes/flex/releases/download/v$(version)/flex-$(version).tar.gz")
+    end
+
     add_versions("2.6.4", "e87aae032bf07c26f85ac0ed3250998c37621d95f8bd748b31f15b33c45ee995")
 
-    if is_plat("linux") then
+    if is_plat("windows") then
+        add_deps("winflexbison")
+    elseif is_plat("linux") then
         add_deps("m4")
     end
 
+    on_install("windows", function (package)
+        -- nothing to do, winflexbison does everything
+    end)
+
     on_install("macosx", "linux", function (package)
         import("package.tools.autoconf").install(package)
     end)

+ 34 - 0
packages/w/winflexbison/xmake.lua

@@ -0,0 +1,34 @@
+package("winflexbison")
+
+    set_kind("binary")
+
+    set_homepage("https://github.com/lexxmark/winflexbison")
+    set_description("Win flex-bison is a windows port the Flex (the fast lexical analyser) and Bison (GNU parser generator)")
+    set_license("GPL")
+
+    set_urls("https://github.com/lexxmark/winflexbison/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/lexxmark/winflexbison.git")
+
+    add_versions("v2.5.25", "8e1b71e037b524ba3f576babb0cf59182061df1f19cd86112f085a882560f60b")
+
+    add_deps("cmake")
+
+    on_install("windows", function (package)
+        local debugType = (package:debug() and "Debug" or "Release")
+        local configs = {}
+        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. debugType)
+        table.insert(configs, "-DUSE_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
+
+        import("package.tools.cmake").build(package, configs)
+
+        os.mv("custom_build_rules", package:installdir("bin"))
+        os.mv("flex/src/FlexLexer.h", package:installdir("include"))
+        os.mv(path.join("bin", debugType, "*"), package:installdir("bin"))
+        os.cp(path.join(package:installdir("bin"), "win_bison.exe"), path.join(package:installdir("bin"), "bison.exe"))
+        os.cp(path.join(package:installdir("bin"), "win_flex.exe"), path.join(package:installdir("bin"), "flex.exe"))
+    end)
+
+    on_test(function (package)
+        os.vrun("win_bison.exe -h")
+        os.vrun("win_flex.exe -h")
+    end)