diff options
| author | ruki <[email protected]> | 2020-12-16 23:45:37 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-12-16 23:45:37 +0800 |
| commit | acb182fce388de57b6f7262087e1e27ae3d71b41 (patch) | |
| tree | b7b38ee9ba7e86bc539c0b74a569bea63d36b0c8 | |
| parent | 207b4e753a4bed1f75836b78180411442103a9cd (diff) | |
improve to check config
| -rw-r--r-- | xmake/actions/config/main.lua | 16 | ||||
| -rw-r--r-- | xmake/core/platform/platform.lua | 10 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/platform/platform.lua | 7 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/project/config.lua | 15 | ||||
| -rw-r--r-- | xmake/modules/private/detect/find_platform.lua | 6 |
5 files changed, 17 insertions, 37 deletions
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua index b3aeeb9a3..6c143bf81 100644 --- a/xmake/actions/config/main.lua +++ b/xmake/actions/config/main.lua @@ -26,6 +26,7 @@ import("core.project.config") import("core.project.project") import("core.platform.platform") import("core.project.cache") +import("private.detect.find_platform") import("lib.detect.cache", {alias = "detectcache"}) import("scangen") import("menuconf", {alias = "menuconf_show"}) @@ -268,6 +269,14 @@ force to build in current directory via run `xmake -P .`]], os.projectdir()) end end + -- find default platform and save to configuration + local plat, arch = find_platform({global = true}) + assert(plat == config.plat()) + assert(arch == config.arch()) + + -- load platform instance + local instance_plat = platform.load(plat, arch) + -- merge the checked configure local recheck = _need_check(options_changed or not configcache_loaded or autogen) if recheck then @@ -275,8 +284,8 @@ force to build in current directory via run `xmake -P .`]], os.projectdir()) -- clear detect cache detectcache.clear() - -- check configure - config.check() + -- check platform + instance_plat:check() -- check project options if not trybuild then @@ -284,9 +293,6 @@ force to build in current directory via run `xmake -P .`]], os.projectdir()) end end - -- load platform - platform.load(config.plat()) - -- translate the build directory local buildir = config.get("buildir") if buildir and path.is_absolute(buildir) then diff --git a/xmake/core/platform/platform.lua b/xmake/core/platform/platform.lua index 4d0aa8fd0..5467d7944 100644 --- a/xmake/core/platform/platform.lua +++ b/xmake/core/platform/platform.lua @@ -279,15 +279,6 @@ end -- do check function _instance:check() - -- check platform - local on_check = self:script("check") - if on_check then - local ok, errors = sandbox.load(on_check, self) - if not ok then - return false, errors - end - end - -- check toolchains local toolchains = self:toolchains({all = true}) local idx = 1 @@ -396,7 +387,6 @@ function platform._apis() { -- platform.on_xxx "platform.on_load" - , "platform.on_check" } , keyvalues = { diff --git a/xmake/core/sandbox/modules/import/core/platform/platform.lua b/xmake/core/sandbox/modules/import/core/platform/platform.lua index fab24e1e0..b4a7799b7 100644 --- a/xmake/core/sandbox/modules/import/core/platform/platform.lua +++ b/xmake/core/sandbox/modules/import/core/platform/platform.lua @@ -27,12 +27,11 @@ local raise = require("sandbox/modules/raise") -- load the current platform function sandbox_core_platform.load(plat, arch) - - -- load the platform configure - local ok, errors = platform.load(plat, arch) - if not ok then + local instance, errors = platform.load(plat, arch) + if not instance then raise(errors) end + return instance end -- get the platform os diff --git a/xmake/core/sandbox/modules/import/core/project/config.lua b/xmake/core/sandbox/modules/import/core/project/config.lua index 7adb6f003..ab9db683f 100644 --- a/xmake/core/sandbox/modules/import/core/project/config.lua +++ b/xmake/core/sandbox/modules/import/core/project/config.lua @@ -111,21 +111,6 @@ function sandbox_core_project_config.clear() config.clear() end --- check the configuration -function sandbox_core_project_config.check() - - -- check configuration for the current platform - local instance, errors = platform.load() - if instance then - local ok, errors = instance:check() - if not ok then - raise(errors) - end - else - raise(errors) - end -end - -- dump the configuration function sandbox_core_project_config.dump() config.dump() diff --git a/xmake/modules/private/detect/find_platform.lua b/xmake/modules/private/detect/find_platform.lua index a18849b82..26a09cc0e 100644 --- a/xmake/modules/private/detect/find_platform.lua +++ b/xmake/modules/private/detect/find_platform.lua @@ -110,9 +110,9 @@ end -- find default platform and architecture -- --- @param opt the argument options, e.g. {plat = "", arch = "", global = true} +-- @param opt the argument options, e.g. {plat = "", arch = "", global = true} -- --- @return {plat = "", arch = ""} +-- @return plat, arch -- -- @code -- @@ -142,5 +142,5 @@ function main(opt) cprint("checking for architecture ... ${color.success}%s", plat) end end - return {plat = plat, arch = arch} + return plat, arch end |
