summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-09-01 00:39:52 +0800
committerruki <[email protected]>2023-09-01 00:39:52 +0800
commit6dc3f73929a7dde224d77bbcd5db54be22958cda (patch)
treece48016aca43fe9d4830a8963f74820957a7dced
parent515dbd9e94793b0bd126a19ecc8f482752897ed9 (diff)
improve to rebuild target #4154
-rw-r--r--xmake/actions/build/build.lua11
-rw-r--r--xmake/core/project/target.lua5
-rw-r--r--xmake/modules/private/action/build/object.lua2
-rw-r--r--xmake/rules/c++/modules/modules_support/clang.lua2
-rw-r--r--xmake/rules/c++/modules/modules_support/gcc.lua2
-rw-r--r--xmake/rules/c++/modules/modules_support/msvc.lua2
-rw-r--r--xmake/rules/qt/deploy/android.lua2
-rw-r--r--xmake/rules/qt/deploy/macosx.lua2
-rw-r--r--xmake/rules/utils/merge_object/xmake.lua2
-rw-r--r--xmake/rules/utils/symbols/extract/xmake.lua2
-rw-r--r--xmake/rules/wdk/inf/xmake.lua2
-rw-r--r--xmake/rules/wdk/man/xmake.lua2
-rw-r--r--xmake/rules/wdk/mc/xmake.lua2
-rw-r--r--xmake/rules/wdk/mof/xmake.lua2
-rw-r--r--xmake/rules/wdk/sign/xmake.lua2
-rw-r--r--xmake/rules/wdk/tracewpp/xmake.lua2
-rw-r--r--xmake/rules/xcode/info_plist/xmake.lua2
-rw-r--r--xmake/rules/xcode/storyboard/xmake.lua2
-rw-r--r--xmake/rules/xcode/xcassets/xmake.lua2
19 files changed, 31 insertions, 19 deletions
diff --git a/xmake/actions/build/build.lua b/xmake/actions/build/build.lua
index 69b1de5da..227786a9f 100644
--- a/xmake/actions/build/build.lua
+++ b/xmake/actions/build/build.lua
@@ -178,7 +178,7 @@ function _add_batchjobs_for_target(batchjobs, rootjob, target)
end
-- clean target if rebuild
- if option.get("rebuild") and not option.get("dry-run") then
+ if target:is_rebuilt() and not option.get("dry-run") then
_clean_target(target)
end
@@ -234,7 +234,11 @@ function get_batchjobs(targetname, group_pattern)
-- get root targets
local targets_root = {}
if targetname then
- table.insert(targets_root, project.target(targetname))
+ local target = project.target(targetname)
+ table.insert(targets_root, target)
+ if option.get("rebuild") then
+ target:data_set("rebuilt", true)
+ end
else
local depset = hashset.new()
local targets = {}
@@ -253,6 +257,9 @@ function get_batchjobs(targetname, group_pattern)
if not depset:has(target:name()) then
table.insert(targets_root, target)
end
+ if option.get("rebuild") then
+ target:data_set("rebuilt", true)
+ end
end
end
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index a537b5986..491c00729 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -878,6 +878,11 @@ function _instance:is_enabled()
return self:get("enabled") ~= false
end
+-- is rebuilt?
+function _instance:is_rebuilt()
+ return self:data("rebuilt")
+end
+
-- get the enabled option
function _instance:opt(name)
return self:opts()[name]
diff --git a/xmake/modules/private/action/build/object.lua b/xmake/modules/private/action/build/object.lua
index 6668d9695..5b8188d49 100644
--- a/xmake/modules/private/action/build/object.lua
+++ b/xmake/modules/private/action/build/object.lua
@@ -43,7 +43,7 @@ function _do_build_file(target, sourcefile, opt)
local compflags = compinst:compflags({target = target, sourcefile = sourcefile, configs = opt.configs})
-- load dependent info
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
-- dry run?
local dryrun = option.get("dry-run")
diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua
index 9f7e2225d..a65defe53 100644
--- a/xmake/rules/c++/modules/modules_support/clang.lua
+++ b/xmake/rules/c++/modules/modules_support/clang.lua
@@ -247,7 +247,7 @@ function _build_modulefile(target, sourcefile, opt)
local dependfile = opt.dependfile
local compinst = compiler.load("cxx", {target = target})
local compflags = compinst:compflags({sourcefile = sourcefile, target = target})
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
-- need build this object?
local dryrun = option.get("dry-run")
diff --git a/xmake/rules/c++/modules/modules_support/gcc.lua b/xmake/rules/c++/modules/modules_support/gcc.lua
index 20b783821..206bf3c43 100644
--- a/xmake/rules/c++/modules/modules_support/gcc.lua
+++ b/xmake/rules/c++/modules/modules_support/gcc.lua
@@ -123,7 +123,7 @@ function _build_modulefile(target, sourcefile, opt)
local dependfile = opt.dependfile
local compinst = compiler.load("cxx", {target = target})
local compflags = table.join("-x", "c++", compinst:compflags({sourcefile = sourcefile, target = target}))
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
-- need build this object?
local dryrun = option.get("dry-run")
diff --git a/xmake/rules/c++/modules/modules_support/msvc.lua b/xmake/rules/c++/modules/modules_support/msvc.lua
index 0372ca997..3e7dce2ba 100644
--- a/xmake/rules/c++/modules/modules_support/msvc.lua
+++ b/xmake/rules/c++/modules/modules_support/msvc.lua
@@ -100,7 +100,7 @@ function _build_modulefile(target, sourcefile, opt)
local dependfile = opt.dependfile
local compinst = compiler.load("cxx", {target = target})
local compflags = compinst:compflags({sourcefile = sourcefile, target = target})
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
-- need build this object?
local dryrun = option.get("dry-run")
diff --git a/xmake/rules/qt/deploy/android.lua b/xmake/rules/qt/deploy/android.lua
index 5aea7fa02..9299c61e0 100644
--- a/xmake/rules/qt/deploy/android.lua
+++ b/xmake/rules/qt/deploy/android.lua
@@ -45,7 +45,7 @@ function main(target, opt)
-- need re-generate this apk?
local targetfile = target:targetfile()
local dependfile = target:dependfile(target_apk)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(dependfile)}) then
return
end
diff --git a/xmake/rules/qt/deploy/macosx.lua b/xmake/rules/qt/deploy/macosx.lua
index 5abbe4263..7cc056099 100644
--- a/xmake/rules/qt/deploy/macosx.lua
+++ b/xmake/rules/qt/deploy/macosx.lua
@@ -79,7 +79,7 @@ function main(target, opt)
local target_app = path.join(target:targetdir(), target:basename() .. ".app")
local targetfile = target:targetfile()
local dependfile = target:dependfile(target_app)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(dependfile)}) then
return
end
diff --git a/xmake/rules/utils/merge_object/xmake.lua b/xmake/rules/utils/merge_object/xmake.lua
index 8bebb5f5c..f53138a6d 100644
--- a/xmake/rules/utils/merge_object/xmake.lua
+++ b/xmake/rules/utils/merge_object/xmake.lua
@@ -41,7 +41,7 @@ rule("utils.merge.object")
-- load dependent info
local dependfile = target:dependfile(objectfile)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
-- need build this object?
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(objectfile)}) then
diff --git a/xmake/rules/utils/symbols/extract/xmake.lua b/xmake/rules/utils/symbols/extract/xmake.lua
index dd1f3a1df..cdc1e044a 100644
--- a/xmake/rules/utils/symbols/extract/xmake.lua
+++ b/xmake/rules/utils/symbols/extract/xmake.lua
@@ -67,7 +67,7 @@ rule("utils.symbols.extract")
local symbolfile = target:symbolfile()
local targetfile = target:targetfile()
local dependfile = target:dependfile(symbolfile)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(dependfile)}) then
return
end
diff --git a/xmake/rules/wdk/inf/xmake.lua b/xmake/rules/wdk/inf/xmake.lua
index 354fbc5a7..19533a463 100644
--- a/xmake/rules/wdk/inf/xmake.lua
+++ b/xmake/rules/wdk/inf/xmake.lua
@@ -83,7 +83,7 @@ rule("wdk.inf")
-- need build this object?
local dependfile = target:dependfile(targetfile)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(targetfile), values = args}) then
return
end
diff --git a/xmake/rules/wdk/man/xmake.lua b/xmake/rules/wdk/man/xmake.lua
index c5219aa56..c9859b9b8 100644
--- a/xmake/rules/wdk/man/xmake.lua
+++ b/xmake/rules/wdk/man/xmake.lua
@@ -110,7 +110,7 @@ rule("wdk.man")
-- need build this object?
local dependfile = target:dependfile(headerfile)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(headerfile), values = args}) then
return
end
diff --git a/xmake/rules/wdk/mc/xmake.lua b/xmake/rules/wdk/mc/xmake.lua
index 689c9786c..2c016a85d 100644
--- a/xmake/rules/wdk/mc/xmake.lua
+++ b/xmake/rules/wdk/mc/xmake.lua
@@ -92,7 +92,7 @@ rule("wdk.mc")
-- need build this object?
local dependfile = target:dependfile(headerfile)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(headerfile), values = args}) then
return
end
diff --git a/xmake/rules/wdk/mof/xmake.lua b/xmake/rules/wdk/mof/xmake.lua
index a1a2a0366..25e3d6a03 100644
--- a/xmake/rules/wdk/mof/xmake.lua
+++ b/xmake/rules/wdk/mof/xmake.lua
@@ -102,7 +102,7 @@ rule("wdk.mof")
-- need build this object?
local dependfile = target:dependfile(headerfile)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(headerfile), values = args}) then
return
end
diff --git a/xmake/rules/wdk/sign/xmake.lua b/xmake/rules/wdk/sign/xmake.lua
index 6be72e7b3..32d8fc936 100644
--- a/xmake/rules/wdk/sign/xmake.lua
+++ b/xmake/rules/wdk/sign/xmake.lua
@@ -98,7 +98,7 @@ rule("wdk.sign")
-- need build this object?
local tempfile = os.tmpfile(target:targetfile())
local dependfile = tempfile .. ".d"
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(tempfile)}) then
return
end
diff --git a/xmake/rules/wdk/tracewpp/xmake.lua b/xmake/rules/wdk/tracewpp/xmake.lua
index 75f4f37ef..650b0c4db 100644
--- a/xmake/rules/wdk/tracewpp/xmake.lua
+++ b/xmake/rules/wdk/tracewpp/xmake.lua
@@ -88,7 +88,7 @@ rule("wdk.tracewpp")
-- need build this object?
local targetfile = path.join(outputdir, path.basename(sourcefile) .. ".tmh")
local dependfile = target:dependfile(targetfile)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(targetfile), values = args}) then
return
end
diff --git a/xmake/rules/xcode/info_plist/xmake.lua b/xmake/rules/xcode/info_plist/xmake.lua
index ddcc30336..235481846 100644
--- a/xmake/rules/xcode/info_plist/xmake.lua
+++ b/xmake/rules/xcode/info_plist/xmake.lua
@@ -43,7 +43,7 @@ rule("xcode.info_plist")
-- need re-compile it?
local dependfile = target:dependfile(sourcefile)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(dependfile)}) then
return
end
diff --git a/xmake/rules/xcode/storyboard/xmake.lua b/xmake/rules/xcode/storyboard/xmake.lua
index 3db9db4c3..129e130c2 100644
--- a/xmake/rules/xcode/storyboard/xmake.lua
+++ b/xmake/rules/xcode/storyboard/xmake.lua
@@ -46,7 +46,7 @@ rule("xcode.storyboard")
-- need re-compile it?
local dependfile = target:dependfile(sourcefile)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(dependfile)}) then
return
end
diff --git a/xmake/rules/xcode/xcassets/xmake.lua b/xmake/rules/xcode/xcassets/xmake.lua
index 9322d10c1..4479b6b95 100644
--- a/xmake/rules/xcode/xcassets/xmake.lua
+++ b/xmake/rules/xcode/xcassets/xmake.lua
@@ -43,7 +43,7 @@ rule("xcode.xcassets")
-- need re-compile it?
local dependfile = target:dependfile(sourcefile)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(dependfile)}) then
return
end