diff options
| author | ruki <[email protected]> | 2017-07-12 13:07:18 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-07-12 13:07:18 +0800 |
| commit | f6688e9eaff8ce02c097ba4e1da27d9efd8ece90 (patch) | |
| tree | 00248715b7f53a9957d35d833fc4f3127a86f0f7 | |
| parent | 7346528e00d1175b1ee4ce0c88234434a47a35ec (diff) | |
add os.args and fix command args
| -rw-r--r-- | xmake/core/base/os.lua | 29 | ||||
| -rw-r--r-- | xmake/core/tool/compiler.lua | 2 | ||||
| -rw-r--r-- | xmake/core/tool/linker.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/core/tools/dmd.lua | 2 | ||||
| -rw-r--r-- | xmake/platforms/android/load.lua | 4 | ||||
| -rw-r--r-- | xmake/platforms/iphoneos/load.lua | 16 | ||||
| -rw-r--r-- | xmake/platforms/macosx/load.lua | 2 | ||||
| -rw-r--r-- | xmake/platforms/mingw/load.lua | 10 | ||||
| -rw-r--r-- | xmake/platforms/watchos/load.lua | 16 | ||||
| -rw-r--r-- | xmake/platforms/windows/xmake.lua | 6 |
10 files changed, 59 insertions, 30 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 6616c2849..aeab699c4 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -156,6 +156,35 @@ function os.argw(argv) return results end +-- make string from arguments list +function os.args(argv) + + -- make it + local args = nil + for _, arg in ipairs(argv) do + arg = arg:trim() + if #arg > 0 then + arg = arg:gsub("([\"\\])", "\\%1") + if arg:find("%s") then + if args then + args = args .. " \"" .. arg .. "\"" + else + args = "\"" .. arg .. "\"" + end + else + if args then + args = args .. " " .. arg + else + args = arg + end + end + end + end + + -- ok? + return args or "" +end + -- match files or directories -- -- @param pattern the search pattern diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua index e6104608f..c477f8d8a 100644 --- a/xmake/core/tool/compiler.lua +++ b/xmake/core/tool/compiler.lua @@ -245,7 +245,7 @@ function compiler:compflags(opt) self:_addflags_from_compiler(flags, targetkind) -- make flags string - local flags_str = table.concat(flags, " "):trim():gsub("\"", "\\\"") + local flags_str = os.args(flags) -- save flags if key then diff --git a/xmake/core/tool/linker.lua b/xmake/core/tool/linker.lua index c6144a7bb..c313c045b 100644 --- a/xmake/core/tool/linker.lua +++ b/xmake/core/tool/linker.lua @@ -252,7 +252,7 @@ function linker:linkflags(opt) self:_addflags_from_linker(flags) -- make flags string - local flags_str = table.concat(flags, " "):trim():gsub("\"", "\\\"") + local flags_str = os.args(flags) -- save flags if key then diff --git a/xmake/modules/core/tools/dmd.lua b/xmake/modules/core/tools/dmd.lua index 45f915afc..30c0ce394 100644 --- a/xmake/modules/core/tools/dmd.lua +++ b/xmake/modules/core/tools/dmd.lua @@ -58,7 +58,7 @@ function nf_optimize(self, level) -- the maps local maps = { - , fast = {"-O"} + fast = {"-O"} , faster = {"-O", "-release"} , fastest = {"-O", "-release", "-inline", "-boundscheck=off"} , smallest = {"-O", "-release", "-boundscheck=off"} diff --git a/xmake/platforms/android/load.lua b/xmake/platforms/android/load.lua index 102540e71..36725f271 100644 --- a/xmake/platforms/android/load.lua +++ b/xmake/platforms/android/load.lua @@ -113,8 +113,8 @@ function main() -- init flags for rust _g.rcflags = { "--target=" .. targets[arch] } - _g["rc-shflags"] = { "-C", "linker=" .. config.get("sh"), "-C", "link-args=\"" .. (table.concat(_g.shflags, " "):gsub("%-march=.-%s", "")) .. "\"" } - _g["rc-ldflags"] = { "-C", "linker=" .. config.get("ld"), "-C", "link-args=\"" .. (table.concat(_g.ldflags, " "):gsub("%-march=.-%s", "")) .. "\"" } + _g["rc-shflags"] = { "-C", "linker=" .. config.get("sh"), "-C", "link-args=" .. (table.concat(_g.shflags, " "):gsub("%-march=.-%s", ""))} + _g["rc-ldflags"] = { "-C", "linker=" .. config.get("ld"), "-C", "link-args=" .. (table.concat(_g.ldflags, " "):gsub("%-march=.-%s", ""))} -- ok return _g diff --git a/xmake/platforms/iphoneos/load.lua b/xmake/platforms/iphoneos/load.lua index f6c67c88f..c422ef234 100644 --- a/xmake/platforms/iphoneos/load.lua +++ b/xmake/platforms/iphoneos/load.lua @@ -45,20 +45,20 @@ function main() local xcode_sdkdir = format("%s/Contents/Developer/Platforms/%s.platform/Developer/SDKs/%s%s.sdk", xcode_dir, platname, platname, xcode_sdkver) -- init flags for c/c++ - _g.cxflags = { "-arch " .. arch, target_minver_flags, "-isysroot " .. xcode_sdkdir } - _g.ldflags = { "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", target_minver_flags, "-isysroot " .. xcode_sdkdir } - _g.shflags = { "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", target_minver_flags, "-isysroot " .. xcode_sdkdir } + _g.cxflags = { "-arch", arch, target_minver_flags, "-isysroot", xcode_sdkdir } + _g.ldflags = { "-arch", arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", target_minver_flags, "-isysroot", xcode_sdkdir } + _g.shflags = { "-arch", arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", target_minver_flags, "-isysroot", xcode_sdkdir } -- init flags for objc/c++ - _g.mxflags = { "-arch " .. arch, target_minver_flags, "-isysroot " .. xcode_sdkdir } + _g.mxflags = { "-arch", arch, target_minver_flags, "-isysroot", xcode_sdkdir } -- init flags for asm - _g.asflags = { "-arch " .. arch, target_minver_flags, "-isysroot " .. xcode_sdkdir } + _g.asflags = { "-arch", arch, target_minver_flags, "-isysroot", xcode_sdkdir } -- init flags for swift (with _g.ldflags and _g.shflags) - _g.scflags = { format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sdkdir } - _g["sc-shflags"] = { format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sdkdir } - _g["sc-ldflags"] = { format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sdkdir } + _g.scflags = { "-target", format("%s-apple-ios%s", arch, target_minver) , "-sdk", xcode_sdkdir } + _g["sc-shflags"] = { "-target", format("%s-apple-ios%s", arch, target_minver) , "-sdk", xcode_sdkdir } + _g["sc-ldflags"] = { "-target", format("%s-apple-ios%s", arch, target_minver) , "-sdk", xcode_sdkdir } -- ok return _g diff --git a/xmake/platforms/macosx/load.lua b/xmake/platforms/macosx/load.lua index aa85a92ee..6baf60dcd 100644 --- a/xmake/platforms/macosx/load.lua +++ b/xmake/platforms/macosx/load.lua @@ -43,7 +43,7 @@ function main() _g.shflags = { "-arch", arch, "-mmacosx-version-min=" .. target_minver, "-isysroot", xcode_sdkdir, "-L/usr/local/lib", "-L/usr/lib", "-stdlib=libc++", "-lz" } -- init flags for objc/c++ (with _g.ldflags and _g.shflags) - _g.mxflags = { "-arch", arch, "-fpascal-strings", "-fmessage-length=0", "-isysroot " .. xcode_sdkdir } + _g.mxflags = { "-arch", arch, "-fpascal-strings", "-fmessage-length=0", "-isysroot", xcode_sdkdir } -- init flags for asm (with _g.ldflags and _g.shflags) _g.asflags = { "-arch", arch, "-isysroot", xcode_sdkdir } diff --git a/xmake/platforms/mingw/load.lua b/xmake/platforms/mingw/load.lua index 0199573d9..a312e8cff 100644 --- a/xmake/platforms/mingw/load.lua +++ b/xmake/platforms/mingw/load.lua @@ -34,13 +34,13 @@ function main() if arch then if arch == "x86_64" then archflags = "-m64" elseif arch == "i386" then archflags = "-m32" - else archflags = "-arch " .. arch + else archflags = {"-arch", arch} end end - _g.cxflags = { archflags } - _g.asflags = { archflags } - _g.ldflags = { archflags } - _g.shflags = { archflags } + _g.cxflags = table.wrap(archflags) + _g.asflags = table.wrap(archflags) + _g.ldflags = table.wrap(archflags) + _g.shflags = table.wrap(archflags) -- init linkdirs and includedirs local sdkdir = config.get("sdk") diff --git a/xmake/platforms/watchos/load.lua b/xmake/platforms/watchos/load.lua index 3d366f477..be5a96d82 100644 --- a/xmake/platforms/watchos/load.lua +++ b/xmake/platforms/watchos/load.lua @@ -45,20 +45,20 @@ function main() local xcode_sdkdir = format("%s/Contents/Developer/Platforms/%s.platform/Developer/SDKs/%s%s.sdk", xcode_dir, platname, platname, xcode_sdkver) -- init flags for c/c++ - _g.cxflags = { "-arch " .. arch, target_minver_flags, "-isysroot " .. xcode_sdkdir } - _g.ldflags = { "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", target_minver_flags, "-isysroot " .. xcode_sdkdir } - _g.shflags = { "-arch " .. arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", target_minver_flags, "-isysroot " .. xcode_sdkdir } + _g.cxflags = { "-arch", arch, target_minver_flags, "-isysroot", xcode_sdkdir } + _g.ldflags = { "-arch", arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", target_minver_flags, "-isysroot", xcode_sdkdir } + _g.shflags = { "-arch", arch, "-ObjC", "-lstdc++", "-fobjc-link-runtime", target_minver_flags, "-isysroot", xcode_sdkdir } -- init flags for objc/c++ - _g.mxflags = { "-arch " .. arch, target_minver_flags, "-isysroot " .. xcode_sdkdir } + _g.mxflags = { "-arch", arch, target_minver_flags, "-isysroot", xcode_sdkdir } -- init flags for asm - _g.asflags = { "-arch " .. arch, target_minver_flags, "-isysroot " .. xcode_sdkdir } + _g.asflags = { "-arch", arch, target_minver_flags, "-isysroot", xcode_sdkdir } -- init flags for swift (with _g.ldflags and _g.shflags) - _g.scflags = { format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sdkdir } - _g["sc-shflags"] = { format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sdkdir } - _g["sc-ldflags"] = { format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sdkdir } + _g.scflags = { "-target", format("%s-apple-ios%s", arch, target_minver) , "-sdk", xcode_sdkdir } + _g["sc-shflags"] = { "-target", format("%s-apple-ios%s", arch, target_minver) , "-sdk", xcode_sdkdir } + _g["sc-ldflags"] = { "-target", format("%s-apple-ios%s", arch, target_minver) , "-sdk", xcode_sdkdir } -- ok return _g diff --git a/xmake/platforms/windows/xmake.lua b/xmake/platforms/windows/xmake.lua index 8c90aa9df..65066025d 100644 --- a/xmake/platforms/windows/xmake.lua +++ b/xmake/platforms/windows/xmake.lua @@ -53,9 +53,9 @@ platform("windows") -- init flags for dlang local dc_archs = { x86 = "-m32", x64 = "-m64" } - _g.dcflags = { dc_archs[arch] or "" } - _g["dc-shflags"] = { dc_archs[arch] or "" } - _g["dc-ldflags"] = { dc_archs[arch] or "" } + _g.dcflags = { dc_archs[arch] } + _g["dc-shflags"] = { dc_archs[arch] } + _g["dc-ldflags"] = { dc_archs[arch] } -- ok return _g |
