diff options
| author | ruki <[email protected]> | 2021-04-18 22:22:07 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-04-18 22:22:07 +0800 |
| commit | dbd3a2970da280b42f93a79caeb65e29034ba2bd (patch) | |
| tree | 981074cc237eb45a6c6426d1ff738abeea7fc3da /xmake | |
| parent | a87d6552004a1fb9f89c29bb89f6918b22aedb3c (diff) | |
improve to search package file
Diffstat (limited to 'xmake')
| -rw-r--r-- | xmake/modules/private/action/require/impl/actions/download.lua | 20 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/info.lua | 4 |
2 files changed, 19 insertions, 5 deletions
diff --git a/xmake/modules/private/action/require/impl/actions/download.lua b/xmake/modules/private/action/require/impl/actions/download.lua index 01d75025c..019b01ae8 100644 --- a/xmake/modules/private/action/require/impl/actions/download.lua +++ b/xmake/modules/private/action/require/impl/actions/download.lua @@ -118,14 +118,24 @@ function _download(package, url, sourcedir, url_alias, url_excludes) os.tryrm(packagefile) -- download or copy package file - local localfile = find_file(path.filename(packagefile), core_package.searchdirs()) if os.isfile(url) then os.cp(url, packagefile) - elseif localfile and os.isfile(localfile) then - -- we can use local package from the search directories directly if network is too slow - os.cp(localfile, packagefile) else - http.download(url, packagefile) + local localfile + local searchnames = {package:name() .. "-" .. package:version_str() .. archive.extension(url), + packagefile} + for _, searchname in ipairs(searchnames) do + localfile = find_file(searchname, core_package.searchdirs()) + if localfile then + break + end + end + if localfile and os.isfile(localfile) then + -- we can use local package from the search directories directly if network is too slow + os.cp(localfile, packagefile) + else + http.download(url, packagefile) + end end -- check hash diff --git a/xmake/modules/private/action/require/info.lua b/xmake/modules/private/action/require/info.lua index ecb8ba7d6..963488104 100644 --- a/xmake/modules/private/action/require/info.lua +++ b/xmake/modules/private/action/require/info.lua @@ -154,6 +154,10 @@ function main(requires_raw) local searchnames = hashset.new() for _, url in ipairs(instance:urls()) do url = filter.handle(url, instance) + local extension = archive.extension(url) + if extension then + searchnames:insert(instance:name() .. "-" .. instance:version_str() .. extension) + end searchnames:insert(url_filename(url)) end cprint(" -> ${magenta}searchnames${clear}: %s", table.concat(searchnames:to_array(), ", ")) |
