diff options
| author | ruki <[email protected]> | 2021-06-25 22:42:55 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-06-25 22:42:55 +0800 |
| commit | e90da39112c300c003cc9482acfcec7f28e85efc (patch) | |
| tree | e47d4afd373ae07d54daa9d95b8b5e1a750c24a5 /xmake/modules/private | |
| parent | cfdd992044c10dce5c181a3b61e38021926c399a (diff) | |
install precompiled artifacts
Diffstat (limited to 'xmake/modules/private')
4 files changed, 43 insertions, 3 deletions
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 ffa303cde..e603b3d9f 100644 --- a/xmake/modules/private/action/require/impl/actions/download_resources.lua +++ b/xmake/modules/private/action/require/impl/actions/download_resources.lua @@ -128,6 +128,11 @@ end -- download all resources of the given package function main(package) + -- we need not download it if we use the precompiled artifacts to install package + if not package:is_built() then + return + end + -- no resources? local resources = package:resources() if not resources then diff --git a/xmake/modules/private/action/require/impl/actions/patch_sources.lua b/xmake/modules/private/action/require/impl/actions/patch_sources.lua index d3ca226b1..23d46f3d3 100644 --- a/xmake/modules/private/action/require/impl/actions/patch_sources.lua +++ b/xmake/modules/private/action/require/impl/actions/patch_sources.lua @@ -100,6 +100,11 @@ end -- patch the given package function main(package) + -- we need not patch it if we use the precompiled artifacts to install package + if not package:is_built() then + return + end + -- no patches? local patches = package:patches() if not patches then diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua index e3fa7e3af..d66686482 100644 --- a/xmake/modules/private/action/require/impl/package.lua +++ b/xmake/modules/private/action/require/impl/package.lua @@ -78,6 +78,7 @@ end -- true: only get system package -- false: only get remote packages -- +-- {build = true}: always build packages, we do not use the precompiled artifacts -- function _parse_require(require_str) @@ -173,7 +174,8 @@ function _load_require(require_str, requires_extra, parentinfo) optional = parentinfo.optional or require_extra.optional, -- default: false, inherit parentinfo.optional verify = require_extra.verify, -- default: true, we can set false to ignore sha256sum and select any version external = require_extra.external, -- default: true, we use sysincludedirs/-isystem instead of -I/xxx - private = require_extra.private -- default: false, private package, only for installation, do not export any links/includes and environments + private = require_extra.private, -- default: false, private package, only for installation, do not export any links/includes and environments + build = require_extra.build -- default: false, always build packages, we do not use the precompiled artifacts } return required.packagename, required.requireinfo end @@ -544,8 +546,12 @@ function _load_package(packagename, requireinfo, opt) end -- load package from repositories + local from_repo = false if not package then package = _load_package_from_repository(packagename, requireinfo.reponame) + if package then + from_repo = true + end end -- load package from system @@ -616,6 +622,18 @@ function _load_package(packagename, requireinfo, opt) -- check package configurations _check_package_configurations(package) + -- save artifacts info, we need add it at last before buildhash need depend on package configurations + if from_repo and not option.get("build") and not requireinfo.build then + local artifacts_manifest = repository.artifacts_manifest(packagename, version) + if artifacts_manifest then + local buildid = package:plat() .. "-" .. package:arch() .. "-" .. package:buildhash() + local artifacts_info = artifacts_manifest[buildid] + if artifacts_info then + package:artifacts_set(artifacts_info) + end + end + end + -- do load local on_load = package:script("load") if on_load then diff --git a/xmake/modules/private/action/require/impl/repository.lua b/xmake/modules/private/action/require/impl/repository.lua index f997ee703..4dbf44e52 100644 --- a/xmake/modules/private/action/require/impl/repository.lua +++ b/xmake/modules/private/action/require/impl/repository.lua @@ -51,6 +51,7 @@ end function packagedir(packagename, reponame) -- strip trailng ~tag, e.g. zlib~debug + packagename = packagename:lower() if packagename:find('~', 1, true) then packagename = packagename:gsub("~.+$", "") end @@ -64,8 +65,8 @@ function packagedir(packagename, reponame) -- find the package directory from repositories for _, repo in ipairs(repositories()) do - local dir = path.join(repo:directory(), "packages", packagename:sub(1, 1):lower(), packagename) - if os.isdir(dir) and (not reponame or reponame == repo:name()) then + local dir = path.join(repo:directory(), "packages", packagename:sub(1, 1), packagename) + if os.isdir(dir) and os.isfile(path.join(dir, "xmake.lua")) and (not reponame or reponame == repo:name()) then foundir = {dir, repo} break end @@ -77,6 +78,17 @@ function packagedir(packagename, reponame) end end +-- get artifacts manifest from repositories +function artifacts_manifest(packagename, version) + packagename = packagename:lower() + for _, repo in ipairs(repositories()) do + local manifestfile = path.join(repo:directory(), "packages", packagename:sub(1, 1), packagename, version, "manifest.txt") + if os.isfile(manifestfile) then + return io.load(manifestfile) + end + end +end + -- search package directories from repositories function searchdirs(name) |
