diff options
| author | ruki <[email protected]> | 2021-03-12 00:41:28 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-03-12 00:41:28 +0800 |
| commit | e963699a72d351970cbd31246b601a9731e006a5 (patch) | |
| tree | 743f2729bade415410695fa2b18b5dc7dd0fdf6c | |
| parent | 051264aa60973d3b7a1654412ea936e1da3a515c (diff) | |
support fetchonly
9 files changed, 53 insertions, 44 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index 7a6fd4fe3..36a50146b 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -326,6 +326,23 @@ function _instance:is_toplevel() return not self:parents() end +-- is the system package? +function _instance:is_system() + return self._is_system +end + +-- is the third-party package? e.g. brew::pcre2/libpcre2-8, conan::OpenSSL/1.0.2n@conan/stable +-- we need install and find package by third-party package manager directly +-- +function _instance:is_thirdparty() + return self._is_thirdparty +end + +-- is fetch only? +function _instance:is_fetchonly() + return self:get("fetch") and not self:get("install") +end + -- get the filelock of the whole package directory function _instance:filelock() local filelock = self._FILELOCK @@ -702,7 +719,7 @@ end -- get the version string function _instance:version_str() - if self:is3rd() then + if self:is_thirdparty() then local requireinfo = self:requireinfo() if requireinfo then return requireinfo.version @@ -923,18 +940,6 @@ function _instance:parallelize() return self:get("parallelize") ~= false end --- is the third-party package? e.g. brew::pcre2/libpcre2-8, conan::OpenSSL/1.0.2n@conan/stable --- we need install and find package by third-party package manager directly --- -function _instance:is3rd() - return self._is3rd -end - --- is the system package? -function _instance:isSys() - return self._isSys -end - -- get xxx_script function _instance:script(name, generic) @@ -1011,7 +1016,7 @@ function _instance:_fetch_tool(opt) self._find_tool = self._find_tool or sandbox_module.import("lib.detect.find_tool", {anonymous = true}) if opt.system then local fetchnames = {self:name()} - if not self:is3rd() then + if not self:is_thirdparty() then table.join2(fetchnames, self:extsources()) end for _, fetchname in ipairs(fetchnames) do @@ -1063,7 +1068,7 @@ function _instance:_fetch_library(opt) self._find_package = self._find_package or sandbox_module.import("lib.detect.find_package", {anonymous = true}) if opt.system then local fetchnames = {self:name()} - if not self:is3rd() then + if not self:is_thirdparty() then table.join2(fetchnames, self:extsources()) end for _, fetchname in ipairs(fetchnames) do @@ -1072,7 +1077,7 @@ function _instance:_fetch_library(opt) require_version = opt.require_version, mode = self:mode(), pkgconfigs = self:configs(), - buildhash = self:is3rd() and self:buildhash(), -- only for 3rd package manager, e.g. go:: .. + buildhash = self:is_thirdparty() and self:buildhash(), -- only for 3rd package manager, e.g. go:: .. cachekey = "fetch_package_system", external = opt.external, system = true}) @@ -1112,7 +1117,7 @@ function _instance:fetch(opt) -- fetch the require version local require_ver = opt.version or self:requireinfo().version - if not self:is3rd() and not require_ver:find('.', 1, true) then + if not self:is_thirdparty() and not require_ver:find('.', 1, true) then -- strip branch version only system package require_ver = nil end @@ -1124,7 +1129,7 @@ function _instance:fetch(opt) if system == nil then system = self:requireinfo().system end - if self:is3rd() then + if self:is_thirdparty() then -- we need ignore `{system = true/false}` argument if be 3rd package -- @see https://github.com/xmake-io/xmake/issues/726 system = nil @@ -1143,14 +1148,14 @@ function _instance:fetch(opt) -- fetch binary tool? fetchinfo = nil - local isSys = nil + local is_system = nil if self:is_binary() then -- only fetch it from the xmake repository first - if not fetchinfo and system ~= true and not self:is3rd() then + if not fetchinfo and system ~= true and not self:is_thirdparty() then fetchinfo = self:_fetch_tool({require_version = self:version_str(), force = opt.force}) if fetchinfo then - isSys = self._isSys + is_system = self._is_system end end @@ -1158,16 +1163,16 @@ function _instance:fetch(opt) if not fetchinfo and system ~= false then fetchinfo = self:_fetch_tool({system = true, require_version = require_ver, force = opt.force}) if fetchinfo then - isSys = true + is_system = true end end else -- only fetch it from the xmake repository first - if not fetchinfo and system ~= true and not self:is3rd() then + if not fetchinfo and system ~= true and not self:is_thirdparty() then fetchinfo = self:_fetch_library({require_version = self:version_str(), external = external, force = opt.force}) if fetchinfo then - isSys = self._isSys + is_system = self._is_system end end @@ -1175,7 +1180,7 @@ function _instance:fetch(opt) if not fetchinfo and system ~= false then fetchinfo = self:_fetch_library({system = true, require_version = require_ver, external = external, force = opt.force}) if fetchinfo then - isSys = true + is_system = true end end end @@ -1184,8 +1189,8 @@ function _instance:fetch(opt) self._FETCHINFO = fetchinfo -- mark as system package? - if isSys ~= nil then - self._isSys = isSys + if is_system ~= nil then + self._is_system = is_system end return fetchinfo end @@ -1658,7 +1663,7 @@ function package.load_from_system(packagename) -- get package info local packageinfo = {} - local is3rd = false + local is_thirdparty = false if packagename:find("::", 1, true) then -- get interpreter @@ -1686,7 +1691,7 @@ function package.load_from_system(packagename) -- is third-party package? if not packagename:startswith("xmake::") then - is3rd = true + is_thirdparty = true end end @@ -1694,10 +1699,10 @@ function package.load_from_system(packagename) instance = _instance.new(packagename, scopeinfo.new("package", packageinfo)) -- mark as system or 3rd package - instance._isSys = true - instance._is3rd = is3rd + instance._is_system = true + instance._is_thirdparty = is_thirdparty - if is3rd then + if is_thirdparty then -- add configurations for the 3rd package local install_package = sandbox_module.import("package.manager." .. packagename:split("::")[1]:lower() .. ".install_package", {try = true, anonymous = true}) if install_package and install_package.configurations then diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index ba3592a32..548b00e40 100644 --- a/xmake/modules/package/tools/cmake.lua +++ b/xmake/modules/package/tools/cmake.lua @@ -452,7 +452,7 @@ function buildenvs(package, opt) local CMAKE_INCLUDE_PATH = {} local CMAKE_PREFIX_PATH = {} for _, dep in ipairs(package:orderdeps()) do - if dep:isSys() then + if dep:is_system() then local fetchinfo = dep:fetch() if fetchinfo then table.join2(CMAKE_LIBRARY_PATH, fetchinfo.linkdirs) diff --git a/xmake/modules/private/action/require/impl/actions/install.lua b/xmake/modules/private/action/require/impl/actions/install.lua index e280d0cec..91cee4ba3 100644 --- a/xmake/modules/private/action/require/impl/actions/install.lua +++ b/xmake/modules/private/action/require/impl/actions/install.lua @@ -146,7 +146,7 @@ function main(package) -- install the third-party package directly, e.g. brew::pcre2/libpcre2-8, conan::OpenSSL/1.0.2n@conan/stable local installed_now = false - if package:is3rd() then + if package:is_thirdparty() then local script = package:script("install") if script ~= nil then filter.call(script, package) diff --git a/xmake/modules/private/action/require/impl/install_packages.lua b/xmake/modules/private/action/require/impl/install_packages.lua index 036f2ac2d..d89f83e05 100644 --- a/xmake/modules/private/action/require/impl/install_packages.lua +++ b/xmake/modules/private/action/require/impl/install_packages.lua @@ -105,8 +105,8 @@ function _get_confirm(packages) local packages_group = {} for _, instance in ipairs(packages) do -- achive packages by repository - local reponame = instance:repo() and instance:repo():name() or (instance:isSys() and "system" or "") - if instance:is3rd() then + local reponame = instance:repo() and instance:repo():name() or (instance:is_system() and "system" or "") + if instance:is_thirdparty() then reponame = instance:name():lower():split("::")[1] end packages_repo[reponame] = packages_repo[reponame] or {} diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua index 3095e10a9..c088bef4c 100644 --- a/xmake/modules/private/action/require/impl/package.lua +++ b/xmake/modules/private/action/require/impl/package.lua @@ -587,6 +587,10 @@ function should_install(package) if package:exists() then return false end + -- we need not install it if this package need only be fetched + if package:is_fetchonly() then + return false + end if package:parents() then -- if all the packages that depend on it already exist, then there is no need to install it for _, parent in pairs(package:parents()) do diff --git a/xmake/modules/private/action/require/impl/register_packages.lua b/xmake/modules/private/action/require/impl/register_packages.lua index 21716bc3f..485da8770 100644 --- a/xmake/modules/private/action/require/impl/register_packages.lua +++ b/xmake/modules/private/action/require/impl/register_packages.lua @@ -68,7 +68,7 @@ end -- register the base info of required package function _register_required_package_base(instance, required_package) - if not instance:isSys() and not instance:is3rd() then + if not instance:is_system() and not instance:is_thirdparty() then required_package:set("__installdir", instance:installdir()) end end diff --git a/xmake/modules/private/action/require/info.lua b/xmake/modules/private/action/require/info.lua index 37d4eb6a3..1c5977134 100644 --- a/xmake/modules/private/action/require/info.lua +++ b/xmake/modules/private/action/require/info.lua @@ -37,9 +37,9 @@ import("private.action.require.impl.utils.get_requires") function _from(instance) local fetchinfo = instance:fetch() if fetchinfo then - if instance:is3rd() then + if instance:is_thirdparty() then return ", ${green}3rd${clear}" - elseif instance:isSys() then + elseif instance:is_system() then return ", ${green}system${clear}" else return "" @@ -48,7 +48,7 @@ function _from(instance) local repo = instance:repo() local reponame = repo and repo:name() or "unknown" return instance:supported() and format(", ${yellow}remote${clear}(in %s)", reponame) or format(", ${yellow}remote${clear}(${red}unsupported${clear} in %s)", reponame) - elseif instance:isSys() then + elseif instance:is_system() then return ", ${red}missing${clear}" else return "" diff --git a/xmake/modules/private/action/require/list.lua b/xmake/modules/private/action/require/list.lua index 2a165111b..95a4158ba 100644 --- a/xmake/modules/private/action/require/list.lua +++ b/xmake/modules/private/action/require/list.lua @@ -29,16 +29,16 @@ import("private.action.require.impl.environment") function _from(instance) local fetchinfo = instance:fetch() if fetchinfo then - if instance:is3rd() then + if instance:is_thirdparty() then return ", ${green}3rd${clear}" - elseif instance:isSys() then + elseif instance:is_system() then return ", ${green}system${clear}" else return "" end elseif #instance:urls() > 0 then return instance:supported() and format(", ${yellow}remote${clear}(in %s)", instance:repo():name()) or format(", ${yellow}remote${clear}(${red}unsupported${clear} in %s)", instance:repo():name()) - elseif instance:isSys() then + elseif instance:is_system() then return ", ${red}missing${clear}" else return "" diff --git a/xmake/modules/private/xrepo/action/env.lua b/xmake/modules/private/xrepo/action/env.lua index cc49534c7..46fe2cbe7 100644 --- a/xmake/modules/private/xrepo/action/env.lua +++ b/xmake/modules/private/xrepo/action/env.lua @@ -166,7 +166,7 @@ end function _package_addenvs(envs, instance) -- only for xmake::package - if instance:isSys() then + if instance:is_system() then return end |
