diff options
| author | ruki <[email protected]> | 2017-07-12 18:34:01 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-07-12 18:34:01 +0800 |
| commit | b72d2cd32d1919170eb621dd6c0074c975eb67e1 (patch) | |
| tree | d34c3d1fbae58091301403fd9dc450bdad78647e /xmake/modules/core/tools | |
| parent | 693619f971581f9b7bc66fcdb1ef65d01aa002e5 (diff) | |
modify compflags and add compargv
Diffstat (limited to 'xmake/modules/core/tools')
| -rw-r--r-- | xmake/modules/core/tools/ar.lua | 12 | ||||
| -rw-r--r-- | xmake/modules/core/tools/gcc.lua | 42 |
2 files changed, 32 insertions, 22 deletions
diff --git a/xmake/modules/core/tools/ar.lua b/xmake/modules/core/tools/ar.lua index bce088fc3..bfbc8a577 100644 --- a/xmake/modules/core/tools/ar.lua +++ b/xmake/modules/core/tools/ar.lua @@ -49,14 +49,14 @@ function strip(self, level) return maps[level] end --- make the link command -function linkcmd(self, objectfiles, targetkind, targetfile, flags) +-- make the link arguments list +function linkargv(self, objectfiles, targetkind, targetfile, flags) -- check assert(targetkind == "static") -- make it - return format("%s %s %s %s", self:program(), flags, targetfile, objectfiles) + return self:program(), table.join(flags or {}, targetfile, objectfiles) end -- link the library file @@ -69,7 +69,7 @@ function link(self, objectfiles, targetkind, targetfile, flags) os.mkdir(path.directory(targetfile)) -- link it - os.run(linkcmd(self, objectfiles, targetkind, targetfile, flags)) + os.runv(linkargv(self, objectfiles, targetkind, targetfile, flags)) end -- extract the static library to object directory @@ -85,11 +85,11 @@ function extract(self, libraryfile, objectdir) local olddir = os.cd(objectdir) -- extract it - os.run("%s -x %s", self:program(), libraryfile) + os.runv(self:program(), {"-x", libraryfile}) -- check repeat object name local repeats = {} - local objectfiles = os.iorun("%s -t %s", self:program(), libraryfile) + local objectfiles = os.iorunv(self:program(), {"-t", libraryfile}) for _, objectfile in ipairs(objectfiles:split('\n')) do if repeats[objectfile] then raise("object name(%s) conflicts in library: %s", objectfile, libraryfile) diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index 62d41abc3..3d510fb39 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -243,9 +243,9 @@ function nf_framework(self, framework) return {"-framework", framework} end --- make the link command -function linkcmd(self, objectfiles, targetkind, targetfile, flags) - return format("%s -o %s %s %s", self:program(), targetfile, objectfiles, flags) +-- make the link arguments list +function linkargv(self, objectfiles, targetkind, targetfile, flags) + return self:program(), table.join("-o", targetfile, objectfiles, flags) end -- link the target file @@ -255,11 +255,11 @@ function link(self, objectfiles, targetkind, targetfile, flags) os.mkdir(path.directory(targetfile)) -- link it - os.run(linkcmd(self, objectfiles, targetkind, targetfile, flags)) + os.runv(linkargv(self, objectfiles, targetkind, targetfile, flags)) end --- make the complie command -function _compcmd1(self, sourcefile, objectfile, flags) +-- make the complie arguments list +function _compargv1(self, sourcefile, objectfile, flags) -- get ccache local ccache = nil @@ -267,14 +267,24 @@ function _compcmd1(self, sourcefile, objectfile, flags) ccache = find_ccache() end - -- make it - local command = format("%s -c %s -o %s %s", self:program(), flags, objectfile, sourcefile) + -- make argv + local argv = table.join("-c", flags or {}, "-o", objectfile, sourcefile) + + -- uses cache? + local program = self:program() if ccache then - command = ccache:append(command, " ") + + -- parse the filename and arguments, .e.g "xcrun -sdk macosx clang" + if not os.isexec(program) then + argv = table.join(program:split("%s"), argv) + else + table.insert(argv, 1, program) + end + return ccache, argv end - -- ok - return command + -- no cache + return program, argv end -- complie the source file @@ -287,7 +297,7 @@ function _compile1(self, sourcefile, objectfile, incdepfile, flags) try { function () - local outdata, errdata = os.iorun(_compcmd1(self, sourcefile, objectfile, flags)) + local outdata, errdata = os.iorunv(_compargv1(self, sourcefile, objectfile, flags)) return (outdata or "") .. (errdata or "") end, catch @@ -317,7 +327,7 @@ function _compile1(self, sourcefile, objectfile, incdepfile, flags) local tmpfile = os.tmpfile() -- generate it - os.run("%s -c -MM %s -o %s %s", self:program(), flags or "", tmpfile, sourcefile) + os.runv(self:program(), table.join("-c", "-MM", flags or {}, "-o", tmpfile, sourcefile)) -- translate it local results = {} @@ -338,14 +348,14 @@ function _compile1(self, sourcefile, objectfile, incdepfile, flags) end end --- make the complie command -function compcmd(self, sourcefiles, objectfile, flags) +-- make the complie arguments list +function compargv(self, sourcefiles, objectfile, flags) -- only support single source file now assert(type(sourcefiles) ~= "table", "'object:sources' not support!") -- for only single source file - return _compcmd1(self, sourcefiles, objectfile, flags) + return _compargv1(self, sourcefiles, objectfile, flags) end -- complie the source file |
