Skip to content

Commit

Permalink
add build.always_update_configfiles policy #4747
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Feb 19, 2024
1 parent e2d9752 commit f133d02
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion xmake/actions/config/configfiles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ function _get_configfiles()
srcinfo.dependfile = target:dependfile(srcfile)
end

-- always update?
local always_update = target:policy("build.always_update_configfiles")
if always_update == nil then
always_update = project.policy("build.always_update_configfiles")
end
srcinfo.always_update = always_update

-- save targets
srcinfo.targets = srcinfo.targets or {}
table.insert(srcinfo.targets, target)
Expand Down Expand Up @@ -320,6 +327,7 @@ function main(opt)
opt = opt or {}
local oldir = os.cd(project.directory())


-- generate all configuration files
local configfiles = _get_configfiles()
for dstfile, srcinfo in pairs(configfiles) do
Expand All @@ -328,7 +336,7 @@ function main(opt)
end, {files = srcinfo.srcfile,
lastmtime = os.mtime(dstfile),
dependfile = srcinfo.dependfile,
changed = opt.force})
changed = opt.force or srcinfo.always_update})
end

-- leave project directory
Expand Down
2 changes: 2 additions & 0 deletions xmake/core/project/policy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ function policy.policies()
["build.ccache"] = {description = "Enable C/C++ build cache.", type = "boolean"},
-- Use global storage if build.ccache is enabled
["build.ccache.global_storage"] = {description = "Use global storge if build.ccache is enabled.", type = "boolean"},
-- Always update configfiles when building
["build.always_update_configfiles"] = {description = "Always update configfiles when building.", type = "boolean"},
-- Enable build warning output, it's enabled by default.
["build.warning"] = {description = "Enable build warning output.", default = true, type = "boolean"},
-- Enable LTO linker-time optimization for c/c++ building.
Expand Down

0 comments on commit f133d02

Please sign in to comment.