diff options
| author | ruki <[email protected]> | 2020-01-15 22:51:18 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-01-15 11:07:48 +0800 |
| commit | 20cf6c946fc6c3a09205dc8d4e768ab9d2b001ca (patch) | |
| tree | 47b976574dc68d456537d45504c9afc41f9a3d52 /xmake/core/package/package.lua | |
| parent | eb1effdccd96425375af083d45a94a790f0c6d56 (diff) | |
download resources for package
Diffstat (limited to 'xmake/core/package/package.lua')
| -rw-r--r-- | xmake/core/package/package.lua | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index df9ba6435..83e8f82ba 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -939,7 +939,8 @@ function _instance:resources() resources = {} resourceinfos = table.wrap(resourceinfos) for idx = 1, #resourceinfos, 3 do - table.insert(resources, {name = resourceinfos[idx], url = resourceinfos[idx + 1], sha256 = resourceinfos[idx + 2]}) + local name = resourceinfos[idx] + resources[name] = {url = resourceinfos[idx + 1], sha256 = resourceinfos[idx + 2]} end end end @@ -948,6 +949,28 @@ function _instance:resources() return resources and resources or nil end +-- get the the given resource +function _instance:resource(name) + local resources = self:resources() + return resources and resources[name] or nil +end + +-- get the the given resource file +function _instance:resourcefile(name) + local resource = self:resource(name) + if resource and resource.url then + return path.join(self:cachedir(), "resources", name, (path.filename(resource.url):gsub("%?.+$", ""))) + end +end + +-- get the the given resource directory +function _instance:resourcedir(name) + local resource = self:resource(name) + if resource and resource.url then + return path.join(self:cachedir(), "resources", name, (path.filename(resource.url):gsub("%?.+$", "")) .. ".dir") + end +end + -- has the given c funcs? -- -- @param funcs the funcs |
