From 4d2fbb049f34e5899d962a148bf5e560fe9d978c Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 8 Jun 2015 12:16:34 +0800 Subject: load switch files --- xmake/scripts/base/project.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'xmake/scripts/base/project.lua') diff --git a/xmake/scripts/base/project.lua b/xmake/scripts/base/project.lua index 8b8873983..a0e963909 100644 --- a/xmake/scripts/base/project.lua +++ b/xmake/scripts/base/project.lua @@ -175,6 +175,27 @@ function project._init_switches(target) end end + -- load switches from the xxxx.xswf + if target.switchfiles then + for _, switchfile in ipairs(target.switchfiles) do + if not path.is_absolute(switchfile) then + switchfile = path.absolute(switchfile, xmake._PROJECT_DIR) + end + local newenv, errors = preprocessor.loadfile(switchfile, "switches", {"defines"}) + if newenv and newenv._CONFIGS then + if newenv._CONFIGS.defines then + for _, switch in ipairs(newenv._CONFIGS.defines) do + target._SWITCHES[switch] = true + end + end + else + -- error + utils.error(errors) + assert(false) + end + end + end + -- attempt to get it from the switches setmetatable(target, { @@ -293,6 +314,7 @@ function project.loadxproj(file) , "shflags" , "defines" , "switches" + , "switchfiles" , "strip" , "symbols" , "warnings" -- cgit v1.3.1