diff options
| author | ruki <[email protected]> | 2016-01-14 09:19:14 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-01-14 09:19:14 +0800 |
| commit | cdcf953259aee5e7e1a06855ddbedbaabf585bc9 (patch) | |
| tree | 47b8e5de10522cca3b67354fa527b3525193e880 /xmake/scripts/platform/linux | |
| parent | 8c50566e7ab2139b9f6c2976b9ce875b7ad11b7a (diff) | |
rename script directory to core
Diffstat (limited to 'xmake/scripts/platform/linux')
| -rw-r--r-- | xmake/scripts/platform/linux/install.lua | 182 | ||||
| -rw-r--r-- | xmake/scripts/platform/linux/linux.lua | 103 | ||||
| -rw-r--r-- | xmake/scripts/platform/linux/prober.lua | 198 | ||||
| -rw-r--r-- | xmake/scripts/platform/linux/uninstall.lua | 134 |
4 files changed, 0 insertions, 617 deletions
diff --git a/xmake/scripts/platform/linux/install.lua b/xmake/scripts/platform/linux/install.lua deleted file mode 100644 index 870cf5040..000000000 --- a/xmake/scripts/platform/linux/install.lua +++ /dev/null @@ -1,182 +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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file install.lua --- - --- define module: install -local install = install or {} - --- load modules -local os = require("base/os") -local path = require("base/path") -local rule = require("base/rule") -local utils = require("base/utils") -local string = require("base/string") -local platform = require("platform/platform") - --- install target for the library file -function install._done_library(target) - - -- check - assert(target and target.name and target.archs) - - -- the output directory - local outputdir = target.outputdir or "/usr/local" - assert(outputdir) - - -- get target info - local info = target.archs[xmake._ARCH] or target.archs["x86_64"] or target.archs["i386"] - if not info then return -1 end - - -- check - assert(info.targetdir and info.targetfile) - - -- make the library directory - local librarydir = outputdir .. "/lib" - if not os.isdir(librarydir) then - if not os.mkdir(librarydir) then - utils.error("create directory %s failed", librarydir) - return -1 - end - end - - -- copy the library file to the library directory - local ok, errors = os.cp(string.format("%s/%s", info.targetdir, info.targetfile), string.format("%s/%s", librarydir, path.filename(info.targetfile))) - if not ok then - utils.error(errors) - return -1 - end - - -- make the include directory - local includedir = outputdir .. "/include" - if not os.isdir(includedir) then - if not os.mkdir(includedir) then - utils.error("create directory %s failed", includedir) - return -1 - end - end - - -- copy the config.h to the output directory - if info.config_h then - local ok, errors = os.cp(string.format("%s/%s", info.targetdir, info.config_h), string.format("%s/%s/%s", includedir, target.name, path.filename(info.config_h))) - if not ok then - utils.error(errors) - return -1 - end - - -- update the config.h - info.config_h = string.format("%s/%s/%s", includedir, target.name, path.filename(info.config_h)) - end - - -- copy headers - if target.headers then - local srcheaders, dstheaders = rule.headerfiles(target, includedir) - if srcheaders and dstheaders then - local i = 1 - for _, srcheader in ipairs(srcheaders) do - local dstheader = dstheaders[i] - if dstheader then - local ok, errors = os.cp(srcheader, dstheader) - if not ok then - utils.error(errors) - return -1 - end - end - i = i + 1 - end - end - - -- update the headers - target.headers = dstheaders - end - - -- update the target directory and file - info.targetdir = librarydir - info.targetfile = path.filename(info.targetfile) - - -- ok - return 1 -end - --- install target for the binary file -function install._done_binary(target) - - -- check - assert(target and target.archs) - - -- the output directory - local outputdir = target.outputdir or "/usr/local" - assert(outputdir) - - -- make the binary directory - local binarydir = outputdir .. "/bin" - if not os.isdir(binarydir) then - if not os.mkdir(binarydir) then - utils.error("create directory %s failed", binarydir) - return -1 - end - end - - -- get target info - local info = target.archs[xmake._ARCH] or target.archs["x86_64"] or target.archs["i386"] - if not info then return -1 end - - -- check - assert(info.targetdir and info.targetfile) - - -- copy the binary file to the binary directory - local ok, errors = os.cp(string.format("%s/%s", info.targetdir, info.targetfile), binarydir) - if not ok then - utils.error(errors) - return -1 - end - - -- update the target directory and file - info.targetdir = binarydir - info.targetfile = path.filename(info.targetfile) - - -- ok - return 1 -end - --- install target -function install.main(target) - - -- check - assert(target and target.kind) - - -- the install scripts - local installscripts = - { - static = install._done_library - , shared = install._done_library - , binary = install._done_binary - } - - -- install it - local installscript = installscripts[target.kind] - if installscript then return installscript(target) end - - -- continue - return 0 -end - --- return module: install -return install diff --git a/xmake/scripts/platform/linux/linux.lua b/xmake/scripts/platform/linux/linux.lua deleted file mode 100644 index 406dc5c58..000000000 --- a/xmake/scripts/platform/linux/linux.lua +++ /dev/null @@ -1,103 +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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file linux.lua --- - --- define module: linux -local linux = linux or {} - --- load modules -local config = require("base/config") - --- init host -linux._HOST = "linux" - --- init os -linux._OS = "linux" - --- init architectures -linux._ARCHS = {"i386", "x86_64"} - --- make configure -function linux.make(configs) - - -- init the file formats - configs.formats = {} - configs.formats.static = {"lib", ".a"} - configs.formats.object = {"", ".o"} - configs.formats.shared = {"lib", ".so"} - - -- init the toolchains - configs.tools = {} - configs.tools.make = config.get("make") - configs.tools.ccache = config.get("__ccache") - configs.tools.cc = config.get("cc") - configs.tools.cxx = config.get("cxx") - configs.tools.mm = config.get("mm") - configs.tools.mxx = config.get("mxx") - configs.tools.ld = config.get("ld") - configs.tools.ar = config.get("ar") - configs.tools.sh = config.get("sh") - configs.tools.ex = config.get("ar") - configs.tools.sc = config.get("sc") - - -- cross toolchains? - if config.get("cross") then return end - - -- init flags for architecture - local archflags = nil - local arch = config.get("arch") - if arch then - if arch == "x86_64" then archflags = "-m64" - elseif arch == "i386" then archflags = "-m32" - else archflags = "-arch " .. arch - end - end - configs.cxflags = { archflags } - configs.mxflags = { archflags } - configs.asflags = { archflags } - configs.ldflags = { archflags } - configs.shflags = { archflags } - - -- init linkdirs and includedirs - configs.linkdirs = {"/usr/lib", "/usr/local/lib"} - configs.includedirs = {"/usr/include", "/usr/local/include"} - -end - --- get the option menu for action: xmake config or global -function linux.menu(action) - - -- init config option menu - linux._MENU_CONFIG = linux._MENU_CONFIG or {} - - -- init global option menu - linux._MENU_GLOBAL = linux._MENU_GLOBAL or {} - - -- get the option menu - if action == "config" then - return linux._MENU_CONFIG - elseif action == "global" then - return linux._MENU_GLOBAL - end -end - --- return module: linux -return linux diff --git a/xmake/scripts/platform/linux/prober.lua b/xmake/scripts/platform/linux/prober.lua deleted file mode 100644 index 4e50b13cf..000000000 --- a/xmake/scripts/platform/linux/prober.lua +++ /dev/null @@ -1,198 +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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file prober.lua --- - --- 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("tools/tools") -local config = require("base/config") -local global = require("base/global") - --- define module: prober -local prober = prober or {} - --- probe the architecture -function prober._probe_arch(configs) - - -- get the architecture - local arch = configs.get("arch") - - -- ok? - if arch then return true end - - -- init the default architecture - if configs.get("cross") then - configs.set("arch", "none") - else - configs.set("arch", xmake._ARCH) - end - - -- trace - utils.printf("checking for the architecture ... %s", configs.get("arch")) - - -- ok - return true -end - --- probe the make -function prober._probe_make(configs) - - -- ok? - local make = configs.get("make") - if make then return true end - - -- probe the make path - make = tools.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"}) - - -- probe ok? update it - if make then configs.set("make", make) end - - -- trace - utils.printf("checking for the make ... %s", utils.ifelse(make, make, "no")) - - -- ok - return true -end - --- probe the ccache -function prober._probe_ccache(configs) - - -- ok? - local ccache_enable = configs.get("ccache") - if ccache_enable and configs.get("__ccache") then return true end - - -- disable? - if type(ccache_enable) == "boolean" and not ccache_enable then - configs.set("__ccache", nil) - return true - end - - -- probe the ccache path - local ccache_path = tools.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"}) - - -- probe ok? update it - if ccache_path then - configs.set("ccache", true) - configs.set("__ccache", ccache_path) - else - configs.set("ccache", false) - end - - -- trace - utils.printf("checking for the ccache ... %s", utils.ifelse(ccache_path, ccache_path, "no")) - - -- ok - return true -end - --- probe the tool path -function prober._probe_toolpath(configs, kind, cross, names, description) - - -- check - assert(kind) - - -- get the cross - cross = configs.get("cross") or cross - - -- done - local toolpath = nil - local toolchains = configs.get("toolchains") - for _, name in ipairs(utils.wrap(names)) do - - -- attempt to get it from the given cross toolchains - if toolchains then - toolpath = tools.probe(cross .. (configs.get(kind) or name), toolchains) - end - - -- attempt to get it directly from the configure - if not toolpath then - toolpath = configs.get(kind) - end - - -- attempt to run it directly - if not toolpath then - toolpath = tools.probe(cross .. name) - end - - -- probe ok? - if toolpath then - - -- update config - configs.set(kind, toolpath) - - -- end - break - end - - end - - -- trace - if toolpath then - utils.printf("checking for %s (%s) ... %s", description, kind, path.filename(toolpath)) - else - utils.printf("checking for %s (%s) ... no", description, kind) - end - - -- ok - return true -end - --- probe the toolchains -function prober._probe_toolchains(configs) - - -- done - if not prober._probe_toolpath(configs, "cc", "", "gcc", "the c compiler") then return false end - if not prober._probe_toolpath(configs, "cxx", "", {"g++", "gcc"}, "the c++ compiler") then return false end - if not prober._probe_toolpath(configs, "as", "", "gcc", "the assember") then return false end - if not prober._probe_toolpath(configs, "ld", "", {"g++", "gcc"}, "the linker") then return false end - if not prober._probe_toolpath(configs, "ar", "", "ar", "the static library linker") then return false end - if not prober._probe_toolpath(configs, "sh", "", {"g++", "gcc"}, "the shared library linker") then return false end - if not prober._probe_toolpath(configs, "sc", "", "swiftc", "the swift compiler") then return false end - return true -end - --- probe the project configure -function prober.config() - - -- call all probe functions - return utils.call( { prober._probe_arch - , prober._probe_make - , prober._probe_ccache - , prober._probe_toolchains} - , nil - , config) -end - --- probe the global configure -function prober.global() - - -- call all probe functions - return utils.call( { prober._probe_make - , prober._probe_ccache} - , nil - , global) -end - --- return module: prober -return prober diff --git a/xmake/scripts/platform/linux/uninstall.lua b/xmake/scripts/platform/linux/uninstall.lua deleted file mode 100644 index 468692620..000000000 --- a/xmake/scripts/platform/linux/uninstall.lua +++ /dev/null @@ -1,134 +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) 2009 - 2015, ruki All rights reserved. --- --- @author ruki --- @file uninstall.lua --- - --- define module: uninstall -local uninstall = uninstall or {} - --- load modules -local os = require("base/os") -local path = require("base/path") -local rule = require("base/rule") -local utils = require("base/utils") -local string = require("base/string") -local platform = require("platform/platform") - --- uninstall target for the library file -function uninstall._done_library(target) - - -- check - assert(target and target.name and target.archs) - - -- get target info - local info = target.archs[xmake._ARCH] or target.archs["x86_64"] or target.archs["i386"] - if not info then return -1 end - - -- check - assert(info.targetdir and info.targetfile) - - -- remove the target file - local targetfile = info.targetdir .. "/" .. info.targetfile - if os.isfile(targetfile) then - local ok, errors = os.rm(targetfile) - if not ok then - utils.error(errors) - return -1 - end - end - - -- remove config.h - if info.config_h and os.isfile(info.config_h) then - local ok, errors = os.rm(info.config_h) - if not ok then - utils.error(errors) - return -1 - end - end - - -- remove headers - if target.headers then - for _, header in ipairs(target.headers) do - if os.isfile(header) then - local ok, errors = os.rm(header) - if not ok then - utils.error(errors) - return -1 - end - end - end - end - - -- ok - return 1 -end - --- uninstall target for the binary file -function uninstall._done_binary(target) - - -- check - assert(target and target.archs) - - -- get target info - local info = target.archs[xmake._ARCH] or target.archs["x86_64"] or target.archs["i386"] - if not info then return -1 end - - -- check - assert(info.targetdir and info.targetfile) - - -- the target file - local targetfile = info.targetdir .. "/" .. info.targetfile - if not os.isfile(targetfile) then return 1 end - - -- remove the target file - local ok, errors = os.rm(targetfile) - if not ok then - utils.error(errors) - return -1 - end - - -- ok - return 1 -end - --- uninstall target -function uninstall.main(target) - - -- check - assert(target and target.kind) - - -- the uninstall scripts - local uninstallscripts = - { - static = uninstall._done_library - , shared = uninstall._done_library - , binary = uninstall._done_binary - } - - -- uninstall it - local uninstallscript = uninstallscripts[target.kind] - if uninstallscript then return uninstallscript(target) end - - -- continue - return 0 -end - --- return module: uninstall -return uninstall |
