diff options
| author | ruki <[email protected]> | 2015-05-16 17:00:07 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-05-16 17:00:07 +0800 |
| commit | 5fefc1a0bc38a6917c38590d08bf14a4c43dd886 (patch) | |
| tree | 9d1e8d5708a5a2bff68797b422d432b25b8ddfc8 /xmake/scripts/base/project.lua | |
| parent | 05c2b5a567c1e2174ae136e18ca254d98a6b257c (diff) | |
add filter to preprocessor
Diffstat (limited to 'xmake/scripts/base/project.lua')
| -rw-r--r-- | xmake/scripts/base/project.lua | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/xmake/scripts/base/project.lua b/xmake/scripts/base/project.lua index a85941b78..6b93b32fc 100644 --- a/xmake/scripts/base/project.lua +++ b/xmake/scripts/base/project.lua @@ -28,28 +28,6 @@ local utils = require("base/utils") local config = require("base/config") local preprocessor = require("base/preprocessor") --- preprocess value -function _preprocess(value) - - -- the value is string? - if type(value) == "string" then - - -- replace $(variable) - value = value:gsub("%$%((.*)%)", function (v) - if v == "buildir" then - local target = config.getarget() - return utils.ifelse(target, target.output, nil); - elseif v == "projectdir" then - return xmake._OPTIONS.project - end - return v - end) - end - - -- ok - return value -end - -- load xproj function project.loadxproj(file) @@ -74,8 +52,19 @@ function project.loadxproj(file) , "mxflags" , "defines"} + -- init filter + local filter = function (v) + if v == "buildir" then + local target = config.getarget() + return utils.ifelse(target, target.output, nil); + elseif v == "projectdir" then + return xmake._OPTIONS.project + end + return v + end + -- load and execute the xmake.xproj - local configs, errors = preprocessor.loadfile(file, "project", configures, {"target", "platforms"}) + local configs, errors = preprocessor.loadfile(file, "project", configures, {"target", "platforms"}, filter) if configs then -- ok project._CONFIGS = configs |
