summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-11-09 00:33:39 +0800
committerruki <[email protected]>2018-11-08 21:21:57 +0800
commit03cd8eb7dce64295cf9ed5a11695796d23a18019 (patch)
tree3dee48b2809e2331d5136bfd2d2f6d6542a3aa31
parentd41f7ae50ae262ed3017c3713db50b79985e28e8 (diff)
move the on_load position of pacakge
-rw-r--r--xmake/actions/require/impl/package.lua8
-rw-r--r--xmake/core/package/package.lua27
2 files changed, 8 insertions, 27 deletions
diff --git a/xmake/actions/require/impl/package.lua b/xmake/actions/require/impl/package.lua
index 7a5885e76..89d39d5be 100644
--- a/xmake/actions/require/impl/package.lua
+++ b/xmake/actions/require/impl/package.lua
@@ -395,6 +395,14 @@ function load_packages(requires, opt)
for _, package in ipairs(packages) do
local key = package:name() .. (package:version_str() or "")
if not unique[key] then
+
+ -- do load for package
+ local on_load = package:script("load")
+ if on_load then
+ on_load(package)
+ end
+
+ -- add package
table.insert(results, package)
unique[key] = true
end
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index e209a2532..b0ae85bd3 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -772,15 +772,6 @@ function package.load_from_system(packagename)
-- mark as system package
instance._FROMKIND = "system"
- -- do load for package
- local on_load = instance:script("load")
- if on_load then
- local ok, errors = sandbox.load(on_load, instance)
- if not ok then
- return nil, errors
- end
- end
-
-- save instance to the cache
package._PACKAGES[packagename] = instance
@@ -820,15 +811,6 @@ function package.load_from_project(packagename, project)
-- mark as local package
instance._FROMKIND = "local"
- -- do load for package
- local on_load = instance:script("load")
- if on_load then
- local ok, errors = sandbox.load(on_load, instance)
- if not ok then
- return nil, errors
- end
- end
-
-- save instance to the cache
package._PACKAGES[packagename] = instance
@@ -888,15 +870,6 @@ function package.load_from_repository(packagename, repo, packagedir, packagefile
-- mark as global/project package?
instance._FROMKIND = repo:is_global() and "global" or "local"
- -- do load for package
- local on_load = instance:script("load")
- if on_load then
- local ok, errors = sandbox.load(on_load, instance)
- if not ok then
- return nil, errors
- end
- end
-
-- save instance to the cache
package._PACKAGES[packagename] = instance