diff options
| author | ruki <[email protected]> | 2015-06-02 09:35:37 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-06-02 09:35:37 +0800 |
| commit | f6177ffb405aa474e5d8e8af787778bd8ed8439c (patch) | |
| tree | c4520100c7b617a4ef54f137f2f8acb13d98f5ab /xmake/scripts/platform/platform.lua | |
| parent | 52b7de2f4d73e08aba2fea79aa04bb06a9af449d (diff) | |
add linker and compiler common flags
Diffstat (limited to 'xmake/scripts/platform/platform.lua')
| -rw-r--r-- | xmake/scripts/platform/platform.lua | 59 |
1 files changed, 43 insertions, 16 deletions
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 |
