diff options
Diffstat (limited to 'xmake/plugins/pack/xpack.lua')
| -rw-r--r-- | xmake/plugins/pack/xpack.lua | 87 |
1 files changed, 3 insertions, 84 deletions
diff --git a/xmake/plugins/pack/xpack.lua b/xmake/plugins/pack/xpack.lua index 484aa3e2a..0afc62868 100644 --- a/xmake/plugins/pack/xpack.lua +++ b/xmake/plugins/pack/xpack.lua @@ -26,6 +26,7 @@ import("core.base.hashset") import("core.project.config") import("core.project.project") import("private.core.base.select_script") +import("private.core.base.match_copyfiles") import("lib.detect.find_tool") import("filter") import("xpack_component") @@ -382,91 +383,9 @@ function xpack:version() return version, version_build end --- get the copied files -function xpack:_copiedfiles(filetype, outputdir) - - -- no copied files? - local copiedfiles = self:get(filetype) - if not copiedfiles then return end - - -- get the extra information - local extrainfo = table.wrap(self:extraconf(filetype)) - - -- get the source paths and destinate paths - local srcfiles = {} - local dstfiles = {} - local fileinfos = {} - for _, copiedfile in ipairs(table.wrap(copiedfiles)) do - - -- get the root directory - local rootdir, count = copiedfile:gsub("|.*$", ""):gsub("%(.*%)$", "") - if count == 0 then - rootdir = nil - end - if rootdir and rootdir:trim() == "" then - rootdir = "." - end - - -- remove '(' and ')' - local srcpaths = copiedfile:gsub("[%(%)]", "") - if srcpaths then - - -- get the source paths - srcpaths = os.match(srcpaths) - if srcpaths and #srcpaths > 0 then - - -- add the source copied files - table.join2(srcfiles, srcpaths) - - -- the copied directory exists? - if outputdir then - - -- get the file info - local fileinfo = extrainfo[copiedfile] or {} - - -- get the prefix directory - local prefixdir = fileinfo.prefixdir - if fileinfo.rootdir then - rootdir = fileinfo.rootdir - end - - -- add the destinate copied files - for _, srcpath in ipairs(srcpaths) do - - -- get the destinate directory - local dstdir = outputdir - if prefixdir then - dstdir = path.join(dstdir, prefixdir) - end - - -- the destinate file - local dstfile = nil - if rootdir then - dstfile = path.absolute(path.relative(srcpath, rootdir), dstdir) - else - dstfile = path.join(dstdir, path.filename(srcpath)) - end - assert(dstfile) - - -- modify filename - if fileinfo.filename then - dstfile = path.join(path.directory(dstfile), fileinfo.filename) - end - - -- add it - table.insert(dstfiles, dstfile) - table.insert(fileinfos, fileinfo) - end - end - end - end - end - return srcfiles, dstfiles, fileinfos -end - -- get the install files function xpack:installfiles() - return self:_copiedfiles("installfiles", self:installdir()) + return match_copyfiles(self, "installfiles", self:installdir()) end -- get the installed root directory, this is just a temporary sandbox installation path, @@ -487,7 +406,7 @@ end -- get the source files function xpack:sourcefiles() - return self:_copiedfiles("sourcefiles", self:sourcedir()) + return match_copyfiles(self, "sourcefiles", self:sourcedir()) end -- get the source root directory |
