diff options
| author | ruki <[email protected]> | 2016-04-14 09:31:29 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-04-14 09:31:29 +0800 |
| commit | 1479b3c2c9ef3621fec864c0dd305ad4b1f5c60f (patch) | |
| tree | 0d9a4039f232ec44940f3ceab90e001594a454b5 | |
| parent | 9e736d8b83930330edaee2958b4c66093ca87e37 (diff) | |
add swiftc and remove tools
| -rw-r--r-- | xmake/actions/lua/scripts/cat.lua (renamed from xmake/core/platform/tools/cat.lua) | 17 | ||||
| -rw-r--r-- | xmake/core/platform/tools/ar.lua | 114 | ||||
| -rw-r--r-- | xmake/core/platform/tools/clang++.lua | 38 | ||||
| -rw-r--r-- | xmake/core/platform/tools/clang.lua | 38 | ||||
| -rw-r--r-- | xmake/core/platform/tools/dispatcher.lua | 80 | ||||
| -rw-r--r-- | xmake/core/platform/tools/g++.lua | 38 | ||||
| -rw-r--r-- | xmake/core/platform/tools/gcc.lua | 192 | ||||
| -rw-r--r-- | xmake/core/platform/tools/make.lua | 84 | ||||
| -rw-r--r-- | xmake/tools/compiler/swiftc.lua (renamed from xmake/core/platform/tools/swiftc.lua) | 55 | ||||
| -rwxr-xr-x | xmake/tools/gas-preprocessor.pl (renamed from xmake/core/platform/tools/gas-preprocessor.pl) | 0 |
10 files changed, 21 insertions, 635 deletions
diff --git a/xmake/core/platform/tools/cat.lua b/xmake/actions/lua/scripts/cat.lua index 5eb14c88f..bb5f679f1 100644 --- a/xmake/core/platform/tools/cat.lua +++ b/xmake/actions/lua/scripts/cat.lua @@ -20,24 +20,13 @@ -- @file cat.lua -- --- define module: cat -local cat = cat or {} - --- load modules -local io = require("base/io") -local os = require("base/os") - --- the main function -function cat.main(self, ...) +-- main +function main(...) -- cat all for _, v in ipairs(...) do if os.isfile(v) then io.cat(v) end end + print("") - -- ok - return true end - --- return module: cat -return cat diff --git a/xmake/core/platform/tools/ar.lua b/xmake/core/platform/tools/ar.lua deleted file mode 100644 index 46b420e55..000000000 --- a/xmake/core/platform/tools/ar.lua +++ /dev/null @@ -1,114 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- XMake is free software; you can redistribute it and/or modify --- it under the terms of the GNU Lesser General Public License as published by --- the Free Software Foundation; either version 2.1 of the License, or --- (at your option) any later version. --- --- XMake is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public License --- along with XMake; --- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> --- --- Copyright (C) 2015 - 2016, ruki All rights reserved. --- --- @author ruki --- @file ar.lua --- - --- define module: ar -local ar = ar or {} - --- load modules -local utils = require("base/utils") -local string = require("base/string") -local config = require("project/config") - --- init the linker -function ar.init(self, name) - - -- save name - self.name = name or "ar" - - -- init arflags - self.arflags = { "-crs" } - -end - --- make the link command -function ar.command_link(self, objfiles, targetfile, flags, logfile) - - -- redirect - local redirect = "" - if logfile then redirect = string.format(" > %s 2>&1", logfile) end - - -- make it - return string.format("%s %s %s %s%s", self.name, flags, targetfile, objfiles, redirect) -end - --- extract the static library to object files -function ar.extract(self, ...) - - -- check - local args = ... - assert(#args == 2 and self.name) - - -- get library and object file path - local libfile = args[1] - local objfile = args[2] - assert(libfile and objfile) - - -- get object directory - local objdir = path.directory(objfile) - if not os.isdir(objdir) then os.mkdir(objdir) end - if not os.isdir(objdir) then - utils.error("%s not found!", objdir) - return false - end - - -- absolute the library path - libfile = path.absolute(libfile) - assert(libfile) - - -- enter the object directory - ok, errors = os.cd(objdir) - if not ok then - utils.error(errors) - return false - end - - -- extract it - local ok = self:main(string.format("%s -x %s", self.name, libfile)) - if not ok then - utils.error("extract %s to %s failed!", libfile, objdir) - return false - end - - -- leave the object directory - ok, errors = os.cd("-") - if not ok then - utils.error(errors) - return false - end - - -- ok - return true -end - - --- the main function -function ar.main(self, cmd) - - -- execute it - local ok = os.execute(cmd) - - -- ok? - return utils.ifelse(ok == 0, true, false) -end - --- return module: ar -return ar diff --git a/xmake/core/platform/tools/clang++.lua b/xmake/core/platform/tools/clang++.lua deleted file mode 100644 index dd261df7d..000000000 --- a/xmake/core/platform/tools/clang++.lua +++ /dev/null @@ -1,38 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- XMake is free software; you can redistribute it and/or modify --- it under the terms of the GNU Lesser General Public License as published by --- the Free Software Foundation; either version 2.1 of the License, or --- (at your option) any later version. --- --- XMake is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public License --- along with XMake; --- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> --- --- Copyright (C) 2015 - 2016, ruki All rights reserved. --- --- @author ruki --- @file clang.lua --- - --- load modules -local gcc = require("platform/tools/gcc") - --- define module: clang++ -local clangxx = clangxx or {} - --- only copy the interfaces of gcc to clang++ -for k, v in pairs(gcc) do - if type(v) == "function" then - clangxx[k] = v - end -end - --- return module: clang++ -return clangxx - diff --git a/xmake/core/platform/tools/clang.lua b/xmake/core/platform/tools/clang.lua deleted file mode 100644 index 8cff2dab5..000000000 --- a/xmake/core/platform/tools/clang.lua +++ /dev/null @@ -1,38 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- XMake is free software; you can redistribute it and/or modify --- it under the terms of the GNU Lesser General Public License as published by --- the Free Software Foundation; either version 2.1 of the License, or --- (at your option) any later version. --- --- XMake is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public License --- along with XMake; --- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> --- --- Copyright (C) 2015 - 2016, ruki All rights reserved. --- --- @author ruki --- @file clang.lua --- - --- load modules -local gcc = require("platform/tools/gcc") - --- define module: clang -local clang = clang or {} - --- only copy the interfaces of gcc to clang -for k, v in pairs(gcc) do - if type(v) == "function" then - clang[k] = v - end -end - --- return module: clang -return clang - diff --git a/xmake/core/platform/tools/dispatcher.lua b/xmake/core/platform/tools/dispatcher.lua deleted file mode 100644 index 32deb3f2d..000000000 --- a/xmake/core/platform/tools/dispatcher.lua +++ /dev/null @@ -1,80 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- XMake is free software; you can redistribute it and/or modify --- it under the terms of the GNU Lesser General Public License as published by --- the Free Software Foundation; either version 2.1 of the License, or --- (at your option) any later version. --- --- XMake is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public License --- along with XMake; --- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> --- --- Copyright (C) 2015 - 2016, ruki All rights reserved. --- --- @author ruki --- @file dispatcher.lua --- - --- define module: dispatcher -local dispatcher = dispatcher or {} - --- load modules -local os = require("base/os") -local path = require("base/path") -local utils = require("base/utils") -local string = require("base/string") -local tools = require("platform/tool") - --- the main function --- --- dispatcher toolname toolpath action arguments ... -function dispatcher.main(self, ...) - - -- check - local args = ... - assert(#args >= 2) - - -- get tool kind and action name - local tool_kind = args[1] - local action_name = args[2] - assert(tool_kind and action_name) - - -- get the tool - local tool = tools.get(tool_kind) - if tool then - - -- load action - local action = tool[action_name] - if action then - - -- init arguments for action - local action_args = {} - for i = 3, #args do - table.insert(action_args, args[i]:decode()) - end - - -- done action - if not action(tool, action_args) then - utils.error("run action %s failed!", action_name) - assert(false) - end - else - utils.error("load action %s failed!", action_name) - assert(false) - end - - else - assert(false) - end - - -- ok - return true -end - --- return module: dispatcher -return dispatcher diff --git a/xmake/core/platform/tools/g++.lua b/xmake/core/platform/tools/g++.lua deleted file mode 100644 index 82dc7f627..000000000 --- a/xmake/core/platform/tools/g++.lua +++ /dev/null @@ -1,38 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- XMake is free software; you can redistribute it and/or modify --- it under the terms of the GNU Lesser General Public License as published by --- the Free Software Foundation; either version 2.1 of the License, or --- (at your option) any later version. --- --- XMake is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public License --- along with XMake; --- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> --- --- Copyright (C) 2015 - 2016, ruki All rights reserved. --- --- @author ruki --- @file g++.lua --- - --- load modules -local gcc = require("platform/tools/gcc") - --- define module: gxx -local gxx = gxx or {} - --- only copy the interfaces of gcc to g++ -for k, v in pairs(gcc) do - if type(v) == "function" then - gxx[k] = v - end -end - --- return module: g++ -return gxx - diff --git a/xmake/core/platform/tools/gcc.lua b/xmake/core/platform/tools/gcc.lua deleted file mode 100644 index 637f9792b..000000000 --- a/xmake/core/platform/tools/gcc.lua +++ /dev/null @@ -1,192 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- XMake is free software; you can redistribute it and/or modify --- it under the terms of the GNU Lesser General Public License as published by --- the Free Software Foundation; either version 2.1 of the License, or --- (at your option) any later version. --- --- XMake is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public License --- along with XMake; --- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> --- --- Copyright (C) 2015 - 2016, ruki All rights reserved. --- --- @author ruki --- @file gcc.lua --- - --- load modules -local utils = require("base/utils") -local table = require("base/table") -local string = require("base/string") -local config = require("project/config") -local platform = require("platform/platform") - --- define module: gcc -local gcc = gcc or {} - --- check the given flag -function gcc._check(self, flag) - - -- this flag has been checked? - self._CHECK = self._CHECK or {} - if self._CHECK[flag] then - return self._CHECK[flag] - end - - -- check it - local result = flag - if 0 ~= os.execute(string.format("%s %s -S -o %s -xc %s > %s 2>&1", self.name, flag, xmake._NULDEV, xmake._NULDEV, xmake._NULDEV)) then - result = "" - end - - -- trace - utils.verbose("checking for the compiler flags %s ... %s", flag, utils.ifelse(#result ~= 0, "ok", "no")) - - -- save it - self._CHECK[flag] = result - - -- ok? - return result -end - --- the init function -function gcc.init(self, name) - - -- save name - self.name = name or "gcc" - - -- init mxflags - self.mxflags = { "-fmessage-length=0" - , "-pipe" - , "-fpascal-strings" - , "\"-DIBOutlet=__attribute__((iboutlet))\"" - , "\"-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))\"" - , "\"-DIBAction=void)__attribute__((ibaction)\""} - - -- init shflags - if name:find("clang") then - self.shflags = { "-dynamiclib", "-fPIC" } - else - self.shflags = { "-shared", "-fPIC" } - end - - -- init cxflags for the kind: shared - self.shared = {} - self.shared.cxflags = {"-fPIC"} - - -- suppress warning for the clang - local isclang = false - if name:find("clang") then - isclang = true - self.cxflags = self.cxflags or {} - self.mxflags = self.mxflags or {} - self.asflags = self.asflags or {} - table.join2(self.cxflags, "-Qunused-arguments") - table.join2(self.mxflags, "-Qunused-arguments") - table.join2(self.asflags, "-Qunused-arguments") - end - - -- init flags map - self.mapflags = - { - -- vectorexts - ["-mmmx"] = self._check - , ["-msse$"] = self._check - , ["-msse2"] = self._check - , ["-msse3"] = self._check - , ["-mssse3"] = self._check - , ["-mavx$"] = self._check - , ["-mavx2"] = self._check - , ["-mfpu=.*"] = self._check - - -- warnings - , ["-W1"] = "-Wall" - , ["-W2"] = "-Wall" - , ["-W3"] = "-Wall" - - -- strip - , ["-s"] = utils.ifelse(isclang, "-Wl,-S", "-s") - , ["-S"] = utils.ifelse(isclang, "-Wl,-S", "-S") - - -- others - , ["-ftrapv"] = self._check - , ["-fsanitize=address"] = self._check - } - -end - --- make the compile command -function gcc.command_compile(self, srcfile, objfile, flags, logfile) - - -- redirect - local redirect = "" - if logfile then redirect = string.format(" > %s 2>&1", logfile) end - - -- make it - return string.format("%s -c %s -o %s %s%s", self.name, flags, objfile, srcfile, redirect) -end - --- make the link command -function gcc.command_link(self, objfiles, targetfile, flags, logfile) - - -- redirect - local redirect = "" - if logfile then redirect = string.format(" > %s 2>&1", logfile) end - - -- make it - return string.format("%s -o %s %s %s%s", self.name, targetfile, objfiles, flags, redirect) -end - --- make the define flag -function gcc.flag_define(self, define) - - -- make it - return "-D" .. define:gsub("\"", "\\\"") -end - --- make the undefine flag -function gcc.flag_undefine(self, undefine) - - -- make it - return "-U" .. undefine -end - --- make the includedir flag -function gcc.flag_includedir(self, includedir) - - -- make it - return "-I" .. includedir -end - --- make the link flag -function gcc.flag_link(self, link) - - -- make it - return "-l" .. link -end - --- make the linkdir flag -function gcc.flag_linkdir(self, linkdir) - - -- make it - return "-L" .. linkdir -end - --- the main function -function gcc.main(self, cmd) - - -- execute it - local ok = os.execute(cmd) - - -- ok? - return utils.ifelse(ok == 0, true, false) -end - --- return module: gcc -return gcc diff --git a/xmake/core/platform/tools/make.lua b/xmake/core/platform/tools/make.lua deleted file mode 100644 index dc9681277..000000000 --- a/xmake/core/platform/tools/make.lua +++ /dev/null @@ -1,84 +0,0 @@ ---!The Automatic Cross-platform Build Tool --- --- XMake is free software; you can redistribute it and/or modify --- it under the terms of the GNU Lesser General Public License as published by --- the Free Software Foundation; either version 2.1 of the License, or --- (at your option) any later version. --- --- XMake is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU Lesser General Public License for more details. --- --- You should have received a copy of the GNU Lesser General Public License --- along with XMake; --- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> --- --- Copyright (C) 2015 - 2016, ruki All rights reserved. --- --- @author ruki --- @file make.lua --- - --- load modules -local os = require("base/os") -local utils = require("base/utils") -local option = require("base/option") - --- define module: make -local make = make or {} - --- the init function -function make.init(self, name) - - -- save name - self.name = name or "make" - - -- is verbose? - self._VERBOSE = utils.ifelse(option.get("verbose"), "-v", "") - -end - --- the main function -function make.main(self, makefile, target, jobs) - - -- enable jobs? - if jobs ~= nil then - if tonumber(jobs) ~= 0 then - jobs = "-j" .. jobs - else - jobs = "-j" - end - else - jobs = "" - end - - -- make command - local cmd = nil - if makefile and os.isfile(makefile) then - cmd = string.format("%s -r %s -f %s %s VERBOSE=%s", self.name, jobs, makefile, target or "", self._VERBOSE) - else - cmd = string.format("%s -r %s %s VERBOSE=%s", self.name, jobs, target or "", self._VERBOSE) - end - - -- done - local ok = os.execute(cmd) - if ok ~= 0 then - - -- attempt to execute it again for getting the error logs without jobs - if makefile and os.isfile(makefile) then - cmd = string.format("%s -r -f %s %s VERBOSE=%s", self.name, makefile, target or "", self._VERBOSE) - else - cmd = string.format("%s -r %s VERBOSE=%s", self.name, target or "", self._VERBOSE) - end - - -- done - return os.execute(cmd) == 0 - end - - -- ok - return true -end - --- return module: make -return make diff --git a/xmake/core/platform/tools/swiftc.lua b/xmake/tools/compiler/swiftc.lua index fa09d566c..b61a342d6 100644 --- a/xmake/core/platform/tools/swiftc.lua +++ b/xmake/tools/compiler/swiftc.lua @@ -20,24 +20,17 @@ -- @file swiftc.lua -- --- load modules -local utils = require("base/utils") -local table = require("base/table") -local string = require("base/string") -local config = require("project/config") -local platform = require("platform/platform") +-- imports +import("core.project.config") --- define module: swiftc -local swiftc = swiftc or {} - --- the init function -function swiftc.init(self, name) - - -- save name - self.name = name or "swiftc" +-- init it +function init(shellname) + + -- save the shell name + _g.shellname = shellname or "swiftc" -- init flags map - self.mapflags = + _g.mapflags = { -- symbols ["-fvisibility=hidden"] = "" @@ -66,52 +59,40 @@ function swiftc.init(self, name) -- init ldflags local swift_linkdirs = config.get("__swift_linkdirs") if swift_linkdirs then - self.ldflags = { "-L" .. swift_linkdirs } + _g.ldflags = { "-L" .. swift_linkdirs } end end -- make the compile command -function swiftc.command_compile(self, srcfile, objfile, flags, logfile) +function command(srcfile, objfile, flags, logfile) -- redirect local redirect = "" - if logfile then redirect = string.format(" > %s 2>&1", logfile) end + if logfile then redirect = format(" > %s 2>&1", logfile) end -- make it - return string.format("%s -c %s -o %s %s%s", self.name, flags, objfile, srcfile, redirect) + return format("%s -c %s -o %s %s%s", _g.shellname, flags, objfile, srcfile, redirect) end -- make the includedir flag -function swiftc.flag_includedir(self, includedir) +function includedir(dir) -- make it - return "-Xcc -I" .. includedir + return "-Xcc -I" .. dir end -- make the define flag -function swiftc.flag_define(self, define) +function define(macro) -- make it - return "-Xcc -D" .. define:gsub("\"", "\\\"") + return "-Xcc -D" .. macro:gsub("\"", "\\\"") end -- make the undefine flag -function swiftc.flag_undefine(self, undefine) +function undefine(macro) -- make it - return "-Xcc -U" .. undefine -end - --- the main function -function swiftc.main(self, cmd) - - -- execute it - local ok = os.execute(cmd) - - -- ok? - return utils.ifelse(ok == 0, true, false) + return "-Xcc -U" .. macro end --- return module: swiftc -return swiftc diff --git a/xmake/core/platform/tools/gas-preprocessor.pl b/xmake/tools/gas-preprocessor.pl index 98dfe4ad9..98dfe4ad9 100755 --- a/xmake/core/platform/tools/gas-preprocessor.pl +++ b/xmake/tools/gas-preprocessor.pl |
