diff options
| author | ruki <[email protected]> | 2017-02-15 20:16:00 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-02-15 20:16:00 +0800 |
| commit | 80d3a926e762d7b05654fdc778c70dad9881356d (patch) | |
| tree | 34fcd030a4534e094a33d98adf70efbcd80e5438 | |
| parent | 97a9f451af73896e0b3f9158962e23bcff9787d1 (diff) | |
remove archiver
| -rwxr-xr-x | xmake/actions/build/kinds/static.lua | 8 | ||||
| -rw-r--r-- | xmake/core/language/language.lua | 6 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/tool/archiver.lua | 63 | ||||
| -rw-r--r-- | xmake/core/tool/archiver.lua | 126 | ||||
| -rw-r--r-- | xmake/core/tool/builder.lua | 76 | ||||
| -rw-r--r-- | xmake/core/tool/compiler.lua | 2 | ||||
| -rw-r--r-- | xmake/core/tool/linker.lua | 60 | ||||
| -rwxr-xr-x | xmake/languages/asm/xmake.lua | 21 | ||||
| -rwxr-xr-x | xmake/languages/c++/xmake.lua | 21 | ||||
| -rwxr-xr-x | xmake/languages/golang/xmake.lua | 19 | ||||
| -rwxr-xr-x | xmake/languages/objc++/xmake.lua | 25 | ||||
| -rwxr-xr-x | xmake/languages/swift/xmake.lua | 25 | ||||
| -rwxr-xr-x | xmake/plugins/project/makefile/makefile.lua | 8 | ||||
| -rw-r--r-- | xmake/tools/ar.lua | 12 | ||||
| -rwxr-xr-x | xmake/tools/go.lua | 4 | ||||
| -rwxr-xr-x | xmake/tools/link.lua | 10 |
16 files changed, 184 insertions, 302 deletions
diff --git a/xmake/actions/build/kinds/static.lua b/xmake/actions/build/kinds/static.lua index 4df049a47..612ba194b 100755 --- a/xmake/actions/build/kinds/static.lua +++ b/xmake/actions/build/kinds/static.lua @@ -24,7 +24,7 @@ -- imports import("core.base.option") -import("core.tool.archiver") +import("core.tool.linker") import("object") -- build binary target @@ -75,10 +75,10 @@ function build(target, buildinfo) -- trace verbose info if verbose then - print(archiver.archivecmd(objectfiles, targetfile, target)) + print(linker.linkcmd(objectfiles, targetfile, target)) end - -- archive it - archiver.archive(objectfiles, targetfile, target) + -- link it + linker.link(objectfiles, targetfile, target) end diff --git a/xmake/core/language/language.lua b/xmake/core/language/language.lua index c4d19c5b3..4b0ee358c 100644 --- a/xmake/core/language/language.lua +++ b/xmake/core/language/language.lua @@ -163,10 +163,10 @@ function _instance:nameflags() -- get nameflags local results = {} - for toolkind, nameflags in pairs(table.wrap(self._INFO.nameflags)) do + for targetkind, nameflags in pairs(table.wrap(self._INFO.nameflags)) do -- make tool info - local toolinfo = results[toolkind] or {} + local toolinfo = results[targetkind] or {} for _, namedflag in ipairs(nameflags) do -- split it by '.' @@ -195,7 +195,7 @@ function _instance:nameflags() end -- save this tool info - results[toolkind] = toolinfo + results[targetkind] = toolinfo end -- cache this results diff --git a/xmake/core/sandbox/modules/import/core/tool/archiver.lua b/xmake/core/sandbox/modules/import/core/tool/archiver.lua deleted file mode 100644 index 1eac4bac2..000000000 --- a/xmake/core/sandbox/modules/import/core/tool/archiver.lua +++ /dev/null @@ -1,63 +0,0 @@ ---!The Make-like Build Utility based on Lua --- --- Licensed to the Apache Software Foundation (ASF) under one --- or more contributor license agreements. See the NOTICE file --- distributed with this work for additional information --- regarding copyright ownership. The ASF licenses this file --- to you under the Apache License, Version 2.0 (the --- "License"); you may not use this file except in compliance --- with the License. You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015 - 2017, TBOOX Open Source Group. --- --- @author ruki --- @file archiver.lua --- - --- define module -local sandbox_core_tool_archiver = sandbox_core_tool_archiver or {} - --- load modules -local platform = require("platform/platform") -local archiver = require("tool/archiver") -local raise = require("sandbox/modules/raise") - --- make command for archiving library file -function sandbox_core_tool_archiver.archivecmd(objectfiles, targetfile, target) - - -- get the archiver instance - local instance, errors = archiver.load(target:sourcekinds()) - if not instance then - raise(errors) - end - - -- make command - return instance:archivecmd(objectfiles, targetfile, target) -end - --- archive library file -function sandbox_core_tool_archiver.archive(objectfiles, targetfile, target) - - -- get the archiver instance - local instance, errors = archiver.load(target:sourcekinds()) - if not instance then - raise(errors) - end - - -- archive it - local ok, errors = instance:archive(objectfiles, targetfile, target) - if not ok then - raise(errors) - end -end - --- return module -return sandbox_core_tool_archiver diff --git a/xmake/core/tool/archiver.lua b/xmake/core/tool/archiver.lua deleted file mode 100644 index dcc630261..000000000 --- a/xmake/core/tool/archiver.lua +++ /dev/null @@ -1,126 +0,0 @@ ---!The Make-like Build Utility based on Lua --- --- Licensed to the Apache Software Foundation (ASF) under one --- or more contributor license agreements. See the NOTICE file --- distributed with this work for additional information --- regarding copyright ownership. The ASF licenses this file --- to you under the Apache License, Version 2.0 (the --- "License"); you may not use this file except in compliance --- with the License. You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015 - 2017, TBOOX Open Source Group. --- --- @author ruki --- @file archiver.lua --- - --- define module -local archiver = archiver or {} - --- load modules -local io = require("base/io") -local path = require("base/path") -local utils = require("base/utils") -local table = require("base/table") -local string = require("base/string") -local option = require("base/option") -local config = require("project/config") -local sandbox = require("sandbox/sandbox") -local language = require("language/language") -local platform = require("platform/platform") -local tool = require("tool/tool") -local builder = require("tool/builder") - --- get the flags -function archiver:_flags(target) - - -- get the target key - local key = tostring(target) - - -- get it directly from cache dirst - self._FLAGS = self._FLAGS or {} - if self._FLAGS[key] then - return self._FLAGS[key] - end - - -- add flags from the configure - local flags = {} - self:_addflags_from_config(flags) - - -- add flags from the target - self:_addflags_from_target(flags, target) - - -- add flags (named) from language - self:_addflags_from_language(flags, target) - - -- add flags from the platform - self:_addflags_from_platform(flags) - - -- add flags from the archiver - self:_addflags_from_archiver(flags) - - -- remove repeat - flags = table.unique(flags) - - -- merge flags - flags = table.concat(flags, " "):trim() - - -- save flags - self._FLAGS[key] = flags - - -- get it - return flags -end - --- add flags from the archiver -function archiver:_addflags_from_archiver(flags) - - -- add flags - for _, flagkind in ipairs(self:_flagkinds()) do - table.join2(flags, self:get(flagkind)) - end -end - --- load the archiver -function archiver.load(sourcekinds) - - -- load linker - return builder.load_linker(archiver, "archiver", "static", sourcekinds) -end - --- archive the library file -function archiver:archive(objectfiles, targetfile, target) - - -- get flags - local flags = nil - if target then - flags = self:_flags(target) - end - - -- archive it - return sandbox.load(self:_tool().archive, table.concat(table.wrap(objectfiles), " "), targetfile, flags or "") -end - --- get the archive command -function archiver:archivecmd(objectfiles, targetfile, target) - - -- get flags - local flags = nil - if target then - flags = self:_flags(target) - end - - -- get it - return self:_tool().archivecmd(table.concat(table.wrap(objectfiles), " "), targetfile, flags or "") -end - --- return module -return archiver diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua index 0cee9be22..19d462551 100644 --- a/xmake/core/tool/builder.lua +++ b/xmake/core/tool/builder.lua @@ -225,11 +225,21 @@ function builder:get(name) return self:_tool().get(name) end +-- get the format of the given file kind +function builder:format(kind) + + -- get formats + local formats = self:get("formats") + if formats then + return formats[kind] + end +end + -- get feature of the tool function builder:feature(name) -- get it - local features = self:_tool().get("features") + local features = self:get("features") if features then return features[name] end @@ -270,69 +280,5 @@ function builder:check(flags) return ok end --- load the linker from the given target kind -function builder.load_linker(linker, linkername, targetkind, sourcekinds) - - -- check - assert(sourcekinds) - - -- wrap sourcekinds first - sourcekinds = table.wrap(sourcekinds) - - -- get the linker info - local linkerinfo, errors = language.linkerinfo_of(targetkind, sourcekinds) - if not linkerinfo then - return nil, errors - end - - -- get it directly from cache dirst - builder._INSTANCES = builder._INSTANCES or {} - if builder._INSTANCES[linkerinfo.kind] then - return builder._INSTANCES[linkerinfo.kind] - end - - -- new instance - local instance = table.inherit(linker, builder) - - -- load the linker tool from the source file type - local result, errors = tool.load(linkerinfo.kind) - if not result then - return nil, errors - end - instance._TOOL = result - - -- load the name flags of archiver - local nameflags = {} - local nameflags_exists = {} - for _, sourcekind in ipairs(sourcekinds) do - - -- load language - result, errors = language.load_sk(sourcekind) - if not result then - return nil, errors - end - - -- merge name flags - for _, flaginfo in ipairs(table.wrap(result:nameflags()[linkername])) do - local key = flaginfo[1] .. flaginfo[2] - if not nameflags_exists[key] then - table.insert(nameflags, flaginfo) - nameflags_exists[key] = flaginfo - end - end - end - instance._NAMEFLAGS = nameflags - - -- init flag kinds - instance._FLAGKINDS = {linkerinfo.flag} - - -- save this instance - builder._INSTANCES[linkerinfo.kind] = instance - - -- ok - return instance -end - - -- return module return builder diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua index cf0a7d56a..7d6d133be 100644 --- a/xmake/core/tool/compiler.lua +++ b/xmake/core/tool/compiler.lua @@ -92,7 +92,7 @@ function compiler.load(sourcekind) instance._LANGUAGE = result -- init name flags - instance._NAMEFLAGS = result:nameflags()["compiler"] + instance._NAMEFLAGS = result:nameflags()["object"] -- init flag kinds instance._FLAGKINDS = table.wrap(result:sourceflags()[sourcekind]) diff --git a/xmake/core/tool/linker.lua b/xmake/core/tool/linker.lua index 3419fec04..50ac0db7e 100644 --- a/xmake/core/tool/linker.lua +++ b/xmake/core/tool/linker.lua @@ -72,8 +72,64 @@ end -- load the linker from the given target kind function linker.load(targetkind, sourcekinds) - -- load linker - return builder.load_linker(linker, "linker", targetkind, sourcekinds) + -- check + assert(sourcekinds) + + -- wrap sourcekinds first + sourcekinds = table.wrap(sourcekinds) + + -- get the linker info + local linkerinfo, errors = language.linkerinfo_of(targetkind, sourcekinds) + if not linkerinfo then + return nil, errors + end + + -- get it directly from cache dirst + builder._INSTANCES = builder._INSTANCES or {} + if builder._INSTANCES[linkerinfo.kind] then + return builder._INSTANCES[linkerinfo.kind] + end + + -- new instance + local instance = table.inherit(linker, builder) + + -- load the linker tool from the source file type + local result, errors = tool.load(linkerinfo.kind) + if not result then + return nil, errors + end + instance._TOOL = result + + -- load the name flags of archiver + local nameflags = {} + local nameflags_exists = {} + for _, sourcekind in ipairs(sourcekinds) do + + -- load language + result, errors = language.load_sk(sourcekind) + if not result then + return nil, errors + end + + -- merge name flags + for _, flaginfo in ipairs(table.wrap(result:nameflags()[targetkind])) do + local key = flaginfo[1] .. flaginfo[2] + if not nameflags_exists[key] then + table.insert(nameflags, flaginfo) + nameflags_exists[key] = flaginfo + end + end + end + instance._NAMEFLAGS = nameflags + + -- init flag kinds + instance._FLAGKINDS = {linkerinfo.flag} + + -- save this instance + builder._INSTANCES[linkerinfo.kind] = instance + + -- ok + return instance end -- link the target file diff --git a/xmake/languages/asm/xmake.lua b/xmake/languages/asm/xmake.lua index 19ee1d9ff..11fb8732b 100755 --- a/xmake/languages/asm/xmake.lua +++ b/xmake/languages/asm/xmake.lua @@ -43,7 +43,7 @@ language("asm") -- set name flags set_nameflags { - compiler = + object = { "config.includedirs" , "target.symbols" @@ -68,7 +68,7 @@ language("asm") , "platform.defines" , "platform.undefines" } - , linker = + , binary = { "config.linkdirs" , "target.linkdirs" @@ -83,7 +83,22 @@ language("asm") , "option.links" , "platform.links" } - , archiver = + , shared = + { + "config.linkdirs" + , "target.linkdirs" + , "target.strip" + , "target.symbols" + , "option.strip" + , "option.symbols" + , "option.linkdirs" + , "platform.linkdirs" + , "config.links" + , "target.links" + , "option.links" + , "platform.links" + } + , static = { "target.strip" , "target.symbols" diff --git a/xmake/languages/c++/xmake.lua b/xmake/languages/c++/xmake.lua index 0ddb6a60b..d91855d2c 100755 --- a/xmake/languages/c++/xmake.lua +++ b/xmake/languages/c++/xmake.lua @@ -46,7 +46,7 @@ language("c++") -- set name flags set_nameflags { - compiler = + object = { "config.includedirs" , "target.symbols" @@ -71,7 +71,7 @@ language("c++") , "platform.defines" , "platform.undefines" } - , linker = + , binary = { "config.linkdirs" , "target.linkdirs" @@ -86,7 +86,22 @@ language("c++") , "option.links" , "platform.links" } - , archiver = + , shared = + { + "config.linkdirs" + , "target.linkdirs" + , "target.strip" + , "target.symbols" + , "option.strip" + , "option.symbols" + , "option.linkdirs" + , "platform.linkdirs" + , "config.links" + , "target.links" + , "option.links" + , "platform.links" + } + , static = { "target.strip" , "target.symbols" diff --git a/xmake/languages/golang/xmake.lua b/xmake/languages/golang/xmake.lua index 12b5b84f5..691f89be0 100755 --- a/xmake/languages/golang/xmake.lua +++ b/xmake/languages/golang/xmake.lua @@ -46,7 +46,7 @@ language("golang") -- set name flags set_nameflags { - compiler = + object = { "config.includedirs" , "target.symbols" @@ -60,7 +60,7 @@ language("golang") , "platform.defines" , "platform.undefines" } - , linker = + , binary = { "config.linkdirs" , "target.linkdirs" @@ -73,7 +73,20 @@ language("golang") , "option.links" , "platform.links" } - , archiver = + , shared = + { + "config.linkdirs" + , "target.linkdirs" + , "target.strip" + , "target.symbols" + , "option.linkdirs" + , "platform.linkdirs" + , "config.links" + , "target.links" + , "option.links" + , "platform.links" + } + , static = { "target.strip" , "target.symbols" diff --git a/xmake/languages/objc++/xmake.lua b/xmake/languages/objc++/xmake.lua index e94dd97ab..71792a9fc 100755 --- a/xmake/languages/objc++/xmake.lua +++ b/xmake/languages/objc++/xmake.lua @@ -46,7 +46,7 @@ language("objc++") -- set name flags set_nameflags { - compiler = + object = { "config.includedirs" , "config.frameworks" @@ -75,7 +75,7 @@ language("objc++") , "platform.undefines" , "platform.frameworks" } - , linker = + , binary = { "config.linkdirs" , "target.linkdirs" @@ -94,7 +94,26 @@ language("objc++") , "platform.links" , "platform.frameworks" } - , archiver = + , shared = + { + "config.linkdirs" + , "target.linkdirs" + , "target.strip" + , "target.symbols" + , "option.strip" + , "option.symbols" + , "option.linkdirs" + , "platform.linkdirs" + , "config.links" + , "config.frameworks" + , "target.links" + , "target.frameworks" + , "option.links" + , "option.frameworks" + , "platform.links" + , "platform.frameworks" + } + , static = { "target.strip" , "target.symbols" diff --git a/xmake/languages/swift/xmake.lua b/xmake/languages/swift/xmake.lua index 261039895..4af71bc15 100755 --- a/xmake/languages/swift/xmake.lua +++ b/xmake/languages/swift/xmake.lua @@ -43,7 +43,7 @@ language("swift") -- set name flags set_nameflags { - compiler = + object = { "config.includedirs" , "config.Frameworks" @@ -72,7 +72,7 @@ language("swift") , "platform.undefines" , "platform.frameworks" } - , linker = + , binary = { "config.linkdirs" , "target.linkdirs" @@ -91,7 +91,26 @@ language("swift") , "platform.links" , "platform.frameworks" } - , archiver = + , shared = + { + "config.linkdirs" + , "target.linkdirs" + , "target.strip" + , "target.symbols" + , "option.strip" + , "option.symbols" + , "option.linkdirs" + , "platform.linkdirs" + , "config.links" + , "config.frameworks" + , "target.links" + , "target.frameworks" + , "option.links" + , "option.frameworks" + , "platform.links" + , "platform.frameworks" + } + , static = { "target.strip" , "target.symbols" diff --git a/xmake/plugins/project/makefile/makefile.lua b/xmake/plugins/project/makefile/makefile.lua index 350cbc040..1c7ea5733 100755 --- a/xmake/plugins/project/makefile/makefile.lua +++ b/xmake/plugins/project/makefile/makefile.lua @@ -25,7 +25,6 @@ -- imports import("core.tool.tool") import("core.tool.linker") -import("core.tool.archiver") import("core.tool.compiler") import("core.project.config") import("core.project.project") @@ -162,12 +161,7 @@ function _make_target(makefile, target) makefile:print("") -- make the command - local command = nil - if target:get("kind") == "static" then - command = archiver.archivecmd(target:objectfiles(), targetfile, target) - else - command = linker.linkcmd(target:objectfiles(), targetfile, target) - end + local command = linker.linkcmd(target:objectfiles(), targetfile, target) -- make body makefile:print("\t@echo linking.$(mode) %s", path.filename(targetfile)) diff --git a/xmake/tools/ar.lua b/xmake/tools/ar.lua index 802b53860..dfecc9340 100644 --- a/xmake/tools/ar.lua +++ b/xmake/tools/ar.lua @@ -60,21 +60,21 @@ function strip(level) return maps[level] or "" end --- make the archive command -function archivecmd(objectfiles, targetfile, flags) +-- make the link command +function linkcmd(objectfiles, targetfile, flags) -- make it return format("%s %s %s %s", _g.shellname, flags, targetfile, objectfiles) end --- archive the library file -function archive(objectfiles, targetfile, flags) +-- link the library file +function link(objectfiles, targetfile, flags) -- ensure the target directory os.mkdir(path.directory(targetfile)) -- link it - os.run(archivecmd(objectfiles, targetfile, flags)) + os.run(linkcmd(objectfiles, targetfile, flags)) end -- extract the static library to object directory @@ -125,7 +125,7 @@ function check(flags) compiler.compile(sourcefile, objectfile) -- check it - archive(objectfile, libraryfile, arflags) + link(objectfile, libraryfile, arflags) -- remove files os.rm(objectfile) diff --git a/xmake/tools/go.lua b/xmake/tools/go.lua index 9a3f45ab5..154676e89 100755 --- a/xmake/tools/go.lua +++ b/xmake/tools/go.lua @@ -40,6 +40,10 @@ function init(shellname, kind) -- init arflags _g.arflags = { "grc" } + -- init the file formats + _g.formats = {} + _g.formats.static = {"", ".a"} + -- init features _g.features = { diff --git a/xmake/tools/link.lua b/xmake/tools/link.lua index ecd00190e..c6413b04f 100755 --- a/xmake/tools/link.lua +++ b/xmake/tools/link.lua @@ -129,16 +129,6 @@ function link(objectfiles, targetfile, flags) os.run(linkcmd(objectfiles, targetfile, flags)) end --- make the archive command -function archivecmd(objectfiles, targetfile, flags) - return linkcmd(objectfiles, targetfile, flags) -end - --- archive the library file -function archive(objectfiles, targetfile, flags) - link(objectfiles, targetfile, flags) -end - -- check the given flags function check(flags) |
