diff options
| author | ruki <[email protected]> | 2018-10-11 23:22:59 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-10-11 14:17:56 +0800 |
| commit | 336a34ee43980fdcace50990111f2f3c49b6d23a (patch) | |
| tree | d3b5dd6fa2c08ee597ae7dc12d1b497f7343c9d8 | |
| parent | 2b0891928e7c36256a95a90c37677ebdc7b5687d (diff) | |
add on_load for package
| -rw-r--r-- | xmake/actions/require/impl/action/install.lua | 2 | ||||
| -rw-r--r-- | xmake/core/package/package.lua | 30 |
2 files changed, 30 insertions, 2 deletions
diff --git a/xmake/actions/require/impl/action/install.lua b/xmake/actions/require/impl/action/install.lua index 42643b7ba..a39f38149 100644 --- a/xmake/actions/require/impl/action/install.lua +++ b/xmake/actions/require/impl/action/install.lua @@ -83,7 +83,7 @@ function main(package) prefix.uninstall(package) -- build and install package to the install directory - local installedfile = path.join(package:installdir(), "installed.txt") + local packagefile = path.join(package:installdir(), "info.txt") if not os.isfile(installedfile) then -- clean install directory first diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index fdc01169d..b6ab7ad71 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -610,7 +610,8 @@ function package.apis() , script = { -- package.on_xxx - "package.on_install" + "package.on_load" + , "package.on_install" , "package.on_test" -- package.before_xxx @@ -734,6 +735,15 @@ 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 @@ -773,6 +783,15 @@ 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 @@ -832,6 +851,15 @@ 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 |
