diff options
| author | ruki <[email protected]> | 2020-05-18 22:39:36 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-05-18 09:57:41 +0800 |
| commit | 937bd96c26edc111a3226a4feb2a6748041ab461 (patch) | |
| tree | 0db02fdc1321ac02cee907ed0aa9efc0a9e4ebc8 | |
| parent | c0afaacde90abf081bab19279c3ea6d4dbeae86d (diff) | |
check toolchains for macosx
36 files changed, 80 insertions, 338 deletions
diff --git a/xmake/actions/global/main.lua b/xmake/actions/global/main.lua index 720eb0351..9472c9b24 100644 --- a/xmake/actions/global/main.lua +++ b/xmake/actions/global/main.lua @@ -59,11 +59,6 @@ function main() end end - -- check the global configure - if changed or option.get("clean") then - global.check() - end - -- load and check theme local themename = option.get("theme") if themename then diff --git a/xmake/core/platform/platform.lua b/xmake/core/platform/platform.lua index d80b72be5..677e36906 100644 --- a/xmake/core/platform/platform.lua +++ b/xmake/core/platform/platform.lua @@ -163,6 +163,14 @@ function _instance:data_add(name, data) self._DATA[name] = table.unwrap(table.join(self._DATA[name] or {}, data)) end +-- do check +function _instance:check() + local on_check = self:script("check") + if on_check then + on_check(self) + end +end + -- is builtin configuration? function _instance:_is_builtin_conf(name) @@ -219,8 +227,7 @@ function platform._apis() { -- platform.on_xxx "platform.on_load" - , "platform.on_config_check" - , "platform.on_global_check" + , "platform.on_check" , "platform.on_environment_enter" , "platform.on_environment_leave" } @@ -367,17 +374,6 @@ function platform.tool(toolkind, plat) config.set(toolkind, program, {force = true, readonly = true}) config.set("__toolname_" .. toolkind, toolname) config.save() - else - -- TODO deprecated - -- check it first - local on_check = instance:script("config_check") - if on_check then - on_check(instance, toolkind) - end - - -- get it again - program = config.get(toolkind) - toolname = config.get("__toolname_" .. toolkind) end end diff --git a/xmake/core/sandbox/modules/import/core/base/global.lua b/xmake/core/sandbox/modules/import/core/base/global.lua index 4ea5b2745..9141a2d76 100644 --- a/xmake/core/sandbox/modules/import/core/base/global.lua +++ b/xmake/core/sandbox/modules/import/core/base/global.lua @@ -68,31 +68,6 @@ function sandbox_core_base_global.clear() return global.clear() end --- check the configure -function sandbox_core_base_global.check() - - -- check all platforms with the current host - for _, plat in ipairs(table.wrap(platform.plats())) do - - -- load platform - local instance, errors = platform.load(plat) - if not instance then - raise(errors) - end - - -- belong to the current host? - for _, host in ipairs(table.wrap(instance:hosts())) do - if host == os.host() then - local on_check = instance:script("global_check") - if on_check then - on_check(instance) - end - break - end - end - end -end - -- get all options function sandbox_core_base_global.options() return global.options() diff --git a/xmake/core/sandbox/modules/import/core/project/config.lua b/xmake/core/sandbox/modules/import/core/project/config.lua index 449fac71f..c7121a8a4 100644 --- a/xmake/core/sandbox/modules/import/core/project/config.lua +++ b/xmake/core/sandbox/modules/import/core/project/config.lua @@ -116,12 +116,7 @@ function sandbox_core_project_config.check() -- get the current platform local instance, errors = platform.load() if instance then - - -- do check - local on_check = instance:script("config_check") - if on_check then - on_check(instance) - end + instance:check() else raise(errors) end diff --git a/xmake/core/tool/toolchain.lua b/xmake/core/tool/toolchain.lua index 246d46a99..e79a32b22 100644 --- a/xmake/core/tool/toolchain.lua +++ b/xmake/core/tool/toolchain.lua @@ -61,6 +61,19 @@ end -- get the toolchain configuration function _instance:get(name) + + -- attempt to get the static configure value + local value = self._INFO:get(name) + if value ~= nil then + return value + end + + -- lazy loading platform if get other configuration + if not self:_is_builtin_conf(name) then + self:_load() + end + + -- get other platform info return self._INFO:get(name) end @@ -102,17 +115,21 @@ function _instance:_load() end -- do check -function _instance:_check() +function _instance:check() + local checkok = true if not self._CHECKED then local on_check = self._INFO:get("check") if on_check then - local ok, errors = sandbox.load(on_check, self) - if not ok then - os.raise(errors) + local ok, results_or_errors = sandbox.load(on_check, self) + if ok then + checkok = results_or_errors + else + os.raise(results_or_errors) end end self._CHECKED = true end + return checkok end -- get the tool description from the tool kind @@ -158,9 +175,6 @@ end -- check the given tool path function _instance:_checktool(toolkind, toolpath) - -- ensure to check this toolchain first - self:_check() - -- get find_tool local find_tool = self._find_tool if not find_tool then @@ -187,11 +201,6 @@ function _instance:_checktool(toolkind, toolpath) utils.cprint("${dim}checking for %s (%s: ${bright}%s${clear}) ... ${color.nothing}${text.nothing}", description, toolkind, name) end end - - -- we only load it when checking the given tool successfully - if program then - self:_load() - end return program, toolname end diff --git a/xmake/platforms/android/config.lua b/xmake/platforms/android/check.lua index e99a4d14a..04d639483 100644 --- a/xmake/platforms/android/config.lua +++ b/xmake/platforms/android/check.lua @@ -15,7 +15,7 @@ -- Copyright (C) 2015-2020, TBOOX Open Source Group. -- -- @author ruki --- @file config.lua +-- @file check.lua -- -- imports diff --git a/xmake/platforms/android/xmake.lua b/xmake/platforms/android/xmake.lua index 45a4eaf8d..cb7d52594 100644 --- a/xmake/platforms/android/xmake.lua +++ b/xmake/platforms/android/xmake.lua @@ -39,8 +39,8 @@ platform("android") -- set formats set_formats {static = "lib$(name).a", object = "$(name).o", shared = "lib$(name).so", symbol = "$(name).sym"} - -- on check project configuration - on_config_check("config") + -- on check + on_check("check") -- on load on_load("load") diff --git a/xmake/platforms/bsd/config.lua b/xmake/platforms/bsd/check.lua index 69164b8b4..1eb8834ef 100644 --- a/xmake/platforms/bsd/config.lua +++ b/xmake/platforms/bsd/check.lua @@ -15,7 +15,7 @@ -- Copyright (C) 2015-2020, TBOOX Open Source Group. -- -- @author ruki --- @file config.lua +-- @file check.lua -- -- imports diff --git a/xmake/platforms/bsd/global.lua b/xmake/platforms/bsd/global.lua deleted file mode 100644 index d74d84943..000000000 --- a/xmake/platforms/bsd/global.lua +++ /dev/null @@ -1,32 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-2020, TBOOX Open Source Group. --- --- @author ruki --- @file global.lua --- - --- imports -import("core.base.global") - --- check it -function main(platform, name) - - -- we cannot check the global configuration with the given name - if name then - raise("we cannot check global." .. name) - end -end - diff --git a/xmake/platforms/bsd/xmake.lua b/xmake/platforms/bsd/xmake.lua index 3ea3ed9f6..d0cacd28a 100644 --- a/xmake/platforms/bsd/xmake.lua +++ b/xmake/platforms/bsd/xmake.lua @@ -36,11 +36,8 @@ platform("bsd") -- set install directory set_installdir("/usr/local") - -- on check project configuration - on_config_check("config") - - -- on check global configuration - on_global_check("global") + -- on check + on_check("check") -- on load on_load("load") diff --git a/xmake/platforms/cross/config.lua b/xmake/platforms/cross/check.lua index b159cf5c1..833dcb921 100644 --- a/xmake/platforms/cross/config.lua +++ b/xmake/platforms/cross/check.lua @@ -15,7 +15,7 @@ -- Copyright (C) 2015-2020, TBOOX Open Source Group. -- -- @author ruki --- @file config.lua +-- @file check.lua -- -- imports diff --git a/xmake/platforms/cross/xmake.lua b/xmake/platforms/cross/xmake.lua index 31e7f6d95..a76dde03c 100644 --- a/xmake/platforms/cross/xmake.lua +++ b/xmake/platforms/cross/xmake.lua @@ -30,8 +30,8 @@ platform("cross") -- set formats set_formats {static = "lib$(name).a", object = "$(name).o", shared = "lib$(name).so", symbol = "$(name).sym"} - -- on check project configuration - on_config_check("config") + -- on check + on_check("check") -- on load on_load("load") diff --git a/xmake/platforms/cygwin/config.lua b/xmake/platforms/cygwin/check.lua index 26f008970..3b1221387 100644 --- a/xmake/platforms/cygwin/config.lua +++ b/xmake/platforms/cygwin/check.lua @@ -15,7 +15,7 @@ -- Copyright (C) 2015-2020, TBOOX Open Source Group. -- -- @author ruki --- @file config.lua +-- @file check.lua -- -- imports diff --git a/xmake/platforms/cygwin/xmake.lua b/xmake/platforms/cygwin/xmake.lua index e43c5e35c..32ab7df58 100644 --- a/xmake/platforms/cygwin/xmake.lua +++ b/xmake/platforms/cygwin/xmake.lua @@ -36,8 +36,8 @@ platform("cygwin") -- set install directory set_installdir("/usr/local") - -- on check project configuration - on_config_check("config") + -- on check + on_check("check") -- on load on_load("load") diff --git a/xmake/platforms/iphoneos/config.lua b/xmake/platforms/iphoneos/check.lua index 1e3592f45..94a3a9ae9 100644 --- a/xmake/platforms/iphoneos/config.lua +++ b/xmake/platforms/iphoneos/check.lua @@ -15,7 +15,7 @@ -- Copyright (C) 2015-2020, TBOOX Open Source Group. -- -- @author ruki --- @file config.lua +-- @file check.lua -- -- imports diff --git a/xmake/platforms/iphoneos/global.lua b/xmake/platforms/iphoneos/global.lua deleted file mode 100644 index f625eb103..000000000 --- a/xmake/platforms/iphoneos/global.lua +++ /dev/null @@ -1,36 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-2020, TBOOX Open Source Group. --- --- @author ruki --- @file global.lua --- - --- imports -import("core.base.global") -import("private.platform.check_xcode") - --- check it -function main(platform, name) - - -- we cannot check the global configuration with the given name - if name then - raise("we cannot check global." .. name) - end - - -- check xcode - check_xcode(global, true) -end - diff --git a/xmake/platforms/iphoneos/xmake.lua b/xmake/platforms/iphoneos/xmake.lua index 2f6bcf00f..6d2af82ae 100644 --- a/xmake/platforms/iphoneos/xmake.lua +++ b/xmake/platforms/iphoneos/xmake.lua @@ -33,11 +33,8 @@ platform("iphoneos") -- set formats set_formats {static = "lib$(name).a", object = "$(name).o", shared = "lib$(name).dylib", symbol = "$(name).dSYM"} - -- on check project configuration - on_config_check("config") - - -- on check global configuration - on_global_check("global") + -- on check + on_check("check") -- on load on_load("load") diff --git a/xmake/platforms/linux/config.lua b/xmake/platforms/linux/check.lua index ac9b42931..1671ee0e9 100644 --- a/xmake/platforms/linux/config.lua +++ b/xmake/platforms/linux/check.lua @@ -15,7 +15,7 @@ -- Copyright (C) 2015-2020, TBOOX Open Source Group. -- -- @author ruki --- @file config.lua +-- @file check.lua -- -- imports diff --git a/xmake/platforms/linux/global.lua b/xmake/platforms/linux/global.lua deleted file mode 100644 index d74d84943..000000000 --- a/xmake/platforms/linux/global.lua +++ /dev/null @@ -1,32 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-2020, TBOOX Open Source Group. --- --- @author ruki --- @file global.lua --- - --- imports -import("core.base.global") - --- check it -function main(platform, name) - - -- we cannot check the global configuration with the given name - if name then - raise("we cannot check global." .. name) - end -end - diff --git a/xmake/platforms/linux/xmake.lua b/xmake/platforms/linux/xmake.lua index 53517239a..21e4d2e51 100644 --- a/xmake/platforms/linux/xmake.lua +++ b/xmake/platforms/linux/xmake.lua @@ -36,11 +36,8 @@ platform("linux") -- set install directory set_installdir("/usr/local") - -- on check project configuration - on_config_check("config") - - -- on check global configuration - on_global_check("global") + -- on check + on_check("check") -- on load on_load("load") diff --git a/xmake/platforms/macosx/config.lua b/xmake/platforms/macosx/check.lua index a1713a657..ff552ad6b 100644 --- a/xmake/platforms/macosx/config.lua +++ b/xmake/platforms/macosx/check.lua @@ -15,11 +15,13 @@ -- Copyright (C) 2015-2020, TBOOX Open Source Group. -- -- @author ruki --- @file config.lua +-- @file check.lua -- -- imports import("core.project.config") + +--[[ import("core.base.singleton") import("private.platform.toolchain") import("private.platform.check_arch") @@ -141,10 +143,18 @@ function _toolchains() cu_ccbin:add("$(env CXX)", "$(env CC)", "clang", "gcc") return toolchains -end +end]] -- check it -function main(platform, name) +function main(platform) + + -- check toolchains + local toolchains = platform:toolchains() + for idx, toolchain in irpairs(toolchains) do + if not toolchain:check() then + table.remove(toolchains, idx) + end + end --[[ -- only check the given config name? diff --git a/xmake/platforms/macosx/global.lua b/xmake/platforms/macosx/global.lua deleted file mode 100644 index f625eb103..000000000 --- a/xmake/platforms/macosx/global.lua +++ /dev/null @@ -1,36 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-2020, TBOOX Open Source Group. --- --- @author ruki --- @file global.lua --- - --- imports -import("core.base.global") -import("private.platform.check_xcode") - --- check it -function main(platform, name) - - -- we cannot check the global configuration with the given name - if name then - raise("we cannot check global." .. name) - end - - -- check xcode - check_xcode(global, true) -end - diff --git a/xmake/platforms/macosx/xmake.lua b/xmake/platforms/macosx/xmake.lua index fc390d953..512499c7c 100644 --- a/xmake/platforms/macosx/xmake.lua +++ b/xmake/platforms/macosx/xmake.lua @@ -36,11 +36,8 @@ platform("macosx") -- set install directory set_installdir("/usr/local") - -- on check project configuration --- on_config_check("config") - - -- on check global configuration - on_global_check("global") + -- on check + on_check("check") -- on load on_load("load") diff --git a/xmake/platforms/mingw/config.lua b/xmake/platforms/mingw/check.lua index bbfc6f7f9..9905a53cc 100644 --- a/xmake/platforms/mingw/config.lua +++ b/xmake/platforms/mingw/check.lua @@ -15,7 +15,7 @@ -- Copyright (C) 2015-2020, TBOOX Open Source Group. -- -- @author ruki --- @file config.lua +-- @file check.lua -- -- imports diff --git a/xmake/platforms/mingw/xmake.lua b/xmake/platforms/mingw/xmake.lua index 7b5ad2624..e119f137f 100644 --- a/xmake/platforms/mingw/xmake.lua +++ b/xmake/platforms/mingw/xmake.lua @@ -33,8 +33,8 @@ platform("mingw") -- set formats set_formats {static = "$(name).lib", object = "$(name).obj", shared = "$(name).dll", binary = "$(name).exe", symbol = "$(name).pdb"} - -- on check project configuration - on_config_check("config") + -- on check + on_check("check") -- on load on_load("load") diff --git a/xmake/platforms/msys/config.lua b/xmake/platforms/msys/check.lua index dbb1be255..8c5a2dcdd 100644 --- a/xmake/platforms/msys/config.lua +++ b/xmake/platforms/msys/check.lua @@ -15,7 +15,7 @@ -- Copyright (C) 2015-2020, TBOOX Open Source Group. -- -- @author ruki --- @file config.lua +-- @file check.lua -- -- imports diff --git a/xmake/platforms/msys/xmake.lua b/xmake/platforms/msys/xmake.lua index b3abadbf9..69c56db22 100644 --- a/xmake/platforms/msys/xmake.lua +++ b/xmake/platforms/msys/xmake.lua @@ -36,8 +36,8 @@ platform("msys") -- set install directory set_installdir("/usr/local") - -- on check project configuration - on_config_check("config") + -- on check + on_check("check") -- on load on_load("load") diff --git a/xmake/platforms/sdcc/config.lua b/xmake/platforms/sdcc/check.lua index ad2f14626..6532ea00e 100644 --- a/xmake/platforms/sdcc/config.lua +++ b/xmake/platforms/sdcc/check.lua @@ -15,7 +15,7 @@ -- Copyright (C) 2015-2020, TBOOX Open Source Group. -- -- @author ruki --- @file config.lua +-- @file check.lua -- -- imports diff --git a/xmake/platforms/sdcc/xmake.lua b/xmake/platforms/sdcc/xmake.lua index b06094f9f..ad2f02be9 100644 --- a/xmake/platforms/sdcc/xmake.lua +++ b/xmake/platforms/sdcc/xmake.lua @@ -30,8 +30,8 @@ platform("sdcc") -- set formats set_formats {static = "$(name).lib", object = "$(name).rel", binary = "$(name).bin", symbol = "$(name).sym"} - -- on check project configuration - on_config_check("config") + -- on check + on_check("check") -- on load on_load("load") diff --git a/xmake/platforms/watchos/config.lua b/xmake/platforms/watchos/check.lua index f16878b2e..89086d74c 100644 --- a/xmake/platforms/watchos/config.lua +++ b/xmake/platforms/watchos/check.lua @@ -15,7 +15,7 @@ -- Copyright (C) 2015-2020, TBOOX Open Source Group. -- -- @author ruki --- @file config.lua +-- @file check.lua -- -- imports diff --git a/xmake/platforms/watchos/global.lua b/xmake/platforms/watchos/global.lua deleted file mode 100644 index f625eb103..000000000 --- a/xmake/platforms/watchos/global.lua +++ /dev/null @@ -1,36 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-2020, TBOOX Open Source Group. --- --- @author ruki --- @file global.lua --- - --- imports -import("core.base.global") -import("private.platform.check_xcode") - --- check it -function main(platform, name) - - -- we cannot check the global configuration with the given name - if name then - raise("we cannot check global." .. name) - end - - -- check xcode - check_xcode(global, true) -end - diff --git a/xmake/platforms/watchos/xmake.lua b/xmake/platforms/watchos/xmake.lua index 5c2e2a731..1311c47ba 100644 --- a/xmake/platforms/watchos/xmake.lua +++ b/xmake/platforms/watchos/xmake.lua @@ -33,11 +33,8 @@ platform("watchos") -- set formats set_formats {static = "lib$(name).a", object = "$(name).o", shared = "lib$(name).dylib", symbol = "$(name).dSYM"} - -- on check project configuration - on_config_check("config") - - -- on check global configuration - on_global_check("global") + -- on check + on_check("check") -- on load on_load("load") diff --git a/xmake/platforms/windows/config.lua b/xmake/platforms/windows/check.lua index c74205efe..55027ff6a 100644 --- a/xmake/platforms/windows/config.lua +++ b/xmake/platforms/windows/check.lua @@ -15,7 +15,7 @@ -- Copyright (C) 2015-2020, TBOOX Open Source Group. -- -- @author ruki --- @file config.lua +-- @file check.lua -- -- imports diff --git a/xmake/platforms/windows/global.lua b/xmake/platforms/windows/global.lua deleted file mode 100644 index 9ef580bef..000000000 --- a/xmake/platforms/windows/global.lua +++ /dev/null @@ -1,49 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-2020, TBOOX Open Source Group. --- --- @author ruki --- @file global.lua --- - --- imports -import("core.base.global") -import("private.platform.check_arch") -import("private.platform.check_vstudio") - --- clean temporary global configs -function _clean_global() - global.set("arch", nil) - global.set("__vcvarsall", nil) -end - --- check it -function main(platform, name) - - -- we cannot check the global configuration with the given name - if name then - raise("we cannot check global." .. name) - end - - -- check arch - check_arch(global) - - -- check vstudio - check_vstudio(global, {try = true}) - - -- clean temporary global configs - _clean_global() -end - diff --git a/xmake/platforms/windows/xmake.lua b/xmake/platforms/windows/xmake.lua index 43c7acccb..3bc2bf0cf 100644 --- a/xmake/platforms/windows/xmake.lua +++ b/xmake/platforms/windows/xmake.lua @@ -33,11 +33,8 @@ platform("windows") -- set formats set_formats {static = "$(name).lib", object = "$(name).obj", shared = "$(name).dll", binary = "$(name).exe", symbol = "$(name).pdb"} - -- on check project configuration - on_config_check("config") - - -- on check global configuration - on_global_check("global") + -- on check + on_check("check") -- on environment enter on_environment_enter("environment.enter") diff --git a/xmake/toolchains/xcode/check.lua b/xmake/toolchains/xcode/check.lua index c10fe48d9..0e34232a6 100644 --- a/xmake/toolchains/xcode/check.lua +++ b/xmake/toolchains/xcode/check.lua @@ -25,4 +25,5 @@ import("private.platform.check_xcode") -- main entry function main(toolchain) check_xcode(config, true) + return true end |
