From 85c024e699198fa0f20e87a611c7e8b579f76b23 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 15 May 2015 13:07:27 +0800 Subject: reimpl configure --- xmake/scripts/base/config.lua | 15 ++++++--------- xmake/scripts/base/project.lua | 8 ++++---- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/xmake/scripts/base/config.lua b/xmake/scripts/base/config.lua index 45ec33494..e054df0a5 100644 --- a/xmake/scripts/base/config.lua +++ b/xmake/scripts/base/config.lua @@ -135,9 +135,6 @@ function _save_with_level(file, object, level) -- save number elseif type(object) == "number" then file:write(object) - -- save function - elseif type(object) == "function" then - file:write("") -- save table elseif type(object) == "table" then @@ -271,11 +268,7 @@ function getarget() -- for all targets? if name == "all" then return _CONFIGS - else - -- init it if not exists - _CONFIGS._TARGETS = _CONFIGS._TARGETS or {} - _CONFIGS._TARGETS[name] = _CONFIGS._TARGETS[name] or {} - + elseif _CONFIGS._TARGETS then -- get it return _CONFIGS._TARGETS[name] end @@ -350,8 +343,12 @@ function loadxconf() local name = options.target or options._DEFAULTS.target assert(name and type(name) == "string") - -- ensures the configs + -- init it if not exists _CONFIGS = _CONFIGS or {} + _CONFIGS._TARGETS = _CONFIGS._TARGETS or {} + if name ~= "all" then + _CONFIGS._TARGETS[name] = _CONFIGS._TARGETS[name] or {} + end -- get the current target scope local target = getarget() diff --git a/xmake/scripts/base/project.lua b/xmake/scripts/base/project.lua index a36b71af1..a14b1a8ed 100644 --- a/xmake/scripts/base/project.lua +++ b/xmake/scripts/base/project.lua @@ -21,7 +21,8 @@ -- -- load modules -local utils = require("base/utils") +local utils = require("base/utils") +local config = require("base/config") -- enter project local _PROJECT = _PROJECT or {} @@ -51,9 +52,8 @@ function _preprocess(value) -- replace $(variable) value = value:gsub("%$%((.*)%)", function (v) if v == "buildir" then - -- TODO - return v - --return xmake._CONFIGS.all.output + local target = config.getarget() + return utils.ifelse(target, target.output, nil); elseif v == "projectdir" then return xmake._OPTIONS.project end -- cgit v1.3.1