summaryrefslogtreecommitdiff
path: root/xmake/scripts/platform/macosx/_macosx.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2015-05-26 10:19:43 +0800
committerruki <[email protected]>2015-05-26 10:19:43 +0800
commitf4562609df7ac3f395e5178e76fcefa2c1ffa980 (patch)
tree526caad47b590de1be57996ee19b28d4e34d082a /xmake/scripts/platform/macosx/_macosx.lua
parent49ae120e090b2d4dd15e486ade2dfc2ea1ded440 (diff)
probe configure for macosx
Diffstat (limited to 'xmake/scripts/platform/macosx/_macosx.lua')
-rw-r--r--xmake/scripts/platform/macosx/_macosx.lua121
1 files changed, 107 insertions, 14 deletions
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