diff options
| author | ruki <[email protected]> | 2019-05-11 00:42:14 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-05-10 22:13:29 +0800 |
| commit | ffa81cffcd6788d70b05a96cd5cc9ab2bbc52ce5 (patch) | |
| tree | f3aed645a033b2b6d7c4737d776eb6e6cfd5d7fe | |
| parent | 788106769627016f41c510e23212a54039d8bb32 (diff) | |
improve force and shallow to require package
| -rw-r--r-- | xmake/actions/require/impl/action/download.lua | 4 | ||||
| -rw-r--r-- | xmake/actions/require/impl/package.lua | 23 | ||||
| -rw-r--r-- | xmake/core/package/package.lua | 13 |
3 files changed, 26 insertions, 14 deletions
diff --git a/xmake/actions/require/impl/action/download.lua b/xmake/actions/require/impl/action/download.lua index 699d3a063..15a5d3570 100644 --- a/xmake/actions/require/impl/action/download.lua +++ b/xmake/actions/require/impl/action/download.lua @@ -47,7 +47,7 @@ function _checkout(package, url, sourcedir, url_alias) -- use previous source directory if exists local packagedir = path.join(sourcedir, package:name()) - if os.isdir(packagedir) and (not option.get("force") or option.get("shallow")) then + if os.isdir(packagedir) then -- clean the previous build files git.clean({repodir = packagedir, force = true}) @@ -96,7 +96,7 @@ function _download(package, url, sourcedir, url_alias, url_excludes) -- the package file have been downloaded? local cached = true - if (option.get("force") and not option.get("shallow")) or not os.isfile(packagefile) or sourcehash ~= hash.sha256(packagefile) then + if not os.isfile(packagefile) or sourcehash ~= hash.sha256(packagefile) then -- no cached cached = false diff --git a/xmake/actions/require/impl/package.lua b/xmake/actions/require/impl/package.lua index 10d71974f..39889efcc 100644 --- a/xmake/actions/require/impl/package.lua +++ b/xmake/actions/require/impl/package.lua @@ -362,11 +362,12 @@ function _load_packages(requires, opt) if package then -- load dependent packages and save them first of this package - if not package._DEPS and not option.get("shallow") then + if not package._DEPS then local deps = package:get("deps") if deps and opt.nodeps ~= true then local packagedeps = {} for _, dep in ipairs(_load_packages(deps, {requires_extra = package:get("__extra_deps"), parentinfo = requireinfo.info, nodeps = opt.nodeps})) do + dep:parents_add(package) table.insert(packages, dep) packagedeps[dep:name()] = dep end @@ -696,23 +697,21 @@ function install_packages(requires, opt) local packages = load_packages(requires, opt) -- fetch packages (with system) from local first - if not option.get("force") then - process.runjobs(function (index) - local package = packages[index] - if package then - package:envs_enter() - package:fetch() - package:envs_leave() - end - end, #packages) - end + process.runjobs(function (index) + local package = packages[index] + if package and (not option.get("force") or (option.get("shallow") and package:parents())) then + package:envs_enter() + package:fetch() + package:envs_leave() + end + end, #packages) -- filter packages local packages_install = {} local packages_download = {} local packages_unsupported = {} for _, package in ipairs(packages) do - if (option.get("force") or not package:exists()) and (#package:urls() > 0 or package:script("install")) then + if not package:exists() and (#package:urls() > 0 or package:script("install")) then if package:supported() then if #package:urls() > 0 then packages_download[tostring(package)] = package diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index 301a4ea94..78b012a71 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -196,6 +196,19 @@ function _instance:deps_add(...) end end +-- get parents +function _instance:parents() + return self._PARENTS +end + +-- add parents +function _instance:parents_add(...) + for _, parent in ipairs({...}) do + self._PARENTS = self._PARENTS or {} + self._PARENTS[parent:name()] = parent + end +end + -- get hash of the source package for the url_alias@version_str function _instance:sourcehash(url_alias) |
