diff options
Diffstat (limited to 'xmake/scripts/platform')
| -rw-r--r-- | xmake/scripts/platform/macosx/_macosx.lua | 2 | ||||
| -rw-r--r-- | xmake/scripts/platform/platform.lua | 59 |
2 files changed, 44 insertions, 17 deletions
diff --git a/xmake/scripts/platform/macosx/_macosx.lua b/xmake/scripts/platform/macosx/_macosx.lua index b23204224..532a540df 100644 --- a/xmake/scripts/platform/macosx/_macosx.lua +++ b/xmake/scripts/platform/macosx/_macosx.lua @@ -55,7 +55,7 @@ function _macosx.make(configs) configs.linker = {} configs.linker.binary = config.get("ld") or "xcrun -sdk macosx clang++" configs.linker.static = config.get("ar") or "xcrun -sdk macosx ar" - configs.linker.shared = config.get("ld") or "xcrun -sdk macosx clang++" + configs.linker.shared = config.get("sh") or "xcrun -sdk macosx clang++" -- init xcode sdk directory configs.xcode_sdkdir = config.get("xcode_dir") .. "/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX" .. config.get("xcode_sdkver") .. ".sdk" diff --git a/xmake/scripts/platform/platform.lua b/xmake/scripts/platform/platform.lua index 57f50576c..ec21f0300 100644 --- a/xmake/scripts/platform/platform.lua +++ b/xmake/scripts/platform/platform.lua @@ -105,37 +105,64 @@ function platform.filename(name, kind) end -- get the linker from the given name -function platform.linker(name) +function platform.linker(kind) -- check - assert(name) + assert(kind) + + -- init linkers + platform._LINKERS = platform._LINKERS or {} + local linkers = platform._LINKERS + + -- return it directly if the linker has been cached + local l = linkers[kind] + if l then return l end -- get linker local c = platform.get("linker") assert(c) -- load linker - c = c[name] - if c then - return linker.load(c) - end + c = c[kind] + if c then return linker.load(c) end + + -- cache this linker + linkers[kind] = l + + -- ok + return l end --- get the compiler from the given name -function platform.compiler(name) +-- get the compiler from the given source file +function platform.compiler(srcfile) - -- check - assert(name) + -- get the source file type + local filetype = compiler.filetype(srcfile) + if not filetype then + return + end + + -- init compilers + platform._COMPILERS = platform._COMPILERS or {} + local compilers = platform._COMPILERS - -- get compiler - local c = platform.get("compiler") + -- return it directly if the compiler has been cached + local c = compilers[filetype] + if c then return c, filetype end + + -- get compiler from the current platform + c = platform.get("compiler") assert(c) -- load compiler - c = c[name] - if c then - return compiler.load(c) - end + c = c[filetype] + if c then c = compiler.load(c) end + + -- cache this compiler + compilers[filetype] = c + + -- ok + return c, filetype end -- dump the platform configure |
