summaryrefslogtreecommitdiff
path: root/xmake/core
diff options
context:
space:
mode:
authorruki <[email protected]>2016-06-30 10:17:13 +0800
committerruki <[email protected]>2016-06-30 10:17:13 +0800
commitb3f129d3137855271bd929f4d6df7e51cf99f7ac (patch)
treee4c2b32b01e93c76ecd32fbb7c0af0f2690b5bfa /xmake/core
parent1cdf952d5a7d754a99d21c30930032f91ddf4860 (diff)
fix install config header and update api for template
Diffstat (limited to 'xmake/core')
-rw-r--r--xmake/core/project/target.lua46
1 files changed, 43 insertions, 3 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 991816e96..a1f75be5f 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -139,6 +139,38 @@ function target:targetfile()
return path.join(targetdir, filename)
end
+-- get the config header files
+function target:configheader(outputdir)
+
+ -- get config header
+ local configheader = self:get("config_h")
+ if not configheader then
+ return
+ end
+
+ -- get the root directory
+ local rootdir, count = configheader:gsub("|.*$", ""):gsub("%(.*%)$", "")
+ if count == 0 then
+ rootdir = nil
+ end
+
+ -- remove '(' and ')'
+ configheader = configheader:gsub("[%(%)]", "")
+
+ -- get the output header
+ local outputheader = nil
+ if outputdir then
+ if rootdir then
+ outputheader = path.absolute(path.relative(configheader, rootdir), outputdir)
+ else
+ outputheader = path.join(outputdir, path.filename(configheader))
+ end
+ end
+
+ -- ok
+ return configheader, outputheader
+end
+
-- get the source files
function target:sourcefiles()
@@ -302,7 +334,10 @@ function target:headerfiles(outputdir)
for _, header in ipairs(table.wrap(headers)) do
-- get the root directory
- local rootdir = header:gsub("%(.*%)", ""):gsub("|.*$", "")
+ local rootdir, count = header:gsub("|.*$", ""):gsub("%(.*%)$", "")
+ if count == 0 then
+ rootdir = nil
+ end
-- remove '(' and ')'
local srcpathes = header:gsub("[%(%)]", "")
@@ -318,8 +353,13 @@ function target:headerfiles(outputdir)
-- add the destinate headers
for _, srcpath in ipairs(srcpathes) do
- -- the header
- local dstheader = path.absolute(path.relative(srcpath, rootdir), headerdir)
+ -- the destinate header
+ local dstheader = nil
+ if rootdir then
+ dstheader = path.absolute(path.relative(srcpath, rootdir), headerdir)
+ else
+ dstheader = path.join(headerdir, path.filename(srcpath))
+ end
assert(dstheader)
-- add it