From eabbc4ff68278c584cb908bb68991c4ea4224fbf Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 9 Aug 2016 20:36:16 +0800 Subject: improve builtin-variable and option --- CHANGELOG.md | 7 +++++++ xmake/core/base/filter.lua | 26 +++++++++++++++----------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8a6203f7..6ba6e8423 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ ### Changes +* Improve builtin-variable format +* Support option for string type ### Bugs fixed @@ -149,6 +151,11 @@ * 添加`getenv`接口到`xmake.lua`的全局作用域中 * 添加生成vs200x工程插件 +### 改进 + +* 增强内建变量的处理 +* 支持字符串类型的选项option设置 + ### Bugs修复 * 修复在linux下检测ld连接器失败,如果没装g++的话 diff --git a/xmake/core/base/filter.lua b/xmake/core/base/filter.lua index 5fc9cbed4..0af64bedb 100644 --- a/xmake/core/base/filter.lua +++ b/xmake/core/base/filter.lua @@ -98,24 +98,28 @@ function filter:handle(value) if variable:startswith("shell ") then return filter.shell(variable:sub(7, -1)) end - - -- is upper? - local isupper = false - local c = string.char(variable:byte()) - if c >= 'A' and c <= 'Z' then isupper = true end + -- parse variable:mode + local varmode = variable:split(':') + local mode = varmode[2] + variable = varmode[1] + -- handler it - local result = handler(variable:lower()) - - -- convert to upper? - if isupper and result and type(result) == "string" then - result = result:upper() - end + local result = handler(variable) -- invalid builtin variable? if result == nil then os.raise("invalid variable: $(%s)", variable) end + + -- handle mode + if mode then + if mode == "upper" then + result = result:upper() + elseif mode == "lower" then + result = result:lower() + end + end -- ok? return result -- cgit v1.3.1