Skip to content

Commit

Permalink
improve to rebuild target xmake-io#4154
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi authored and tokomine committed Oct 30, 2023
1 parent 54c989b commit e6abfd5
Show file tree
Hide file tree
Showing 19 changed files with 31 additions and 19 deletions.
11 changes: 9 additions & 2 deletions xmake/actions/build/build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 = {}
Expand All @@ -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

Expand Down
5 changes: 5 additions & 0 deletions xmake/core/project/target.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion xmake/modules/private/action/build/object.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion xmake/rules/c++/modules/modules_support/clang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion xmake/rules/c++/modules/modules_support/gcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion xmake/rules/c++/modules/modules_support/msvc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion xmake/rules/qt/deploy/android.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion xmake/rules/qt/deploy/macosx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion xmake/rules/utils/merge_object/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion xmake/rules/utils/symbols/extract/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion xmake/rules/wdk/inf/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion xmake/rules/wdk/man/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion xmake/rules/wdk/mc/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion xmake/rules/wdk/mof/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion xmake/rules/wdk/sign/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion xmake/rules/wdk/tracewpp/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion xmake/rules/xcode/info_plist/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion xmake/rules/xcode/storyboard/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion xmake/rules/xcode/xcassets/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e6abfd5

Please sign in to comment.