summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-02-02 17:52:12 +0800
committerruki <[email protected]>2019-02-02 17:52:26 +0800
commit0566e24964765535bd2f81c1132164e0f4e1272e (patch)
treef8d33051bb5fa14cb2ec704f7172e13384b0cac9
parent4dbcbd611628ac3534000071c13e9f25ed86c92c (diff)
improve to replace variables for configuration files
-rw-r--r--xmake/actions/config/configfiles.lua23
1 files changed, 22 insertions, 1 deletions
diff --git a/xmake/actions/config/configfiles.lua b/xmake/actions/config/configfiles.lua
index 98773149c..7c4152199 100644
--- a/xmake/actions/config/configfiles.lua
+++ b/xmake/actions/config/configfiles.lua
@@ -26,6 +26,7 @@
import("core.base.option")
import("core.project.config")
import("core.project.project")
+import("core.platform.platform")
-- get all configuration files
function _get_configfiles()
@@ -90,7 +91,27 @@ function _generate_configfile(srcfile, dstfile, fileinfo, targets)
local variables = fileinfo.variables or {}
local pattern = fileinfo.pattern or "%${(.-)}"
io.gsub(dstfile_tmp, "(" .. pattern .. ")", function(_, variable)
- return variables[variable]
+
+ -- attempt to get it directly from the configure
+ local result = variables[variable] or config.get(variable)
+ if not result or type(result) ~= "string" then
+
+ -- init maps
+ local maps =
+ {
+ os = platform.os()
+ , host = os.host()
+ }
+ result = maps[variable]
+
+ -- attempt to get it from the platform tools, e.g. cc, cxx, ld ..
+ -- because these values may not exist in config cache when call `config.get()`, we need check and get it.
+ --
+ if not result then
+ result = platform.tool(variable)
+ end
+ end
+ return result
end)
-- update file if the content is changed