diff options
| author | ruki <[email protected]> | 2020-11-14 18:22:16 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-11-14 18:22:16 +0800 |
| commit | b64d782bc0ae37950aa8d5c7e155a939348820d3 (patch) | |
| tree | 33a4dbe07e67aa5c7da961230608d6f5e9cb01f7 | |
| parent | 76dc49d6ea92fa8d22f24725de7e661f55bce3ca (diff) | |
improve add_patches
| -rw-r--r-- | xmake/core/package/package.lua | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index 2efbf797c..9f1baf523 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -997,12 +997,23 @@ function _instance:patches() local patchinfos = self:get("patches") if patchinfos then local version_str = self:version_str() - patchinfos = patchinfos[version_str] - if patchinfos then + local patchinfo = patchinfos[version_str] + if patchinfo then patches = {} - patchinfos = table.wrap(patchinfos) - for idx = 1, #patchinfos, 2 do - table.insert(patches , {url = patchinfos[idx], sha256 = patchinfos[idx + 1]}) + patchinfo = table.wrap(patchinfo) + for idx = 1, #patchinfo, 2 do + table.insert(patches , {url = patchinfo[idx], sha256 = patchinfo[idx + 1]}) + end + else + -- match semver, e.g add_patches(">=1.0.0", url, sha256) + for range, patchinfo in pairs(patchinfos) do + if semver.satisfies(version_str, range) then + patches = patches or {} + patchinfo = table.wrap(patchinfo) + for idx = 1, #patchinfo, 2 do + table.insert(patches , {url = patchinfo[idx], sha256 = patchinfo[idx + 1]}) + end + end end end end |
