summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-06-15 09:30:59 +0800
committerruki <[email protected]>2019-06-15 09:30:59 +0800
commitb9d1112e010f26972e8510e19211f3aa87a1b6ae (patch)
tree0cfdd96a42be017c4154a0639f6160afba722758
parent115665bd7ad421d448b7dda421303096a677dd72 (diff)
load lex/yacc in rule
-rw-r--r--xmake/rules/lex_yacc/lex/xmake.lua16
-rw-r--r--xmake/rules/lex_yacc/yacc/xmake.lua12
2 files changed, 28 insertions, 0 deletions
diff --git a/xmake/rules/lex_yacc/lex/xmake.lua b/xmake/rules/lex_yacc/lex/xmake.lua
index 1f49731c1..4aaaeb96a 100644
--- a/xmake/rules/lex_yacc/lex/xmake.lua
+++ b/xmake/rules/lex_yacc/lex/xmake.lua
@@ -26,4 +26,20 @@ rule("lex")
-- load lex/flex
before_load(function (target)
+ import("core.project.config")
+ import("lib.detect.find_tool")
+ local lex = config.get("lex")
+ if not lex then
+ lex = find_tool("flex") or find_tool("lex")
+ if lex and lex.program then
+ config.set("lex", lex.program)
+ cprint("checking for the Lex ... ${color.success}%s", lex.program)
+ else
+ cprint("checking for the Lex ... ${color.nothing}${text.nothing}")
+ end
+ end
+ end)
+
+ -- build lex file
+ on_build_file(function (target, sourcefile_lex, opt)
end)
diff --git a/xmake/rules/lex_yacc/yacc/xmake.lua b/xmake/rules/lex_yacc/yacc/xmake.lua
index 5a7e3ae76..4297df6dd 100644
--- a/xmake/rules/lex_yacc/yacc/xmake.lua
+++ b/xmake/rules/lex_yacc/yacc/xmake.lua
@@ -26,4 +26,16 @@ rule("yacc")
-- load yacc/bison
before_load(function (target)
+ import("core.project.config")
+ import("lib.detect.find_tool")
+ local yacc = config.get("yacc")
+ if not yacc then
+ yacc = find_tool("bison") or find_tool("yacc")
+ if yacc and yacc.program then
+ config.set("yacc", yacc.program)
+ cprint("checking for the Yacc ... ${color.success}%s", yacc.program)
+ else
+ cprint("checking for the Yacc ... ${color.nothing}${text.nothing}")
+ end
+ end
end)