diff options
| author | ruki <[email protected]> | 2018-04-11 22:32:32 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-04-11 09:15:15 +0800 |
| commit | 4b9de4cb6a555c80be771fad26fe4c00ac3f4e2e (patch) | |
| tree | 2eecb45ffd1745822c366f30dc6afd8dab2b1f54 | |
| parent | 2d1b8aeda4966843acdcc67851d941234630f147 (diff) | |
seperate project and package
| -rw-r--r-- | xmake/core/main.lua | 4 | ||||
| -rw-r--r-- | xmake/core/package/package.lua | 3 | ||||
| -rw-r--r-- | xmake/core/project/project.lua | 19 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/package/package.lua | 3 |
4 files changed, 7 insertions, 22 deletions
diff --git a/xmake/core/main.lua b/xmake/core/main.lua index 5bb50d850..9eec272ca 100644 --- a/xmake/core/main.lua +++ b/xmake/core/main.lua @@ -38,7 +38,6 @@ local task = require("base/task") local colors = require("base/colors") local project = require("project/project") local history = require("project/history") -local package = require("package/package") -- init the option menu local menu = @@ -213,9 +212,6 @@ force to build in current directory via run `xmake -P .`]], os.projectdir()) else os.addenv("PATH", os.programdir()) end - - -- define package apis first before loading project's xmake.lua - project.define_apis(package.apis()) end -- the main function diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index efb78c7fb..f26884f58 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -36,7 +36,6 @@ local global = require("base/global") local interpreter = require("base/interpreter") local sandbox = require("sandbox/sandbox") local config = require("project/config") -local project = require("project/project") local platform = require("platform/platform") local sandbox = require("sandbox/sandbox") local sandbox_os = require("sandbox/modules/os") @@ -507,7 +506,7 @@ function package.load_from_system(packagename) end -- load the package from the project file -function package.load_from_project(packagename) +function package.load_from_project(packagename, project) -- get it directly from cache first package._PACKAGES = package._PACKAGES or {} diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index f5b525470..e5785a645 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -41,6 +41,7 @@ local target = require("project/target") local config = require("project/config") local option = require("project/option") local deprecated_project = require("project/deprecated/project") +local package = require("package/package") local platform = require("platform/platform") local environment = require("platform/environment") local language = require("language/language") @@ -211,14 +212,12 @@ function project.interpreter() -- define apis for option interp:api_define(option.apis()) + -- define apis for package + interp:api_define(package.apis()) + -- define apis for language interp:api_define(language.apis()) - -- define registered apis - for _, apis in ipairs(project._APIS or {}) do - interp:api_define(apis) - end - -- define apis for project interp:api_define { @@ -303,16 +302,6 @@ function project.interpreter() return interp end --- define apis -function project.define_apis(apis) - - -- init apis - project._APIS = project._APIS or {} - - -- define these apis - table.insert(project._APIS, apis) -end - -- get the project file function project.file() return os.projectfile() diff --git a/xmake/core/sandbox/modules/import/core/package/package.lua b/xmake/core/sandbox/modules/import/core/package/package.lua index dc4c78351..5a507e20d 100644 --- a/xmake/core/sandbox/modules/import/core/package/package.lua +++ b/xmake/core/sandbox/modules/import/core/package/package.lua @@ -26,6 +26,7 @@ local sandbox_core_package_package = sandbox_core_package_package or {} -- load modules +local project = require("project/project") local package = require("package/package") local raise = require("sandbox/modules/raise") @@ -43,7 +44,7 @@ end function sandbox_core_package_package.load_from_project(packagename) -- load package instance - local instance, errors = package.load_from_project(packagename) + local instance, errors = package.load_from_project(packagename, project) if errors then raise(errors) end |
