Skip to content

[vcpkg-tool] Replace curl command calls with libcurl - #1660

Merged
Victor Romero (vicroms) merged 37 commits into
microsoft:mainfrom
vicroms:link-libcurl
Nov 17, 2025
Merged

[vcpkg-tool] Replace curl command calls with libcurl#1660
Victor Romero (vicroms) merged 37 commits into
microsoft:mainfrom
vicroms:link-libcurl

Conversation

@vicroms

@vicroms Victor Romero (vicroms) commented Apr 22, 2025

Copy link
Copy Markdown
Member

Summary by Copilot:

This PR replaces the existing curl command line tool usage with direct libcurl API calls throughout the vcpkg codebase. The main goal is to improve reliability, error handling, and reduce external dependencies by using libcurl directly instead of spawning curl subprocesses.

  • Install libcurl headers on Linux CI runners.
  • Replace curl command-line invocations with libcurl API calls
  • Add new libcurl infrastructure with proper initialization and error handling
  • Update test expectations to match new libcurl error message format
  • Make z-upload-metrics work on non-Windows platforms

Before merging these changes, we require confirmation from telemetry that the large majority of non-Windows users have a system-installed libcurl.

TODO:

  • Add license notice

This comment was marked as outdated.

@microsoft Microsoft (microsoft) deleted a comment from Copilot AI Aug 22, 2025
@vicroms
Victor Romero (vicroms) force-pushed the link-libcurl branch 3 times, most recently from dedafaf to 8a25177 Compare August 22, 2025 09:37
Comment thread cmake/FindLibCURL.cmake Outdated
Comment thread cmake/FindLibCURL.cmake Outdated

This comment was marked as outdated.

This comment was marked as outdated.

@vicroms
Victor Romero (vicroms) force-pushed the link-libcurl branch 2 times, most recently from 64cfadf to cddb978 Compare August 25, 2025 21:23
Comment thread src/vcpkg.cpp Outdated
Comment thread src/vcpkg.cpp Outdated
Comment thread src/vcpkg/base/downloads.cpp Outdated
@microsoft Microsoft (microsoft) deleted a comment from Copilot AI Aug 28, 2025
@microsoft Microsoft (microsoft) deleted a comment from Copilot AI Aug 28, 2025
@microsoft Microsoft (microsoft) deleted a comment from Copilot AI Aug 28, 2025
@vicroms Victor Romero (vicroms) changed the title [WIP][vcpkg-tool] Replace curl command calls with libcurl [vcpkg-tool] Replace curl command calls with libcurl Aug 28, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces the existing curl command line tool usage with direct libcurl API calls throughout the vcpkg codebase. The goal is to improve reliability, error handling, and reduce external dependencies by using libcurl directly instead of spawning curl subprocesses.

Key changes include:

  • Adding new libcurl infrastructure with proper initialization and error handling
  • Replacing all curl command-line invocations with libcurl API calls in download, upload, and metrics functionality
  • Making the z-upload-metrics command work on non-Windows platforms by removing the Windows-only restriction

Reviewed Changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/vcpkg/metrics.cpp Replaces WinHTTP metrics upload with libcurl implementation and updates background process execution
src/vcpkg/commands.z-upload-metrics.cpp Removes Windows-only restriction and adds file deletion after upload
src/vcpkg/base/downloads.cpp Replaces all curl command-line calls with libcurl API calls for downloads, uploads, and HTTP requests
src/vcpkg/base/curl.cpp Adds new libcurl global initialization infrastructure
include/vcpkg/base/curl.h Provides libcurl header includes and initialization function
src/vcpkg/base/files.cpp Adds file size methods to ReadFilePointer for libcurl upload functionality
CMakeLists.txt Adds libcurl dependency and linking configuration
locales/messages.json Updates error message formats to match libcurl error reporting

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/vcpkg/base/downloads.cpp Outdated
Comment thread src/vcpkg/base/downloads.cpp Outdated
Comment thread cmake/FindLibCURL.cmake
@vicroms
Victor Romero (vicroms) marked this pull request as ready for review November 7, 2025 17:33
Comment thread src/vcpkg/base/curl.cpp Outdated
Comment thread src/vcpkg/base/curl.cpp Outdated
Comment thread include/vcpkg/base/curl.h Outdated
Comment thread src/vcpkg/base/curl.cpp Outdated
Comment thread src/vcpkg/base/curl.cpp Outdated
Comment thread src/vcpkg/commands.z-upload-metrics.cpp Outdated
Comment thread src/vcpkg/metrics.cpp Outdated
Comment thread src/vcpkg/metrics.cpp
Comment on lines +556 to +559
maybe_accepted->is_integer() && maybe_errors->is_array())
{
auto item_received = maybe_received->integer(VCPKG_LINE_INFO);
auto item_accepted = maybe_accepted->integer(VCPKG_LINE_INFO);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fan of this check followed by assert pattern but there's currently no maybe_integer so no change requested for now.

Comment thread include/vcpkg/metrics.h Outdated
Comment thread src/vcpkg/base/downloads.cpp Outdated
Comment thread .github/workflows/build.yaml
Comment thread cmake/FindLibCURL.cmake Outdated
Comment thread cmake/FindLibCURL.cmake
Comment on lines +53 to +57
set(CMAKE_DISABLE_FIND_PACKAGE_ZLIB ON)
set(CMAKE_DISABLE_FIND_PACKAGE_LibPSL ON)
set(CMAKE_DISABLE_FIND_PACKAGE_LibSSH2 ON)
set(CMAKE_DISABLE_FIND_PACKAGE_Brotli ON)
set(CMAKE_DISABLE_FIND_PACKAGE_Zstd ON)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another reason to consider hosting ourselves rather than FetchContent would be to more easily support ZLIB for Content-encoding: deflate or gzip.

Co-authored-by: Billy O'Neal <bion@microsoft.com>
Co-authored-by: Thomas1664 <46387399+Thomas1664@users.noreply.github.com>
Comment thread cmake/FindLibCURL.cmake
Comment thread src/vcpkg/base/downloads.cpp Outdated
@vicroms
Victor Romero (vicroms) merged commit 1cc117b into microsoft:main Nov 17, 2025
7 checks passed
Billy O'Neal (BillyONeal) added a commit to BillyONeal/vcpkg-tool that referenced this pull request Nov 18, 2025
Billy O'Neal (BillyONeal) added a commit to BillyONeal/vcpkg-tool that referenced this pull request Nov 18, 2025
…ft#1660)"

This reverts commit 1cc117b.

# Conflicts:
#	locales/messages.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants