diff options
| author | ruki <[email protected]> | 2024-03-14 23:37:37 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-03-14 23:37:37 +0800 |
| commit | e971dacae2e572575b5ef11d37cbfde2785b4daf (patch) | |
| tree | ead9d9688e4fedb2fc4c36476e69b27069c8c65b /xmake/plugins/pack/xpack_component.lua | |
| parent | 5af56d8d7d820a3b7c88e337bdc3a397499bd06a (diff) | |
improve xpack
Diffstat (limited to 'xmake/plugins/pack/xpack_component.lua')
| -rw-r--r-- | xmake/plugins/pack/xpack_component.lua | 87 |
1 files changed, 3 insertions, 84 deletions
diff --git a/xmake/plugins/pack/xpack_component.lua b/xmake/plugins/pack/xpack_component.lua index 5dc6ec10f..2cca2485f 100644 --- a/xmake/plugins/pack/xpack_component.lua +++ b/xmake/plugins/pack/xpack_component.lua @@ -24,6 +24,7 @@ import("core.base.option") import("core.project.config") import("core.project.project") import("private.core.base.select_script") +import("private.core.base.match_copyfiles") -- define module local xpack_component = xpack_component or object {_init = {"_name", "_info", "_package"}} @@ -107,88 +108,6 @@ function xpack_component:target(name) end end --- get the copied files -function xpack_component:_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 package function xpack_component:package() return self._package @@ -196,7 +115,7 @@ end -- get the install files function xpack_component:installfiles() - return self:_copiedfiles("installfiles", self:package():installdir()) + return match_copyfiles(self, "installfiles", self:package():installdir()) end -- get the installed root directory, this is just a temporary sandbox installation path, @@ -212,7 +131,7 @@ end -- get the source files function xpack_component:sourcefiles() - return self:_copiedfiles("sourcefiles", self:package():sourcedir()) + return match_copyfiles(self, "sourcefiles", self:package():sourcedir()) end -- get the source root directory |
