diff options
| -rw-r--r-- | xmake/rules/lex_yacc/lex/xmake.lua | 16 | ||||
| -rw-r--r-- | xmake/rules/lex_yacc/yacc/xmake.lua | 12 |
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) |
