summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-06-15 10:16:24 +0800
committerruki <[email protected]>2019-06-15 10:16:24 +0800
commit5bc284eb77475d2d6b64b293a8320233a33b3229 (patch)
tree237d447287a5e3bde26c3ba77b281a8ae41986da
parent1540dce16cfc82189c0a8e00f72b9640be321aab (diff)
clean lex/yacc files
-rw-r--r--xmake/rules/lex_yacc/lex/xmake.lua12
-rw-r--r--xmake/rules/lex_yacc/yacc/xmake.lua14
-rw-r--r--xmake/rules/qt/moc/xmake.lua2
-rw-r--r--xmake/rules/qt/qrc/xmake.lua2
4 files changed, 21 insertions, 9 deletions
diff --git a/xmake/rules/lex_yacc/lex/xmake.lua b/xmake/rules/lex_yacc/lex/xmake.lua
index 0b1d93246..a34c82a19 100644
--- a/xmake/rules/lex_yacc/lex/xmake.lua
+++ b/xmake/rules/lex_yacc/lex/xmake.lua
@@ -58,7 +58,7 @@ rule("lex")
local extension = path.extension(sourcefile_lex)
-- get c/c++ source file for lex
- local sourcefile_cx = path.join(config.buildir(), ".lex_yacc", "lex", target:name(), path.basename(sourcefile_lex) .. (extension == ".ll" and ".cpp" or ".c"))
+ local sourcefile_cx = path.join(config.buildir(), ".lex_yacc", target:name(), path.basename(sourcefile_lex) .. (extension == ".ll" and ".cpp" or ".c"))
local sourcefile_dir = path.directory(sourcefile_cx)
-- get object file
@@ -68,7 +68,7 @@ rule("lex")
local compinst = compiler.load((extension == ".ll" and "cxx" or "cc"), {target = target})
-- get compile flags
- local compflags = compinst:compflags({target = target, sourcefile = sourcefile_cx})
+ local compflags = compinst:compflags({target = target, sourcefile = sourcefile_cx, configs = {includedirs = sourcefile_dir}})
-- add objectfile
table.insert(target:objectfiles(), objectfile)
@@ -106,10 +106,16 @@ rule("lex")
-- compile c++ source file for qrc
dependinfo.files = {}
- compinst:compile(sourcefile_cx, objectfile, {dependinfo = dependinfo, compflags = compflags})
+ assert(compinst:compile(sourcefile_cx, objectfile, {dependinfo = dependinfo, compflags = compflags}))
-- update files and values to the dependent file
dependinfo.values = depvalues
table.insert(dependinfo.files, sourcefile_lex)
depend.save(dependinfo, dependfile)
end)
+
+ -- clean files
+ after_clean(function (target)
+ import("core.project.config")
+ os.tryrm(path.join(config.buildir(), ".lex_yacc", target:name()))
+ end)
diff --git a/xmake/rules/lex_yacc/yacc/xmake.lua b/xmake/rules/lex_yacc/yacc/xmake.lua
index 546d98597..5867e5981 100644
--- a/xmake/rules/lex_yacc/yacc/xmake.lua
+++ b/xmake/rules/lex_yacc/yacc/xmake.lua
@@ -42,7 +42,7 @@ rule("yacc")
end)
-- build yacc file
- on_build_file(function (target, sourcefile_yacc, opt)
+ before_build_file(function (target, sourcefile_yacc, opt)
-- imports
import("core.base.option")
@@ -58,7 +58,7 @@ rule("yacc")
local extension = path.extension(sourcefile_yacc)
-- get c/c++ source file for yacc
- local sourcefile_cx = path.join(config.buildir(), ".lex_yacc", "yacc", target:name(), path.basename(sourcefile_yacc) .. (extension == ".yy" and ".cpp" or ".c"))
+ local sourcefile_cx = path.join(config.buildir(), ".lex_yacc", target:name(), path.basename(sourcefile_yacc) .. ".tab" .. (extension == ".yy" and ".cpp" or ".c"))
local sourcefile_dir = path.directory(sourcefile_cx)
-- get object file
@@ -97,7 +97,7 @@ rule("yacc")
end
-- compile yacc
- os.vrunv(yacc, {"-o", sourcefile_cx, sourcefile_yacc})
+ os.vrunv(yacc, {"-d", "-o", sourcefile_cx, sourcefile_yacc})
-- trace
if option.get("verbose") then
@@ -106,10 +106,16 @@ rule("yacc")
-- compile c++ source file for qrc
dependinfo.files = {}
- compinst:compile(sourcefile_cx, objectfile, {dependinfo = dependinfo, compflags = compflags})
+ assert(compinst:compile(sourcefile_cx, objectfile, {dependinfo = dependinfo, compflags = compflags}))
-- update files and values to the dependent file
dependinfo.values = depvalues
table.insert(dependinfo.files, sourcefile_yacc)
depend.save(dependinfo, dependfile)
end)
+
+ -- clean files
+ after_clean(function (target)
+ import("core.project.config")
+ os.tryrm(path.join(config.buildir(), ".lex_yacc", target:name()))
+ end)
diff --git a/xmake/rules/qt/moc/xmake.lua b/xmake/rules/qt/moc/xmake.lua
index e4bd6b93e..40be6bf07 100644
--- a/xmake/rules/qt/moc/xmake.lua
+++ b/xmake/rules/qt/moc/xmake.lua
@@ -92,7 +92,7 @@ rule("qt.moc")
-- compile c++ source file for moc
dependinfo.files = {}
- compinst:compile(sourcefile_moc, objectfile, {dependinfo = dependinfo, compflags = compflags})
+ assert(compinst:compile(sourcefile_moc, objectfile, {dependinfo = dependinfo, compflags = compflags}))
-- update files and values to the dependent file
dependinfo.values = depvalues
diff --git a/xmake/rules/qt/qrc/xmake.lua b/xmake/rules/qt/qrc/xmake.lua
index b296e9154..24a8a4b3a 100644
--- a/xmake/rules/qt/qrc/xmake.lua
+++ b/xmake/rules/qt/qrc/xmake.lua
@@ -100,7 +100,7 @@ rule("qt.qrc")
-- compile c++ source file for qrc
dependinfo.files = {}
- compinst:compile(sourcefile_cpp, objectfile, {dependinfo = dependinfo, compflags = compflags})
+ assert(compinst:compile(sourcefile_cpp, objectfile, {dependinfo = dependinfo, compflags = compflags}))
-- update files and values to the dependent file
dependinfo.values = depvalues