summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-03-12 00:42:34 +0800
committerruki <[email protected]>2024-03-12 00:42:34 +0800
commite1166c435b5715873ac5118beb6465f7fa22a4f7 (patch)
treee549c63f635664d7a56faee3f0ceef63050406a7
parentb450d1d7e1f8da386fc8d5fcb0239232962a4eb0 (diff)
improve lex and yacc #4820
-rw-r--r--xmake/rules/lex_yacc/yacc/xmake.lua8
1 files changed, 6 insertions, 2 deletions
diff --git a/xmake/rules/lex_yacc/yacc/xmake.lua b/xmake/rules/lex_yacc/yacc/xmake.lua
index 96da386b3..501bd2b00 100644
--- a/xmake/rules/lex_yacc/yacc/xmake.lua
+++ b/xmake/rules/lex_yacc/yacc/xmake.lua
@@ -23,8 +23,12 @@ rule("yacc")
add_deps("c++")
set_extensions(".y", ".yy")
on_load(function (target)
- local sourcefile_dir = path.join(target:autogendir(), "rules", "yacc_yacc")
- target:add("includedirs", sourcefile_dir)
+ -- add yacc includedirs if there are yacc files
+ -- @see https://github.com/xmake-io/xmake/issues/4820
+ if target:sourcebatches()["yacc"] then
+ local sourcefile_dir = path.join(target:autogendir(), "rules", "yacc_yacc")
+ target:add("includedirs", sourcefile_dir)
+ end
end)
before_buildcmd_file(function (target, batchcmds, sourcefile_yacc, opt)