diff options
| author | ruki <[email protected]> | 2015-05-26 10:19:43 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-05-26 10:19:43 +0800 |
| commit | f4562609df7ac3f395e5178e76fcefa2c1ffa980 (patch) | |
| tree | 526caad47b590de1be57996ee19b28d4e34d082a /xmake/scripts/platform | |
| parent | 49ae120e090b2d4dd15e486ade2dfc2ea1ded440 (diff) | |
probe configure for macosx
Diffstat (limited to 'xmake/scripts/platform')
| -rw-r--r-- | xmake/scripts/platform/android/_android.lua | 11 | ||||
| -rw-r--r-- | xmake/scripts/platform/ios/_ios.lua | 33 | ||||
| -rw-r--r-- | xmake/scripts/platform/linux/_linux.lua | 7 | ||||
| -rw-r--r-- | xmake/scripts/platform/macosx/_macosx.lua | 121 | ||||
| -rw-r--r-- | xmake/scripts/platform/platform.lua | 29 | ||||
| -rw-r--r-- | xmake/scripts/platform/windows/_windows.lua | 11 |
6 files changed, 176 insertions, 36 deletions
diff --git a/xmake/scripts/platform/android/_android.lua b/xmake/scripts/platform/android/_android.lua index b91aa4eca..630c95ab1 100644 --- a/xmake/scripts/platform/android/_android.lua +++ b/xmake/scripts/platform/android/_android.lua @@ -26,6 +26,9 @@ local _android = _android or {} -- init _android function _android.init(configs) + -- init host + configs.host = xmake._HOST + -- init the file name formats configs.formats = {} configs.formats.static = {"lib", ".a"} @@ -44,15 +47,15 @@ function _android.menu(action) -- init config option menu _android._MENU_CONFIG = _android._MENU_CONFIG or { {} - , {nil, "ndk", "kv", nil, "The NDK directory" } - , {nil, "ndk_sdkver", "kv", "auto", "The SDK version for NDK" } + , {nil, "ndk", "kv", nil, "The NDK Directory" } + , {nil, "ndk_sdkver", "kv", "auto", "The SDK Version for NDK" } , } -- init global option menu _android._MENU_GLOBAL = _android._MENU_GLOBAL or { {} - , {nil, "ndk", "kv", nil, "The NDK directory" } - , {nil, "ndk_sdkver", "kv", "auto", "The SDK version for NDK" } + , {nil, "ndk", "kv", nil, "The NDK Directory" } + , {nil, "ndk_sdkver", "kv", "auto", "The SDK Version for NDK" } , } -- get the option menu diff --git a/xmake/scripts/platform/ios/_ios.lua b/xmake/scripts/platform/ios/_ios.lua index a8cb3dc75..8cc91c62b 100644 --- a/xmake/scripts/platform/ios/_ios.lua +++ b/xmake/scripts/platform/ios/_ios.lua @@ -26,6 +26,9 @@ local _ios = _ios or {} -- init _ios function _ios.init(configs) + -- init host + configs.host = "macosx" + -- init the file name formats configs.formats = {} configs.formats.static = {"lib", ".a"} @@ -45,24 +48,30 @@ function _ios.menu(action) -- init config option menu _ios._MENU_CONFIG = _ios._MENU_CONFIG or { {} - , {nil, "mm", "kv", nil, "The objc compiler" } - , {nil, "mx", "kv", nil, "The objc/c++ compiler" } - , {nil, "mxx", "kv", nil, "The objc++ compiler" } - , {nil, "mflags", "kv", nil, "The objc compiler flags" } - , {nil, "mxflags", "kv", nil, "The objc/c++ compiler flags" } - , {nil, "mxxflags", "kv", nil, "The objc++ compiler flags" } + , {nil, "mm", "kv", nil, "The Objc Compiler" } + , {nil, "mx", "kv", nil, "The Objc/c++ Compiler" } + , {nil, "mxx", "kv", nil, "The Objc++ Compiler" } + , {nil, "mflags", "kv", nil, "The Objc Compiler Flags" } + , {nil, "mxflags", "kv", nil, "The Objc/c++ Compiler Flags" } + , {nil, "mxxflags", "kv", nil, "The Objc++ Compiler Flags" } + , {} + , {nil, "xcode", "kv", "auto", "The Xcode Application Directory" } + , {nil, "xcode_sdkver", "kv", "auto", "The SDK Version for Xcode" } , {} - , {nil, "xcode", "kv", "/Applications/Xcode.app" - , "The Xcode application directory" } - , {nil, "xcode_sdkver", "kv", "auto", "The SDK version for Xcode" } + , {nil, "mobileprovision","kv", "auto", "The Provisioning Profile File" } + , {nil, "codesign", "kv", "auto", "The Code Signing Indentity" } + , {nil, "entitlements", "kv", "auto", "The Code Signing Entitlements" } , } -- init global option menu _ios._MENU_GLOBAL = _ios._MENU_GLOBAL or { {} - , {nil, "xcode", "kv", "/Applications/Xcode.app" - , "The Xcode application directory" } - , {nil, "xcode_sdkver", "kv", "auto", "The SDK version for Xcode" } + , {nil, "xcode", "kv", "auto", "The Xcode Application Directory" } + , {nil, "xcode_sdkver", "kv", "auto", "The SDK Version for Xcode" } + , {} + , {nil, "mobileprovision","kv", "auto", "The Provisioning Profile File" } + , {nil, "codesign", "kv", "auto", "The Code Signing Indentity" } + , {nil, "entitlements", "kv", "auto", "The Code Signing Entitlements" } , } -- get the option menu diff --git a/xmake/scripts/platform/linux/_linux.lua b/xmake/scripts/platform/linux/_linux.lua index 8aba6d7ec..51e3ee89a 100644 --- a/xmake/scripts/platform/linux/_linux.lua +++ b/xmake/scripts/platform/linux/_linux.lua @@ -26,6 +26,9 @@ local _linux = _linux or {} -- init _linux function _linux.init(configs) + -- init host + configs.host = "linux" + -- init the file name formats configs.formats = {} configs.formats.static = {"lib", ".a"} @@ -44,8 +47,8 @@ function _linux.menu(action) -- init config option menu _linux._MENU_CONFIG = _linux._MENU_CONFIG or { {} - , {nil, "ar", "kv", "ar", "The library creator" } - , {nil, "arflags", "kv", nil, "The library creator flags" } + , {nil, "ar", "kv", "ar", "The Library Creator" } + , {nil, "arflags", "kv", nil, "The Library Creator Flags" } } -- init global option menu diff --git a/xmake/scripts/platform/macosx/_macosx.lua b/xmake/scripts/platform/macosx/_macosx.lua index ee6df36c4..e42b1c81f 100644 --- a/xmake/scripts/platform/macosx/_macosx.lua +++ b/xmake/scripts/platform/macosx/_macosx.lua @@ -20,12 +20,21 @@ -- @file _macosx.lua -- +-- load modules +local os = require("base/os") +local path = require("base/path") +local utils = require("base/utils") +local string = require("base/string") + -- define module: _macosx local _macosx = _macosx or {} -- init configure function _macosx.init(configs) + -- init host + configs.host = "macosx" + -- init the file name formats configs.formats = {} configs.formats.static = {"lib", ".a"} @@ -37,8 +46,94 @@ function _macosx.init(configs) configs.archs.x86 = {} configs.archs.x64 = {} - -- save configure - _macosx._CONFIGS = configs +end + +-- probe the xcode application directory +function _macosx._probe_xcode(configs) + + -- get the xcode + local xcode = configs.xcode + + -- ok? + if xcode and xcode ~= "auto" then return true end + + -- clear it first + xcode = nil + + -- attempt to get the default directory + if not xcode then + if os.isdir("/Applications/Xcode.app") then + xcode = "/Applications/Xcode.app" + end + end + + -- attempt to match the other directories + if not xcode then + local dirs = os.match("/Applications/Xcode*.app", true) + if dirs and table.getn(dirs) ~= 0 then + xcode = dirs[1] + end + end + + -- probe ok? update it + if xcode then + configs.xcode = xcode + else + -- failed + utils.error("The Xcode directory is unknown now, please config it first!") + utils.error(" - xmake config --xcode=xxx") + utils.error("or - xmake global --xcode=xxx") + return false + end + + -- ok + return true +end + +-- probe the xcode sdk version +function _macosx._probe_xcode_sdkver(configs) + + -- get the xcode sdk version + local xcode_sdkver = configs.xcode_sdkver + + -- ok? + if xcode_sdkver and xcode_sdkver ~= "auto" then return true end + + -- clear it first + xcode_sdkver = nil + + -- attempt to match the directory + if not xcode_sdkver then + local dirs = os.match("/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX*.sdk", true) + if dirs and table.getn(dirs) ~= 0 then + xcode_sdkver = string.match(dirs[1], "%d+%.%d+") + end + end + + -- probe ok? update it + if xcode_sdkver then + configs.xcode_sdkver = xcode_sdkver + else + -- failed + utils.error("The Xcode SDK version is unknown now, please config it first!") + utils.error(" - xmake config --xcode_sdkver=xxx") + utils.error("or - xmake global --xcode_sdkver=xxx") + return false + end + + -- ok + return true +end + +-- probe the configure and update the values with "auto" +function _macosx.probe(configs) + + -- probe the xcode application directory + if not _macosx._probe_xcode(configs) then return end + + -- probe the xcode sdk version + if not _macosx._probe_xcode_sdkver(configs) then return end + end -- get the option menu for action: xmake config or global @@ -47,24 +142,22 @@ function _macosx.menu(action) -- init config option menu _macosx._MENU_CONFIG = _macosx._MENU_CONFIG or { {} - , {nil, "mm", "kv", nil, "The objc compiler" } - , {nil, "mx", "kv", nil, "The objc/c++ compiler" } - , {nil, "mxx", "kv", nil, "The objc++ compiler" } - , {nil, "mflags", "kv", nil, "The objc compiler flags" } - , {nil, "mxflags", "kv", nil, "The objc/c++ compiler flags" } - , {nil, "mxxflags", "kv", nil, "The objc++ compiler flags" } + , {nil, "mm", "kv", nil, "The Objc Compiler" } + , {nil, "mx", "kv", nil, "The Objc/c++ Compiler" } + , {nil, "mxx", "kv", nil, "The Objc++ Compiler" } + , {nil, "mflags", "kv", nil, "The Objc Compiler Flags" } + , {nil, "mxflags", "kv", nil, "The Objc/c++ Compiler Flags" } + , {nil, "mxxflags", "kv", nil, "The Objc++ Compiler Flags" } , {} - , {nil, "xcode", "kv", "/Applications/Xcode.app" - , "The Xcode application directory" } - , {nil, "xcode_sdkver", "kv", "auto", "The SDK version for Xcode" } + , {nil, "xcode", "kv", "auto", "The Xcode Application Directory" } + , {nil, "xcode_sdkver", "kv", "auto", "The SDK Version for Xcode" } , } -- init global option menu _macosx._MENU_GLOBAL = _macosx._MENU_GLOBAL or { {} - , {nil, "xcode", "kv", "/Applications/Xcode.app" - , "The Xcode application directory" } - , {nil, "xcode_sdkver", "kv", "auto", "The SDK version for Xcode" } + , {nil, "xcode", "kv", "auto", "The Xcode Application Directory" } + , {nil, "xcode_sdkver", "kv", "auto", "The SDK Version for Xcode" } , } -- get the option menu diff --git a/xmake/scripts/platform/platform.lua b/xmake/scripts/platform/platform.lua index 533026c9c..dc5c9616e 100644 --- a/xmake/scripts/platform/platform.lua +++ b/xmake/scripts/platform/platform.lua @@ -207,6 +207,35 @@ function platform.menu(action) -- get all platform menus return menus end + +-- probe the platform configure and update the values with "auto" +function platform.probe(configs, is_global) + + -- probe global + if is_global then + + -- get all platforms + local plats = platform.plats() + assert(plats) + + -- probe all platforms with the current host + for _, plat in ipairs(plats) do + local p = platform._load(plat) + local c = platform._configs(plat) + if p and p.probe and c and c.host and c.host == xmake._HOST then + p.probe(configs) + end + end + + -- probe config + else + -- probe it + local p = platform._load(config.get("plat")) + if p and p.probe then + p.probe(configs) + end + end +end -- return module: platform return platform diff --git a/xmake/scripts/platform/windows/_windows.lua b/xmake/scripts/platform/windows/_windows.lua index 7a31eabaa..793de81b0 100644 --- a/xmake/scripts/platform/windows/_windows.lua +++ b/xmake/scripts/platform/windows/_windows.lua @@ -26,6 +26,9 @@ local _windows = _windows or {} -- init _windows function _windows.init(configs) + -- init host + configs.host = "windows" + -- init the file name formats configs.formats = {} configs.formats.static = {"", ".lib"} @@ -45,15 +48,15 @@ function _windows.menu(action) -- init config option menu _windows._MENU_CONFIG = _windows._MENU_CONFIG or { {} - , {nil, "vs", "kv", "auto", "The Microsoft Visual Studio directory" } - , {nil, "vs_sdk", "kv", "auto", "The Microsoft Visual Studio SDK directory" } + , {nil, "vs", "kv", "auto", "The Microsoft Visual Studio Directory" } + , {nil, "vs_sdk", "kv", "auto", "The Microsoft Visual Studio SDK Directory" } , } -- init global option menu _windows._MENU_GLOBAL = _windows._MENU_GLOBAL or { {} - , {nil, "vs", "kv", "auto", "The Microsoft Visual Studio directory" } - , {nil, "vs_sdk", "kv", "auto", "The Microsoft Visual Studio SDK directory" } + , {nil, "vs", "kv", "auto", "The Microsoft Visual Studio Directory" } + , {nil, "vs_sdk", "kv", "auto", "The Microsoft Visual Studio SDK Directory" } , } -- get the option menu |
