summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-03-03 11:07:43 +0800
committerruki <[email protected]>2016-03-03 11:07:43 +0800
commitaf8e19e9b32faeadc816087a8d0b86e13e8f948c (patch)
treed660c23f8803dcd82917aa002c03137ba25d9113
parent4fa3ca927a032f57aaae44156ceeec6732c159f6 (diff)
adjust core architecture
-rwxr-xr-xxmake/actions/config/xmake.lua12
-rwxr-xr-xxmake/actions/create/xmake.lua4
-rwxr-xr-xxmake/actions/global/xmake.lua7
-rwxr-xr-xxmake/actions/package/xmake.lua4
-rw-r--r--xmake/core/_xmake_main.lua2
-rw-r--r--xmake/core/action/build.lua121
-rw-r--r--xmake/core/action/clean.lua107
-rw-r--r--xmake/core/action/config.lua216
-rw-r--r--xmake/core/action/create.lua124
-rw-r--r--xmake/core/action/debug.lua89
-rw-r--r--xmake/core/action/global.lua104
-rw-r--r--xmake/core/action/install.lua208
-rw-r--r--xmake/core/action/lua.lua169
-rw-r--r--xmake/core/action/man.lua89
-rw-r--r--xmake/core/action/package.lua349
-rw-r--r--xmake/core/action/run.lua170
-rw-r--r--xmake/core/action/uninstall.lua161
-rw-r--r--xmake/core/base/action.lua142
-rw-r--r--xmake/core/base/clean.lua207
-rw-r--r--xmake/core/base/install.lua140
-rw-r--r--xmake/core/base/makefile.lua417
-rw-r--r--xmake/core/base/package.lua311
-rw-r--r--xmake/core/base/rule.lua300
-rw-r--r--xmake/core/main.lua (renamed from xmake/core/base/main.lua)0
-rw-r--r--xmake/core/platform/compiler.lua (renamed from xmake/core/base/compiler.lua)2
-rw-r--r--xmake/core/platform/linker.lua (renamed from xmake/core/base/linker.lua)2
-rw-r--r--xmake/core/platform/platform.lua (renamed from xmake/core/base/platform.lua)0
-rw-r--r--xmake/core/platform/platforms/android/android.lua (renamed from xmake/core/platforms/android/android.lua)0
-rw-r--r--xmake/core/platform/platforms/android/prober.lua (renamed from xmake/core/platforms/android/prober.lua)10
-rw-r--r--xmake/core/platform/platforms/iphoneos/iphoneos.lua (renamed from xmake/core/platforms/iphoneos/iphoneos.lua)0
-rw-r--r--xmake/core/platform/platforms/iphoneos/package.lua (renamed from xmake/core/platforms/iphoneos/package.lua)0
-rw-r--r--xmake/core/platform/platforms/iphoneos/prober.lua (renamed from xmake/core/platforms/iphoneos/prober.lua)10
-rw-r--r--xmake/core/platform/platforms/iphonesimulator/iphonesimulator.lua (renamed from xmake/core/platforms/iphonesimulator/iphonesimulator.lua)0
-rw-r--r--xmake/core/platform/platforms/iphonesimulator/prober.lua (renamed from xmake/core/platforms/iphonesimulator/prober.lua)10
-rw-r--r--xmake/core/platform/platforms/linux/install.lua (renamed from xmake/core/platforms/linux/install.lua)0
-rw-r--r--xmake/core/platform/platforms/linux/linux.lua (renamed from xmake/core/platforms/linux/linux.lua)0
-rw-r--r--xmake/core/platform/platforms/linux/prober.lua (renamed from xmake/core/platforms/linux/prober.lua)10
-rw-r--r--xmake/core/platform/platforms/linux/uninstall.lua (renamed from xmake/core/platforms/linux/uninstall.lua)0
-rw-r--r--xmake/core/platform/platforms/macosx/install.lua (renamed from xmake/core/platforms/macosx/install.lua)0
-rw-r--r--xmake/core/platform/platforms/macosx/macosx.lua (renamed from xmake/core/platforms/macosx/macosx.lua)0
-rw-r--r--xmake/core/platform/platforms/macosx/prober.lua (renamed from xmake/core/platforms/macosx/prober.lua)10
-rw-r--r--xmake/core/platform/platforms/macosx/uninstall.lua (renamed from xmake/core/platforms/macosx/uninstall.lua)0
-rw-r--r--xmake/core/platform/platforms/mingw/mingw.lua (renamed from xmake/core/platforms/mingw/mingw.lua)0
-rw-r--r--xmake/core/platform/platforms/mingw/prober.lua (renamed from xmake/core/platforms/mingw/prober.lua)10
-rw-r--r--xmake/core/platform/platforms/watchos/package.lua (renamed from xmake/core/platforms/watchos/package.lua)0
-rw-r--r--xmake/core/platform/platforms/watchos/prober.lua (renamed from xmake/core/platforms/watchos/prober.lua)10
-rw-r--r--xmake/core/platform/platforms/watchos/watchos.lua (renamed from xmake/core/platforms/watchos/watchos.lua)0
-rw-r--r--xmake/core/platform/platforms/watchsimulator/prober.lua (renamed from xmake/core/platforms/watchsimulator/prober.lua)10
-rw-r--r--xmake/core/platform/platforms/watchsimulator/watchsimulator.lua (renamed from xmake/core/platforms/watchsimulator/watchsimulator.lua)0
-rw-r--r--xmake/core/platform/platforms/windows/prober.lua (renamed from xmake/core/platforms/windows/prober.lua)2
-rw-r--r--xmake/core/platform/platforms/windows/tools/cl.lua (renamed from xmake/core/platforms/windows/tools/cl.lua)0
-rw-r--r--xmake/core/platform/platforms/windows/tools/lib.lua (renamed from xmake/core/platforms/windows/tools/lib.lua)0
-rw-r--r--xmake/core/platform/platforms/windows/tools/link.lua (renamed from xmake/core/platforms/windows/tools/link.lua)0
-rw-r--r--xmake/core/platform/platforms/windows/tools/ml.lua (renamed from xmake/core/platforms/windows/tools/ml.lua)0
-rw-r--r--xmake/core/platform/platforms/windows/tools/nmake.lua (renamed from xmake/core/platforms/windows/tools/nmake.lua)0
-rw-r--r--xmake/core/platform/platforms/windows/windows.lua (renamed from xmake/core/platforms/windows/windows.lua)0
-rw-r--r--xmake/core/platform/tool.lua (renamed from xmake/core/tools/tools.lua)48
-rw-r--r--xmake/core/platform/tools/ar.lua (renamed from xmake/core/tools/ar.lua)0
-rw-r--r--xmake/core/platform/tools/cat.lua (renamed from xmake/core/tools/cat.lua)0
-rw-r--r--xmake/core/platform/tools/clang++.lua (renamed from xmake/core/tools/clang++.lua)0
-rw-r--r--xmake/core/platform/tools/clang.lua (renamed from xmake/core/tools/clang.lua)0
-rw-r--r--xmake/core/platform/tools/cp.lua (renamed from xmake/core/tools/cp.lua)0
-rw-r--r--xmake/core/platform/tools/dispatcher.lua (renamed from xmake/core/tools/dispatcher.lua)2
-rw-r--r--xmake/core/platform/tools/echo.lua (renamed from xmake/core/tools/echo.lua)0
-rw-r--r--xmake/core/platform/tools/g++.lua (renamed from xmake/core/tools/g++.lua)0
-rwxr-xr-xxmake/core/platform/tools/gas-preprocessor.pl (renamed from xmake/core/tools/gas-preprocessor.pl)0
-rw-r--r--xmake/core/platform/tools/gcc.lua (renamed from xmake/core/tools/gcc.lua)0
-rw-r--r--xmake/core/platform/tools/make.lua (renamed from xmake/core/tools/make.lua)0
-rw-r--r--xmake/core/platform/tools/mkdir.lua (renamed from xmake/core/tools/mkdir.lua)0
-rw-r--r--xmake/core/platform/tools/mv.lua (renamed from xmake/core/tools/mv.lua)0
-rw-r--r--xmake/core/platform/tools/rm.lua (renamed from xmake/core/tools/rm.lua)0
-rw-r--r--xmake/core/platform/tools/rmdir.lua (renamed from xmake/core/tools/rmdir.lua)0
-rw-r--r--xmake/core/platform/tools/swiftc.lua (renamed from xmake/core/tools/swiftc.lua)0
-rw-r--r--xmake/core/platform/tools/verbose.lua (renamed from xmake/core/tools/verbose.lua)0
-rw-r--r--xmake/core/project/deprecated/project.lua (renamed from xmake/core/base/deprecated/project.lua)0
-rw-r--r--xmake/core/project/project.lua (renamed from xmake/core/base/project.lua)0
-rw-r--r--xmake/core/sandbox/import/core/global.lua69
-rw-r--r--xmake/core/sandbox/import/core/option.lua37
-rw-r--r--xmake/core/sandbox/import/core/platform.lua59
-rw-r--r--xmake/core/sandbox/import/core/project.lua74
-rw-r--r--xmake/core/sandbox/import/core/template.lua52
-rw-r--r--xmake/core/template/template.lua (renamed from xmake/core/base/template.lua)0
82 files changed, 81 insertions, 3799 deletions
diff --git a/xmake/actions/config/xmake.lua b/xmake/actions/config/xmake.lua
index 9efde3222..0a507f70b 100755
--- a/xmake/actions/config/xmake.lua
+++ b/xmake/actions/config/xmake.lua
@@ -46,7 +46,7 @@ task("config")
{'c', "clean", "k", nil, "Clean the cached configure and configure all again." }
, {}
- , {'p', "plat", "kv", "$(host)", "Compile for the given platform."
+--[[ , {'p', "plat", "kv", "$(host)", "Compile for the given platform."
-- show the description of all platforms
, function ()
@@ -83,7 +83,7 @@ task("config")
-- get it
return description
end }
- , {'m', "mode", "kv", "release", "Compile for the given mode."
+]] , {'m', "mode", "kv", "release", "Compile for the given mode."
, " - debug"
, " - release"
, " - profile" }
@@ -94,7 +94,7 @@ task("config")
, {nil, "host", "kv", "$(host)", "The current host environment." }
-- show menu for project
- , function ()
+--[[ , function ()
-- import platform
import("core.project")
@@ -102,7 +102,7 @@ task("config")
-- get menu for project
return project.menu()
end
-
+]]
, {}
, {nil, "make", "kv", "auto", "Set the make path." }
, {nil, "ccache", "kv", "auto", "Enable or disable the c/c++ compiler cache." }
@@ -142,7 +142,7 @@ task("config")
, {nil, "shflags", "kv", nil, "The Shared Library Linker Flags" }
-- show menu for platform
- , function ()
+--[[ , function ()
-- import platform
import("core.platform")
@@ -150,7 +150,7 @@ task("config")
-- get menu for platform
return platform.menu("config")
end
-
+]]
, {'o', "buildir", "kv", "build", "Set the build directory." }
diff --git a/xmake/actions/create/xmake.lua b/xmake/actions/create/xmake.lua
index 9225ee771..40880c99a 100755
--- a/xmake/actions/create/xmake.lua
+++ b/xmake/actions/create/xmake.lua
@@ -38,7 +38,7 @@ task("create")
, options =
{
{'n', "name", "kv", nil, "The project name." }
- , {'l', "language", "kv", "c", "The project language"
+--[[ , {'l', "language", "kv", "c", "The project language"
-- show the description of all languages
, function ()
@@ -75,7 +75,7 @@ task("create")
-- get it
return description
end }
-
+]]
, {}
, {nil, "target", "v", nil, "Create the given target."
, "Uses the project name as target if not exists." }
diff --git a/xmake/actions/global/xmake.lua b/xmake/actions/global/xmake.lua
index c71f27d15..fa2023c58 100755
--- a/xmake/actions/global/xmake.lua
+++ b/xmake/actions/global/xmake.lua
@@ -29,9 +29,6 @@ task("global")
-- on run
on_task_run(function ()
- -- imports
- import("core.option")
- import("core.global")
end)
@@ -58,7 +55,7 @@ task("global")
, {}
-- show menu for platform
- , function ()
+--[[ , function ()
-- import platform
import("core.platform")
@@ -66,7 +63,7 @@ task("global")
-- get menu for platform
return platform.menu("global")
end
-
+]]
}
})
diff --git a/xmake/actions/package/xmake.lua b/xmake/actions/package/xmake.lua
index c0fdb9771..ccb878ceb 100755
--- a/xmake/actions/package/xmake.lua
+++ b/xmake/actions/package/xmake.lua
@@ -40,7 +40,7 @@ task("package")
-- options
, options =
{
- {'a', "archs", "kv", nil, "Package multiple given architectures."
+--[[ {'a', "archs", "kv", nil, "Package multiple given architectures."
, " .e.g --archs=\"armv7, arm64\" or -a i386"
, ""
-- show the description of all architectures
@@ -62,7 +62,7 @@ task("package")
return description
end }
- , {'o', "outputdir", "kv", nil, "Set the output directory." }
+ ,]] {'o', "outputdir", "kv", nil, "Set the output directory." }
, {}
, {nil, "target", "v", "all", "Package a given target" }
diff --git a/xmake/core/_xmake_main.lua b/xmake/core/_xmake_main.lua
index d0415c924..754baa3e9 100644
--- a/xmake/core/_xmake_main.lua
+++ b/xmake/core/_xmake_main.lua
@@ -38,7 +38,7 @@ xmake._PROJECT_FILE = "xmake.lua"
package.path = xmake._CORE_DIR .. "/?.lua;" .. package.path
-- load modules
-local main = require("base/main")
+local main = require("main")
-- the main function
function _xmake_main()
diff --git a/xmake/core/action/build.lua b/xmake/core/action/build.lua
deleted file mode 100644
index 8e0858c22..000000000
--- a/xmake/core/action/build.lua
+++ /dev/null
@@ -1,121 +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 build.lua
---
-
--- define module: action_build
-local action_build = action_build or {}
-
--- load modules
-local rule = require("base/rule")
-local utils = require("base/utils")
-local clean = require("base/clean")
-local config = require("base/config")
-local option = require("base/option")
-local project = require("base/project")
-local makefile = require("base/makefile")
-
--- need access to the given file?
-function action_build.need(name)
-
- -- check
- assert(name)
-
- -- the accessors
- local accessors = { config = true, global = true, project = true, platform = true }
-
- -- need it?
- return accessors[name]
-end
-
--- done
-function action_build.done()
-
- -- the options
- local options = option.options()
- assert(options)
-
- -- the target name
- local target_name = options.target
-
- -- check target
- if not project.checktarget(target_name) then
- return false
- end
-
- -- rebuild it?
- if options.rebuild or config.get("__rebuild") then
- clean.remove(target_name, "build")
- -- update it?
- elseif options.update then
- clean.remove(target_name, "targets")
- end
-
- -- clear rebuild mark and save configure to file
- if config.get("__rebuild") then
-
- -- clear it
- config.set("__rebuild", nil)
-
- -- save the configure
- if not config.save() then
- -- error
- utils.error("update configure failed!")
- end
- end
-
- -- check makefile
- if not os.isfile(rule.makefile()) then
-
- -- make the configure file for the given target
- if not project.makeconf(options.target) then
- -- error
- utils.error("make configure failed!")
- return false
- end
-
- -- make makefile
- if not makefile.make() then
- -- error
- utils.error("make makefile failed!")
- return false
- end
- end
-
- -- build target for makefile
- if not makefile.build(target_name) then
- -- error
- print("")
- if options.verbose then
- io.cat(rule.logfile())
- else
- io.tail(rule.logfile(), 32)
- end
- utils.error("build target: %s failed!\n", target_name)
- return false
- end
-
- -- ok
- print("build ok!")
- return true
-end
-
--- return module: action_build
-return action_build
diff --git a/xmake/core/action/clean.lua b/xmake/core/action/clean.lua
deleted file mode 100644
index b6955c942..000000000
--- a/xmake/core/action/clean.lua
+++ /dev/null
@@ -1,107 +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 clean.lua
---
-
--- define module: action_clean
-local action_clean = action_clean or {}
-
--- load modules
-local clean = require("base/clean")
-local config = require("base/config")
-local project = require("base/project")
-local utils = require("base/utils")
-local option = require("base/option")
-local platform = require("base/platform")
-
--- need access to the given file?
-function action_clean.need(name)
-
- -- check
- assert(name)
-
- -- the accessors
- local accessors = { global = true, config = true, project = true, platform = true }
-
- -- need it?
- return accessors[name]
-end
-
--- done
-function action_clean.done()
-
- -- the options
- local options = option.options()
- assert(options)
-
- -- check target
- if not project.checktarget(options.target) then
- return false
- end
-
- -- clean the current target
- if not clean.remove(options.target, utils.ifelse(options.all, "all", "build")) then
- return false
- end
-
- -- trace
- print("clean ok!")
-
- -- ok
- return true
-end
-
--- the menu
-function action_clean.menu()
-
- return {
- -- xmake c
- shortname = 'c'
-
- -- usage
- , usage = "xmake clean|c [options] [target]"
-
- -- description
- , description = "Remove all binary and temporary files."
-
- -- options
- , options =
- {
- {'f', "file", "kv", "xmake.lua", "Read a given xmake.lua file." }
- , {'P', "project", "kv", nil, "Change to the given project directory."
- , "Search priority:"
- , " 1. The Given Command Argument"
- , " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR"
- , " 3. The Current Directory" }
- , {}
- , {'a', "all", "k", nil, "Clean all auto-generated files by xmake." }
- , {}
- , {'v', "verbose", "k", nil, "Print lots of verbose information." }
- , {nil, "version", "k", nil, "Print the version number and exit." }
- , {'h', "help", "k", nil, "Print this help message and exit." }
-
- , {}
- , {nil, "target", "v", "all", "Clean for the given target." }
- }
- }
-end
-
--- return module: action_clean
-return action_clean
diff --git a/xmake/core/action/config.lua b/xmake/core/action/config.lua
deleted file mode 100644
index 741eb49e9..000000000
--- a/xmake/core/action/config.lua
+++ /dev/null
@@ -1,216 +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 config.lua
---
-
--- define module: action_config
-local action_config = action_config or {}
-
--- load modules
-local utils = require("base/utils")
-local option = require("base/option")
-local config = require("base/config")
-local project = require("base/project")
-local makefile = require("base/makefile")
-local platform = require("base/platform")
-
--- need access to the given file?
-function action_config.need(name)
-
- -- check
- assert(name)
-
- -- the accessors
- local accessors = { config = true, global = true, project = true, platform = true }
-
- -- need it?
- return accessors[name]
-end
-
--- done
-function action_config.done()
-
- -- the options
- local options = option.options()
- assert(options)
-
- -- check target
- if not project.checktarget(options.target) then
- return false
- end
-
- -- trace
- print("configure ...")
-
- -- save the configure
- if not config.save() then
- -- error
- utils.error("save configure failed!")
- return false
- end
-
- -- make the configure file for the given target
- if not project.makeconf(options.target) then
- -- error
- utils.error("make configure failed!")
- return false
- end
-
- -- make makefile
- if not makefile.make() then
- -- error
- utils.error("make makefile failed!")
- return false
- end
-
- -- dump configure
- config.dump()
-
- -- trace
- print("configure ok!")
-
- -- ok
- return true
-end
-
--- the menu
-function action_config.menu()
-
- return {
- -- xmake f
- shortname = 'f'
-
- -- usage
- , usage = "xmake config|f [options] [target]"
-
- -- description
- , description = "Configure the project."
-
- -- options
- , options =
- {
- {'c', "clean", "k", nil, "Clean the cached configure and configure all again." }
-
- , {}
- , {'p', "plat", "kv", xmake._HOST, "Compile for the given platform."
- , function ()
- local descriptions = {}
- local plats = platform.plats()
- if plats then
- for i, plat in ipairs(plats) do
- descriptions[i] = " - " .. plat
- end
- end
- return descriptions
- end }
- , {'a', "arch", "kv", "auto", "Compile for the given architecture."
- , function ()
- local descriptions = {}
- local plats = platform.plats()
- if plats then
- for i, plat in ipairs(plats) do
- descriptions[i] = " - " .. plat .. ":"
- local archs = platform.archs(plat)
- if archs then
- for _, arch in ipairs(archs) do
- descriptions[i] = descriptions[i] .. " " .. arch
- end
- end
- end
- end
- return descriptions
- end }
- , {'m', "mode", "kv", "release", "Compile for the given mode."
- , " - debug"
- , " - release"
- , " - profile" }
- , {'k', "kind", "kv", "static", "Compile for the given target kind."
- , " - static"
- , " - shared"
- , " - binary" }
- , {nil, "host", "kv", xmake._HOST, "The current host environment." }
-
- -- the options for project
- , function () return project.menu() end
-
- , {}
- , {nil, "make", "kv", "auto", "Set the make path." }
- , {nil, "ccache", "kv", "auto", "Enable or disable the c/c++ compiler cache." }
-
- , {}
- , {nil, "cross", "kv", nil, "The cross toolchains prefix"
- , ".e.g"
- , " - i386-mingw32-"
- , " - arm-linux-androideabi-" }
- , {nil, "toolchains", "kv", nil, "The cross toolchains directory" }
-
- , {}
- , {nil, "cc", "kv", nil, "The C Compiler" }
- , {nil, "cxx", "kv", nil, "The C++ Compiler" }
- , {nil, "cflags", "kv", nil, "The C Compiler Flags" }
- , {nil, "cxflags", "kv", nil, "The C/C++ compiler Flags" }
- , {nil, "cxxflags", "kv", nil, "The C++ Compiler Flags" }
-
- , {}
- , {nil, "as", "kv", nil, "The Assembler" }
- , {nil, "asflags", "kv", nil, "The Assembler Flags" }
-
- , {}
- , {nil, "sc", "kv", nil, "The Swift Compiler" }
- , {nil, "scflags", "kv", nil, "The Swift Compiler Flags" }
-
- , {}
- , {nil, "ld", "kv", nil, "The Linker" }
- , {nil, "ldflags", "kv", nil, "The Binary Linker Flags" }
-
- , {}
- , {nil, "ar", "kv", nil, "The Static Library Linker" }
- , {nil, "arflags", "kv", nil, "The Static Library Linker Flags" }
-
- , {}
- , {nil, "sh", "kv", nil, "The Shared Library Linker" }
- , {nil, "shflags", "kv", nil, "The Shared Library Linker Flags" }
-
- -- the options for all platforms
- , function () return platform.menu("config") end
-
- , {}
- , {'f', "file", "kv", "xmake.lua", "Read a given xmake.lua file." }
- , {'P', "project", "kv", nil, "Change to the given project directory."
- , "Search priority:"
- , " 1. The Given Command Argument"
- , " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR"
- , " 3. The Current Directory" }
- , {'o', "buildir", "kv", "build", "Set the build directory." }
-
-
- , {}
- , {'v', "verbose", "k", nil, "Print lots of verbose information." }
- , {nil, "version", "k", nil, "Print the version number and exit." }
- , {'h', "help", "k", nil, "Print this help message and exit." }
-
- , {}
- , {nil, "target", "v", "all", "Configure for the given target." }
- }
- }
-end
-
--- return module: action_config
-return action_config
diff --git a/xmake/core/action/create.lua b/xmake/core/action/create.lua
deleted file mode 100644
index eb420959e..000000000
--- a/xmake/core/action/create.lua
+++ /dev/null
@@ -1,124 +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 create.lua
---
-
--- define module: action_create
-local action_create = action_create or {}
-
--- load modules
-local path = require("base/path")
-local utils = require("base/utils")
-local option = require("base/option")
-local template = require("base/template")
-
--- need access to the given file?
-function action_create.need(name)
-
- -- no accessors
- return false
-end
-
--- done
-function action_create.done()
-
- -- the options
- local options = option.options()
- assert(options)
-
- -- the target name
- local targetname = options.target or options.name or path.basename(xmake._PROJECT_DIR) or "demo"
-
- -- trace
- utils.printf("create %s ...", targetname)
-
- -- create project from template
- local ok, errors = template.create(options.language, options.template, targetname)
- if not ok then
- utils.error(errors)
- return false
- end
-
- -- trace
- utils.printf("create %s ok!", targetname)
-
- -- ok
- return true
-end
-
--- the menu
-function action_create.menu()
-
- return {
- -- usage
- usage = "xmake create [options] [target]"
-
- -- description
- , description = "Create a new project."
-
- -- options
- , options =
- {
- {'n', "name", "kv", nil, "The project name." }
- , {'f', "file", "kv", "xmake.lua", "Create a given xmake.lua file." }
- , {'P', "project", "kv", nil, "Create from the given project directory."
- , "Search priority:"
- , " 1. The Given Command Argument"
- , " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR"
- , " 3. The Current Directory" }
- , {'l', "language", "kv", "c", "The project language"
- , function ()
- local descriptions = {}
- local languages = template.languages()
- for _, language in ipairs(languages) do
- table.insert(descriptions, " - " .. language)
- end
- return descriptions
- end }
- , {'t', "template", "kv", "1", "Select the project template id of the given language."
- , function ()
- local descriptions = {}
- local languages = template.languages()
- for _, language in ipairs(languages) do
- table.insert(descriptions, string.format(" - language: %s", language))
- local templates = template.templates(language)
- if templates then
- for i, template in ipairs(templates) do
- table.insert(descriptions, string.format(" %d. %s", i, utils.ifelse(template.description, template.description, "The Unknown Project")))
- end
- end
- end
- return descriptions
- end }
-
- , {}
- , {'v', "verbose", "k", nil, "Print lots of verbose information." }
- , {nil, "version", "k", nil, "Print the version number and exit." }
- , {'h', "help", "k", nil, "Print this help message and exit." }
-
- , {}
- , {nil, "target", "v", nil, "Create the given target."
- , "Uses the project name as target if not exists." }
- }
- }
-end
-
--- return module: action_create
-return action_create
diff --git a/xmake/core/action/debug.lua b/xmake/core/action/debug.lua
deleted file mode 100644
index 7d23019d1..000000000
--- a/xmake/core/action/debug.lua
+++ /dev/null
@@ -1,89 +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 debug.lua
---
-
--- define module: action_debug
-local action_debug = action_debug or {}
-
--- load modules
-local utils = require("base/utils")
-local config = require("base/config")
-local platform = require("base/platform")
-
--- need access to the given file?
-function action_debug.need(name)
-
- -- check
- assert(name)
-
- -- the accessors
- local accessors = { config = true, global = true, project = true, platform = true }
-
- -- need it?
- return accessors[name]
-end
-
--- done
-function action_debug.done()
-
- -- TODO
- print("not implement!")
-
- -- ok
- return true
-end
-
--- the menu
-function action_debug.menu()
-
- return {
- -- xmake d
- shortname = 'd'
-
- -- usage
- , usage = "xmake debug|d [options] [target]"
-
- -- description
- , description = "Debug target."
-
- -- options
- , options =
- {
- {'f', "file", "kv", "xmake.lua", "Create a given xmake.lua file." }
- , {'P', "project", "kv", nil, "Create from the given project directory."
- , "Search priority:"
- , " 1. The Given Command Argument"
- , " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR"
- , " 3. The Current Directory" }
-
- , {}
- , {'v', "verbose", "k", nil, "Print lots of verbose information." }
- , {nil, "version", "k", nil, "Print the version number and exit." }
- , {'h', "help", "k", nil, "Print this help message and exit." }
-
- , {}
- , {nil, "target", "v", nil, "Debug a given target" }
- }
- }
-end
-
--- return module: action_debug
-return action_debug
diff --git a/xmake/core/action/global.lua b/xmake/core/action/global.lua
deleted file mode 100644
index 6222b9f1e..000000000
--- a/xmake/core/action/global.lua
+++ /dev/null
@@ -1,104 +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 global.lua
---
-
--- define module: action_global
-local action_global = action_global or {}
-
--- load modules
-local utils = require("base/utils")
-local global = require("base/global")
-local platform = require("base/platform")
-
--- need access to the given file?
-function action_global.need(name)
-
- -- check
- assert(name)
-
- -- the accessors
- local accessors = { global = true }
-
- -- need it?
- return accessors[name]
-end
-
--- done
-function action_global.done()
-
- -- probe the global platform configure
- if not platform.probe(true) then
- return false
- end
-
- -- clear up the global configure
- global.clearup()
-
- -- save the global configure
- if not global.save() then
- -- error
- utils.error("save configure failed!")
- return false
- end
-
- -- dump global
- global.dump()
-
- -- ok
- print("configure ok!")
- return true
-end
-
--- the menu
-function action_global.menu()
-
- return {
- -- xmake g
- shortname = 'g'
-
- -- usage
- , usage = "xmake global|g [options] [target]"
-
- -- description
- , description = "Configure the global options for xmake."
-
- -- options
- , options =
- {
- {'c', "clean", "k", nil, "Clean the cached configure and configure all again." }
- , {nil, "make", "kv", "auto", "Set the make path." }
- , {nil, "ccache", "kv", "auto", "Enable or disable the c/c++ compiler cache."
- , " --ccache=[y|n]" }
-
- , {}
- -- the options for all platforms
- , function () return platform.menu("global") end
-
- , {}
- , {'v', "verbose", "k", nil, "Print lots of verbose information." }
- , {nil, "version", "k", nil, "Print the version number and exit." }
- , {'h', "help", "k", nil, "Print this help message and exit." }
- }
- }
-end
-
--- return module: action_global
-return action_global
diff --git a/xmake/core/action/install.lua b/xmake/core/action/install.lua
deleted file mode 100644
index 581945093..000000000
--- a/xmake/core/action/install.lua
+++ /dev/null
@@ -1,208 +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: action_install
-local action_install = action_install or {}
-
--- load modules
-local utils = require("base/utils")
-local config = require("base/config")
-local option = require("base/option")
-local global = require("base/global")
-local install = require("base/install")
-local package = require("base/package")
-local project = require("base/project")
-local platform = require("base/platform")
-
--- need access to the given file?
-function action_install.need(name)
-
- -- no accessors
- return false
-end
-
--- make configure for the given target
-function action_install._makeconf(configs, target_name, target)
-
- -- check
- assert(configs and target_name and target)
-
- -- init configs for targets
- configs[target_name] = configs[target_name] or {}
- local configs_target = configs[target_name]
-
- -- save the install script
- configs_target.installscript = target.installscript
-
- -- ok
- return true
-end
-
--- package target
-function action_install._package(target_name)
-
- -- get the target name
- if not target_name or target_name == "all" then
- target_name = ""
- end
-
- -- package it
- if os.execute(string.format("xmake p -P %s -f %s %s", xmake._PROJECT_DIR, xmake._PROJECT_FILE, target_name)) ~= 0 then
- return false
- end
-
- -- ok
- return true
-end
-
--- done
-function action_install.done()
-
- -- the options
- local options = option.options()
- assert(options)
-
- -- trace
- print("install: ...")
-
- -- load the global configure first
- global.load()
-
- -- enter the project directory
- if not os.cd(xmake._PROJECT_DIR) then
- -- errors
- utils.error("not found project: %s!", xmake._PROJECT_DIR)
- return false
- end
-
- -- package the given target first
- if not action_install._package(options.target) then
- -- errors
- utils.error("package: failed!")
- return false
- end
-
- -- load the package configure
- local configs, errors = package.load()
- if not configs then
- -- errors
- utils.error(errors)
- return false
- end
-
- -- reload configure
- local errors = config.reload()
- if errors then
- -- error
- utils.error(errors)
- return false
- end
-
- -- make the platform configure
- if not platform.make() then
- utils.error("make platform configure: %s failed!", config.get("plat"))
- return false
- end
-
- -- reload project
- local errors = project.reload()
- if errors then
- -- error
- utils.error(errors)
- return false
- end
-
- -- update the outputdir
- for _, target in pairs(configs) do
- target.outputdir = options.installdir
- end
-
- -- the targets
- local targets = project.targets()
- assert(targets)
-
- -- make configure for the given target
- if target_name and target_name ~= "all" then
- if not action_install._makeconf(configs, target_name, targets[target_name]) then
- utils.error("make target configure: %s failed!", target_name)
- return false
- end
- else
- for target_name, target in pairs(targets) do
- if not action_install._makeconf(configs, target_name, target) then
- utils.error("make target configure: %s failed!", target_name)
- return false
- end
- end
- end
-
- -- done install
- if not install.done(configs) then
- -- errors
- utils.error("install: failed!")
- return false
- end
-
- -- trace
- print("install: ok!")
-
- -- ok
- return true
-end
-
--- the menu
-function action_install.menu()
-
- return {
- -- xmake i
- shortname = 'i'
-
- -- usage
- , usage = "xmake install|i [options] [target]"
-
- -- description
- , description = "Package and install the project binary files."
-
- -- options
- , options =
- {
- {'f', "file", "kv", "xmake.lua", "Read a given xmake.lua file." }
- , {'P', "project", "kv", nil, "Change to the given project directory."
- , "Search priority:"
- , " 1. The Given Command Argument"
- , " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR"
- , " 3. The Current Directory" }
- , {'o', "installdir", "kv", nil, "Set the install directory." }
-
- , {}
- , {'v', "verbose", "k", nil, "Print lots of verbose information." }
- , {nil, "version", "k", nil, "Print the version number and exit." }
- , {'h', "help", "k", nil, "Print this help message and exit." }
-
- , {}
- , {nil, "target", "v", "all", "Install the given target." }
- }
- }
-end
-
--- return module: action_install
-return action_install
diff --git a/xmake/core/action/lua.lua b/xmake/core/action/lua.lua
deleted file mode 100644
index 9e22eb5ee..000000000
--- a/xmake/core/action/lua.lua
+++ /dev/null
@@ -1,169 +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 lua.lua
---
-
--- define module: action_lua
-local action_lua = action_lua or {}
-
--- load modules
-local os = require("base/os")
-local path = require("base/path")
-local utils = require("base/utils")
-local option = require("base/option")
-local config = require("base/config")
-local string = require("base/string")
-local tools = require("tools/tools")
-local platform = require("base/platform")
-
--- need access to the given file?
-function action_lua.need(name)
-
- -- the options
- local options = option.options()
- assert(options)
-
- -- do not load config if be not given -f or -P options
- if options.file == nil and options.project == nil then
- return false
- end
-
- -- patch target for loading config ok
- options.target = "all"
-
- -- the accessors
- local accessors = { config = true, global = true, platform = true }
-
- -- need it?
- return accessors[name]
-end
-
--- done
-function action_lua.done()
-
- -- the options
- local options = option.options()
- assert(options)
-
- -- no script?
- if not options.script then
- return false
- end
-
- -- the arguments
- local arguments = options.arguments or {}
- if type(arguments) ~= "table" then
- arguments = {}
- end
-
- -- is string script?
- if options.string then
-
- -- trace
- utils.verbose("script: %s", options.script)
-
- -- load and run string
- local script = loadstring(options.script)
- if script then
- return script(arguments)
- end
- else
- -- attempt to load script from the given file if exists
- local file = options.script
- if not path.is_absolute(file) then
- file = path.absolute(file)
- end
-
- -- attempt to load script from the tools directory
- if not os.isfile(file) then
- file = tools.find(options.script, xmake._CORE_DIR .. "/tools")
- end
-
- -- load and run the script file
- if os.isfile(file) then
-
- -- load script
- local script = loadfile(file)
- if script then
-
- -- load module
- local module = script()
- if module then
-
- -- init module
- if module.init then
- module:init(options.script)
- end
-
- -- done module
- return module:main(arguments)
- end
- end
- end
- end
-
- -- failed
- utils.error("cannot run this script: %s", options.script)
- return false
-end
-
--- the menu
-function action_lua.menu()
-
- return {
- -- xmake l
- shortname = 'l'
-
- -- usage
- , usage = "xmake lua|l [options] [script] [arguments]"
-
- -- description
- , description = "Run the lua script."
-
- -- options
- , options =
- {
- {'f', "file", "kv", nil, "Read a given xmake.lua file." }
- , {'P', "project", "kv", nil, "Change to the given project directory."
- , "Search priority:"
- , " 1. The Given Command Argument"
- , " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR"
- , " 3. The Current Directory" }
-
- , {}
- , {'s', "string", "k", nil, "Run the lua string script." }
-
- , {}
- , {'v', "verbose", "k", nil, "Print lots of verbose information." }
- , {nil, "version", "k", nil, "Print the version number and exit." }
- , {'h', "help", "k", nil, "Print this help message and exit." }
-
- , {}
- , {nil, "script", "v", nil, "Run the given lua script."
- , " - The script name from the xmake tool directory"
- , " - The script file"
- , " - The script string" }
- , {nil, "arguments", "vs", nil, "The script arguments" }
- }
- }
-end
-
--- return module: action_lua
-return action_lua
diff --git a/xmake/core/action/man.lua b/xmake/core/action/man.lua
deleted file mode 100644
index 0b8b853cf..000000000
--- a/xmake/core/action/man.lua
+++ /dev/null
@@ -1,89 +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 man.lua
---
-
--- define module: action_man
-local action_man = action_man or {}
-
--- load modules
-local utils = require("base/utils")
-local config = require("base/config")
-local platform = require("base/platform")
-
--- need access to the given file?
-function action_man.need(name)
-
- -- check
- assert(name)
-
- -- the accessors
- local accessors = { config = true, global = true, project = true }
-
- -- need it?
- return accessors[name]
-end
-
--- done
-function action_man.done()
-
- -- TODO
- print("not implement!")
-
- -- ok
- return true
-end
-
--- the menu
-function action_man.menu()
-
- return {
- -- xmake m
- shortname = 'm'
-
- -- usage
- , usage = "xmake man|m [options] [target]"
-
- -- description
- , description = "Create a project man."
-
- -- options
- , options =
- {
- {'f', "file", "kv", "xmake.lua", "Create a given xmake.lua file." }
- , {'P', "project", "kv", nil, "Create from the given project directory."
- , "Search priority:"
- , " 1. The Given Command Argument"
- , " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR"
- , " 3. The Current Directory" }
-
- , {}
- , {'v', "verbose", "k", nil, "Print lots of verbose information." }
- , {nil, "version", "k", nil, "Print the version number and exit." }
- , {'h', "help", "k", nil, "Print this help message and exit." }
-
- , {}
- , {nil, "target", "v", "all", "Create man for the given target" }
- }
- }
-end
-
--- return module: action_man
-return action_man
diff --git a/xmake/core/action/package.lua b/xmake/core/action/package.lua
deleted file mode 100644
index 22866081f..000000000
--- a/xmake/core/action/package.lua
+++ /dev/null
@@ -1,349 +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: action_package
-local action_package = action_package or {}
-
--- load modules
-local rule = require("base/rule")
-local path = require("base/path")
-local utils = require("base/utils")
-local option = require("base/option")
-local config = require("base/config")
-local global = require("base/global")
-local string = require("base/string")
-local project = require("base/project")
-local package = require("base/package")
-local platform = require("base/platform")
-
--- need access to the given file?
-function action_package.need(name)
-
- -- no accessors
- return false
-end
-
--- configure target for the given architecture
-function action_package._config(arch, target_name)
-
- -- need not configure it
- if not arch then return true end
-
- -- done the command
- return os.execute(string.format("xmake f -P %s -f %s -a %s %s", xmake._PROJECT_DIR, xmake._PROJECT_FILE, arch, target_name)) == 0;
-end
-
--- build target for the given architecture
-function action_package._build(arch, target_name)
-
- -- get the target name
- if not target_name or target_name == "all" then
- target_name = ""
- end
-
- -- configure it first
- if not action_package._config(arch, target_name) then return false end
-
- -- build it
- if os.execute(string.format("xmake -P %s %s", xmake._PROJECT_DIR, target_name)) ~= 0 then
- -- errors
- utils.error("build failed!")
- return false
- end
-
- -- ok
- return true
-end
-
--- backup the target files
-function action_package._backup(rootdir, filepath)
-
- -- the relative file path
- if filepath and path.is_absolute(filepath) then
- filepath = path.relative(filepath, xmake._PROJECT_DIR)
- end
-
- -- not exists? return it directly
- if not filepath or not os.isfile(filepath) then return end
-
- -- the backup file
- local backupfile = string.format("%s/%s", rootdir, filepath)
-
- -- backup it
- local ok, errors = os.cp(filepath, backupfile)
- if not ok then
- -- errors
- utils.error(errors)
- return
- end
-
- -- ok
- return filepath
-end
-
--- make configure for the given target
-function action_package._makeconf(target_name, target)
-
- -- check
- assert(target_name and target)
-
- -- the options
- local options = option.options()
- assert(options)
-
- -- the configs
- local configs = action_package._CONFIGS
- assert(configs)
-
- -- the architecture
- local arch = config.get("arch")
- if not arch then return false end
-
- -- init configs for targets
- configs[target_name] = configs[target_name] or {}
- local configs_target = configs[target_name]
-
- -- init configs for architectures
- configs_target.archs = configs_target.archs or {}
-
- -- init configs for architecture
- configs_target.archs[arch] = configs_target.archs[arch] or {}
- local configs_arch = configs_target.archs[arch]
-
- -- save name
- configs_target.name = target_name
-
- -- save kind
- configs_target.kind = target.kind
-
- -- save the output directory
- configs_target.outputdir = options.outputdir or config.get("buildir")
-
- -- save the header files
- configs_target.headers = target.headers
-
- -- save the target directory
- configs_arch.targetdir = rule.backupdir(target_name, arch)
-
- -- save the config file
- configs_arch.config_h = action_package._backup(configs_arch.targetdir, rule.config_h(target))
-
- -- save the target file
- configs_arch.targetfile = action_package._backup(configs_arch.targetdir, rule.targetfile(target_name, target))
-
- -- save the package script
- configs_target.packagescript = target.packagescript
-
- -- ok
- return true
-end
-
--- load configure for the given target
-function action_package._loadconf(target_name)
-
- -- reload configure
- local errors = config.reload()
- if errors then
- -- error
- utils.error(errors)
- return false
- end
-
- -- make the platform configure
- if not platform.make() then
- utils.error("make platform configure: %s failed!", config.get("plat"))
- return false
- end
-
- -- reload project
- local errors = project.reload()
- if errors then
- -- error
- utils.error(errors)
- return false
- end
-
- -- the targets
- local targets = project.targets()
- assert(targets)
-
- -- make configure for the given target
- if target_name and target_name ~= "all" then
- if not action_package._makeconf(target_name, targets[target_name]) then
- utils.error("make target configure: %s failed!", target_name)
- return false
- end
- else
- for target_name, target in pairs(targets) do
- if not action_package._makeconf(target_name, target) then
- utils.error("make target configure: %s failed!", target_name)
- return false
- end
- end
- end
-
- -- ok
- return true
-end
-
--- build target for all architectures
-function action_package._build_all(archs, target_name)
-
- -- exists the given architectures?
- if archs then
-
- -- split all architectures
- archs = archs:split(",")
- if not archs then return false end
-
- -- build for all architectures
- for _, arch in ipairs(archs) do
-
- -- trim it
- arch = arch:trim()
-
- -- build it
- if not action_package._build(arch, target_name) then return false end
-
- -- load configure
- if not action_package._loadconf(target_name) then return false end
-
- end
-
- -- build for single architecture
- else
-
- -- build it
- if not action_package._build(nil, target_name) then return false end
-
- -- load configure
- if not action_package._loadconf(target_name) then return false end
-
- end
-
- -- ok
- return true
-end
-
--- done
-function action_package.done()
-
- -- the options
- local options = option.options()
- assert(options)
-
- -- trace
- print("package: ...")
-
- -- init configs
- action_package._CONFIGS = action_package._CONFIGS or {}
- local configs = action_package._CONFIGS
-
- -- load the global configure first
- global.load()
-
- -- enter the project directory
- if not os.cd(xmake._PROJECT_DIR) then
- -- errors
- utils.error("not found project: %s!", xmake._PROJECT_DIR)
- return false
- end
-
- -- build the given target first for all architectures
- if not action_package._build_all(options.archs, options.target) then
- -- errors
- utils.error("build package failed!")
- return false
- end
-
- -- done package
- if not package.done(configs) then
- -- errors
- utils.error("package: failed!")
- return false
- end
-
- -- trace
- print("package: ok!")
-
- -- ok
- return true
-end
-
--- the menu
-function action_package.menu()
-
- return {
- -- xmake p
- shortname = 'p'
-
- -- usage
- , usage = "xmake package|p [options] [target]"
-
- -- description
- , description = "Package target."
-
- -- options
- , options =
- {
- {'a', "archs", "kv", nil, "Package multiple given architectures."
- , " .e.g --archs=\"armv7, arm64\" or -a i386"
- , ""
- , function ()
- local descriptions = {}
- local plats = platform.plats()
- if plats then
- for i, plat in ipairs(plats) do
- descriptions[i] = " - " .. plat .. ":"
- local archs = platform.archs(plat)
- if archs then
- for _, arch in ipairs(archs) do
- descriptions[i] = descriptions[i] .. " " .. arch
- end
- end
- end
- end
- return descriptions
- end }
-
- , {}
- , {'f', "file", "kv", "xmake.lua", "Create a given xmake.lua file." }
- , {'P', "project", "kv", nil, "Create from the given project directory."
- , "Search priority:"
- , " 1. The Given Command Argument"
- , " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR"
- , " 3. The Current Directory" }
- , {'o', "outputdir", "kv", nil, "Set the output directory." }
-
- , {}
- , {'v', "verbose", "k", nil, "Print lots of verbose information." }
- , {nil, "version", "k", nil, "Print the version number and exit." }
- , {'h', "help", "k", nil, "Print this help message and exit." }
-
- , {}
- , {nil, "target", "v", "all", "Package a given target" }
- }
- }
-end
-
--- return module: action_package
-return action_package
diff --git a/xmake/core/action/run.lua b/xmake/core/action/run.lua
deleted file mode 100644
index df0db276a..000000000
--- a/xmake/core/action/run.lua
+++ /dev/null
@@ -1,170 +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 run.lua
---
-
--- define module: action_run
-local action_run = action_run or {}
-
--- load modules
-local rule = require("base/rule")
-local path = require("base/path")
-local utils = require("base/utils")
-local option = require("base/option")
-local config = require("base/config")
-local project = require("base/project")
-local sandbox = require("base/sandbox")
-local platform = require("base/platform")
-
--- need access to the given file?
-function action_run.need(name)
-
- -- check
- assert(name)
-
- -- the accessors
- local accessors = { config = true, global = true, project = true, platform = true }
-
- -- need it?
- return accessors[name]
-end
-
--- done
-function action_run.done()
-
- -- the options
- local options = option.options()
- assert(options and xmake._PROJECT_DIR)
-
- -- the target name
- local name = options.target
- if not name then
- -- error
- utils.error("no runable target!")
- return false
- end
-
- -- the arguments
- local arguments = options.arguments or {}
- if type(arguments) ~= "table" then
- arguments = {}
- end
-
- -- the targets
- local targets = project.targets()
- if not targets or not targets[name] then
- -- error
- utils.error("not found target: %s!", name)
- return false
- end
-
- -- the target
- local target = targets[name]
-
- -- the target file
- local targetfile = rule.targetfile(name, target)
- if targetfile and not path.is_absolute(targetfile) then
- targetfile = path.absolute(targetfile, xmake._PROJECT_DIR)
- end
-
- -- run script
- local runscript = target.runscript
- if runscript ~= nil then
-
- -- make passed target
- local target_passed = {}
- target_passed.name = name
- target_passed.arguments = arguments
- target_passed.targetfile = targetfile
-
- -- run script
- local ok, results = sandbox.load(runscript, target_passed)
- if not ok then
- utils.error(results)
- return false
- end
-
- -- check results
- if results ~= 0 then
- return utils.ifelse(results == 1, true, false)
- end
- end
-
- -- not executale?
- if not target.kind or type(target.kind) ~= "string" or target.kind ~= "binary" then
- -- error
- utils.error("the target %s is not executale!", name)
- return false
- end
-
- -- check the target file
- if not targetfile and not os.isfile(targetfile) then
- -- error
- utils.error("not found target file: %s!", targetfile)
- return false
- end
-
- -- done
- local ok = os.execute(string.format("%s %s", targetfile, table.concat(arguments, " ")))
-
- -- ok?
- return utils.ifelse(ok == 0, true, false)
-end
-
--- the menu
-function action_run.menu()
-
- return {
- -- xmake r
- shortname = 'r'
-
- -- usage
- , usage = "xmake run|r [options] [target] [arguments]"
-
- -- description
- , description = "Run the project target."
-
- -- options
- , options =
- {
- {'d', "debug", "k", nil, "Run and debug the given target." }
- , {nil, "debugger", "kv", "auto", "Set the debugger path." }
-
- , {}
- , {'f', "file", "kv", "xmake.lua", "Read a given xmake.lua file." }
- , {'P', "project", "kv", nil, "Change to the given project directory."
- , "Search priority:"
- , " 1. The Given Command Argument"
- , " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR"
- , " 3. The Current Directory" }
- , {}
- , {'v', "verbose", "k", nil, "Print lots of verbose information." }
- , {nil, "version", "k", nil, "Print the version number and exit." }
- , {'h', "help", "k", nil, "Print this help message and exit." }
-
- , {}
- , {nil, "target", "v", nil, "Run the given target." }
- , {nil, "arguments", "vs", nil, "The target arguments" }
- }
- }
-end
-
--- return module: action_run
-return action_run
diff --git a/xmake/core/action/uninstall.lua b/xmake/core/action/uninstall.lua
deleted file mode 100644
index 18938dc5f..000000000
--- a/xmake/core/action/uninstall.lua
+++ /dev/null
@@ -1,161 +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: action_uninstall
-local action_uninstall = action_uninstall or {}
-
--- load modules
-local utils = require("base/utils")
-local config = require("base/config")
-local global = require("base/global")
-local option = require("base/option")
-local install = require("base/install")
-local uninstall = require("base/uninstall")
-local package = require("base/package")
-local project = require("base/project")
-local platform = require("base/platform")
-
--- need access to the given file?
-function action_uninstall.need(name)
-
- -- no accessors
- return false
-end
-
--- package target
-function action_uninstall._package(target_name)
-
- -- get the target name
- if not target_name or target_name == "all" then
- target_name = ""
- end
-
- -- package it
- if os.execute(string.format("xmake p -P %s -f %s %s", xmake._PROJECT_DIR, xmake._PROJECT_FILE, target_name)) ~= 0 then
- return false
- end
-
- -- ok
- return true
-end
-
-
--- done
-function action_uninstall.done()
-
- -- the options
- local options = option.options()
- assert(options)
-
- -- trace
- print("uninstall: ...")
-
- -- load the global configure first
- global.load()
-
- -- enter the project directory
- if not os.cd(xmake._PROJECT_DIR) then
- -- errors
- utils.error("not found project: %s!", xmake._PROJECT_DIR)
- return false
- end
-
- -- load the install configure
- local configs, errors = install.load()
- if not configs then
- -- errors
- utils.error(errors)
- return false
- end
-
- -- reload configure
- local errors = config.reload()
- if errors then
- -- error
- utils.error(errors)
- return false
- end
-
- -- make the platform configure
- if not platform.make() then
- utils.error("make platform configure: %s failed!", config.get("plat"))
- return false
- end
-
- -- reload project
- local errors = project.reload()
- if errors then
- -- error
- utils.error(errors)
- return false
- end
-
- -- done uninstall
- if not uninstall.done(configs) then
- -- errors
- utils.error("uninstall: failed!")
- return false
- end
-
- -- trace
- print("uninstall: ok!")
-
- -- ok
- return true
-end
-
--- the menu
-function action_uninstall.menu()
-
- return {
- -- xmake u
- shortname = 'u'
-
- -- usage
- , usage = "xmake uninstall|u [options] [target]"
-
- -- description
- , description = "Uninstall the project binary files."
-
- -- options
- , options =
- {
- {'f', "file", "kv", "xmake.lua", "Read a given xmake.lua file." }
- , {'P', "project", "kv", nil, "Change to the given project directory."
- , "Search priority:"
- , " 1. The Given Command Argument"
- , " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR"
- , " 3. The Current Directory" }
-
- , {}
- , {'v', "verbose", "k", nil, "Print lots of verbose information." }
- , {nil, "version", "k", nil, "Print the version number and exit." }
- , {'h', "help", "k", nil, "Print this help message and exit." }
-
- , {}
- , {nil, "target", "v", "all", "Install the given target." }
- }
- }
-end
-
--- return module: action_uninstall
-return action_uninstall
diff --git a/xmake/core/base/action.lua b/xmake/core/base/action.lua
deleted file mode 100644
index de417ffc2..000000000
--- a/xmake/core/base/action.lua
+++ /dev/null
@@ -1,142 +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 action.lua
---
-
--- define module: action
-local action = action or {}
-
--- load modules
-local os = require("base/os")
-local path = require("base/path")
-local utils = require("base/utils")
-local option = require("base/option")
-local global = require("base/global")
-local config = require("base/config")
-local project = require("base/project")
-local platform = require("base/platform")
-
--- load the given action
-function action._load(name)
-
- -- load the given action
- return require("action/" .. name)
-end
-
--- load the project file
-function action._load_project()
-
- -- the options
- local options = option.options()
- assert(options)
-
- -- enter the project directory
- if not os.cd(xmake._PROJECT_DIR) then
- -- error
- return string.format("not found project: %s!", xmake._PROJECT_DIR)
- end
-
- -- check the project file
- if not os.isfile(xmake._PROJECT_FILE) then
- return string.format("not found the project file: %s", xmake._PROJECT_FILE)
- end
-
- -- init the build directory
- if options.buildir and path.is_absolute(options.buildir) then
- options.buildir = path.relative(options.buildir, xmake._PROJECT_DIR)
- end
-
- -- xmake config or marked as "reconfig"?
- if option.task() == "config" or config._RECONFIG then
-
- -- probe the current project
- project.probe()
-
- -- clear up the configure
- config.clearup()
-
- end
-
- -- load the project
- return project.load()
-end
-
--- done the given action
-function action.done(name)
-
- -- load the given action
- local _action = action._load(name)
- if not _action then return false end
-
- -- load the global configure first
- if _action.need("global") then global.load() end
-
- -- load the project configure
- if _action.need("config") then
- local errors = config.load()
- if errors then
- -- error
- utils.error(errors)
- return false
- end
- end
-
- -- probe the platform
- if _action.need("platform") and (option.task() == "config" or config._RECONFIG) then
- if not platform.probe(false) then
- return false
- end
- end
-
- -- make the platform configure
- if _action.need("platform") and not platform.make() then
- utils.error("make platform configure: %s failed!", config.get("plat"))
- return false
- end
-
- -- load the project file
- if _action.need("project") then
- local errors = action._load_project()
- if errors then
- -- error
- utils.error(errors)
- return false
- end
- end
-
- -- reconfig it first if marked as "reconfig"
- if _action.need("config") and config._RECONFIG then
-
- -- config it
- local _action_config = action._load("config")
- if not _action_config or not _action_config.done() then
- -- error
- utils.error("reconfig failed for the changed host!")
- return false
- end
- end
-
- -- done the given action
- return _action.done()
-end
-
-
--- return module: action
-return action
diff --git a/xmake/core/base/clean.lua b/xmake/core/base/clean.lua
deleted file mode 100644
index 714fc4cc7..000000000
--- a/xmake/core/base/clean.lua
+++ /dev/null
@@ -1,207 +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 clean.lua
---
-
--- define module: clean
-local clean = clean or {}
-
--- load modules
-local os = require("base/os")
-local rule = require("base/rule")
-local utils = require("base/utils")
-local config = require("base/config")
-local project = require("base/project")
-
--- remove the given files or directories
-function clean._remove(filedirs)
-
- -- empty?
- if not filedirs then return true end
-
- -- wrap it first
- filedirs = utils.wrap(filedirs)
- for _, filedir in ipairs(filedirs) do
-
- -- exists? remove it
- if os.exists(filedir) then
- -- remove it
- local ok, errors = os.rm(filedir)
- if not ok then
- -- error
- utils.error(errors)
- return false
- end
- -- remove "*.o/obj" files?
- elseif filedir:find("%*") then
- -- match all files
- local files = os.match(filedir)
- if files then
- for _, file in ipairs(files) do
- -- remove it
- local ok, errors = os.rm(file)
- if not ok then
- -- error
- utils.error(errors)
- return false
- end
- end
- end
- end
- end
-
- -- ok
- return true
-end
-
--- remove the given target name
-function clean._remove_target(target_name, target, mode, buildir)
-
- -- check
- assert(target_name and target)
-
- -- remove the target file
- if not clean._remove(rule.targetfile(target_name, target, buildir)) then
- return false
- end
-
- -- not only remove target file?
- if mode ~= "targets" then
-
- -- remove the object files
- if not clean._remove(rule.objectfiles(target_name, target, rule.sourcefiles(target), buildir)) then
- return false
- end
-
- -- remove the header files
- local _, dstheaders = rule.headerfiles(target)
- if not clean._remove(dstheaders) then
- return false
- end
-
- -- remove the config.h file
- if mode == "all" and target.config_h then
-
- -- translate file path
- local config_h = nil
- if not path.is_absolute(target.config_h) then
- config_h = path.absolute(target.config_h, xmake._PROJECT_DIR)
- else
- config_h = path.translate(target.config_h)
- end
- if not clean._remove(config_h) then
- return false
- end
- end
- end
-
- -- ok
- return true
-end
-
--- remove the given target and all dependent targets
-function clean._remove_target_and_deps(target_name, mode, buildir)
-
- -- the targets
- local targets = project.targets()
- assert(targets)
-
- -- the target
- local target = targets[target_name]
- assert(target)
-
- -- remove the target
- if not clean._remove_target(target_name, target, mode, buildir) then
- return false
- end
-
- -- exists the dependent targets?
- if target.deps then
- local deps = utils.wrap(target.deps)
- for _, dep in ipairs(deps) do
- if not clean._remove_target_and_deps(dep, mode, buildir) then return false end
- end
- end
-
- -- ok
- return true
-end
-
--- remove the target and object files for the given target
---
--- mode:
--- all
--- build
--- targets
---
-function clean.remove(target_name, mode)
-
- -- the build directory
- local buildir = config.get("buildir")
- assert(buildir and mode)
-
- -- the target name
- if target_name and target_name ~= "all" then
- -- remove target
- if not clean._remove_target_and_deps(target_name, mode, buildir) then return false end
- else
-
- -- the targets
- local targets = project.targets()
- assert(targets)
-
- -- remove targets
- for target_name, target in pairs(targets) do
- if not clean._remove_target(target_name, target, mode, buildir) then return false end
- end
- end
-
- -- remove all
- if mode == "all" then
-
- -- remove makefile
- if not clean._remove(rule.makefile()) then
- return false
- end
-
- -- remove the configure directory
- if not clean._remove(config.directory()) then
- return false
- end
-
- -- remove the log file
- if not clean._remove(rule.logfile()) then
- return false
- end
-
- -- remove build directory if be empty
- local buildir = config.get("buildir")
- if os.isdir(buildir) then
- os.rm(buildir, true)
- end
-
- end
-
- -- ok
- return true
-end
-
--- return module: clean
-return clean
diff --git a/xmake/core/base/install.lua b/xmake/core/base/install.lua
deleted file mode 100644
index d5e7916d4..000000000
--- a/xmake/core/base/install.lua
+++ /dev/null
@@ -1,140 +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 io = require("base/io")
-local rule = require("base/rule")
-local path = require("base/path")
-local utils = require("base/utils")
-local config = require("base/config")
-local sandbox = require("base/sandbox")
-local platform = require("base/platform")
-
--- install target from the project script
-function install._done_from_project(target)
-
- -- check
- assert(target)
-
- -- no script? continue
- if target.installscript == nil then
- return 0
- end
-
- -- get script
- local script = target.installscript
- target.installscript = nil
-
- -- install it using the project script first
- local ok, results = sandbox.load(script, target)
- if not ok then
- utils.error(results)
- return -1
- end
-
- -- ok?
- return results
-end
-
--- install target from the platform script
-function install._done_from_platform(target)
-
- -- check
- assert(target)
-
- -- no script? continue
- local scriptfile = path.join(platform.directory(), "install.lua")
- if not os.isfile(scriptfile) then
- return 0
- end
-
- -- the platform install script file
- local ok, results = sandbox.load(scriptfile, target)
- if not ok then
- utils.error(results)
- return -1
- end
-
- -- ok?
- return results
-end
-
--- install target from the given target configure
-function install._done(target)
-
- -- check
- assert(target)
-
- -- install it from the project script
- local ok = install._done_from_project(target)
- if ok ~= 0 then return utils.ifelse(ok == 1, true, false) end
-
- -- install it from the platform script
- local ok = install._done_from_platform(target)
- if ok ~= 0 then return utils.ifelse(ok == 1, true, false) end
-
- -- ok
- return true
-end
-
--- get the configure file
-function install._file()
-
- -- get it
- return config.directory() .. "/install.conf"
-end
-
--- done install from the configure
-function install.done(configs)
-
- -- check
- assert(configs)
-
- -- install targets
- for _, target in pairs(configs) do
-
- -- install it
- if not install._done(target) then
- -- errors
- utils.error("install %s failed!", target.name)
- return false
- end
-
- end
-
- -- save to the configure file
- return io.save(install._file(), configs)
-end
-
--- load the install configure
-function install.load()
-
- -- load it
- return io.load(install._file())
-end
-
--- return module: install
-return install
diff --git a/xmake/core/base/makefile.lua b/xmake/core/base/makefile.lua
deleted file mode 100644
index d5093d0a9..000000000
--- a/xmake/core/base/makefile.lua
+++ /dev/null
@@ -1,417 +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 makefile.lua
---
-
--- define module: makefile
-local makefile = makefile or {}
-
--- load modules
-local io = require("base/io")
-local os = require("base/os")
-local rule = require("base/rule")
-local path = require("base/path")
-local utils = require("base/utils")
-local config = require("base/config")
-local project = require("base/project")
-local linker = require("base/linker")
-local compiler = require("base/compiler")
-local tools = require("tools/tools")
-local platform = require("base/platform")
-
--- make object for the *.[o|obj] source file
-function makefile._make_object_for_object(file, target, srcfile, objfile)
-
- -- get the source file type
- local filetype = path.extension(srcfile)
- if not filetype then return false end
-
- -- get the lower file type
- filetype = filetype:lower()
-
- -- not object file?
- if filetype ~= ".o" and filetype ~= ".obj" then return false end
-
- -- get mode
- local mode = config.get("mode")
- if mode then
- mode = "." .. mode
- else
- mode = ""
- end
-
- -- make command
- local cmd = string.format("xmake l cp %s %s", srcfile, objfile)
-
- -- make head
- file:write(string.format("%s:", objfile))
-
- -- make dependence
- file:write(string.format(" %s\n", srcfile))
-
- -- make body
- file:write(string.format("\t@echo inserting%s %s\n", mode, srcfile))
- file:write(string.format("\t@xmake l $(VERBOSE) verbose \"%s\"\n", cmd:encode()))
- file:write(string.format("\t@%s\n", cmd))
-
- -- make tail
- file:write("\n")
-
- -- ok
- return true
-end
-
--- make object for the *.[a|lib] source file
-function makefile._make_object_for_static(file, target, srcfile, objfile)
-
- -- get the source file type
- local filetype = path.extension(srcfile)
- if not filetype then return false end
-
- -- get the lower file type
- filetype = filetype:lower()
-
- -- not static file?
- if filetype ~= ".a" and filetype ~= ".lib" then return false end
-
- -- get mode
- local mode = config.get("mode")
- if mode then
- mode = "." .. mode
- else
- mode = ""
- end
-
- -- make command
- local cmd = string.format("xmake l -P %s -f %s dispatcher ex extract %s %s > %s 2>&1", xmake._PROJECT_DIR, xmake._PROJECT_FILE, srcfile:encode(), objfile:encode(), makefile._LOGFILE)
-
- -- make head
- file:write(string.format("%s:", objfile))
-
- -- make dependence
- file:write(string.format(" %s\n", srcfile))
-
- -- make body
- file:write(string.format("\t@echo inserting%s %s\n", mode, srcfile))
- file:write(string.format("\t@xmake l $(VERBOSE) verbose \"%s\"\n", cmd:encode()))
- file:write(string.format("\t@xmake l rmdir %s\n", path.directory(objfile)))
- file:write(string.format("\t@%s\n", cmd))
-
- -- make tail
- file:write("\n")
-
- -- ok
- return true
-end
-
--- make the object to the makefile
-function makefile._make_object(file, target, srcfile, objfile)
-
- -- check
- assert(file and target and srcfile and objfile)
-
- -- make object for the *.o/obj source file
- if makefile._make_object_for_object(file, target, srcfile, objfile) then
- return true
- elseif makefile._make_object_for_static(file, target, srcfile, objfile) then
- return true
- end
-
- -- get the compiler
- local c, errors = compiler.get(srcfile)
- if not c then
- -- error
- utils.error(errors)
- return false
- end
-
- -- get mode
- local mode = config.get("mode")
- if mode then
- mode = "." .. mode
- else
- mode = ""
- end
-
- -- get ccache
- local ccache = platform.tool("ccache")
-
- -- make command
- local cmd = compiler.make(c, target, srcfile, objfile, makefile._LOGFILE)
- if ccache then
- cmd = ccache:append(cmd, " ")
- end
-
- -- make head
- file:write(string.format("%s:", objfile))
-
- -- make dependence
- file:write(string.format(" %s\n", srcfile))
-
- -- make body
- file:write(string.format("\t@echo %scompiling%s %s\n", utils.ifelse(ccache, "ccache ", ""), mode, srcfile))
- file:write(string.format("\t@xmake l $(VERBOSE) verbose \"%s\"\n", cmd:encode()))
- file:write(string.format("\t@xmake l mkdir %s\n", path.directory(objfile)))
- file:write(string.format("\t@%s\n", cmd))
-
- -- make tail
- file:write("\n")
-
- -- ok
- return true
-end
-
--- make all objects of the given target to the makefile
-function makefile._make_objects(file, target, srcfiles, objfiles)
-
- -- check
- assert(file and target and srcfiles and objfiles)
-
- -- make all objects
- local i = 1
- for _, objfile in ipairs(objfiles) do
-
- -- make object
- if not makefile._make_object(file, target, srcfiles[i], objfile) then
- return false
- end
-
- -- next
- i = i + 1
- end
-
- -- ok
- return true
-end
-
--- make the given target to the makefile
-function makefile._make_target(file, name, target)
-
- -- check
- assert(file and name and target and target.kind)
-
- -- get source and object files
- local srcfiles = rule.sourcefiles(target)
- local objfiles = rule.objectfiles(name, target, srcfiles)
- assert(srcfiles and objfiles)
-
- -- get source and destinate header files
- local srcheaders, dstheaders = rule.headerfiles(target)
-
- -- get target file
- local targetfile = rule.targetfile(name, target)
- assert(targetfile)
-
- -- get the targets
- local targets = project.targets()
- assert(targets)
-
- -- get the linker from the given kind
- local l = linker.get(target.kind)
- if not l then
- utils.error("cannot get linker with kind: %s", target.kind)
- return false
- end
-
- -- make head
- file:write(string.format("%s: %s\n", name, targetfile))
- file:write(string.format("%s:", targetfile))
-
- -- make dependence for the dependent targets
- if target.deps then
-
- -- get all dependent target
- local deps = utils.wrap(target.deps)
- for _, dep in ipairs(deps) do
-
- -- the dependent target
- local deptarget = targets[dep]
- if not deptarget then
- utils.error("the dependent target: %s is invalid!", dep)
- return false
- end
-
- -- get the dependent target file
- local depfile = rule.targetfile(dep, deptarget)
- assert(depfile)
-
- -- add dependence
- file:write(" " .. depfile)
- end
- end
-
- -- make dependence for objects
- for _, objfile in ipairs(objfiles) do
- file:write(" " .. objfile)
- end
-
- -- make dependence end
- file:write("\n")
-
- -- get mode
- local mode = config.get("mode")
- if mode then
- mode = "." .. mode
- else
- mode = ""
- end
-
- -- make the command
- local cmd = linker.make(l, target, srcfiles, objfiles, targetfile, makefile._LOGFILE)
-
- -- the verbose
- local verbose = cmd:encode()
- -- too long?
- if verbose and #verbose > 256 then
- verbose = linker.make(l, target, srcfiles, {rule.filename("*", "object")}, targetfile)
- verbose = verbose:encode()
- end
-
- -- make body
- file:write(string.format("\t@echo linking%s %s\n", mode, path.filename(targetfile)))
- file:write(string.format("\t@xmake l $(VERBOSE) verbose \"%s\"\n", verbose))
- file:write(string.format("\t@xmake l mkdir %s\n", path.directory(targetfile)))
- file:write(string.format("\t@%s\n", cmd))
- if srcheaders and dstheaders then
- local i = 1
- for _, srcheader in ipairs(srcheaders) do
- local dstheader = dstheaders[i]
- if dstheader then
- file:write(string.format("\t@xmake l cp %s %s\n", srcheader, dstheader))
- end
- i = i + 1
- end
- end
-
- -- make tail
- file:write("\n")
-
- -- make objects for this target
- return makefile._make_objects(file, target, srcfiles, objfiles)
-end
-
--- make all targets to the makefile
-function makefile._make_targets(file)
-
- -- check
- assert(file)
-
- -- get all project targets
- local targets = project.targets()
- if not targets then
- -- error
- utils.error("not found target in this project!")
- return false
- end
-
- -- make all first
- local all = ""
- for name, _ in pairs(targets) do
- -- append the target name to all
- all = all .. " " .. name
- end
- file:write(string.format("all: %s\n\n", all))
- file:write(string.format(".PHONY: all %s\n\n", all))
-
- -- make it for all targets
- for name, target in pairs(targets) do
- -- make target
- if not makefile._make_target(file, name, target) then
- -- error
- utils.error("failed to make target %s to makefile!", name)
- return false
- end
-
- -- append the target name to all
- all = all .. " " .. name
- end
-
- -- ok
- return true
-end
-
--- make makefile in the build directory
-function makefile.make()
-
- -- get the build directory
- local buildir = config.get("buildir")
- assert(buildir)
-
- -- init the log file
- local logfile = rule.logfile()
- if logfile and os.isfile(logfile) then
- os.rmfile(logfile)
- end
-
- -- save the log file
- makefile._LOGFILE = logfile
- assert(logfile)
-
- -- open the makefile
- local path = rule.makefile()
- local file = io.openmk(path)
- if not file then
- -- error
- utils.error("open %s failed!", path)
- return false
- end
-
- -- make all targets to the makefile
- if not makefile._make_targets(file) then
-
- -- error
- utils.error("save %s failed!", path)
-
- -- close the makefile
- file:close()
-
- -- remove the makefile
- os.rm(path)
-
- -- failed
- return false
- end
-
- -- close the makefile
- file:close()
-
- -- ok
- return true
-end
-
--- build target
-function makefile.build(target)
-
- -- check
- assert(target and type(target) == "string")
-
- -- load make
- local make = tools.get("make")
- if not make then
- utils.error("not found the make command!")
- return false
- end
-
- -- done make
- return make:main(rule.makefile(), target)
-end
-
--- return module: makefile
-return makefile
diff --git a/xmake/core/base/package.lua b/xmake/core/base/package.lua
deleted file mode 100644
index a1c7f5f81..000000000
--- a/xmake/core/base/package.lua
+++ /dev/null
@@ -1,311 +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 io = require("base/io")
-local rule = require("base/rule")
-local path = require("base/path")
-local utils = require("base/utils")
-local config = require("base/config")
-local sandbox = require("base/sandbox")
-local platform = require("base/platform")
-
--- package target for the library file
-function package._done_library(target)
-
- -- check
- assert(target and target.name and target.archs)
-
- -- the output directory
- local outputdir = target.outputdir
- assert(outputdir)
-
- -- the plat and mode
- local plat = config.get("plat")
- local mode = config.get("mode")
- assert(plat and mode)
-
- -- package it
- for arch, info in pairs(target.archs) do
-
- -- check
- assert(info.targetdir and info.targetfile)
-
- -- copy the library file to the output directory
- local ok, errors = os.cp(string.format("%s/%s", info.targetdir, info.targetfile), string.format("%s/%s.pkg/lib/%s/%s/%s/%s", outputdir, target.name, mode, plat, arch, path.filename(info.targetfile)))
- if not ok then
- utils.error(errors)
- return -1
- 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.pkg/inc/%s/%s", outputdir, target.name, plat, path.filename(info.config_h)))
- if not ok then
- utils.error(errors)
- return -1
- end
- end
- end
-
- -- copy headers
- if target.headers then
- local srcheaders, dstheaders = rule.headerfiles(target, string.format("%s/%s.pkg/inc", outputdir, target.name))
- 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
- end
-
- -- make xmake.lua
- local file = io.open(string.format("%s/%s.pkg/xmake.lua", outputdir, target.name), "w")
- if file then
-
- -- the xmake.lua template content
- local template = [[
--- add [targetname] package
-option("[targetname]")
-
- -- show menu
- set_option_showmenu(true)
-
- -- set category
- set_option_category("package")
-
- -- set description
- set_option_description("The [targetname] package")
-
- -- set language: c99, c++11
- set_option_languages("c99", "cxx11")
-
- -- add defines to config.h if checking ok
- add_option_defines_h_if_ok("$(prefix)_PACKAGE_HAVE_[TARGETNAME]")
-
- -- add links for checking
- add_option_links("[targetname]")
-
- -- add link directories
- add_option_linkdirs("lib/$(mode)/$(plat)/$(arch)")
-
- -- add c includes for checking
- add_option_cincludes("[targetname]/[targetname].h")
-
- -- add include directories
- add_option_includedirs("inc/$(plat)", "inc")
-]]
-
- -- save file
- file:write((template:gsub("%[targetname%]", target.name):gsub("%[TARGETNAME%]", target.name:upper())))
-
- -- exit file
- file:close()
- end
-
- -- ok
- return 1
-end
-
--- package target for the binary file
-function package._done_binary(target)
-
- -- check
- assert(target and target.archs)
-
- -- the output directory
- local outputdir = target.outputdir
- assert(outputdir)
-
- -- the count of architectures
- local count = 0
- for _, _ in pairs(target.archs) do count = count + 1 end
-
- -- package it
- local ok = nil
- local errors = nil
- for arch, info in pairs(target.archs) do
-
- -- check
- assert(info.targetdir and info.targetfile)
-
- -- copy the binary file to the output directory
- if count == 1 then
- ok, errors = os.cp(string.format("%s/%s", info.targetdir, info.targetfile), string.format("%s/%s", outputdir, path.filename(info.targetfile)))
- else
- ok, errors = os.cp(string.format("%s/%s", info.targetdir, info.targetfile), string.format("%s/%s", outputdir, rule.filename(path.basename(info.targetfile) .. "_" .. arch, "binary")))
- end
-
- -- ok?
- if not ok then
- utils.error(errors)
- return -1
- end
- end
-
- -- ok
- return 1
-end
-
--- package target from the default script
-function package._done_from_default(target)
-
- -- check
- assert(target.kind)
-
- -- the package scripts
- local packagescripts =
- {
- static = package._done_library
- , shared = package._done_library
- , binary = package._done_binary
- }
-
- -- package it
- local packagescript = packagescripts[target.kind]
- if packagescript then return packagescript(target) end
-
- -- continue
- return 0
-end
-
--- package target from the project script
-function package._done_from_project(target)
-
- -- check
- assert(target)
-
- -- no script? continue
- if target.packagescript == nil then
- return 0
- end
-
- -- get script
- local script = target.packagescript
- target.packagescript = nil
-
- -- package it using the project script first
- local ok, results = sandbox.load(script, target)
- if not ok then
- utils.error(results)
- return -1
- end
-
- -- ok?
- return results
-end
-
--- package target from the platform script
-function package._done_from_platform(target)
-
- -- check
- assert(target)
-
- -- no script? continue
- local scriptfile = path.join(platform.directory(), "package.lua")
- if not os.isfile(scriptfile) then
- return 0
- end
-
- -- the platform package script file
- local ok, results = sandbox.load(scriptfile, target)
- if not ok then
- utils.error(results)
- return -1
- end
-
- -- ok?
- return results
-end
-
--- get the configure file
-function package._file()
-
- -- get it
- return config.directory() .. "/package.conf"
-end
-
--- package target from the given target configure
-function package._done(target)
-
- -- check
- assert(target)
-
- -- package it from the project script
- local ok = package._done_from_project(target)
- if ok ~= 0 then return utils.ifelse(ok == 1, true, false) end
-
- -- package it from the platform script
- local ok = package._done_from_platform(target)
- if ok ~= 0 then return utils.ifelse(ok == 1, true, false) end
-
- -- package it from the default script
- local ok = package._done_from_default(target)
- if ok ~= 0 then return utils.ifelse(ok == 1, true, false) end
-
- -- ok
- return true
-end
-
--- done package from the configure
-function package.done(configs)
-
- -- check
- assert(configs)
-
- -- package targets
- for _, target in pairs(configs) do
-
- -- package it
- if not package._done(target) then
- -- errors
- utils.error("package %s failed!", target.name)
- return false
- end
-
- end
-
- -- save to the configure file
- return io.save(package._file(), configs)
-end
-
--- load the package configure
-function package.load()
-
- -- load it
- return io.load(package._file())
-end
-
--- return module: package
-return package
diff --git a/xmake/core/base/rule.lua b/xmake/core/base/rule.lua
deleted file mode 100644
index 0c515b215..000000000
--- a/xmake/core/base/rule.lua
+++ /dev/null
@@ -1,300 +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 rule.lua
---
-
--- define module: rule
-local rule = rule or {}
-
--- load modules
-local os = require("base/os")
-local path = require("base/path")
-local table = require("base/table")
-local utils = require("base/utils")
-local config = require("base/config")
-local platform = require("base/platform")
-
--- get the building log file path
-function rule.logfile()
-
- -- the logdir
- local logdir = config.get("buildir") or os.tmpdir()
- assert(logdir)
-
- -- get it
- return path.translate(logdir .. "/.build.log")
-end
-
--- get the filename from the given name and kind
-function rule.filename(name, kind)
-
- -- check
- assert(name and kind)
-
- -- get format
- local format = platform.format(kind) or {"", ""}
-
- -- make it
- return format[1] .. name .. format[2]
-end
-
--- get the makefile path
-function rule.makefile()
-
- -- get the build directory
- local buildir = config.get("buildir")
- assert(buildir)
-
- -- get it
- return path.translate(buildir .. "/makefile")
-end
-
--- get configure file for the given target
-function rule.config_h(target)
-
- -- get the target configure file
- local config_h = target.config_h
- if config_h then
- -- translate file path
- if not path.is_absolute(config_h) then
- config_h = path.absolute(config_h, xmake._PROJECT_DIR)
- else
- config_h = path.translate(config_h)
- end
- end
-
- -- ok?
- return config_h
-end
-
--- get the temporary backup directory for package
-function rule.backupdir(target_name, arch)
-
- -- the temporary directory
- local tmpdir = os.tmpdir()
- assert(tmpdir)
-
- -- the project name
- local project_name = path.basename(xmake._PROJECT_DIR)
- assert(project_name)
-
- -- make it
- return string.format("%s/.xmake/%s/pkgfiles/%s/%s", tmpdir, project_name, target_name, arch)
-end
-
--- get target file for the given target
-function rule.targetfile(target_name, target, buildir)
-
- -- check
- assert(target_name and target and target.kind)
-
- -- the target directory
- local targetdir = target.targetdir or buildir or config.get("buildir")
- assert(targetdir and type(targetdir) == "string")
-
- -- the target file name
- local filename = rule.filename(target_name, target.kind)
- assert(filename)
-
- -- make the target file path
- return targetdir .. "/" .. filename
-end
-
--- get object files for the given source files
-function rule.objectdir(target_name, target, buildir)
-
- -- check
- assert(target_name and target)
-
- -- the object directory
- local objectdir = target.objectdir
- if not objectdir then
-
- -- the build directory
- if not buildir then
- buildir = config.get("buildir")
- end
- assert(buildir)
-
- -- make the default object directory
- objectdir = buildir .. "/.objs"
- end
-
- -- ok?
- return objectdir
-end
-
--- get object files for the given source files
-function rule.objectfiles(target_name, target, sourcefiles, buildir)
-
- -- check
- assert(target_name and target and sourcefiles)
-
- -- the object directory
- local objectdir = rule.objectdir(target_name, target, buildir)
- assert(objectdir and type(objectdir) == "string")
-
- -- make object files
- local i = 1
- local objectfiles = {}
- for _, sourcefile in ipairs(sourcefiles) do
-
- -- translate: [lib]xxx*.[a|lib] => xxx/*.[o|obj] object file
- sourcefile = sourcefile:gsub(rule.filename("([%w_]+)", "static"):gsub("%.", "%%.") .. "$", "%1/*")
-
- -- make object file
- local objectfile = string.format("%s/%s/%s/%s", objectdir, target_name, path.directory(sourcefile), rule.filename(path.basename(sourcefile), "object"))
-
- -- translate path
- --
- -- .e.g
- --
- -- src/xxx.c
- -- project/xmake.lua
- -- build/.objs
- --
- -- objectfile: project/build/.objs/xxxx/../../xxx.c will be out of range for objectdir
- --
- -- we need replace '..' to '__' in this case
- --
- objectfile = (path.translate(objectfile):gsub("%.%.", "__"))
-
- -- save it
- objectfiles[i] = objectfile
- i = i + 1
-
- end
-
- -- ok?
- return objectfiles
-end
-
--- get the source files from the given target
-function rule.sourcefiles(target)
-
- -- check
- assert(target)
-
- -- no files?
- if not target.files then
- return {}
- end
-
- -- wrap files first
- local targetfiles = utils.wrap(target.files)
-
- -- match files
- local i = 1
- local sourcefiles = {}
- for _, targetfile in ipairs(targetfiles) do
-
- -- normalize *.[o|obj] filename
- targetfile = targetfile:gsub("([%w%*]+)%.obj|", rule.filename("%1|", "object"))
- targetfile = targetfile:gsub("([%w%*]+)%.obj$", rule.filename("%1", "object"))
- targetfile = targetfile:gsub("([%w%*]+)%.o|", rule.filename("%1|", "object"))
- targetfile = targetfile:gsub("([%w%*]+)%.o$", rule.filename("%1", "object"))
-
- -- normalize [lib]*.[a|lib] filename
- targetfile = targetfile:gsub("([%w%*]+)%.lib|", rule.filename("%1|", "static"))
- targetfile = targetfile:gsub("([%w%*]+)%.lib$", rule.filename("%1", "static"))
- targetfile = targetfile:gsub("lib([%w%*]+)%.a|", rule.filename("%1|", "static"))
- targetfile = targetfile:gsub("lib([%w%*]+)%.a$", rule.filename("%1", "static"))
-
- -- match source files
- local files = os.match(targetfile)
- if #files == 0 then
- utils.warning("cannot match add_files(\"%s\")", targetfile)
- end
-
- -- process source files
- for _, file in ipairs(files) do
-
- -- convert to the relative path
- if path.is_absolute(file) then
- file = path.relative(file, xmake._PROJECT_DIR)
- end
-
- -- save it
- sourcefiles[i] = file
- i = i + 1
-
- end
- end
-
- -- remove repeat files
- sourcefiles = utils.unique(sourcefiles)
-
- -- ok?
- return sourcefiles
-end
-
--- get the header files from the given target
-function rule.headerfiles(target, headerdir)
-
- -- check
- assert(target)
-
- -- no headers?
- local headers = target.headers
- if not headers then return end
-
- -- get the headerdir
- if not headerdir then headerdir = target.headerdir or config.get("buildir") end
- assert(headerdir)
-
- -- get the source pathes and destinate pathes
- local srcheaders = {}
- local dstheaders = {}
- for _, header in ipairs(utils.wrap(headers)) do
-
- -- get the root directory
- local rootdir = header:gsub("%(.*%)", ""):gsub("|.*$", "")
-
- -- remove '(' and ')'
- local srcpathes = header:gsub("[%(%)]", "")
- if srcpathes then
-
- -- get the source pathes
- srcpathes = os.match(srcpathes)
- if srcpathes then
-
- -- add the source headers
- table.join2(srcheaders, srcpathes)
-
- -- add the destinate headers
- for _, srcpath in ipairs(srcpathes) do
-
- -- the header
- local dstheader = path.absolute(path.relative(srcpath, rootdir), headerdir)
- assert(dstheader)
-
- -- add it
- table.insert(dstheaders, dstheader)
- end
- end
- end
- end
-
- -- ok?
- return srcheaders, dstheaders
-end
-
--- return module: rule
-return rule
diff --git a/xmake/core/base/main.lua b/xmake/core/main.lua
index 560d14525..560d14525 100644
--- a/xmake/core/base/main.lua
+++ b/xmake/core/main.lua
diff --git a/xmake/core/base/compiler.lua b/xmake/core/platform/compiler.lua
index b5773827d..7196abd6a 100644
--- a/xmake/core/base/compiler.lua
+++ b/xmake/core/platform/compiler.lua
@@ -32,7 +32,7 @@ local table = require("base/table")
local option = require("base/option")
local string = require("base/string")
local config = require("base/config")
-local tools = require("tools/tools")
+local tools = require("platform/tool")
local platform = require("base/platform")
-- map gcc flag to the given compiler flag
diff --git a/xmake/core/base/linker.lua b/xmake/core/platform/linker.lua
index 4169c5cfe..b245ee767 100644
--- a/xmake/core/base/linker.lua
+++ b/xmake/core/platform/linker.lua
@@ -30,7 +30,7 @@ local string = require("base/string")
local option = require("base/option")
local config = require("base/config")
local compiler = require("base/compiler")
-local tools = require("tools/tools")
+local tools = require("platform/tool")
local platform = require("base/platform")
-- map gcc flag to the given linker flag
diff --git a/xmake/core/base/platform.lua b/xmake/core/platform/platform.lua
index 6a4481a09..6a4481a09 100644
--- a/xmake/core/base/platform.lua
+++ b/xmake/core/platform/platform.lua
diff --git a/xmake/core/platforms/android/android.lua b/xmake/core/platform/platforms/android/android.lua
index 317105fe3..317105fe3 100644
--- a/xmake/core/platforms/android/android.lua
+++ b/xmake/core/platform/platforms/android/android.lua
diff --git a/xmake/core/platforms/android/prober.lua b/xmake/core/platform/platforms/android/prober.lua
index 76ae1fa23..ccfd58ba6 100644
--- a/xmake/core/platforms/android/prober.lua
+++ b/xmake/core/platform/platforms/android/prober.lua
@@ -25,7 +25,7 @@ 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 tool = require("platform/tool")
local config = require("base/config")
local global = require("base/global")
@@ -108,7 +108,7 @@ function prober._probe_make(configs)
if make then return true end
-- probe the make path
- make = tools.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
+ make = tool.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
-- probe ok? update it
if make then configs.set("make", make) end
@@ -134,7 +134,7 @@ function prober._probe_ccache(configs)
end
-- probe the ccache path
- local ccache_path = tools.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
+ local ccache_path = tool.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
-- probe ok? update it
if ccache_path then
@@ -164,7 +164,7 @@ function prober._probe_toolpath(configs, kind, cross, name, description)
local toolpath = nil
local toolchains = configs.get("toolchains")
if toolchains then
- toolpath = tools.probe(cross .. (configs.get(kind) or name), toolchains)
+ toolpath = tool.probe(cross .. (configs.get(kind) or name), toolchains)
end
-- attempt to get it directly from the configure
@@ -188,7 +188,7 @@ function prober._probe_toolpath(configs, kind, cross, name, description)
-- probe the tool path
if toolchains then
for _, filepath in ipairs(toolchains) do
- toolpath = tools.probe(cross .. name, path.directory(filepath))
+ toolpath = tool.probe(cross .. name, path.directory(filepath))
if toolpath then break end
end
end
diff --git a/xmake/core/platforms/iphoneos/iphoneos.lua b/xmake/core/platform/platforms/iphoneos/iphoneos.lua
index 720ac90e2..720ac90e2 100644
--- a/xmake/core/platforms/iphoneos/iphoneos.lua
+++ b/xmake/core/platform/platforms/iphoneos/iphoneos.lua
diff --git a/xmake/core/platforms/iphoneos/package.lua b/xmake/core/platform/platforms/iphoneos/package.lua
index c155b18f8..c155b18f8 100644
--- a/xmake/core/platforms/iphoneos/package.lua
+++ b/xmake/core/platform/platforms/iphoneos/package.lua
diff --git a/xmake/core/platforms/iphoneos/prober.lua b/xmake/core/platform/platforms/iphoneos/prober.lua
index 66e281876..519d3abc1 100644
--- a/xmake/core/platforms/iphoneos/prober.lua
+++ b/xmake/core/platform/platforms/iphoneos/prober.lua
@@ -25,7 +25,7 @@ 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 tool = require("platform/tool")
local config = require("base/config")
local global = require("base/global")
@@ -167,7 +167,7 @@ function prober._probe_make(configs)
if make then return true end
-- probe the make path
- make = tools.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
+ make = tool.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
-- probe ok? update it
if make then configs.set("make", make) end
@@ -193,7 +193,7 @@ function prober._probe_ccache(configs)
end
-- probe the ccache path
- local ccache_path = tools.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
+ local ccache_path = tool.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
-- probe ok? update it
if ccache_path then
@@ -226,7 +226,7 @@ function prober._probe_toolpath(configs, kind, cross, names, description)
-- attempt to get it from the given cross toolchains
if toolchains then
- toolpath = tools.probe(cross .. (configs.get(kind) or name), toolchains)
+ toolpath = tool.probe(cross .. (configs.get(kind) or name), toolchains)
end
-- attempt to get it directly from the configure
@@ -236,7 +236,7 @@ function prober._probe_toolpath(configs, kind, cross, names, description)
-- attempt to run it directly
if not toolpath then
- toolpath = tools.probe(cross .. name)
+ toolpath = tool.probe(cross .. name)
end
-- probe ok?
diff --git a/xmake/core/platforms/iphonesimulator/iphonesimulator.lua b/xmake/core/platform/platforms/iphonesimulator/iphonesimulator.lua
index 1e8bb5eaa..1e8bb5eaa 100644
--- a/xmake/core/platforms/iphonesimulator/iphonesimulator.lua
+++ b/xmake/core/platform/platforms/iphonesimulator/iphonesimulator.lua
diff --git a/xmake/core/platforms/iphonesimulator/prober.lua b/xmake/core/platform/platforms/iphonesimulator/prober.lua
index 334512759..06ecd11f1 100644
--- a/xmake/core/platforms/iphonesimulator/prober.lua
+++ b/xmake/core/platform/platforms/iphonesimulator/prober.lua
@@ -25,7 +25,7 @@ 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 tool = require("platform/tool")
local config = require("base/config")
local global = require("base/global")
@@ -167,7 +167,7 @@ function prober._probe_make(configs)
if make then return true end
-- probe the make path
- make = tools.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
+ make = tool.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
-- probe ok? update it
if make then configs.set("make", make) end
@@ -193,7 +193,7 @@ function prober._probe_ccache(configs)
end
-- probe the ccache path
- local ccache_path = tools.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
+ local ccache_path = tool.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
-- probe ok? update it
if ccache_path then
@@ -226,7 +226,7 @@ function prober._probe_toolpath(configs, kind, cross, names, description)
-- attempt to get it from the given cross toolchains
if toolchains then
- toolpath = tools.probe(cross .. (configs.get(kind) or name), toolchains)
+ toolpath = tool.probe(cross .. (configs.get(kind) or name), toolchains)
end
-- attempt to get it directly from the configure
@@ -236,7 +236,7 @@ function prober._probe_toolpath(configs, kind, cross, names, description)
-- attempt to run it directly
if not toolpath then
- toolpath = tools.probe(cross .. name)
+ toolpath = tool.probe(cross .. name)
end
-- probe ok?
diff --git a/xmake/core/platforms/linux/install.lua b/xmake/core/platform/platforms/linux/install.lua
index 2aaa2d401..2aaa2d401 100644
--- a/xmake/core/platforms/linux/install.lua
+++ b/xmake/core/platform/platforms/linux/install.lua
diff --git a/xmake/core/platforms/linux/linux.lua b/xmake/core/platform/platforms/linux/linux.lua
index 92a61953d..92a61953d 100644
--- a/xmake/core/platforms/linux/linux.lua
+++ b/xmake/core/platform/platforms/linux/linux.lua
diff --git a/xmake/core/platforms/linux/prober.lua b/xmake/core/platform/platforms/linux/prober.lua
index 63438b8ad..b7db919ef 100644
--- a/xmake/core/platforms/linux/prober.lua
+++ b/xmake/core/platform/platforms/linux/prober.lua
@@ -25,7 +25,7 @@ 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 tool = require("platform/tool")
local config = require("base/config")
local global = require("base/global")
@@ -63,7 +63,7 @@ function prober._probe_make(configs)
if make then return true end
-- probe the make path
- make = tools.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
+ make = tool.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
-- probe ok? update it
if make then configs.set("make", make) end
@@ -89,7 +89,7 @@ function prober._probe_ccache(configs)
end
-- probe the ccache path
- local ccache_path = tools.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
+ local ccache_path = tool.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
-- probe ok? update it
if ccache_path then
@@ -122,7 +122,7 @@ function prober._probe_toolpath(configs, kind, cross, names, description)
-- attempt to get it from the given cross toolchains
if toolchains then
- toolpath = tools.probe(cross .. (configs.get(kind) or name), toolchains)
+ toolpath = tool.probe(cross .. (configs.get(kind) or name), toolchains)
end
-- attempt to get it directly from the configure
@@ -132,7 +132,7 @@ function prober._probe_toolpath(configs, kind, cross, names, description)
-- attempt to run it directly
if not toolpath then
- toolpath = tools.probe(cross .. name)
+ toolpath = tool.probe(cross .. name)
end
-- probe ok?
diff --git a/xmake/core/platforms/linux/uninstall.lua b/xmake/core/platform/platforms/linux/uninstall.lua
index 2de89ac8e..2de89ac8e 100644
--- a/xmake/core/platforms/linux/uninstall.lua
+++ b/xmake/core/platform/platforms/linux/uninstall.lua
diff --git a/xmake/core/platforms/macosx/install.lua b/xmake/core/platform/platforms/macosx/install.lua
index 2aaa2d401..2aaa2d401 100644
--- a/xmake/core/platforms/macosx/install.lua
+++ b/xmake/core/platform/platforms/macosx/install.lua
diff --git a/xmake/core/platforms/macosx/macosx.lua b/xmake/core/platform/platforms/macosx/macosx.lua
index dfc011418..dfc011418 100644
--- a/xmake/core/platforms/macosx/macosx.lua
+++ b/xmake/core/platform/platforms/macosx/macosx.lua
diff --git a/xmake/core/platforms/macosx/prober.lua b/xmake/core/platform/platforms/macosx/prober.lua
index 57d0f6c14..a1f1e0a0c 100644
--- a/xmake/core/platforms/macosx/prober.lua
+++ b/xmake/core/platform/platforms/macosx/prober.lua
@@ -25,7 +25,7 @@ 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 tool = require("platform/tool")
local config = require("base/config")
local global = require("base/global")
@@ -167,7 +167,7 @@ function prober._probe_make(configs)
if make then return true end
-- probe the make path
- make = tools.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
+ make = tool.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
-- probe ok? update it
if make then configs.set("make", make) end
@@ -193,7 +193,7 @@ function prober._probe_ccache(configs)
end
-- probe the ccache path
- local ccache_path = tools.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
+ local ccache_path = tool.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
-- probe ok? update it
if ccache_path then
@@ -226,7 +226,7 @@ function prober._probe_toolpath(configs, kind, cross, names, description)
-- attempt to get it from the given cross toolchains
if toolchains then
- toolpath = tools.probe(cross .. (configs.get(kind) or name), toolchains)
+ toolpath = tool.probe(cross .. (configs.get(kind) or name), toolchains)
end
-- attempt to get it directly from the configure
@@ -236,7 +236,7 @@ function prober._probe_toolpath(configs, kind, cross, names, description)
-- attempt to run it directly
if not toolpath then
- toolpath = tools.probe(cross .. name)
+ toolpath = tool.probe(cross .. name)
end
-- probe ok?
diff --git a/xmake/core/platforms/macosx/uninstall.lua b/xmake/core/platform/platforms/macosx/uninstall.lua
index 2de89ac8e..2de89ac8e 100644
--- a/xmake/core/platforms/macosx/uninstall.lua
+++ b/xmake/core/platform/platforms/macosx/uninstall.lua
diff --git a/xmake/core/platforms/mingw/mingw.lua b/xmake/core/platform/platforms/mingw/mingw.lua
index adb771a1f..adb771a1f 100644
--- a/xmake/core/platforms/mingw/mingw.lua
+++ b/xmake/core/platform/platforms/mingw/mingw.lua
diff --git a/xmake/core/platforms/mingw/prober.lua b/xmake/core/platform/platforms/mingw/prober.lua
index c7807d7c0..e5ebf5945 100644
--- a/xmake/core/platforms/mingw/prober.lua
+++ b/xmake/core/platform/platforms/mingw/prober.lua
@@ -25,7 +25,7 @@ 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 tool = require("platform/tool")
local config = require("base/config")
local global = require("base/global")
@@ -59,7 +59,7 @@ function prober._probe_make(configs)
if make then return true end
-- probe the make path
- make = tools.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
+ make = tool.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
-- probe ok? update it
if make then configs.set("make", make) end
@@ -85,7 +85,7 @@ function prober._probe_ccache(configs)
end
-- probe the ccache path
- local ccache_path = tools.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
+ local ccache_path = tool.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
-- probe ok? update it
if ccache_path then
@@ -118,7 +118,7 @@ function prober._probe_toolpath(configs, kind, cross, names, description)
-- attempt to get it from the given cross toolchains
if toolchains then
- toolpath = tools.probe(cross .. (configs.get(kind) or name), toolchains)
+ toolpath = tool.probe(cross .. (configs.get(kind) or name), toolchains)
end
-- attempt to get it directly from the configure
@@ -128,7 +128,7 @@ function prober._probe_toolpath(configs, kind, cross, names, description)
-- attempt to run it directly
if not toolpath then
- toolpath = tools.probe(cross .. name)
+ toolpath = tool.probe(cross .. name)
end
-- probe ok?
diff --git a/xmake/core/platforms/watchos/package.lua b/xmake/core/platform/platforms/watchos/package.lua
index c155b18f8..c155b18f8 100644
--- a/xmake/core/platforms/watchos/package.lua
+++ b/xmake/core/platform/platforms/watchos/package.lua
diff --git a/xmake/core/platforms/watchos/prober.lua b/xmake/core/platform/platforms/watchos/prober.lua
index e6033bb25..5c6ea542d 100644
--- a/xmake/core/platforms/watchos/prober.lua
+++ b/xmake/core/platform/platforms/watchos/prober.lua
@@ -25,7 +25,7 @@ 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 tool = require("platform/tool")
local config = require("base/config")
local global = require("base/global")
@@ -167,7 +167,7 @@ function prober._probe_make(configs)
if make then return true end
-- probe the make path
- make = tools.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
+ make = tool.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
-- probe ok? update it
if make then configs.set("make", make) end
@@ -193,7 +193,7 @@ function prober._probe_ccache(configs)
end
-- probe the ccache path
- local ccache_path = tools.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
+ local ccache_path = tool.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
-- probe ok? update it
if ccache_path then
@@ -226,7 +226,7 @@ function prober._probe_toolpath(configs, kind, cross, names, description)
-- attempt to get it from the given cross toolchains
if toolchains then
- toolpath = tools.probe(cross .. (configs.get(kind) or name), toolchains)
+ toolpath = tool.probe(cross .. (configs.get(kind) or name), toolchains)
end
-- attempt to get it directly from the configure
@@ -236,7 +236,7 @@ function prober._probe_toolpath(configs, kind, cross, names, description)
-- attempt to run it directly
if not toolpath then
- toolpath = tools.probe(cross .. name)
+ toolpath = tool.probe(cross .. name)
end
-- probe ok?
diff --git a/xmake/core/platforms/watchos/watchos.lua b/xmake/core/platform/platforms/watchos/watchos.lua
index 600de3b69..600de3b69 100644
--- a/xmake/core/platforms/watchos/watchos.lua
+++ b/xmake/core/platform/platforms/watchos/watchos.lua
diff --git a/xmake/core/platforms/watchsimulator/prober.lua b/xmake/core/platform/platforms/watchsimulator/prober.lua
index 84c15b8aa..81404150c 100644
--- a/xmake/core/platforms/watchsimulator/prober.lua
+++ b/xmake/core/platform/platforms/watchsimulator/prober.lua
@@ -25,7 +25,7 @@ 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 tool = require("platform/tool")
local config = require("base/config")
local global = require("base/global")
@@ -167,7 +167,7 @@ function prober._probe_make(configs)
if make then return true end
-- probe the make path
- make = tools.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
+ make = tool.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
-- probe ok? update it
if make then configs.set("make", make) end
@@ -193,7 +193,7 @@ function prober._probe_ccache(configs)
end
-- probe the ccache path
- local ccache_path = tools.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
+ local ccache_path = tool.probe("ccache", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"})
-- probe ok? update it
if ccache_path then
@@ -226,7 +226,7 @@ function prober._probe_toolpath(configs, kind, cross, names, description)
-- attempt to get it from the given cross toolchains
if toolchains then
- toolpath = tools.probe(cross .. (configs.get(kind) or name), toolchains)
+ toolpath = tool.probe(cross .. (configs.get(kind) or name), toolchains)
end
-- attempt to get it directly from the configure
@@ -236,7 +236,7 @@ function prober._probe_toolpath(configs, kind, cross, names, description)
-- attempt to run it directly
if not toolpath then
- toolpath = tools.probe(cross .. name)
+ toolpath = tool.probe(cross .. name)
end
-- probe ok?
diff --git a/xmake/core/platforms/watchsimulator/watchsimulator.lua b/xmake/core/platform/platforms/watchsimulator/watchsimulator.lua
index 19f44d3b8..19f44d3b8 100644
--- a/xmake/core/platforms/watchsimulator/watchsimulator.lua
+++ b/xmake/core/platform/platforms/watchsimulator/watchsimulator.lua
diff --git a/xmake/core/platforms/windows/prober.lua b/xmake/core/platform/platforms/windows/prober.lua
index 165b102f2..7acc945f2 100644
--- a/xmake/core/platforms/windows/prober.lua
+++ b/xmake/core/platform/platforms/windows/prober.lua
@@ -28,7 +28,7 @@ local utils = require("base/utils")
local string = require("base/string")
local config = require("base/config")
local global = require("base/global")
-local tools = require("tools/tools")
+local tool = require("platform/tool")
local platform = require("base/platform")
-- define module: prober
diff --git a/xmake/core/platforms/windows/tools/cl.lua b/xmake/core/platform/platforms/windows/tools/cl.lua
index 51184dc1a..51184dc1a 100644
--- a/xmake/core/platforms/windows/tools/cl.lua
+++ b/xmake/core/platform/platforms/windows/tools/cl.lua
diff --git a/xmake/core/platforms/windows/tools/lib.lua b/xmake/core/platform/platforms/windows/tools/lib.lua
index 3ff37829d..3ff37829d 100644
--- a/xmake/core/platforms/windows/tools/lib.lua
+++ b/xmake/core/platform/platforms/windows/tools/lib.lua
diff --git a/xmake/core/platforms/windows/tools/link.lua b/xmake/core/platform/platforms/windows/tools/link.lua
index b8913a42f..b8913a42f 100644
--- a/xmake/core/platforms/windows/tools/link.lua
+++ b/xmake/core/platform/platforms/windows/tools/link.lua
diff --git a/xmake/core/platforms/windows/tools/ml.lua b/xmake/core/platform/platforms/windows/tools/ml.lua
index 75db5194b..75db5194b 100644
--- a/xmake/core/platforms/windows/tools/ml.lua
+++ b/xmake/core/platform/platforms/windows/tools/ml.lua
diff --git a/xmake/core/platforms/windows/tools/nmake.lua b/xmake/core/platform/platforms/windows/tools/nmake.lua
index 68f04a31a..68f04a31a 100644
--- a/xmake/core/platforms/windows/tools/nmake.lua
+++ b/xmake/core/platform/platforms/windows/tools/nmake.lua
diff --git a/xmake/core/platforms/windows/windows.lua b/xmake/core/platform/platforms/windows/windows.lua
index 4b168c835..4b168c835 100644
--- a/xmake/core/platforms/windows/windows.lua
+++ b/xmake/core/platform/platforms/windows/windows.lua
diff --git a/xmake/core/tools/tools.lua b/xmake/core/platform/tool.lua
index 04e1f22f8..79c0d216d 100644
--- a/xmake/core/tools/tools.lua
+++ b/xmake/core/platform/tool.lua
@@ -17,11 +17,11 @@
-- Copyright (C) 2015 - 2016, ruki All rights reserved.
--
-- @author ruki
--- @file tools.lua
+-- @file tool.lua
--
--- define module: tools
-local tools = tools or {}
+-- define module: tool
+local tool = tool or {}
-- load modules
local os = require("base/os")
@@ -31,7 +31,7 @@ local string = require("base/string")
local platform = require("base/platform")
-- match the tool name
-function tools._match(name, toolname)
+function tool._match(name, toolname)
-- match full? ok
if name == toolname then return 100 end
@@ -50,7 +50,7 @@ function tools._match(name, toolname)
end
-- find tool from the given root directory and name
-function tools._find_from(root, name)
+function tool._find_from(root, name)
-- attempt to get it directly first
local filepath = string.format("%s/%s.lua", root, name)
@@ -71,10 +71,10 @@ function tools._find_from(root, name)
local toolname = path.basename(file)
-- found it?
- if toolname and toolname ~= "tools" then
+ if toolname and toolname ~= "tool" then
-- match score
- local score = tools._match(name, toolname:lower())
+ local score = tool._match(name, toolname:lower())
-- ok?
if score >= 100 then return file end
@@ -92,7 +92,7 @@ function tools._find_from(root, name)
end
-- probe it's absolute path if exists from the given tool name and root directory
-function tools._probe(root, name)
+function tool._probe(root, name)
-- check
assert(root and name)
@@ -108,7 +108,7 @@ function tools._probe(root, name)
end
-- find tool from the given name and directory (optional)
-function tools.find(name, root)
+function tool.find(name, root)
-- check
assert(name)
@@ -121,32 +121,32 @@ function tools.find(name, root)
assert(name)
-- only find it from this directory if the given directory exists
- if root then return tools._find_from(root, name) end
+ if root then return tool._find_from(root, name) end
-- attempt to find it from the current platform directory first
- if not filepath then filepath = tools._find_from(platform.directory() .. "/tools", name) end
+ if not filepath then filepath = tool._find_from(platform.directory() .. "/tool", name) end
-- attempt to find it from the script directory
- if not filepath then filepath = tools._find_from(xmake._CORE_DIR .. "/tools", name) end
+ if not filepath then filepath = tool._find_from(xmake._CORE_DIR .. "/tool", name) end
-- ok?
return filepath
end
-- load tool from the given name and directory (optional)
-function tools.load(name, root)
+function tool.load(name, root)
-- check
assert(name)
-- get it directly from cache dirst
- tools._TOOLS = tools._TOOLS or {}
- if tools._TOOLS[name] then
- return tools._TOOLS[name]
+ tool._TOOLS = tool._TOOLS or {}
+ if tool._TOOLS[name] then
+ return tool._TOOLS[name]
end
-- find the tool file path
- local toolpath = tools.find(name, root)
+ local toolpath = tool.find(name, root)
-- not exists?
if not toolpath or not os.isfile(toolpath) then
@@ -166,7 +166,7 @@ function tools.load(name, root)
end
-- save tool to the cache
- tools._TOOLS[name] = tool
+ tool._TOOLS[name] = tool
-- ok?
return tool
@@ -178,7 +178,7 @@ function tools.load(name, root)
end
-- get the given tool script from the given kind
-function tools.get(kind)
+function tool.get(kind)
-- get the tool name
local toolname = platform.tool(kind)
@@ -188,11 +188,11 @@ function tools.get(kind)
end
-- load it
- return tools.load(toolname)
+ return tool.load(toolname)
end
-- probe it's absolute path if exists from the given tool name
-function tools.probe(name, dirs)
+function tool.probe(name, dirs)
-- check
assert(name)
@@ -207,7 +207,7 @@ function tools.probe(name, dirs)
for _, dir in ipairs(utils.wrap(dirs)) do
-- probe it
- local toolpath = tools._probe(dir, name)
+ local toolpath = tool._probe(dir, name)
-- ok?
if toolpath and os.execute(string.format("%s > %s 2>&1", toolpath, xmake._NULDEV)) ~= 0x7f00 then
@@ -218,5 +218,5 @@ function tools.probe(name, dirs)
end
--- return module: tools
-return tools
+-- return module: tool
+return tool
diff --git a/xmake/core/tools/ar.lua b/xmake/core/platform/tools/ar.lua
index 7f019cd17..7f019cd17 100644
--- a/xmake/core/tools/ar.lua
+++ b/xmake/core/platform/tools/ar.lua
diff --git a/xmake/core/tools/cat.lua b/xmake/core/platform/tools/cat.lua
index 5eb14c88f..5eb14c88f 100644
--- a/xmake/core/tools/cat.lua
+++ b/xmake/core/platform/tools/cat.lua
diff --git a/xmake/core/tools/clang++.lua b/xmake/core/platform/tools/clang++.lua
index a71679e4b..a71679e4b 100644
--- a/xmake/core/tools/clang++.lua
+++ b/xmake/core/platform/tools/clang++.lua
diff --git a/xmake/core/tools/clang.lua b/xmake/core/platform/tools/clang.lua
index c4c8586f5..c4c8586f5 100644
--- a/xmake/core/tools/clang.lua
+++ b/xmake/core/platform/tools/clang.lua
diff --git a/xmake/core/tools/cp.lua b/xmake/core/platform/tools/cp.lua
index c2914c6c5..c2914c6c5 100644
--- a/xmake/core/tools/cp.lua
+++ b/xmake/core/platform/tools/cp.lua
diff --git a/xmake/core/tools/dispatcher.lua b/xmake/core/platform/tools/dispatcher.lua
index 231879512..32deb3f2d 100644
--- a/xmake/core/tools/dispatcher.lua
+++ b/xmake/core/platform/tools/dispatcher.lua
@@ -28,7 +28,7 @@ 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 tools = require("platform/tool")
-- the main function
--
diff --git a/xmake/core/tools/echo.lua b/xmake/core/platform/tools/echo.lua
index 9a858c765..9a858c765 100644
--- a/xmake/core/tools/echo.lua
+++ b/xmake/core/platform/tools/echo.lua
diff --git a/xmake/core/tools/g++.lua b/xmake/core/platform/tools/g++.lua
index d61e511eb..d61e511eb 100644
--- a/xmake/core/tools/g++.lua
+++ b/xmake/core/platform/tools/g++.lua
diff --git a/xmake/core/tools/gas-preprocessor.pl b/xmake/core/platform/tools/gas-preprocessor.pl
index 98dfe4ad9..98dfe4ad9 100755
--- a/xmake/core/tools/gas-preprocessor.pl
+++ b/xmake/core/platform/tools/gas-preprocessor.pl
diff --git a/xmake/core/tools/gcc.lua b/xmake/core/platform/tools/gcc.lua
index a27e41341..a27e41341 100644
--- a/xmake/core/tools/gcc.lua
+++ b/xmake/core/platform/tools/gcc.lua
diff --git a/xmake/core/tools/make.lua b/xmake/core/platform/tools/make.lua
index c6664fd69..c6664fd69 100644
--- a/xmake/core/tools/make.lua
+++ b/xmake/core/platform/tools/make.lua
diff --git a/xmake/core/tools/mkdir.lua b/xmake/core/platform/tools/mkdir.lua
index bf0983285..bf0983285 100644
--- a/xmake/core/tools/mkdir.lua
+++ b/xmake/core/platform/tools/mkdir.lua
diff --git a/xmake/core/tools/mv.lua b/xmake/core/platform/tools/mv.lua
index 41eae3cf1..41eae3cf1 100644
--- a/xmake/core/tools/mv.lua
+++ b/xmake/core/platform/tools/mv.lua
diff --git a/xmake/core/tools/rm.lua b/xmake/core/platform/tools/rm.lua
index 5db72c08e..5db72c08e 100644
--- a/xmake/core/tools/rm.lua
+++ b/xmake/core/platform/tools/rm.lua
diff --git a/xmake/core/tools/rmdir.lua b/xmake/core/platform/tools/rmdir.lua
index 9089453e3..9089453e3 100644
--- a/xmake/core/tools/rmdir.lua
+++ b/xmake/core/platform/tools/rmdir.lua
diff --git a/xmake/core/tools/swiftc.lua b/xmake/core/platform/tools/swiftc.lua
index 6317bde2d..6317bde2d 100644
--- a/xmake/core/tools/swiftc.lua
+++ b/xmake/core/platform/tools/swiftc.lua
diff --git a/xmake/core/tools/verbose.lua b/xmake/core/platform/tools/verbose.lua
index 2964ceb67..2964ceb67 100644
--- a/xmake/core/tools/verbose.lua
+++ b/xmake/core/platform/tools/verbose.lua
diff --git a/xmake/core/base/deprecated/project.lua b/xmake/core/project/deprecated/project.lua
index 58831b3fc..58831b3fc 100644
--- a/xmake/core/base/deprecated/project.lua
+++ b/xmake/core/project/deprecated/project.lua
diff --git a/xmake/core/base/project.lua b/xmake/core/project/project.lua
index 6e39d96b7..6e39d96b7 100644
--- a/xmake/core/base/project.lua
+++ b/xmake/core/project/project.lua
diff --git a/xmake/core/sandbox/import/core/global.lua b/xmake/core/sandbox/import/core/global.lua
deleted file mode 100644
index b4f6460df..000000000
--- a/xmake/core/sandbox/import/core/global.lua
+++ /dev/null
@@ -1,69 +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 global.lua
---
-
--- define module
-local sandbox_global = sandbox_global or {}
-
--- load modules
-local global = require("base/global")
-local raise = require("sandbox/raise")
-
--- get the configure
-function sandbox_global.get(name)
-
- -- get it
- return global.get(name)
-end
-
--- set the configure
-function sandbox_global.set(name, value)
-
- -- set it
- global.set(name, value)
-end
-
--- get the configure directory
-function sandbox_global.directory()
-
- -- get it
- local dir = global.directory()
- assert(dir)
-
- -- ok?
- return dir
-end
-
--- save the current configure
-function sandbox_global.save()
-
- -- save it
- local ok, errors = global.save()
- if not ok then
- raise("cannot save global configure, %s", errors)
- end
-
- -- ok
- return true
-end
-
--- return module
-return sandbox_global
diff --git a/xmake/core/sandbox/import/core/option.lua b/xmake/core/sandbox/import/core/option.lua
deleted file mode 100644
index d45363dbc..000000000
--- a/xmake/core/sandbox/import/core/option.lua
+++ /dev/null
@@ -1,37 +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 option.lua
---
-
--- define module
-local sandbox_option = sandbox_option or {}
-
--- load modules
-local option = require("base/option")
-
--- get the option
-function sandbox_option.get(name)
-
- -- get it
- return option.get(name)
-end
-
--- return module
-return sandbox_option
diff --git a/xmake/core/sandbox/import/core/platform.lua b/xmake/core/sandbox/import/core/platform.lua
deleted file mode 100644
index e6de93681..000000000
--- a/xmake/core/sandbox/import/core/platform.lua
+++ /dev/null
@@ -1,59 +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 platform.lua
---
-
--- define module
-local sandbox_platform = sandbox_platform or {}
-
--- load modules
-local platform = require("base/platform")
-
--- get the platform menu
-function sandbox_platform.menu(action)
-
- -- get it
- return platform.menu(action)
-end
-
--- get the all platforms
-function sandbox_platform.plats()
-
- -- get it
- local plats = platform.plats()
- assert(plats)
-
- -- ok
- return plats
-end
-
--- get the all architectures for the given platform
-function sandbox_platform.archs(plat)
-
- -- get it
- local archs = platform.archs(plat)
- assert(archs)
-
- -- ok
- return archs
-end
-
--- return module
-return sandbox_platform
diff --git a/xmake/core/sandbox/import/core/project.lua b/xmake/core/sandbox/import/core/project.lua
deleted file mode 100644
index 3d65b8768..000000000
--- a/xmake/core/sandbox/import/core/project.lua
+++ /dev/null
@@ -1,74 +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 project.lua
---
-
--- define module
-local sandbox_project = sandbox_project or {}
-
--- load modules
-local rule = require("base/rule")
-local config = require("base/config")
-local project = require("base/project")
-
--- get the build directory
-function sandbox_project.buildir()
-
- -- get it
- return config.get("buildir")
-end
-
--- get the project directory
-function sandbox_project.projectdir()
-
- -- get it
- return xmake._PROJECT_DIR
-end
-
--- get the current platform
-function sandbox_project.plat()
-
- -- get it
- return config.get("plat")
-end
-
--- get the current architecture
-function sandbox_project.arch()
-
- -- get it
- return config.get("arch")
-end
-
--- get the current mode
-function sandbox_project.mode()
-
- -- get it
- return config.get("mode")
-end
-
--- get the menu
-function sandbox_project.menu()
-
- -- get it
- return project.menu()
-end
-
--- return module
-return sandbox_project
diff --git a/xmake/core/sandbox/import/core/template.lua b/xmake/core/sandbox/import/core/template.lua
deleted file mode 100644
index 980e98a52..000000000
--- a/xmake/core/sandbox/import/core/template.lua
+++ /dev/null
@@ -1,52 +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 template.lua
---
-
--- define module
-local sandbox_template = sandbox_template or {}
-
--- load modules
-local template = require("base/template")
-
--- get all languages
-function sandbox_template.languages()
-
- -- get it
- local languages = template.languages()
- assert(languages)
-
- -- ok
- return languages
-end
-
--- load all templates from the given language
-function sandbox_template.templates(language)
-
- -- get it
- local templates = template.templates(language)
- assert(templates)
-
- -- ok
- return templates
-end
-
--- return module
-return sandbox_template
diff --git a/xmake/core/base/template.lua b/xmake/core/template/template.lua
index b80e38baf..b80e38baf 100644
--- a/xmake/core/base/template.lua
+++ b/xmake/core/template/template.lua