From eec7b3465a4d80529a907182183e11261c3c12d5 Mon Sep 17 00:00:00 2001 From: carols Date: Mon, 8 Apr 2024 22:07:28 +0800 Subject: After the change of h2, recompile cpp2 containing this h2 --- xmake/rules/cppfront/xmake.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'xmake/rules/cppfront') diff --git a/xmake/rules/cppfront/xmake.lua b/xmake/rules/cppfront/xmake.lua index b90222aa9..b2d0b093e 100644 --- a/xmake/rules/cppfront/xmake.lua +++ b/xmake/rules/cppfront/xmake.lua @@ -21,8 +21,7 @@ rule("cppfront.build.h2") set_extensions(".h2") - on_buildcmd_file(function (target, batchcmds, sourcefile_h2, opt) - + before_buildcmd_file(function (target, batchcmds, sourcefile_h2, opt) -- get cppfront import("lib.detect.find_tool") local cppfront = assert(find_tool("cppfront", {check = "-h"}), "cppfront not found!") @@ -65,7 +64,6 @@ rule("cppfront.build.cpp2") end end) on_buildcmd_file(function (target, batchcmds, sourcefile_cpp2, opt) - -- get cppfront import("lib.detect.find_tool") local cppfront = assert(find_tool("cppfront", {check = "-h"}), "cppfront not found!") @@ -78,6 +76,14 @@ rule("cppfront.build.cpp2") local objectfile = target:objectfile(sourcefile_cpp) table.insert(target:objectfiles(), objectfile) + -- add_depfiles for #include "xxxx/xxxx/xxx.h2" ,exclude // #include "xxxx.h2" + local lines = io.lines(sourcefile_cpp2) + for line in lines do + match_h2 = string.match(line, "^ -#include *\"([%w%p]+.h2)\"") + if match_h2 ~= nil then + batchcmds:add_depfiles(path.join(path.directory(sourcefile_cpp2), match_h2)) + end + end -- add commands local argv = {"-o", path(sourcefile_cpp), path(sourcefile_cpp2)} batchcmds:show_progress(opt.progress, "${color.build.object}compiling.cpp2 %s", sourcefile_cpp2) -- cgit v1.3.1 From ce5259b8ef77f1bb8ad983abc2d4a4392bd6f6ea Mon Sep 17 00:00:00 2001 From: carols Date: Tue, 9 Apr 2024 12:07:47 +0800 Subject: h2 changed use on_buildcmd_file, string.match(line -> line:match --- xmake/rules/cppfront/xmake.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'xmake/rules/cppfront') diff --git a/xmake/rules/cppfront/xmake.lua b/xmake/rules/cppfront/xmake.lua index b2d0b093e..8803a7a38 100644 --- a/xmake/rules/cppfront/xmake.lua +++ b/xmake/rules/cppfront/xmake.lua @@ -21,7 +21,7 @@ rule("cppfront.build.h2") set_extensions(".h2") - before_buildcmd_file(function (target, batchcmds, sourcefile_h2, opt) + on_buildcmd_file(function (target, batchcmds, sourcefile_h2, opt) -- get cppfront import("lib.detect.find_tool") local cppfront = assert(find_tool("cppfront", {check = "-h"}), "cppfront not found!") @@ -79,7 +79,7 @@ rule("cppfront.build.cpp2") -- add_depfiles for #include "xxxx/xxxx/xxx.h2" ,exclude // #include "xxxx.h2" local lines = io.lines(sourcefile_cpp2) for line in lines do - match_h2 = string.match(line, "^ -#include *\"([%w%p]+.h2)\"") + match_h2 = line:match("^ -#include *\"([%w%p]+.h2)\"") if match_h2 ~= nil then batchcmds:add_depfiles(path.join(path.directory(sourcefile_cpp2), match_h2)) end -- cgit v1.3.1 From bb97da112be686014a4807ed951f7a520a9f0248 Mon Sep 17 00:00:00 2001 From: carols Date: Tue, 9 Apr 2024 20:00:05 +0800 Subject: cppfront: use local,and optimize some speed --- xmake/rules/cppfront/xmake.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'xmake/rules/cppfront') diff --git a/xmake/rules/cppfront/xmake.lua b/xmake/rules/cppfront/xmake.lua index 8803a7a38..7d92e0b08 100644 --- a/xmake/rules/cppfront/xmake.lua +++ b/xmake/rules/cppfront/xmake.lua @@ -77,11 +77,11 @@ rule("cppfront.build.cpp2") table.insert(target:objectfiles(), objectfile) -- add_depfiles for #include "xxxx/xxxx/xxx.h2" ,exclude // #include "xxxx.h2" - local lines = io.lines(sourcefile_cpp2) - for line in lines do - match_h2 = line:match("^ -#include *\"([%w%p]+.h2)\"") + local root_dir = path.directory(sourcefile_cpp2) + for line in io.lines(sourcefile_cpp2) do + local match_h2 = line:match("^ -#include *\"([%w%p]+.h2)\"") if match_h2 ~= nil then - batchcmds:add_depfiles(path.join(path.directory(sourcefile_cpp2), match_h2)) + batchcmds:add_depfiles(path.join(root_dir, match_h2)) end end -- add commands -- cgit v1.3.1