summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-05-05 21:50:48 +0800
committerruki <[email protected]>2019-05-05 21:50:48 +0800
commitf97082c4db805cf7989eb6a2a1cd549a1d6d49a5 (patch)
tree7530d05a74a058c137b1e15cdd839b37fb0a2d32
parentdfdbe5da7702606001a2141082708f6ed5acd733 (diff)
improve fetch package and envs
-rw-r--r--xmake/actions/require/impl/package.lua5
-rw-r--r--xmake/core/package/package.lua30
-rw-r--r--xmake/modules/package/manager/xmake/find_package.lua7
3 files changed, 33 insertions, 9 deletions
diff --git a/xmake/actions/require/impl/package.lua b/xmake/actions/require/impl/package.lua
index 56f1b9f7e..4f49b4a11 100644
--- a/xmake/actions/require/impl/package.lua
+++ b/xmake/actions/require/impl/package.lua
@@ -332,6 +332,9 @@ function _load_package(packagename, requireinfo)
on_load(package)
end
+ -- load environments from the manifest
+ package:envs_load()
+
-- save this package package to cache
packages[packagename] = package
_g._PACKAGES = packages
@@ -697,7 +700,9 @@ function install_packages(requires, opt)
process.runjobs(function (index)
local package = packages[index]
if package then
+ package:envs_enter()
package:fetch()
+ package:envs_leave()
end
end, #packages)
end
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 2687a4fd4..6e160ac93 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -270,16 +270,19 @@ end
-- load the manifest file of this package
function _instance:manifest_load()
- local manifest_file = self:manifest_file()
- if os.isfile(manifest_file) then
-
- -- load manifest
- local manifest, errors = io.load(manifest_file)
- if not manifest then
- os.raise(errors)
+ local manifest = self._MANIFEST
+ if not manifest then
+ local manifest_file = self:manifest_file()
+ if os.isfile(manifest_file) then
+ local errors = nil
+ manifest, errors = io.load(manifest_file)
+ if not manifest then
+ os.raise(errors)
+ end
+ self._MANIFEST = manifest
end
- return manifest
end
+ return manifest
end
-- save the manifest file of this package
@@ -340,6 +343,17 @@ function _instance:envs()
return envs
end
+-- load the package environments from the manifest
+function _instance:envs_load()
+ local manifest = self:manifest_load()
+ if manifest then
+ local envs = self:envs()
+ for name, values in pairs(manifest.envs) do
+ envs[name] = values
+ end
+ end
+end
+
-- enter the package environments
function _instance:envs_enter()
diff --git a/xmake/modules/package/manager/xmake/find_package.lua b/xmake/modules/package/manager/xmake/find_package.lua
index c589561a9..595612ba2 100644
--- a/xmake/modules/package/manager/xmake/find_package.lua
+++ b/xmake/modules/package/manager/xmake/find_package.lua
@@ -31,9 +31,14 @@ import("lib.detect.find_library")
-- find package from the repository (maybe only include and no links)
function _find_package_from_repo(name, opt)
+ -- check options
+ if not opt.version or not opt.buildhash then
+ return
+ end
+
-- find the manifest file of package, .e.g ~/.xmake/packages/z/zlib/1.1.12/ed41d5327fad3fc06fe376b4a94f62ef/manifest.txt
local packagedirs = {}
- table.insert(packagedirs, path.join(package.installdir(), name:sub(1, 1), name, opt.version or "*", opt.buildhash))
+ table.insert(packagedirs, path.join(package.installdir(), name:sub(1, 1), name, opt.version, opt.buildhash))
local manifest_file = find_file("manifest.txt", packagedirs)
if not manifest_file then
return