summaryrefslogtreecommitdiff
path: root/xmake/scripts/base
diff options
context:
space:
mode:
authorruki <[email protected]>2015-05-13 22:05:42 +0800
committerruki <[email protected]>2015-05-13 22:05:42 +0800
commit74ece0defa314bab78262d95bee517bdc09df689 (patch)
tree950684880d0193e60956a9b695cab50861208ff4 /xmake/scripts/base
parent1f45e3bf9b41a413804305fc23810639b977a9f1 (diff)
add preprocessor and update tbox
Diffstat (limited to 'xmake/scripts/base')
-rw-r--r--xmake/scripts/base/main.lua31
-rw-r--r--xmake/scripts/base/preprocessor.lua27
-rw-r--r--xmake/scripts/base/project.lua8
3 files changed, 49 insertions, 17 deletions
diff --git a/xmake/scripts/base/main.lua b/xmake/scripts/base/main.lua
index d52648fb3..c5e3d0e4e 100644
--- a/xmake/scripts/base/main.lua
+++ b/xmake/scripts/base/main.lua
@@ -24,11 +24,12 @@
local main = main or {}
-- load modules
-local path = require("base/path")
-local utils = require("base/utils")
-local option = require("base/option")
-local project = require("base/project")
-local action = require("action/action")
+local path = require("base/path")
+local utils = require("base/utils")
+local option = require("base/option")
+local project = require("base/project")
+local preprocessor = require("base/preprocessor")
+local action = require("action/action")
-- init the option menu
local menu =
@@ -59,7 +60,7 @@ local menu =
, {'r', "rebuild", "k", nil, "Rebuild the project." }
, {}
- , {'f', "file", "kv", "xmake.lua", "Read a given xmake.lua file." }
+ , {'f', "file", "kv", "xmake.xproj", "Read a given xmake.xproj file." }
, {'P', "project", "kv", nil, "Change to the given project directory."
, "Search priority:"
, " 1. the given command argument"
@@ -93,7 +94,7 @@ local menu =
, options =
{
{'n', "name", "kv", nil, "The project name." }
- , {'f', "file", "kv", "xmake.lua", "Create a given xmake.lua file." }
+ , {'f', "file", "kv", "xmake.xproj", "Create a given xmake.xproj file." }
, {'P', "project", "kv", nil, "Create from the given project directory."
, "Search priority:"
, " 1. the given command argument"
@@ -172,7 +173,7 @@ local menu =
, {nil, "arflags", "kv", nil, "The library creator flags" }
, {}
- , {'f', "file", "kv", "xmake.lua", "Read a given xmake.lua file." }
+ , {'f', "file", "kv", "xmake.xproj", "Read a given xmake.xproj file." }
, {'P', "project", "kv", nil, "Change to the given project directory."
, "Search priority:"
, " 1. the given command argument"
@@ -205,7 +206,7 @@ local menu =
-- options
, options =
{
- {'f', "file", "kv", "xmake.lua", "Read a given xmake.lua file." }
+ {'f', "file", "kv", "xmake.xproj", "Read a given xmake.xproj file." }
, {'P', "project", "kv", nil, "Change to the given project directory."
, "Search priority:"
, " 1. the given command argument"
@@ -238,7 +239,7 @@ local menu =
-- options
, options =
{
- {'f', "file", "kv", "xmake.lua", "Read a given xmake.lua file." }
+ {'f', "file", "kv", "xmake.xproj", "Read a given xmake.xproj file." }
, {'P', "project", "kv", nil, "Change to the given project directory."
, "Search priority:"
, " 1. the given command argument"
@@ -268,16 +269,16 @@ function main._done_option()
options.project = path.absolute(options.project)
assert(options.project)
- -- init the xmake.lua file path
- options.file = options.file or options._DEFAULTS.file or "xmake.lua"
+ -- init the xmake.xproj file path
+ options.file = options.file or options._DEFAULTS.file or "xmake.xproj"
if not path.is_absolute(options.file) then
options.file = path.absolute(options.file, options.project)
end
assert(options.file)
- -- load and execute the project script
+ -- load and execute the xmake.xproj
local errors = nil
- local script = loadfile(options.file)
+ local script = preprocessor.load_xproj(options.file)
if script then
-- init the project envirnoment
@@ -291,7 +292,7 @@ function main._done_option()
end
else
-- error
- errors = string.format("%s not found!", options.file)
+ errors = string.format("load %s failed!", options.file)
end
-- done help
diff --git a/xmake/scripts/base/preprocessor.lua b/xmake/scripts/base/preprocessor.lua
new file mode 100644
index 000000000..d9c94d096
--- /dev/null
+++ b/xmake/scripts/base/preprocessor.lua
@@ -0,0 +1,27 @@
+--!The Automatic Cross-platform Build Tool
+--
+-- XMake is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU Lesser General Public License as published by
+-- the Free Software Foundation; either version 2.1 of the License, or
+-- (at your option) any later version.
+--
+-- XMake is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public License
+-- along with XMake;
+-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
+--
+-- Copyright (C) 2009 - 2015, ruki All rights reserved.
+--
+-- @author ruki
+-- @file preprocessor.lua
+--
+
+-- define module: preprocessor
+local preprocessor = preprocessor or {}
+
+-- return module: preprocessor
+return preprocessor
diff --git a/xmake/scripts/base/project.lua b/xmake/scripts/base/project.lua
index 40d9c9269..9f0dd7842 100644
--- a/xmake/scripts/base/project.lua
+++ b/xmake/scripts/base/project.lua
@@ -33,6 +33,10 @@ setfenv(1, _PROJECT)
local parent = nil
local current = nil
+-- configure scope end
+function scopend()
+end
+
-- configure target
function target(name)
@@ -40,10 +44,10 @@ function target(name)
assert(name and _ROOT)
-- init targets
- _ROOT._TARGETS = _ROOT._TARGETS or {}
+ current._TARGETS = current._TARGETS or {}
-- init target scope
- _ROOT._TARGETS[name] = {}
+ current._TARGETS[name] = {}
-- TODO
-- enter target scope