Skip to content

Commit

Permalink
fix flex (#5275)
Browse files Browse the repository at this point in the history
* fix flex

* fix flex deps
  • Loading branch information
waruqi authored Sep 18, 2024
1 parent 9286276 commit f008565
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
30 changes: 18 additions & 12 deletions packages/f/flex/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,31 @@ package("flex")
set_homepage("https://github.com/westes/flex/")
set_license("BSD-2-Clause")

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("windows") then
add_deps("winflexbison", {private = true})
elseif is_plat("linux") then
add_deps("m4")
if on_source then
on_source(function (package)
if not package:is_plat("windows") then
package:add("urls", "https://github.com/westes/flex/releases/download/v$(version)/flex-$(version).tar.gz")
end
end)
elseif not is_plat("windows") then
add_urls("https://github.com/westes/flex/releases/download/v$(version)/flex-$(version).tar.gz")
end

on_load("macosx", "linux", "bsd", "windows", function (package)
if package:is_plat("windows") then
package:add("deps", "winflexbison", {private = true})
elseif package:is_plat("linux") then
package:add("deps", "m4")
end

-- we always set it, because flex may be modified as library
-- by add_deps("flex", {kind = "library"})
package:addenv("PATH", "bin")
if package:is_library() then
package:set("kind", "library", {headeronly = true})
end
end)

on_install("windows", function (package)
Expand All @@ -28,16 +37,13 @@ package("flex")

on_install("macosx", "linux", "bsd", "android", "iphoneos", "cross", function (package)
import("package.tools.autoconf").install(package)
if not package:is_binary() then
package:add("links", "")
end
end)

on_test(function (package)
if not package:is_cross() then
os.vrun("flex -h")
end
if not package:is_binary() then
if package:is_library() then
assert(package:has_cxxincludes("FlexLexer.h"))
end
end)
5 changes: 4 additions & 1 deletion packages/w/winflexbison/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ package("winflexbison")
-- we always set it, because flex may be modified as library
-- by add_deps("winflexbison", {kind = "library"})
package:addenv("PATH", "bin")
if package:config("flex") and package:is_library() then
package:set("kind", "library", {headeronly = true})
end
end)

on_install("windows", function (package)
Expand All @@ -42,7 +45,7 @@ package("winflexbison")
end
if package:config("flex") then
os.vrun("flex.exe -h")
if not package:is_binary() then
if package:is_library() then
assert(package:has_cxxincludes("FlexLexer.h"))
end
end
Expand Down

0 comments on commit f008565

Please sign in to comment.