build: fix vcpkg binary package list parsing

Fix parsing of package list from the server html, which was ignoring
brotli because it was on the same line as another package. Use a
different method to extract the links that does not rely on them being
on separate lines.

Also fix the errors from `vcpkg list` on new vcpkg clones.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
Rafael Kitover 2023-12-31 15:39:48 +00:00
parent 92d9230e2c
commit 7dc95076e5
No known key found for this signature in database
GPG Key ID: 08AB596679D86240
1 changed files with 15 additions and 15 deletions

View File

@ -145,7 +145,7 @@ function(vcpkg_is_installed vcpkg_exe pkg_name pkg_ver pkg_triplet powershell ou
string(REPLACE "-" "." pkg_ver ${pkg_ver}) string(REPLACE "-" "." pkg_ver ${pkg_ver})
if(NOT DEFINED VCPKG_INSTALLED) if(NOT DEFINED VCPKG_INSTALLED_COUNT)
if(VCPKG_ROOT MATCHES "^C:/Program Files/Microsoft Visual Studio/") if(VCPKG_ROOT MATCHES "^C:/Program Files/Microsoft Visual Studio/")
execute_process( execute_process(
COMMAND ${powershell} COMMAND ${powershell}
@ -157,6 +157,7 @@ function(vcpkg_is_installed vcpkg_exe pkg_name pkg_ver pkg_triplet powershell ou
execute_process( execute_process(
COMMAND ${vcpkg_exe} list COMMAND ${vcpkg_exe} list
OUTPUT_VARIABLE vcpkg_list_text OUTPUT_VARIABLE vcpkg_list_text
ERROR_QUIET
) )
endif() endif()
@ -242,13 +243,14 @@ function(get_binary_packages vcpkg_exe)
endif() endif()
endforeach() endforeach()
unset(binary_packages_html) unset(binary_packages)
foreach(triplet ${triplets}) foreach(triplet ${triplets})
file( file(READ "${CMAKE_BINARY_DIR}/binary_package_list_${triplet}.html" raw_html)
STRINGS "${CMAKE_BINARY_DIR}/binary_package_list_${triplet}.html" links string(REGEX MATCHALL "<a href=\"[^\"]+[.]zip\"" links ${raw_html})
REGEX "<a href=\".*[.]zip" foreach(link ${links})
) string(REGEX REPLACE "<a href=\"([^\"]+[.]zip)\"" "\\1" pkg ${link})
string(APPEND binary_packages_html "${links}\n") list(APPEND binary_packages ${pkg})
endforeach()
endforeach() endforeach()
set(vcpkg_binpkg_dir ${CMAKE_BINARY_DIR}/vcpkg-binpkg) set(vcpkg_binpkg_dir ${CMAKE_BINARY_DIR}/vcpkg-binpkg)
@ -270,13 +272,11 @@ function(get_binary_packages vcpkg_exe)
set(powershell pwsh) set(powershell pwsh)
endif() endif()
unset(binary_packages)
unset(to_install) unset(to_install)
foreach(pkg ${binary_packages_html}) foreach(pkg ${binary_packages})
if(NOT pkg MATCHES "<a href=\"([^_]+)_([^_]+)_([^.]+)[.]zip\"") if(NOT pkg MATCHES "([^_]+)_([^_]+)_([^.]+)[.]zip")
continue() continue()
endif() endif()
set(pkg "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}_${CMAKE_MATCH_3}.zip")
set(pkg_name ${CMAKE_MATCH_1}) set(pkg_name ${CMAKE_MATCH_1})
set(pkg_version ${CMAKE_MATCH_2}) set(pkg_version ${CMAKE_MATCH_2})
set(pkg_triplet ${CMAKE_MATCH_3}) set(pkg_triplet ${CMAKE_MATCH_3})