summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-05-22 23:59:41 +0800
committerruki <[email protected]>2021-05-22 23:59:41 +0800
commitbd080f2c7943471935bf5d67b04484bed5ace455 (patch)
treeaae79096718dd38b1767a61fc8ecd4e0855afa98
parentfdfa79d46fbaf0f674e343f4939859cbe9bbe40f (diff)
improve config cache
-rw-r--r--xmake/actions/config/main.lua16
-rw-r--r--xmake/modules/private/action/require/impl/actions/download.lua6
-rw-r--r--xmake/modules/private/action/require/impl/actions/download_resources.lua2
3 files changed, 12 insertions, 12 deletions
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua
index 54bcc6a1f..3393e1603 100644
--- a/xmake/actions/config/main.lua
+++ b/xmake/actions/config/main.lua
@@ -65,17 +65,12 @@ function _need_check(changed)
changed = option.get("clean")
end
- -- get the current mtimes
+ -- check for all project files
local mtimes = project.mtimes()
-
- -- get the previous mtimes
if not changed then
local mtimes_prev = localcache.get("config", "mtimes")
if mtimes_prev then
-
- -- check for all project files
for file, mtime in pairs(mtimes) do
-
-- modified? reconfig and rebuild it
local mtime_prev = mtimes_prev[file]
if not mtime_prev or mtime > mtime_prev then
@@ -86,6 +81,11 @@ function _need_check(changed)
end
end
+ -- unfinished config/recheck
+ if not changed and localcache.get("config", "recheck") then
+ changed = true
+ end
+
-- xmake has been updated? force to check config again
-- we need clean the dirty config cache of the old version
if not changed then
@@ -96,8 +96,6 @@ function _need_check(changed)
-- update mtimes
localcache.set("config", "mtimes", mtimes)
-
- -- changed?
return changed
end
@@ -314,6 +312,7 @@ force to build in current directory via run `xmake -P .`]], os.projectdir())
localcache.clear("option")
localcache.clear("package")
localcache.clear("toolchain")
+ localcache.set("config", "recheck", true)
localcache.save()
-- check platform
@@ -369,6 +368,7 @@ force to build in current directory via run `xmake -P .`]], os.projectdir())
end
-- save options and config cache
+ localcache.set("config", "recheck", false)
config.save()
localcache.set("config", "options", options)
localcache.save("config")
diff --git a/xmake/modules/private/action/require/impl/actions/download.lua b/xmake/modules/private/action/require/impl/actions/download.lua
index 6af797b5e..03396cd00 100644
--- a/xmake/modules/private/action/require/impl/actions/download.lua
+++ b/xmake/modules/private/action/require/impl/actions/download.lua
@@ -70,13 +70,13 @@ function _checkout(package, url, sourcedir, url_alias)
if package:branch() then
-- only shadow clone this branch
- git.clone(proxy.mirror(url), {depth = 1, recursive = true, longpaths = longpaths, branch = package:branch(), outputdir = packagedir})
+ git.clone(proxy.mirror(url) or url, {depth = 1, recursive = true, longpaths = longpaths, branch = package:branch(), outputdir = packagedir})
-- download package from revision or tag?
else
-- clone whole history and tags
- git.clone(proxy.mirror(url), {longpaths = longpaths, outputdir = packagedir})
+ git.clone(proxy.mirror(url) or url, {longpaths = longpaths, outputdir = packagedir})
-- attempt to checkout the given version
local revision = package:revision(url_alias) or package:tag() or package:version_str()
@@ -137,7 +137,7 @@ function _download(package, url, sourcedir, url_alias, url_excludes)
-- we can use local package from the search directories directly if network is too slow
os.cp(localfile, packagefile)
else
- http.download(proxy.mirror(url), packagefile)
+ http.download(proxy.mirror(url) or url, packagefile)
end
end
diff --git a/xmake/modules/private/action/require/impl/actions/download_resources.lua b/xmake/modules/private/action/require/impl/actions/download_resources.lua
index 5a85c7c35..f878b27b8 100644
--- a/xmake/modules/private/action/require/impl/actions/download_resources.lua
+++ b/xmake/modules/private/action/require/impl/actions/download_resources.lua
@@ -56,7 +56,7 @@ function _download(package, resource_name, resource_url, resource_hash)
-- we can use local resource from the search directories directly if network is too slow
os.cp(localfile, resource_file)
elseif resource_url:find(string.ipattern("https-://")) or resource_url:find(string.ipattern("ftps-://")) then
- http.download(proxy.mirror(resource_url), resource_file)
+ http.download(proxy.mirror(resource_url) or resource_url, resource_file)
else
raise("invalid resource url(%s)", resource_url)
end