summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-03-18 19:57:22 +0800
committerruki <[email protected]>2016-03-18 19:57:22 +0800
commit7ff5704f835df20b79db4f672204df9a562058aa (patch)
tree936db6ad6da98ae0f97efb45663e933eb54be5a5
parent34d77b966b9640673b4a6d23758b3d9f51cb1169 (diff)
remove install and package from platform
-rw-r--r--xmake/core/base/interpreter.lua6
-rw-r--r--xmake/core/base/io.lua8
-rw-r--r--xmake/core/base/table.lua34
-rw-r--r--xmake/core/platform/compiler.lua1
-rw-r--r--xmake/core/platform/platforms/iphoneos/package.lua76
-rw-r--r--xmake/core/platform/platforms/linux/install.lua182
-rw-r--r--xmake/core/platform/platforms/linux/uninstall.lua134
-rw-r--r--xmake/core/platform/platforms/macosx/install.lua182
-rw-r--r--xmake/core/platform/platforms/macosx/uninstall.lua134
-rw-r--r--xmake/core/platform/platforms/watchos/package.lua76
-rw-r--r--xmake/core/project/deprecated/project.lua1
-rw-r--r--xmake/core/sandbox/modules/import/core/project/menu.lua1
-rw-r--r--xmake/core/sandbox/sandbox.lua6
13 files changed, 38 insertions, 803 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index 590041555..127663c40 100644
--- a/xmake/core/base/interpreter.lua
+++ b/xmake/core/base/interpreter.lua
@@ -424,11 +424,7 @@ function interpreter.init()
, _MTIMES = {}}}
-- inherit the interfaces of interpreter
- for k, v in pairs(interpreter) do
- if type(v) == "function" then
- instance[k] = v
- end
- end
+ table.inherit2(instance, interpreter)
-- register the builtin interfaces
instance:api_register("add_subdirs", interpreter.api_builtin_add_subdirs)
diff --git a/xmake/core/base/io.lua b/xmake/core/base/io.lua
index 300599378..9c55b1f2d 100644
--- a/xmake/core/base/io.lua
+++ b/xmake/core/base/io.lua
@@ -26,6 +26,7 @@ local _file = _file or {}
-- load modules
local path = require("base/path")
+local table = require("base/table")
local utils = require("base/utils")
-- save original open
@@ -255,12 +256,7 @@ function io.open(filepath, mode)
end
-- init file instance
- local file = {}
- for k, v in pairs(_file) do
- if type(v) == "function" then
- file[k] = v
- end
- end
+ local file = table.inherit(_file)
-- open it
local handle, errors = io._open(path.translate(filepath), mode)
diff --git a/xmake/core/base/table.lua b/xmake/core/base/table.lua
index 1ebfa0bc9..5d0bc399a 100644
--- a/xmake/core/base/table.lua
+++ b/xmake/core/base/table.lua
@@ -319,6 +319,40 @@ function table.unique(array)
return array
end
+-- inherit interfaces and create a new instance
+function table.inherit(self)
+
+ -- check
+ assert(self)
+
+ -- init instance
+ local instance = {}
+ for k, v in pairs(self) do
+ if type(v) == "function" then
+ instance[k] = v
+ end
+ end
+
+ -- ok?
+ return instance
+end
+
+-- inherit interfaces from the given class
+function table.inherit2(self, clasz)
+
+ -- check
+ assert(self and clasz)
+
+ -- init instance
+ for k, v in pairs(clasz) do
+ if type(v) == "function" then
+ self[k] = v
+ end
+ end
+
+ -- ok?
+ return self
+end
-- return module: table
return table
diff --git a/xmake/core/platform/compiler.lua b/xmake/core/platform/compiler.lua
index f2e2f1b0f..51c111a56 100644
--- a/xmake/core/platform/compiler.lua
+++ b/xmake/core/platform/compiler.lua
@@ -30,7 +30,6 @@ local utils = require("base/utils")
local table = require("base/table")
local option = require("base/option")
local string = require("base/string")
-local rule = require("project/rule")
local config = require("project/config")
local tool = require("platform/tool")
local platform = require("platform/platform")
diff --git a/xmake/core/platform/platforms/iphoneos/package.lua b/xmake/core/platform/platforms/iphoneos/package.lua
deleted file mode 100644
index 4a7a25fd8..000000000
--- a/xmake/core/platform/platforms/iphoneos/package.lua
+++ /dev/null
@@ -1,76 +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 package.lua
---
-
--- define module: package
-local package = package or {}
-
--- load modules
-local os = require("base/os")
-local path = require("base/path")
-local rule = require("project/rule")
-local utils = require("base/utils")
-local string = require("base/string")
-local platform = require("platform/platform")
-
--- package target
-function package.main(target)
-
- -- check
- assert(target and target.name)
-
- -- the count of architectures
- local count = 0
- for _, _ in pairs(target.archs) do count = count + 1 end
- if count < 2 then return 0 end
-
- -- get the lipo tool
- local lipo = platform.tool("lipo")
- if not lipo then return 0 end
-
- -- make universal info
- local universal = {}
- universal.targetdir = rule.backupdir(target.name, "universal")
- universal.targetfile = rule.targetfile(target.name, target)
- if not universal.targetdir or not universal.targetfile then return 0 end
-
- -- make the universal directory
- os.mkdir(path.directory(string.format("%s/%s", universal.targetdir, universal.targetfile)))
-
- -- make the lipo command
- local cmd = lipo .. " -create"
- for arch, info in pairs(target.archs) do
- cmd = string.format("%s -arch %s %s/%s", cmd, arch, info.targetdir, info.targetfile)
- end
- cmd = string.format("%s -output %s/%s", cmd, universal.targetdir, universal.targetfile)
-
- -- make the universal target
- if 0 ~= os.execute(cmd) then return 0 end
-
- -- ok
- target.archs.universal = universal
-
- -- continue
- return 0
-end
-
--- return module: package
-return package
diff --git a/xmake/core/platform/platforms/linux/install.lua b/xmake/core/platform/platforms/linux/install.lua
deleted file mode 100644
index e8a74804f..000000000
--- a/xmake/core/platform/platforms/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) 2015 - 2016, 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("project/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/core/platform/platforms/linux/uninstall.lua b/xmake/core/platform/platforms/linux/uninstall.lua
deleted file mode 100644
index f83913a4a..000000000
--- a/xmake/core/platform/platforms/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) 2015 - 2016, 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("project/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
diff --git a/xmake/core/platform/platforms/macosx/install.lua b/xmake/core/platform/platforms/macosx/install.lua
deleted file mode 100644
index e8a74804f..000000000
--- a/xmake/core/platform/platforms/macosx/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) 2015 - 2016, 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("project/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/core/platform/platforms/macosx/uninstall.lua b/xmake/core/platform/platforms/macosx/uninstall.lua
deleted file mode 100644
index f83913a4a..000000000
--- a/xmake/core/platform/platforms/macosx/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) 2015 - 2016, 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("project/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
diff --git a/xmake/core/platform/platforms/watchos/package.lua b/xmake/core/platform/platforms/watchos/package.lua
deleted file mode 100644
index 4a7a25fd8..000000000
--- a/xmake/core/platform/platforms/watchos/package.lua
+++ /dev/null
@@ -1,76 +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 package.lua
---
-
--- define module: package
-local package = package or {}
-
--- load modules
-local os = require("base/os")
-local path = require("base/path")
-local rule = require("project/rule")
-local utils = require("base/utils")
-local string = require("base/string")
-local platform = require("platform/platform")
-
--- package target
-function package.main(target)
-
- -- check
- assert(target and target.name)
-
- -- the count of architectures
- local count = 0
- for _, _ in pairs(target.archs) do count = count + 1 end
- if count < 2 then return 0 end
-
- -- get the lipo tool
- local lipo = platform.tool("lipo")
- if not lipo then return 0 end
-
- -- make universal info
- local universal = {}
- universal.targetdir = rule.backupdir(target.name, "universal")
- universal.targetfile = rule.targetfile(target.name, target)
- if not universal.targetdir or not universal.targetfile then return 0 end
-
- -- make the universal directory
- os.mkdir(path.directory(string.format("%s/%s", universal.targetdir, universal.targetfile)))
-
- -- make the lipo command
- local cmd = lipo .. " -create"
- for arch, info in pairs(target.archs) do
- cmd = string.format("%s -arch %s %s/%s", cmd, arch, info.targetdir, info.targetfile)
- end
- cmd = string.format("%s -output %s/%s", cmd, universal.targetdir, universal.targetfile)
-
- -- make the universal target
- if 0 ~= os.execute(cmd) then return 0 end
-
- -- ok
- target.archs.universal = universal
-
- -- continue
- return 0
-end
-
--- return module: package
-return package
diff --git a/xmake/core/project/deprecated/project.lua b/xmake/core/project/deprecated/project.lua
index c31c77f6c..a9c04a007 100644
--- a/xmake/core/project/deprecated/project.lua
+++ b/xmake/core/project/deprecated/project.lua
@@ -28,7 +28,6 @@ local os = require("base/os")
local path = require("base/path")
local utils = require("base/utils")
local table = require("base/table")
-local rule = require("project/rule")
local config = require("project/config")
local platform = require("platform/platform")
local deprecated_interpreter = require("base/deprecated/interpreter")
diff --git a/xmake/core/sandbox/modules/import/core/project/menu.lua b/xmake/core/sandbox/modules/import/core/project/menu.lua
index de3314409..4b46f687c 100644
--- a/xmake/core/sandbox/modules/import/core/project/menu.lua
+++ b/xmake/core/sandbox/modules/import/core/project/menu.lua
@@ -24,7 +24,6 @@
local sandbox_core_project_menu = sandbox_core_project_menu or {}
-- load modules
-local rule = require("project/rule")
local config = require("project/config")
local project = require("project/project")
diff --git a/xmake/core/sandbox/sandbox.lua b/xmake/core/sandbox/sandbox.lua
index 96950ee0b..244f1032d 100644
--- a/xmake/core/sandbox/sandbox.lua
+++ b/xmake/core/sandbox/sandbox.lua
@@ -89,11 +89,7 @@ function sandbox._init()
local instance = {_PUBLIC = {}, _PRIVATE = {}}
-- inherit the interfaces of sandbox
- for k, v in pairs(sandbox) do
- if type(v) == "function" then
- instance[k] = v
- end
- end
+ table.inherit2(instance, sandbox)
-- load builtin module files
local builtin_module_files = os.match(path.join(xmake._CORE_DIR, "sandbox/modules/*.lua"))