summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-03-04 10:31:12 +0800
committerruki <[email protected]>2016-03-04 10:31:12 +0800
commitae466964bd7404958782890a267e98bd104a43bd (patch)
treee9d779b1c8847072674552a90ffb3bf44fdcae7b
parentf4b82ec9289932937c21e00b0ff35bb4f3544e3b (diff)
restore platform and project menu
-rwxr-xr-xxmake/actions/config/xmake.lua46
-rwxr-xr-xxmake/actions/create/xmake.lua8
-rwxr-xr-xxmake/actions/global/xmake.lua14
-rwxr-xr-xxmake/actions/package/xmake.lua12
-rw-r--r--xmake/core/base/storage.lua72
-rw-r--r--xmake/core/platform/compiler.lua10
-rw-r--r--xmake/core/platform/linker.lua10
-rw-r--r--xmake/core/platform/platform.lua6
-rw-r--r--xmake/core/platform/platforms/android/android.lua2
-rw-r--r--xmake/core/platform/platforms/android/prober.lua4
-rw-r--r--xmake/core/platform/platforms/iphoneos/iphoneos.lua2
-rw-r--r--xmake/core/platform/platforms/iphoneos/package.lua4
-rw-r--r--xmake/core/platform/platforms/iphoneos/prober.lua4
-rw-r--r--xmake/core/platform/platforms/iphonesimulator/iphonesimulator.lua2
-rw-r--r--xmake/core/platform/platforms/iphonesimulator/prober.lua4
-rw-r--r--xmake/core/platform/platforms/linux/install.lua4
-rw-r--r--xmake/core/platform/platforms/linux/linux.lua2
-rw-r--r--xmake/core/platform/platforms/linux/prober.lua4
-rw-r--r--xmake/core/platform/platforms/linux/uninstall.lua4
-rw-r--r--xmake/core/platform/platforms/macosx/install.lua4
-rw-r--r--xmake/core/platform/platforms/macosx/macosx.lua2
-rw-r--r--xmake/core/platform/platforms/macosx/prober.lua4
-rw-r--r--xmake/core/platform/platforms/macosx/uninstall.lua4
-rw-r--r--xmake/core/platform/platforms/mingw/mingw.lua2
-rw-r--r--xmake/core/platform/platforms/mingw/prober.lua4
-rw-r--r--xmake/core/platform/platforms/watchos/package.lua4
-rw-r--r--xmake/core/platform/platforms/watchos/prober.lua4
-rw-r--r--xmake/core/platform/platforms/watchos/watchos.lua2
-rw-r--r--xmake/core/platform/platforms/watchsimulator/prober.lua4
-rw-r--r--xmake/core/platform/platforms/watchsimulator/watchsimulator.lua2
-rw-r--r--xmake/core/platform/platforms/windows/prober.lua6
-rw-r--r--xmake/core/platform/platforms/windows/tools/cl.lua4
-rw-r--r--xmake/core/platform/platforms/windows/tools/lib.lua4
-rw-r--r--xmake/core/platform/platforms/windows/tools/link.lua4
-rw-r--r--xmake/core/platform/platforms/windows/tools/ml.lua4
-rw-r--r--xmake/core/platform/platforms/windows/tools/nmake.lua4
-rw-r--r--xmake/core/platform/platforms/windows/windows.lua2
-rw-r--r--xmake/core/platform/tool.lua6
-rw-r--r--xmake/core/platform/tools/ar.lua2
-rw-r--r--xmake/core/platform/tools/gcc.lua4
-rw-r--r--xmake/core/platform/tools/swiftc.lua4
-rw-r--r--xmake/core/project/config.lua388
-rw-r--r--xmake/core/project/deprecated/project.lua6
-rw-r--r--xmake/core/project/global.lua239
-rw-r--r--xmake/core/project/project.lua12
-rw-r--r--xmake/core/project/rule.lua300
-rw-r--r--xmake/core/project/template.lua (renamed from xmake/core/template/template.lua)2
-rw-r--r--xmake/core/sandbox/modules/import/core/platform/menu.lua66
-rw-r--r--xmake/core/sandbox/modules/import/core/project/menu.lua39
-rw-r--r--xmake/core/sandbox/modules/import/core/project/template.lua52
50 files changed, 1205 insertions, 193 deletions
diff --git a/xmake/actions/config/xmake.lua b/xmake/actions/config/xmake.lua
index 0a507f70b..57ab7062a 100755
--- a/xmake/actions/config/xmake.lua
+++ b/xmake/actions/config/xmake.lua
@@ -46,17 +46,17 @@ 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 ()
- -- import platform
- import("core.platform")
+ -- import platform menu
+ import("core.platform.menu")
-- make description
local description = {}
- for i, plat in ipairs(platform.plats()) do
+ for i, plat in ipairs(menu.plats()) do
description[i] = " - " .. plat
end
@@ -68,14 +68,14 @@ task("config")
-- show the description of all architectures
, function ()
- -- import platform
- import("core.platform")
+ -- import platform menu
+ import("core.platform.menu")
-- make description
local description = {}
- for i, plat in ipairs(platform.plats()) do
+ for i, plat in ipairs(menu.plats()) do
description[i] = " - " .. plat .. ":"
- for _, arch in ipairs(platform.archs(plat)) do
+ for _, arch in ipairs(menu.archs(plat)) do
description[i] = description[i] .. " " .. arch
end
end
@@ -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" }
@@ -93,16 +93,16 @@ task("config")
, " - binary" }
, {nil, "host", "kv", "$(host)", "The current host environment." }
- -- show menu for project
---[[ , function ()
+ -- show project menu options
+ , function ()
- -- import platform
- import("core.project")
+ -- import project menu
+ import("core.project.menu")
- -- get menu for project
- return project.menu()
+ -- get project menu options
+ return menu.options()
end
-]]
+
, {}
, {nil, "make", "kv", "auto", "Set the make path." }
, {nil, "ccache", "kv", "auto", "Enable or disable the c/c++ compiler cache." }
@@ -141,16 +141,16 @@ task("config")
, {nil, "sh", "kv", nil, "The Shared Library Linker" }
, {nil, "shflags", "kv", nil, "The Shared Library Linker Flags" }
- -- show menu for platform
---[[ , function ()
+ -- show platform menu options
+ , function ()
- -- import platform
- import("core.platform")
+ -- import platform menu
+ import("core.platform.menu")
- -- get menu for platform
- return platform.menu("config")
+ -- get config menu options
+ return menu.options_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 40880c99a..b0c2bfddb 100755
--- a/xmake/actions/create/xmake.lua
+++ b/xmake/actions/create/xmake.lua
@@ -38,13 +38,13 @@ 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 ()
-- import template
- import("core.template")
+ import("core.project.template")
-- make description
local description = {}
@@ -61,7 +61,7 @@ task("create")
, function ()
-- import template
- import("core.template")
+ import("core.project.template")
-- make description
local description = {}
@@ -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 fa2023c58..7736a411b 100755
--- a/xmake/actions/global/xmake.lua
+++ b/xmake/actions/global/xmake.lua
@@ -54,16 +54,16 @@ task("global")
, {}
- -- show menu for platform
---[[ , function ()
+ -- show platform menu options
+ , function ()
- -- import platform
- import("core.platform")
+ -- import platform menu
+ import("core.platform.menu")
- -- get menu for platform
- return platform.menu("global")
+ -- get global menu options
+ return menu.options_global()
end
-]]
+
}
})
diff --git a/xmake/actions/package/xmake.lua b/xmake/actions/package/xmake.lua
index ccb878ceb..7bc4b59dc 100755
--- a/xmake/actions/package/xmake.lua
+++ b/xmake/actions/package/xmake.lua
@@ -40,20 +40,20 @@ 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
, function ()
- -- import platform
- import("core.platform")
+ -- import platform menu
+ import("core.platform.menu")
-- make description
local description = {}
- for i, plat in ipairs(platform.plats()) do
+ for i, plat in ipairs(menu.plats()) do
description[i] = " - " .. plat .. ":"
- for _, arch in ipairs(platform.archs(plat)) do
+ for _, arch in ipairs(menu.archs(plat)) do
description[i] = description[i] .. " " .. arch
end
end
@@ -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/base/storage.lua b/xmake/core/base/storage.lua
deleted file mode 100644
index 60eb1343a..000000000
--- a/xmake/core/base/storage.lua
+++ /dev/null
@@ -1,72 +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 storage.lua
---
-
--- define module
-local storage = storage or {}
-
--- load modules
-local os = require("base/os")
-local io = require("base/io")
-local path = require("base/path")
-local utils = require("base/utils")
-
--- get root directory from the given scope name
---
--- global: ~/.xmake
--- output: projectdir/output
--- project: projectdir/.xmake
--- temporary: tmpdir/.xmake
-function storage.rootdir(scopename)
-
- -- init root directories
- local rootdirs =
- {
- global = path.translate("~/.xmake")
- , output = path.join(xmake._PROJECT_DIR, "output")
- , project = path.join(xmake._PROJECT_DIR, ".xmake")
- , temporary = path.join(os.tmpdir(), ".xmake")
- }
- storage._ROOTDIRS = storage._ROOTDIRS or {}
-
- -- get root directory from the given scope name
- local rootdir = storage._ROOTDIRS[scopename] or rootdirs[scopename]
- if not rootdir then
- os.raise("unknown scope %s for storage!", scopename)
- end
-
- -- ok
- return rootdir
-end
-
--- register storage scope from the given root directory
-function storage.register(scopename, rootdir)
-
- -- check
- assert(scopename and rootdir)
-
- -- register it
- storage._ROOTDIRS = storage._ROOTDIRS or {}
- storage._ROOTDIRS[scopename] = rootdir
-end
-
--- return module
-return storage
diff --git a/xmake/core/platform/compiler.lua b/xmake/core/platform/compiler.lua
index 7196abd6a..04932dda2 100644
--- a/xmake/core/platform/compiler.lua
+++ b/xmake/core/platform/compiler.lua
@@ -26,14 +26,14 @@ local compiler = compiler or {}
-- load modules
local io = require("base/io")
local path = require("base/path")
-local rule = require("base/rule")
local utils = require("base/utils")
local table = require("base/table")
local option = require("base/option")
local string = require("base/string")
-local config = require("base/config")
-local tools = require("platform/tool")
-local platform = require("base/platform")
+local rule = require("project/rule")
+local config = require("project/config")
+local tool = require("platform/tool")
+local platform = require("platform/platform")
-- map gcc flag to the given compiler flag
function compiler._mapflag(module, flag)
@@ -408,7 +408,7 @@ function compiler.get(srcfile)
end
-- get compiler from the source file type
- local module = tools.get(kind)
+ local module = tool.get(kind)
if module then
-- invalid compiler
diff --git a/xmake/core/platform/linker.lua b/xmake/core/platform/linker.lua
index b245ee767..0ecb3b5a3 100644
--- a/xmake/core/platform/linker.lua
+++ b/xmake/core/platform/linker.lua
@@ -28,10 +28,10 @@ local utils = require("base/utils")
local table = require("base/table")
local string = require("base/string")
local option = require("base/option")
-local config = require("base/config")
-local compiler = require("base/compiler")
-local tools = require("platform/tool")
-local platform = require("base/platform")
+local config = require("project/config")
+local compiler = require("platform/compiler")
+local tool = require("platform/tool")
+local platform = require("platform/platform")
-- map gcc flag to the given linker flag
function linker._mapflag(module, flag)
@@ -289,7 +289,7 @@ function linker.get(kind)
else return end
-- get it
- local module = tools.get(name)
+ local module = tool.get(name)
-- invalid linker?
if module and not module.command_link then
diff --git a/xmake/core/platform/platform.lua b/xmake/core/platform/platform.lua
index 6a4481a09..42e49f1d2 100644
--- a/xmake/core/platform/platform.lua
+++ b/xmake/core/platform/platform.lua
@@ -28,14 +28,14 @@ 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 global = require("base/global")
+local config = require("project/config")
+local global = require("project/global")
-- the directories of platforms
function platform._directories()
return { path.join(global.directory(), "platforms")
- , path.join(xmake._CORE_DIR, "platforms")
+ , path.join(xmake._CORE_DIR, "platform/platforms")
}
end
diff --git a/xmake/core/platform/platforms/android/android.lua b/xmake/core/platform/platforms/android/android.lua
index 317105fe3..961d83dcc 100644
--- a/xmake/core/platform/platforms/android/android.lua
+++ b/xmake/core/platform/platforms/android/android.lua
@@ -24,7 +24,7 @@
local android = android or {}
-- load modules
-local config = require("base/config")
+local config = require("project/config")
-- init host
android._HOST = xmake._HOST
diff --git a/xmake/core/platform/platforms/android/prober.lua b/xmake/core/platform/platforms/android/prober.lua
index ccfd58ba6..215a93bfe 100644
--- a/xmake/core/platform/platforms/android/prober.lua
+++ b/xmake/core/platform/platforms/android/prober.lua
@@ -26,8 +26,8 @@ local path = require("base/path")
local utils = require("base/utils")
local string = require("base/string")
local tool = require("platform/tool")
-local config = require("base/config")
-local global = require("base/global")
+local config = require("project/config")
+local global = require("project/global")
-- define module: prober
local prober = prober or {}
diff --git a/xmake/core/platform/platforms/iphoneos/iphoneos.lua b/xmake/core/platform/platforms/iphoneos/iphoneos.lua
index 720ac90e2..0336cc0b2 100644
--- a/xmake/core/platform/platforms/iphoneos/iphoneos.lua
+++ b/xmake/core/platform/platforms/iphoneos/iphoneos.lua
@@ -24,7 +24,7 @@
local iphoneos = iphoneos or {}
-- load modules
-local config = require("base/config")
+local config = require("project/config")
-- init host
iphoneos._HOST = "macosx"
diff --git a/xmake/core/platform/platforms/iphoneos/package.lua b/xmake/core/platform/platforms/iphoneos/package.lua
index c155b18f8..4a7a25fd8 100644
--- a/xmake/core/platform/platforms/iphoneos/package.lua
+++ b/xmake/core/platform/platforms/iphoneos/package.lua
@@ -26,10 +26,10 @@ local package = package or {}
-- load modules
local os = require("base/os")
local path = require("base/path")
-local rule = require("base/rule")
+local rule = require("project/rule")
local utils = require("base/utils")
local string = require("base/string")
-local platform = require("base/platform")
+local platform = require("platform/platform")
-- package target
function package.main(target)
diff --git a/xmake/core/platform/platforms/iphoneos/prober.lua b/xmake/core/platform/platforms/iphoneos/prober.lua
index 519d3abc1..46b923326 100644
--- a/xmake/core/platform/platforms/iphoneos/prober.lua
+++ b/xmake/core/platform/platforms/iphoneos/prober.lua
@@ -26,8 +26,8 @@ local path = require("base/path")
local utils = require("base/utils")
local string = require("base/string")
local tool = require("platform/tool")
-local config = require("base/config")
-local global = require("base/global")
+local config = require("project/config")
+local global = require("project/global")
-- define module: prober
local prober = prober or {}
diff --git a/xmake/core/platform/platforms/iphonesimulator/iphonesimulator.lua b/xmake/core/platform/platforms/iphonesimulator/iphonesimulator.lua
index 1e8bb5eaa..3b2bd1ff8 100644
--- a/xmake/core/platform/platforms/iphonesimulator/iphonesimulator.lua
+++ b/xmake/core/platform/platforms/iphonesimulator/iphonesimulator.lua
@@ -24,7 +24,7 @@
local iphonesimulator = iphonesimulator or {}
-- load modules
-local config = require("base/config")
+local config = require("project/config")
-- init host
iphonesimulator._HOST = "macosx"
diff --git a/xmake/core/platform/platforms/iphonesimulator/prober.lua b/xmake/core/platform/platforms/iphonesimulator/prober.lua
index 06ecd11f1..1dfef6ec3 100644
--- a/xmake/core/platform/platforms/iphonesimulator/prober.lua
+++ b/xmake/core/platform/platforms/iphonesimulator/prober.lua
@@ -26,8 +26,8 @@ local path = require("base/path")
local utils = require("base/utils")
local string = require("base/string")
local tool = require("platform/tool")
-local config = require("base/config")
-local global = require("base/global")
+local config = require("project/config")
+local global = require("project/global")
-- define module: prober
local prober = prober or {}
diff --git a/xmake/core/platform/platforms/linux/install.lua b/xmake/core/platform/platforms/linux/install.lua
index 2aaa2d401..e8a74804f 100644
--- a/xmake/core/platform/platforms/linux/install.lua
+++ b/xmake/core/platform/platforms/linux/install.lua
@@ -26,10 +26,10 @@ local install = install or {}
-- load modules
local os = require("base/os")
local path = require("base/path")
-local rule = require("base/rule")
+local rule = require("project/rule")
local utils = require("base/utils")
local string = require("base/string")
-local platform = require("base/platform")
+local platform = require("platform/platform")
-- install target for the library file
function install._done_library(target)
diff --git a/xmake/core/platform/platforms/linux/linux.lua b/xmake/core/platform/platforms/linux/linux.lua
index 92a61953d..d70224351 100644
--- a/xmake/core/platform/platforms/linux/linux.lua
+++ b/xmake/core/platform/platforms/linux/linux.lua
@@ -24,7 +24,7 @@
local linux = linux or {}
-- load modules
-local config = require("base/config")
+local config = require("project/config")
-- init host
linux._HOST = "linux"
diff --git a/xmake/core/platform/platforms/linux/prober.lua b/xmake/core/platform/platforms/linux/prober.lua
index b7db919ef..9148185af 100644
--- a/xmake/core/platform/platforms/linux/prober.lua
+++ b/xmake/core/platform/platforms/linux/prober.lua
@@ -26,8 +26,8 @@ local path = require("base/path")
local utils = require("base/utils")
local string = require("base/string")
local tool = require("platform/tool")
-local config = require("base/config")
-local global = require("base/global")
+local config = require("project/config")
+local global = require("project/global")
-- define module: prober
local prober = prober or {}
diff --git a/xmake/core/platform/platforms/linux/uninstall.lua b/xmake/core/platform/platforms/linux/uninstall.lua
index 2de89ac8e..f83913a4a 100644
--- a/xmake/core/platform/platforms/linux/uninstall.lua
+++ b/xmake/core/platform/platforms/linux/uninstall.lua
@@ -26,10 +26,10 @@ local uninstall = uninstall or {}
-- load modules
local os = require("base/os")
local path = require("base/path")
-local rule = require("base/rule")
+local rule = require("project/rule")
local utils = require("base/utils")
local string = require("base/string")
-local platform = require("base/platform")
+local platform = require("platform/platform")
-- uninstall target for the library file
function uninstall._done_library(target)
diff --git a/xmake/core/platform/platforms/macosx/install.lua b/xmake/core/platform/platforms/macosx/install.lua
index 2aaa2d401..e8a74804f 100644
--- a/xmake/core/platform/platforms/macosx/install.lua
+++ b/xmake/core/platform/platforms/macosx/install.lua
@@ -26,10 +26,10 @@ local install = install or {}
-- load modules
local os = require("base/os")
local path = require("base/path")
-local rule = require("base/rule")
+local rule = require("project/rule")
local utils = require("base/utils")
local string = require("base/string")
-local platform = require("base/platform")
+local platform = require("platform/platform")
-- install target for the library file
function install._done_library(target)
diff --git a/xmake/core/platform/platforms/macosx/macosx.lua b/xmake/core/platform/platforms/macosx/macosx.lua
index dfc011418..31a9f0296 100644
--- a/xmake/core/platform/platforms/macosx/macosx.lua
+++ b/xmake/core/platform/platforms/macosx/macosx.lua
@@ -24,7 +24,7 @@
local macosx = macosx or {}
-- load modules
-local config = require("base/config")
+local config = require("project/config")
-- init host
macosx._HOST = "macosx"
diff --git a/xmake/core/platform/platforms/macosx/prober.lua b/xmake/core/platform/platforms/macosx/prober.lua
index a1f1e0a0c..64dd607b5 100644
--- a/xmake/core/platform/platforms/macosx/prober.lua
+++ b/xmake/core/platform/platforms/macosx/prober.lua
@@ -26,8 +26,8 @@ local path = require("base/path")
local utils = require("base/utils")
local string = require("base/string")
local tool = require("platform/tool")
-local config = require("base/config")
-local global = require("base/global")
+local config = require("project/config")
+local global = require("project/global")
-- define module: prober
local prober = prober or {}
diff --git a/xmake/core/platform/platforms/macosx/uninstall.lua b/xmake/core/platform/platforms/macosx/uninstall.lua
index 2de89ac8e..f83913a4a 100644
--- a/xmake/core/platform/platforms/macosx/uninstall.lua
+++ b/xmake/core/platform/platforms/macosx/uninstall.lua
@@ -26,10 +26,10 @@ local uninstall = uninstall or {}
-- load modules
local os = require("base/os")
local path = require("base/path")
-local rule = require("base/rule")
+local rule = require("project/rule")
local utils = require("base/utils")
local string = require("base/string")
-local platform = require("base/platform")
+local platform = require("platform/platform")
-- uninstall target for the library file
function uninstall._done_library(target)
diff --git a/xmake/core/platform/platforms/mingw/mingw.lua b/xmake/core/platform/platforms/mingw/mingw.lua
index adb771a1f..ce263bae6 100644
--- a/xmake/core/platform/platforms/mingw/mingw.lua
+++ b/xmake/core/platform/platforms/mingw/mingw.lua
@@ -24,7 +24,7 @@
local mingw = mingw or {}
-- load modules
-local config = require("base/config")
+local config = require("project/config")
-- init host
mingw._HOST = xmake._HOST
diff --git a/xmake/core/platform/platforms/mingw/prober.lua b/xmake/core/platform/platforms/mingw/prober.lua
index e5ebf5945..098c27244 100644
--- a/xmake/core/platform/platforms/mingw/prober.lua
+++ b/xmake/core/platform/platforms/mingw/prober.lua
@@ -26,8 +26,8 @@ local path = require("base/path")
local utils = require("base/utils")
local string = require("base/string")
local tool = require("platform/tool")
-local config = require("base/config")
-local global = require("base/global")
+local config = require("project/config")
+local global = require("project/global")
-- define module: prober
local prober = prober or {}
diff --git a/xmake/core/platform/platforms/watchos/package.lua b/xmake/core/platform/platforms/watchos/package.lua
index c155b18f8..4a7a25fd8 100644
--- a/xmake/core/platform/platforms/watchos/package.lua
+++ b/xmake/core/platform/platforms/watchos/package.lua
@@ -26,10 +26,10 @@ local package = package or {}
-- load modules
local os = require("base/os")
local path = require("base/path")
-local rule = require("base/rule")
+local rule = require("project/rule")
local utils = require("base/utils")
local string = require("base/string")
-local platform = require("base/platform")
+local platform = require("platform/platform")
-- package target
function package.main(target)
diff --git a/xmake/core/platform/platforms/watchos/prober.lua b/xmake/core/platform/platforms/watchos/prober.lua
index 5c6ea542d..0f893acc0 100644
--- a/xmake/core/platform/platforms/watchos/prober.lua
+++ b/xmake/core/platform/platforms/watchos/prober.lua
@@ -26,8 +26,8 @@ local path = require("base/path")
local utils = require("base/utils")
local string = require("base/string")
local tool = require("platform/tool")
-local config = require("base/config")
-local global = require("base/global")
+local config = require("project/config")
+local global = require("project/global")
-- define module: prober
local prober = prober or {}
diff --git a/xmake/core/platform/platforms/watchos/watchos.lua b/xmake/core/platform/platforms/watchos/watchos.lua
index 600de3b69..3f04d6082 100644
--- a/xmake/core/platform/platforms/watchos/watchos.lua
+++ b/xmake/core/platform/platforms/watchos/watchos.lua
@@ -24,7 +24,7 @@
local watchos = watchos or {}
-- load modules
-local config = require("base/config")
+local config = require("project/config")
-- init host
watchos._HOST = "macosx"
diff --git a/xmake/core/platform/platforms/watchsimulator/prober.lua b/xmake/core/platform/platforms/watchsimulator/prober.lua
index 81404150c..168845d03 100644
--- a/xmake/core/platform/platforms/watchsimulator/prober.lua
+++ b/xmake/core/platform/platforms/watchsimulator/prober.lua
@@ -26,8 +26,8 @@ local path = require("base/path")
local utils = require("base/utils")
local string = require("base/string")
local tool = require("platform/tool")
-local config = require("base/config")
-local global = require("base/global")
+local config = require("project/config")
+local global = require("project/global")
-- define module: prober
local prober = prober or {}
diff --git a/xmake/core/platform/platforms/watchsimulator/watchsimulator.lua b/xmake/core/platform/platforms/watchsimulator/watchsimulator.lua
index 19f44d3b8..c0b29e120 100644
--- a/xmake/core/platform/platforms/watchsimulator/watchsimulator.lua
+++ b/xmake/core/platform/platforms/watchsimulator/watchsimulator.lua
@@ -24,7 +24,7 @@
local watchsimulator = watchsimulator or {}
-- load modules
-local config = require("base/config")
+local config = require("project/config")
-- init host
watchsimulator._HOST = "macosx"
diff --git a/xmake/core/platform/platforms/windows/prober.lua b/xmake/core/platform/platforms/windows/prober.lua
index 7acc945f2..5ed3c9c50 100644
--- a/xmake/core/platform/platforms/windows/prober.lua
+++ b/xmake/core/platform/platforms/windows/prober.lua
@@ -26,10 +26,10 @@ local os = require("base/os")
local path = require("base/path")
local utils = require("base/utils")
local string = require("base/string")
-local config = require("base/config")
-local global = require("base/global")
+local config = require("project/config")
+local global = require("project/global")
local tool = require("platform/tool")
-local platform = require("base/platform")
+local platform = require("platform/platform")
-- define module: prober
local prober = prober or {}
diff --git a/xmake/core/platform/platforms/windows/tools/cl.lua b/xmake/core/platform/platforms/windows/tools/cl.lua
index 51184dc1a..d03cbc056 100644
--- a/xmake/core/platform/platforms/windows/tools/cl.lua
+++ b/xmake/core/platform/platforms/windows/tools/cl.lua
@@ -26,8 +26,8 @@ local cl = cl or {}
-- load modules
local utils = require("base/utils")
local string = require("base/string")
-local config = require("base/config")
-local platform = require("base/platform")
+local config = require("project/config")
+local platform = require("platform/platform")
-- init the compiler
function cl.init(self, name)
diff --git a/xmake/core/platform/platforms/windows/tools/lib.lua b/xmake/core/platform/platforms/windows/tools/lib.lua
index 3ff37829d..571d0ef3f 100644
--- a/xmake/core/platform/platforms/windows/tools/lib.lua
+++ b/xmake/core/platform/platforms/windows/tools/lib.lua
@@ -29,8 +29,8 @@ local os = require("base/os")
local path = require("base/path")
local utils = require("base/utils")
local string = require("base/string")
-local config = require("base/config")
-local platform = require("base/platform")
+local config = require("project/config")
+local platform = require("platform/platform")
-- init the compiler
function lib.init(self, name)
diff --git a/xmake/core/platform/platforms/windows/tools/link.lua b/xmake/core/platform/platforms/windows/tools/link.lua
index b8913a42f..a536626d6 100644
--- a/xmake/core/platform/platforms/windows/tools/link.lua
+++ b/xmake/core/platform/platforms/windows/tools/link.lua
@@ -26,8 +26,8 @@ local link = link or {}
-- load modules
local utils = require("base/utils")
local string = require("base/string")
-local config = require("base/config")
-local platform = require("base/platform")
+local config = require("project/config")
+local platform = require("platform/platform")
-- init the compiler
function link.init(self, name)
diff --git a/xmake/core/platform/platforms/windows/tools/ml.lua b/xmake/core/platform/platforms/windows/tools/ml.lua
index 75db5194b..5b91ab7b7 100644
--- a/xmake/core/platform/platforms/windows/tools/ml.lua
+++ b/xmake/core/platform/platforms/windows/tools/ml.lua
@@ -26,8 +26,8 @@ local ml = ml or {}
-- load modules
local utils = require("base/utils")
local string = require("base/string")
-local config = require("base/config")
-local platform = require("base/platform")
+local config = require("project/config")
+local platform = require("platform/platform")
-- init the compiler
function ml.init(self, name)
diff --git a/xmake/core/platform/platforms/windows/tools/nmake.lua b/xmake/core/platform/platforms/windows/tools/nmake.lua
index 68f04a31a..d2e1505f6 100644
--- a/xmake/core/platform/platforms/windows/tools/nmake.lua
+++ b/xmake/core/platform/platforms/windows/tools/nmake.lua
@@ -25,9 +25,9 @@ local os = require("base/os")
local path = require("base/path")
local utils = require("base/utils")
local string = require("base/string")
-local config = require("base/config")
local option = require("base/option")
-local platform = require("base/platform")
+local config = require("project/config")
+local platform = require("platform/platform")
-- define module: nmake
local nmake = nmake or {}
diff --git a/xmake/core/platform/platforms/windows/windows.lua b/xmake/core/platform/platforms/windows/windows.lua
index 4b168c835..20bfa3046 100644
--- a/xmake/core/platform/platforms/windows/windows.lua
+++ b/xmake/core/platform/platforms/windows/windows.lua
@@ -25,7 +25,7 @@ local windows = windows or {}
-- load modules
local os = require("base/os")
-local config = require("base/config")
+local config = require("project/config")
-- init host
windows._HOST = "windows"
diff --git a/xmake/core/platform/tool.lua b/xmake/core/platform/tool.lua
index 79c0d216d..36047f410 100644
--- a/xmake/core/platform/tool.lua
+++ b/xmake/core/platform/tool.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 platform = require("base/platform")
+local platform = require("platform/platform")
-- match the tool name
function tool._match(name, toolname)
@@ -124,10 +124,10 @@ function tool.find(name, root)
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 = tool._find_from(platform.directory() .. "/tool", name) end
+ if not filepath then filepath = tool._find_from(path.join(platform.directory(), "tools"), name) end
-- attempt to find it from the script directory
- if not filepath then filepath = tool._find_from(xmake._CORE_DIR .. "/tool", name) end
+ if not filepath then filepath = tool._find_from(path.join(xmake._CORE_DIR, "platform/tools"), name) end
-- ok?
return filepath
diff --git a/xmake/core/platform/tools/ar.lua b/xmake/core/platform/tools/ar.lua
index 7f019cd17..46b420e55 100644
--- a/xmake/core/platform/tools/ar.lua
+++ b/xmake/core/platform/tools/ar.lua
@@ -26,7 +26,7 @@ local ar = ar or {}
-- load modules
local utils = require("base/utils")
local string = require("base/string")
-local config = require("base/config")
+local config = require("project/config")
-- init the linker
function ar.init(self, name)
diff --git a/xmake/core/platform/tools/gcc.lua b/xmake/core/platform/tools/gcc.lua
index a27e41341..637f9792b 100644
--- a/xmake/core/platform/tools/gcc.lua
+++ b/xmake/core/platform/tools/gcc.lua
@@ -24,8 +24,8 @@
local utils = require("base/utils")
local table = require("base/table")
local string = require("base/string")
-local config = require("base/config")
-local platform = require("base/platform")
+local config = require("project/config")
+local platform = require("platform/platform")
-- define module: gcc
local gcc = gcc or {}
diff --git a/xmake/core/platform/tools/swiftc.lua b/xmake/core/platform/tools/swiftc.lua
index 6317bde2d..fa09d566c 100644
--- a/xmake/core/platform/tools/swiftc.lua
+++ b/xmake/core/platform/tools/swiftc.lua
@@ -24,8 +24,8 @@
local utils = require("base/utils")
local table = require("base/table")
local string = require("base/string")
-local config = require("base/config")
-local platform = require("base/platform")
+local config = require("project/config")
+local platform = require("platform/platform")
-- define module: swiftc
local swiftc = swiftc or {}
diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua
new file mode 100644
index 000000000..e1bb9a961
--- /dev/null
+++ b/xmake/core/project/config.lua
@@ -0,0 +1,388 @@
+--!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: config
+local config = config or {}
+
+-- load modules
+local io = require("base/io")
+local os = require("base/os")
+local path = require("base/path")
+local utils = require("base/utils")
+local option = require("base/option")
+local global = require("project/global")
+
+-- make configure for the current target
+function config._make(configs)
+
+ -- init current target configure
+ local current = {}
+
+ -- get configs from the default configure
+ if configs._DEFAULTS then
+ for k, v in pairs(configs._DEFAULTS) do
+ if type(v) ~= "string" or v ~= "auto" then current[k] = v end
+ end
+ end
+
+ -- get configs from the global configure
+ if global._CURRENT then
+ for k, v in pairs(global._CURRENT) do
+ current[k] = v
+ end
+ end
+
+ -- get configs from all targets
+ for k, v in pairs(configs) do
+ if type(k) == "string" and not k:find("^_%u+") then
+ current[k] = v
+ end
+ end
+
+ -- get configs from the current target
+ if configs._TARGETS and current.target ~= "all" then
+
+ -- get the target config
+ local target_config = configs._TARGETS[current.target]
+ if target_config then
+
+ -- merge it
+ for k, v in pairs(target_config) do
+ current[k] = v
+ end
+ end
+ end
+
+ -- ok?
+ return current
+end
+
+-- get the configure file
+function config._file()
+
+ -- get it
+ return path.join(config.directory(), "xmake.conf")
+end
+
+-- need configure?
+function config._need(name)
+ return name and name ~= "target" and name ~= "file" and name ~= "project" and name ~= "verbose" and name ~= "clean"
+end
+
+-- get the current target scope
+function config._target()
+
+ -- check
+ local configs = config._CONFIGS
+ assert(configs)
+
+ -- the target name
+ local name = option.get("target")
+ assert(name and type(name) == "string")
+
+ -- for all targets?
+ if name == "all" then
+ return configs
+ elseif configs._TARGETS then
+ -- get it
+ return configs._TARGETS[name]
+ end
+end
+
+-- get the given configure from the current
+function config.get(name)
+
+ -- the configure has been not loaded
+ if not config._CURRENT then return end
+
+ -- get it
+ return config._CURRENT[name]
+end
+
+-- set the given configure to the current
+function config.set(name, value)
+
+ -- check
+ assert(config._CURRENT and name)
+
+ -- get the current target
+ local target = config._target()
+ assert(target)
+
+ -- set it to the current target configure for saving to file
+ target[name] = value
+
+ -- set it to the current configure
+ config._CURRENT[name] = value
+end
+
+-- the given configure need probe automatically
+function config.auto(name)
+
+ -- the configs
+ local configs = config._CONFIGS
+ assert(configs)
+
+ -- need probe it automatically?
+ if configs._DEFAULTS then
+ local value = configs._DEFAULTS[name]
+ if value then
+ if type(value) == "string" and value == "auto" then
+ return true
+ end
+ end
+ end
+
+ -- need not probe it if have been setted manually
+ if config._CURRENT and nil ~= config._CURRENT[name] then
+ return false
+ end
+
+ -- attempt to probe it if not exists
+ return true
+end
+
+-- get the configure directory
+function config.directory()
+
+ -- the directory
+ local dir = path.join(xmake._PROJECT_DIR, ".xmake")
+
+ -- create it directly first if not exists
+ if not os.isdir(dir) then
+ assert(os.mkdir(dir))
+ end
+
+ -- get it
+ return dir
+end
+
+-- save xmake.conf
+function config.save()
+
+ -- the configs
+ local configs = config._CONFIGS
+ assert(configs)
+
+ -- save to the configure file
+ return io.save(config._file(), configs)
+end
+
+function config.load()
+
+ -- the options
+ local options = option.options()
+ assert(options)
+
+ -- check
+ assert(option._MENU)
+ assert(option._MENU.config)
+
+ -- the target name
+ local name = option.get("target")
+ if not name then
+ return "no given target name!"
+ end
+
+ -- does not clean the cached configure?
+ if not option.get("clean") then
+
+ -- load and execute the xmake.xconf
+ local filepath = config._file()
+ if os.isfile(filepath) then
+
+ -- load the configure file
+ local configs, errors = io.load(filepath)
+
+ -- exists local configures?
+ if configs then
+
+ -- save configs
+ config._CONFIGS = configs
+
+ -- make the current target configs
+ local current = config._make(configs)
+
+ -- clear configs and mark as "rebuild" and "reconfig" if the host has been changed
+ if (current and current.host ~= xmake._HOST) then
+
+ -- clear configs and mark as "rebuild"
+ config._CONFIGS = { __rebuild = true }
+
+ -- mark as "reconfig" if the current action is not "config"
+ if option.task() ~= "config" then
+ config._RECONFIG = true
+ end
+ end
+
+ -- clear configs and mark as "rebuild" if the plat has been changed
+ if current and current.plat and options.plat and current.plat ~= options.plat then
+
+ -- clear configs and mark as "rebuild"
+ config._CONFIGS = { __rebuild = true }
+ end
+
+ -- mark as "rebuild" if the arch has been changed
+ if current and current.arch and options.arch and current.arch ~= options.arch then
+
+ -- mark as "rebuild"
+ config._CONFIGS.__rebuild = true
+ end
+
+ -- mark as "rebuild" if the mode has been changed
+ if current and current.mode and options.mode and current.mode ~= options.mode then
+
+ -- mark as "rebuild"
+ config._CONFIGS.__rebuild = true
+ end
+ elseif errors then
+ -- error
+ utils.error(errors)
+ end
+ end
+ end
+
+ -- init configs if not exists
+ if not config._CONFIGS then
+ -- clear configs and mark as "rebuild"
+ config._CONFIGS = { __rebuild = true }
+
+ -- mark as "reconfig" if the current action is not "config"
+ if option.task() ~= "config" then
+ config._RECONFIG = true
+ end
+ end
+
+ -- the configs
+ local configs = config._CONFIGS
+
+ -- mark as "rebuild" if clean the cached configure
+ if option.get("clean") then
+ configs.__rebuild = true
+ end
+
+ -- init the defaults
+ local defaults = nil
+ if not configs._DEFAULTS then
+ if config._RECONFIG then defaults = option.defaults("config")
+ elseif option.task() == "config" then defaults = option.defaults()
+ end
+ if defaults then
+ for k, v in pairs(defaults) do
+
+ -- check
+ assert(type(k) == "string")
+
+ -- skip some options
+ if config._need(k) then
+
+ -- save the default option
+ configs._DEFAULTS = configs._DEFAULTS or {}
+ configs._DEFAULTS[k] = v
+ end
+ end
+ end
+ end
+ defaults = configs._DEFAULTS
+
+ -- init targets
+ configs._TARGETS = configs._TARGETS or {}
+ if name ~= "all" then
+ configs._TARGETS[name] = configs._TARGETS[name] or {}
+ end
+
+ -- get the current target scope
+ local target = config._target()
+ assert(target and type(target) == "table")
+
+ -- merge option.options() to target
+ if option.task() == "config" then
+ for k, v in pairs(options) do
+
+ -- check
+ assert(type(k) == "string")
+
+ -- skip some options
+ if not k:startswith("_") and config._need(k) then
+
+ -- save the option to the target
+ target[k] = v
+
+ -- remove it from the defaults, because we have setted it manually
+ if defaults then defaults[k] = nil end
+ end
+ end
+ end
+
+ -- make the current config
+ config._CURRENT = config._make(config._CONFIGS)
+end
+
+-- clear up and remove all auto values
+function config.clearup()
+
+ -- clear up the current configure
+ local current = config._CURRENT
+ if current then
+ for k, v in pairs(current) do
+ if type(v) == "string" and v == "auto" then
+ current[k] = nil
+ end
+ end
+ end
+
+ -- clear up the current target configure
+ local target = config._target()
+ if target then
+ for k, v in pairs(target) do
+ if type(v) == "string" and v == "auto" then
+ target[k] = nil
+ end
+ end
+ end
+
+end
+
+-- reload configure
+function config.reload()
+
+ -- clear the old configure
+ config._CURRENT = nil
+ config._CONFIGS = nil
+
+ -- load it
+ return config.load()
+end
+
+-- dump the current configure
+function config.dump()
+
+ -- check
+ assert(config._CURRENT)
+
+ -- dump
+ utils.dump(config._CURRENT, "__%w*", "configure")
+
+end
+
+-- return module: config
+return config
diff --git a/xmake/core/project/deprecated/project.lua b/xmake/core/project/deprecated/project.lua
index 58831b3fc..c31c77f6c 100644
--- a/xmake/core/project/deprecated/project.lua
+++ b/xmake/core/project/deprecated/project.lua
@@ -25,12 +25,12 @@ local deprecated_project = deprecated_project or {}
-- load modules
local os = require("base/os")
-local rule = require("base/rule")
local path = require("base/path")
local utils = require("base/utils")
local table = require("base/table")
-local config = require("base/config")
-local platform = require("base/platform")
+local rule = require("project/rule")
+local config = require("project/config")
+local platform = require("platform/platform")
local deprecated_interpreter = require("base/deprecated/interpreter")
-- the current os is belong to the given os?
diff --git a/xmake/core/project/global.lua b/xmake/core/project/global.lua
new file mode 100644
index 000000000..0be86e136
--- /dev/null
+++ b/xmake/core/project/global.lua
@@ -0,0 +1,239 @@
+--!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: global
+local global = global or {}
+
+-- load modules
+local io = require("base/io")
+local os = require("base/os")
+local utils = require("base/utils")
+local option = require("base/option")
+
+-- make configure
+function global._make()
+
+ -- the configs
+ local configs = global._CONFIGS
+ assert(configs)
+
+ -- init current global configure
+ global._CURRENT = global._CURRENT or {}
+ local current = global._CURRENT
+
+ -- make current global configure
+ for k, v in pairs(configs) do
+ if type(k) == "string" and not k:find("^_%u+") then
+ current[k] = v
+ end
+ end
+end
+
+-- get the configure file
+function global._file()
+
+ -- get it
+ return global.directory() .. "/xmake.conf"
+end
+
+-- need configure?
+function global._need(name)
+ return name and name ~= "verbose" and name ~= "clean"
+end
+
+-- get the given configure from the current
+function global.get(name)
+
+ -- check
+ assert(global._CURRENT)
+
+ -- the value
+ local value = global._CURRENT[name]
+ if value and value == "auto" then
+ value = nil
+ end
+
+ -- get it
+ return value
+end
+
+-- set the given configure to the current
+function global.set(name, value)
+
+ -- check
+ assert(global._CURRENT and global._CONFIGS)
+ assert(name and type(value) ~= "table")
+
+ -- set it to the current configure
+ global._CURRENT[name] = value
+
+ -- set it to the configure for saving to file
+ global._CONFIGS[name] = value
+
+end
+
+-- get the global configure directory
+function global.directory()
+
+ -- the directory
+ local dir = path.translate("~/.xmake")
+
+ -- create it directly first if not exists
+ if not os.isdir(dir) then
+ assert(os.mkdir(dir))
+ end
+
+ -- get it
+ return dir
+end
+
+-- save the global configure
+function global.save()
+
+ -- the configs
+ local configs = global._CONFIGS
+ assert(configs)
+
+ -- save to the configure file
+ return io.save(global._file(), configs)
+end
+
+-- load the global configure
+function global.load()
+
+ -- load configure from the file first
+ local filepath = global._file()
+ if os.isfile(filepath) then
+
+ -- load configs
+ local configs, errors = io.load(filepath)
+
+ -- error?
+ if not configs and errors then
+ utils.error(errors)
+ end
+
+ -- save configs
+ global._CONFIGS = configs
+ end
+
+ -- init configs
+ global._CONFIGS = global._CONFIGS or {}
+
+ -- make the current configs
+ global._CURRENT = global._make(global._CONFIGS)
+
+ -- ok
+ return true
+
+ --[[
+ -- the options
+ local options = option.options()
+ assert(options)
+
+ -- does not clean the cached configure?
+ if not option.get("clean") then
+
+ TODO
+ end
+ ]]
+
+ --[[
+
+ -- xmake global?
+ if option.task() == "global" then
+
+ -- merge option.options() to the global configure
+ for k, v in pairs(options) do
+
+ -- check
+ assert(type(k) == "string")
+
+ -- need configure it?
+ if not k:startswith("_") and global._need(k) then
+ configs[k] = v
+ end
+ end
+
+ -- merge the default global configure options to the global configure
+ local defaults = option.defaults()
+ if defaults then
+ for k, v in pairs(defaults) do
+
+ -- check
+ assert(type(k) == "string")
+
+ -- need configure it?
+ if global._need(k) then
+
+ -- save the default option
+ if nil == configs[k] then
+ configs[k] = v
+ end
+ end
+ end
+ end
+ end
+ ]]
+
+end
+
+-- TODO move into probe()
+-- clear up and remove all auto values
+--[[
+function global.clearup()
+
+ -- clear up the current configure
+ local current = global._CURRENT
+ if current then
+ for k, v in pairs(current) do
+ if v and type(v) and v == "auto" then
+ current[k] = nil
+ end
+ end
+ end
+
+ -- clear up the configure
+ local configs = global._CONFIGS
+ if configs then
+ for k, v in pairs(configs) do
+ if v and type(v) and v == "auto" then
+ configs[k] = nil
+ end
+ end
+ end
+end
+]]
+
+-- dump the current configure
+function global.dump()
+
+ -- check
+ assert(global._CURRENT)
+
+ -- dump
+ utils.dump(global._CURRENT, "__%w*", "configure")
+
+end
+
+-- return module: global
+return global
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua
index 6e39d96b7..7124c6a81 100644
--- a/xmake/core/project/project.lua
+++ b/xmake/core/project/project.lua
@@ -26,18 +26,18 @@ local project = project 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 table = require("base/table")
local option = require("base/option")
-local config = require("base/config")
local filter = require("base/filter")
-local linker = require("base/linker")
-local compiler = require("base/compiler")
-local platform = require("base/platform")
local interpreter = require("base/interpreter")
-local deprecated_project = require("base/deprecated/project")
+local rule = require("project/rule")
+local config = require("project/config")
+local deprecated_project = require("project/deprecated/project")
+local linker = require("platform/linker")
+local compiler = require("platform/compiler")
+local platform = require("platform/platform")
-- the current os is belong to the given os?
function project._api_is_os(interp, ...)
diff --git a/xmake/core/project/rule.lua b/xmake/core/project/rule.lua
new file mode 100644
index 000000000..c49cb928e
--- /dev/null
+++ b/xmake/core/project/rule.lua
@@ -0,0 +1,300 @@
+--!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("project/config")
+local platform = require("platform/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/template/template.lua b/xmake/core/project/template.lua
index b80e38baf..357d688e6 100644
--- a/xmake/core/template/template.lua
+++ b/xmake/core/project/template.lua
@@ -31,7 +31,7 @@ local table = require("base/table")
local utils = require("base/utils")
local string = require("base/string")
local filter = require("base/filter")
-local sandbox = require("base/sandbox")
+local sandbox = require("sandbox/sandbox")
local interpreter = require("base/interpreter")
-- the interpreter
diff --git a/xmake/core/sandbox/modules/import/core/platform/menu.lua b/xmake/core/sandbox/modules/import/core/platform/menu.lua
new file mode 100644
index 000000000..0d3e5883e
--- /dev/null
+++ b/xmake/core/sandbox/modules/import/core/platform/menu.lua
@@ -0,0 +1,66 @@
+--!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 menu.lua
+--
+
+-- define module
+local sandbox_core_platform_menu = sandbox_core_platform_menu or {}
+
+-- load modules
+local platform = require("platform/platform")
+
+-- get the all platforms
+function sandbox_core_platform_menu.plats()
+
+ -- get it
+ local plats = platform.plats()
+ assert(plats)
+
+ -- ok
+ return plats
+end
+
+-- get the all architectures for the given platform
+function sandbox_core_platform_menu.archs(plat)
+
+ -- get it
+ local archs = platform.archs(plat)
+ assert(archs)
+
+ -- ok
+ return archs
+end
+
+-- get the platform menu options for global
+function sandbox_core_platform_menu.options_global()
+
+ -- get it
+ return platform.menu("global")
+end
+
+-- get the platform menu options for config
+function sandbox_core_platform_menu.options_config()
+
+ -- get it
+ return platform.menu("config")
+end
+
+-- return module
+return sandbox_core_platform_menu
diff --git a/xmake/core/sandbox/modules/import/core/project/menu.lua b/xmake/core/sandbox/modules/import/core/project/menu.lua
new file mode 100644
index 000000000..de3314409
--- /dev/null
+++ b/xmake/core/sandbox/modules/import/core/project/menu.lua
@@ -0,0 +1,39 @@
+--!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 menu.lua
+--
+
+-- define module
+local sandbox_core_project_menu = sandbox_core_project_menu or {}
+
+-- load modules
+local rule = require("project/rule")
+local config = require("project/config")
+local project = require("project/project")
+
+-- get the menu options
+function sandbox_core_project_menu.options()
+
+ -- get it
+ return project.menu()
+end
+
+-- return module
+return sandbox_core_project_menu
diff --git a/xmake/core/sandbox/modules/import/core/project/template.lua b/xmake/core/sandbox/modules/import/core/project/template.lua
new file mode 100644
index 000000000..8b9f0dbb0
--- /dev/null
+++ b/xmake/core/sandbox/modules/import/core/project/template.lua
@@ -0,0 +1,52 @@
+--!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_core_project_template = sandbox_core_project_template or {}
+
+-- load modules
+local template = require("project/template")
+
+-- get all languages
+function sandbox_core_project_template.languages()
+
+ -- get it
+ local languages = template.languages()
+ assert(languages)
+
+ -- ok
+ return languages
+end
+
+-- load all templates from the given language
+function sandbox_core_project_template.templates(language)
+
+ -- get it
+ local templates = template.templates(language)
+ assert(templates)
+
+ -- ok
+ return templates
+end
+
+-- return module
+return sandbox_core_project_template