-
Notifications
You must be signed in to change notification settings - Fork 350
[vcpkg-tool] Replace curl command calls with libcurl #1660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
d9cbe4a
add and link libcurl
Neumann-A d6aafe4
Replace curl executable with libcurl API calls
vicroms f5a89c7
Fix FindLibCURL for builds wihthout network access
vicroms 5fc4d4e
Merge branch 'main' of https://github.com/microsoft/vcpkg-tool into l…
vicroms 7b40572
Merge branch 'main' of https://github.com/microsoft/vcpkg-tool into l…
vicroms e7f40e1
Remove winHttp
vicroms da2529c
Restore progress function
vicroms 2865022
Handle non-dl transfer progress
vicroms 60b90a5
Merge branch 'main' of github.com:Microsoft/vcpkg-tool into link-libcurl
vicroms dfe1d47
Remove unused WinHttp code
vicroms 8e0bd40
Merge branch 'main' of github.com:Microsoft/vcpkg-tool into link-libcurl
vicroms 245480c
Format and regenerate messages
vicroms b280137
Fix exepected console output of end-to-end test for multiple authorit…
vicroms 03f06ef
Remove unused parameter
vicroms 1517ce7
Remove unused parameters 2
vicroms a12a086
Format and regenerate messages
vicroms 293fe4e
Fix curl info read loop
vicroms e22b475
Fix warnings and remove unused messages
vicroms 022d2b8
Update src/vcpkg/binarycaching.cpp
vicroms bc7816e
Delete CurlRequestPrivateData (#2)
BillyONeal 4433017
PR comments WIP
vicroms 1daf219
PR comments WIP
vicroms 622f98a
Format and regenerate messages
vicroms 06cb1c3
Merge branch 'main' of github.com:Microsoft/vcpkg-tool into link-libcurl
vicroms f7172f4
Fix download retry
vicroms 2577dee
More review comments
vicroms d76569b
Handle response code from file:// downloads/
vicroms 5a2cd88
Update end-to-end test expected output
vicroms c50352d
Fix download progress
vicroms e8f878d
Add curl license and notices
vicroms 60dd34d
Fix call to upload metrics
vicroms 9cc1edc
Fix expected output comparison with newer versions of libcurl
vicroms 87b7169
Fix expected output comparison with newer versions of libcurl
vicroms 8e2018b
Merge branch 'link-libcurl' of github.com:vicroms/vcpkg-tool into lin…
vicroms 1c53d79
Apply suggestions from code review
vicroms fd741eb
More PR comments
vicroms a9c5782
Disable curl examples and fix out-of-bounds access in retry loop
vicroms File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| if (WIN32) | ||
| option(VCPKG_DEPENDENCY_EXTERNAL_LIBCURL "Use an external version of the libcurl library" OFF) | ||
| else() | ||
| option(VCPKG_DEPENDENCY_EXTERNAL_LIBCURL "Use an external version of the libcurl library" ON) | ||
| endif() | ||
|
|
||
| # This option exists to allow the URI to be replaced with a Microsoft-internal URI in official | ||
| # builds which have restricted internet access; see azure-pipelines/signing.yml | ||
| # Note that the SHA512 is the same, so vcpkg-tool contributors need not be concerned that we built | ||
| # with different content. | ||
| if(NOT VCPKG_LIBCURL_URL) | ||
| set(VCPKG_LIBCURL_URL "https://github.com/curl/curl/archive/refs/tags/curl-8_8_0.tar.gz") | ||
| endif() | ||
|
|
||
| if(POLICY CMP0135) | ||
| cmake_policy(SET CMP0135 NEW) | ||
| endif() | ||
|
|
||
| include(FetchContent) | ||
| FetchContent_Declare( | ||
|
vicroms marked this conversation as resolved.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since curl is a nontrivial build should we consider trying to host ourselves rather than using FetchContent for this case? Our existing other dependencies don't really have meaningful builds which is why we never opened that can of worms. |
||
| LibCURL | ||
| URL "${VCPKG_LIBCURL_URL}" | ||
| URL_HASH "SHA512=e66cbf9bd3ae7b9b031475210b80b883b6a133042fbbc7cf2413f399d1b38aa54ab7322626abd3c6f1af56e0d540221f618aa903bd6b463ac8324f2c4e92dfa8" | ||
| ) | ||
|
|
||
| if(NOT LibCURL_FIND_REQUIRED) | ||
| message(FATAL_ERROR "LibCURL must be REQUIRED") | ||
| endif() | ||
|
|
||
| if(VCPKG_DEPENDENCY_EXTERNAL_LIBCURL) | ||
| find_package(CURL REQUIRED) | ||
| else() | ||
| function(get_libcurl) | ||
| set(BUILD_SHARED_LIBS OFF) | ||
| set(BUILD_CURL_EXE OFF) | ||
| set(CURL_ENABLE_EXPORT_TARGET OFF) | ||
| set(ENABLE_UNICODE ON) | ||
| set(BUILD_LIBCURL_DOCS OFF) | ||
| set(BUILD_MISC_DOCS OFF) | ||
| set(ENABLE_CURL_MANUAL OFF) | ||
| set(PICKY_COMPILER OFF) | ||
| set(CMAKE_DISABLE_FIND_PACKAGE_Perl ON) | ||
| set(CMAKE_DISABLE_FIND_PACKAGE_ZLIB ON) | ||
| set(CMAKE_DISABLE_FIND_PACKAGE_LibPSL ON) | ||
| set(CMAKE_DISABLE_FIND_PACKAGE_LibSSH2 ON) | ||
| if(MSVC) # This is in function() so no need to backup the variables | ||
| string(APPEND CMAKE_C_FLAGS " /wd6101") | ||
| string(APPEND CMAKE_C_FLAGS " /wd6011") | ||
| string(APPEND CMAKE_C_FLAGS " /wd6054") | ||
| string(APPEND CMAKE_C_FLAGS " /wd6240") | ||
| string(APPEND CMAKE_C_FLAGS " /wd6239") | ||
| string(APPEND CMAKE_C_FLAGS " /wd6323") | ||
| string(APPEND CMAKE_C_FLAGS " /wd6387") | ||
| string(APPEND CMAKE_C_FLAGS " /wd28182") | ||
| string(APPEND CMAKE_C_FLAGS " /wd28183") | ||
| string(APPEND CMAKE_C_FLAGS " /wd28251") | ||
| string(APPEND CMAKE_C_FLAGS " /wd28301") | ||
| else() | ||
| string(APPEND CMAKE_C_FLAGS " -Wno-error") | ||
| endif() | ||
| if (WIN32) | ||
| set(CURL_USE_SCHANNEL ON) | ||
| endif() | ||
| FetchContent_MakeAvailable(LibCURL) | ||
| endfunction() | ||
|
|
||
| get_libcurl() | ||
|
|
||
| if(NOT TARGET CURL::libcurl) | ||
| if(TARGET libcurl_static) | ||
| add_library(CURL::libcurl ALIAS libcurl_static) | ||
| target_compile_definitions(libcurl_static INTERFACE CURL_STATICLIB) | ||
| elseif(TARGET libcurl) | ||
| add_library(CURL::libcurl ALIAS libcurl) | ||
| if(NOT BUILD_SHARED_LIBS) | ||
| target_compile_definitions(libcurl INTERFACE CURL_STATICLIB) | ||
| endif() | ||
| else() | ||
| message(FATAL_ERROR "After FetchContent_MakeAvailable(LibCURL) no suitable curl target (libcurl or libcurl_static) was found.") | ||
| endif() | ||
| endif() | ||
| endif() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
|
|
||
| #ifdef _MSC_VER | ||
| #pragma warning(push) // Save current warning state | ||
|
vicroms marked this conversation as resolved.
Outdated
|
||
| #pragma warning(disable : 6101) // Disable specific warning (e.g., warning 4996) | ||
|
vicroms marked this conversation as resolved.
Outdated
|
||
| #endif | ||
|
|
||
| #include <curl/curl.h> | ||
| #include <curl/multi.h> | ||
|
|
||
| #ifdef _MSC_VER | ||
| #pragma warning(pop) | ||
| #endif | ||
|
|
||
| namespace vcpkg | ||
| { | ||
| CURLcode curl_global_init_status() noexcept; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems wrong that we care about which libcurl flavor we get?