summaryrefslogtreecommitdiff
path: root/xmake/scripts/base/rule.lua
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/scripts/base/rule.lua')
-rw-r--r--xmake/scripts/base/rule.lua48
1 files changed, 48 insertions, 0 deletions
diff --git a/xmake/scripts/base/rule.lua b/xmake/scripts/base/rule.lua
index 321ceb8c6..0be7aaaab 100644
--- a/xmake/scripts/base/rule.lua
+++ b/xmake/scripts/base/rule.lua
@@ -26,6 +26,7 @@ local rule = rule or {}
-- load modules
local os = require("base/os")
local path = require("base/path")
+local table = require("base/table")
local utils = require("base/utils")
local config = require("base/config")
local platform = require("platform/platform")
@@ -186,5 +187,52 @@ function rule.sourcefiles(target)
return sourcefiles
end
+-- get the header files from the given target
+function rule.headerfiles(target)
+
+ -- check
+ assert(target)
+
+ -- no headers?
+ local headers = target.headers
+ if not headers then return end
+
+ -- get the headerdir
+ local headerdir = target.headerdir or config.get("buildir")
+ assert(headerdir)
+
+ -- get the source pathes and destinate pathes
+ local srcheaders = {}
+ local dstheaders = {}
+ for _, header in ipairs(utils.wrap(headers)) do
+
+ -- get the root directory
+ local rootdir = header:gsub("%(.*%)", "")
+
+ -- remove '(' and ')'
+ local srcpathes = header:gsub("[%(%)]", "")
+ if srcpathes then
+
+ -- get the source pathes
+ srcpathes = os.match(srcpathes)
+ if srcpathes then
+
+ -- add the source headers
+ table.join2(srcheaders, srcpathes)
+
+ -- add the destinate headers
+ local i = 1
+ for _, srcpath in ipairs(srcpathes) do
+ dstheaders[i] = path.absolute(path.relative(srcpath, rootdir), headerdir)
+ i = i + 1
+ end
+ end
+ end
+ end
+
+ -- ok?
+ return srcheaders, dstheaders
+end
+
-- return module: rule
return rule