Skip to content

Commit

Permalink
Merge branch 'main' into bc-vector
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas1664 authored Feb 18, 2024
2 parents 714186c + 05320e4 commit e10e97b
Show file tree
Hide file tree
Showing 122 changed files with 2,252 additions and 2,014 deletions.
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
}
],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.organizeImports": true
"source.fixAll.eslint": "explicit",
"source.organizeImports": "explicit"
},
"eslint.format.enable": true,
"files.eol": "\n",
Expand Down
55 changes: 34 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ if(MSVC)
string(APPEND CMAKE_EXE_LINKER_FLAGS_RELEASE " /CETCOMPAT")
endif()

# Avoid CMake's default taking of the pretty names
string(REPLACE "/DAMD64" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string(REPLACE "/DAMD64" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "/DARM64EC" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string(REPLACE "/DARM64EC" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

if(VCPKG_DEVELOPMENT_WARNINGS)
string(APPEND CMAKE_C_FLAGS " /W4 /sdl")
string(APPEND CMAKE_CXX_FLAGS " /W4 /sdl")
Expand Down Expand Up @@ -155,6 +161,24 @@ endif()

include(GNUInstallDirs)

file(GLOB VCPKGLIB_BASE_SOURCES CONFIGURE_DEPENDS "src/vcpkg/base/*.cpp")
file(GLOB VCPKGLIB_SOURCES CONFIGURE_DEPENDS "src/vcpkg/*.cpp")
file(GLOB VCPKGLIB_BASE_INCLUDES CONFIGURE_DEPENDS "include/vcpkg/base/*.h" "include/vcpkg/base/fwd/*.h")
file(GLOB VCPKGLIB_INCLUDES CONFIGURE_DEPENDS "include/vcpkg/*.h" "include/vcpkg/fwd/*.h")

set(VCPKG_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg.cpp")

file(GLOB VCPKG_TEST_SOURCES CONFIGURE_DEPENDS "src/vcpkg-test/*.cpp")
file(GLOB VCPKG_TEST_INCLUDES CONFIGURE_DEPENDS "include/vcpkg-test/*.h")

set(VCPKG_FUZZ_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg-fuzz/main.cpp")
set(TLS12_DOWNLOAD_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/tls12-download.c")
set(CLOSES_STDIN_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/closes-stdin.c")
set(CLOSES_STDOUT_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/closes-stdout.c")
set(READS_STDIN_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/reads-stdin.c")
set(TEST_EDITOR_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/test-editor.c")
set(TEST_SCRIPT_ASSET_CACHE_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/test-script-asset-cache.c")

# ====================
# === Dependencies ===
# ====================
Expand All @@ -181,11 +205,6 @@ endif()

# === Target: vcpkglib ===

file(GLOB VCPKGLIB_SOURCES CONFIGURE_DEPENDS "src/vcpkg/*.cpp")
file(GLOB VCPKGLIB_BASE_SOURCES CONFIGURE_DEPENDS "src/vcpkg/base/*.cpp")
file(GLOB VCPKGLIB_INCLUDES CONFIGURE_DEPENDS "include/vcpkg/*.h" "include/vcpkg/fwd/*.h")
file(GLOB VCPKGLIB_BASE_INCLUDES CONFIGURE_DEPENDS "include/vcpkg/base/*.h" "include/vcpkg/base/fwd/*.h")

add_library(vcpkglib OBJECT
${VCPKGLIB_BASE_SOURCES}
${VCPKGLIB_SOURCES}
Expand Down Expand Up @@ -431,7 +450,7 @@ add_custom_command(
add_custom_target(vcpkg-ps1 ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/vcpkg.ps1")

# === Target: vcpkg ===
set(VCPKG_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg.cpp")

add_executable(vcpkg ${VCPKG_SOURCES} "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg.manifest")
target_link_libraries(vcpkg PRIVATE vcpkglib)

Expand Down Expand Up @@ -466,9 +485,6 @@ add_custom_target(generate-message-map
if (BUILD_TESTING)
enable_testing()

file(GLOB VCPKG_TEST_SOURCES CONFIGURE_DEPENDS "src/vcpkg-test/*.cpp")
file(GLOB VCPKG_TEST_INCLUDES CONFIGURE_DEPENDS "include/vcpkg-test/*.h")

add_executable(vcpkg-test
${VCPKG_TEST_SOURCES}
${VCPKG_TEST_INCLUDES}
Expand Down Expand Up @@ -496,7 +512,6 @@ if (BUILD_TESTING)
endif()

# === Target: vcpkg-fuzz ===
set(VCPKG_FUZZ_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg-fuzz/main.cpp")
if(VCPKG_BUILD_FUZZING)
add_executable(vcpkg-fuzz ${VCPKG_FUZZ_SOURCES} "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg.manifest")
target_link_libraries(vcpkg-fuzz PRIVATE vcpkglib)
Expand All @@ -505,7 +520,7 @@ endif()


# === Target: tls12-download ===
set(TLS12_DOWNLOAD_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/tls12-download.c")

if(VCPKG_BUILD_TLS12_DOWNLOADER)
add_executable(tls12-download ${TLS12_DOWNLOAD_SOURCES} "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg.manifest")
set_property(TARGET tls12-download PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded")
Expand All @@ -517,27 +532,28 @@ endif()
if (BUILD_TESTING)
# === Target: closes-stdin ===

set(CLOSES_STDIN_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/closes-stdin.c")
add_executable(closes-stdin ${CLOSES_STDIN_SOURCES} "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg.manifest")
set_property(TARGET closes-stdin PROPERTY PDB_NAME "closes-stdin${VCPKG_PDB_SUFFIX}")

# === Target: closes-stdout ===

set(CLOSES_STDOUT_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/closes-stdout.c")
add_executable(closes-stdout ${CLOSES_STDOUT_SOURCES} "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg.manifest")
set_property(TARGET closes-stdout PROPERTY PDB_NAME "closes-stdout${VCPKG_PDB_SUFFIX}")

# === Target: reads-stdin ===

set(READS_STDIN_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/reads-stdin.c")
add_executable(reads-stdin ${READS_STDIN_SOURCES} "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg.manifest")
set_property(TARGET reads-stdin PROPERTY PDB_NAME "reads-stdin${VCPKG_PDB_SUFFIX}")

# === Target: test-editor ===

set(TEST_EDITOR_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/test-editor.c")
add_executable(test-editor ${TEST_EDITOR_SOURCES} "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg.manifest")
set_property(TARGET test-editor PROPERTY PDB_NAME "test-editor${VCPKG_PDB_SUFFIX}")

# === Target: test-editor ===

add_executable(test-script-asset-cache ${TEST_SCRIPT_ASSET_CACHE_SOURCES} "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg.manifest")
set_property(TARGET test-script-asset-cache PROPERTY PDB_NAME "test-script-asset-cache${VCPKG_PDB_SUFFIX}")
endif()

# === Target: format ===
Expand All @@ -557,12 +573,9 @@ if(CLANG_FORMAT)
COMMAND "${CLANG_FORMAT}" -i -verbose ${VCPKG_TEST_SOURCES}
COMMAND "${CLANG_FORMAT}" -i -verbose ${VCPKG_TEST_INCLUDES}

COMMAND "${CLANG_FORMAT}" -i -verbose ${VCPKG_FUZZ_SOURCES}
COMMAND "${CLANG_FORMAT}" -i -verbose ${TLS12_DOWNLOAD_SOURCES}
COMMAND "${CLANG_FORMAT}" -i -verbose ${CLOSES_STDIN_SOURCES}
COMMAND "${CLANG_FORMAT}" -i -verbose ${CLOSES_STDOUT_SOURCES}
COMMAND "${CLANG_FORMAT}" -i -verbose ${READS_STDIN_SOURCES}
COMMAND "${CLANG_FORMAT}" -i -verbose ${TEST_EDITOR_SOURCES}
COMMAND "${CLANG_FORMAT}" -i -verbose ${VCPKG_FUZZ_SOURCES} ${TLS12_DOWNLOAD_SOURCES}
${CLOSES_STDIN_SOURCES} ${CLOSES_STDOUT_SOURCES} ${READS_STDIN_SOURCES}
${TEST_EDITOR_SOURCES} ${TEST_SCRIPT_ASSET_CACHE_SOURCES}
)
endif()

Expand Down
14 changes: 14 additions & 0 deletions azure-pipelines/e2e-ports/vcpkg-test-x-script/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This port is for testing that x-script works; see test-script-asset-cache.c
vcpkg_download_distfile(
SOURCE_PATH
URLS https://example.com/hello-world.txt
SHA512 09E1E2A84C92B56C8280F4A1203C7CFFD61B162CFE987278D4D6BE9AFBF38C0E8934CDADF83751F4E99D111352BFFEFC958E5A4852C8A7A29C95742CE59288A8
FILENAME hello-world.txt
)

file(READ "${SOURCE_PATH}" CONTENTS)
if (NOT CONTENTS STREQUAL "Hello, world!\n")
message(FATAL_ERROR "Downloaded file has incorrect contents: ${CONTENTS}")
endif()

set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
4 changes: 4 additions & 0 deletions azure-pipelines/e2e-ports/vcpkg-test-x-script/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "vcpkg-test-x-script",
"version-string": "1.0.0"
}
5 changes: 5 additions & 0 deletions azure-pipelines/end-to-end-tests-dir/asset-caching.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
. $PSScriptRoot/../end-to-end-tests-prelude.ps1

Refresh-TestRoot
Run-Vcpkg -TestArgs ($commonArgs + @("install", "vcpkg-test-x-script", "--x-binarysource=clear", "--overlay-ports=$PSScriptRoot/../e2e-ports", "--x-asset-sources=x-script,$TestScriptAssetCacheExe {url} {sha512} {dst};x-block-origin"))
Throw-IfFailed
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ $commonArgs += @(
)

# Test simple installation
Run-Vcpkg -TestArgs ($commonArgs + @("install", "vcpkg-hello-world-1", "vcpkg-cmake", "vcpkg-cmake-config", "--binarycaching", "--x-binarysource=clear;files,$ArchiveRoot,write"))
Run-Vcpkg -TestArgs ($commonArgs + @("install", "vcpkg-hello-world-1", "vcpkg-cmake", "vcpkg-cmake-config", "--x-binarysource=clear;files,$ArchiveRoot,write"))
Throw-IfFailed

# Test simple removal
Expand All @@ -16,14 +16,14 @@ Require-FileNotExists "$installRoot/$Triplet/include"

if(-Not $IsLinux -and -Not $IsMacOS) {
# Test simple nuget installation
Run-Vcpkg -TestArgs ($commonArgs + @("install", "vcpkg-hello-world-1", "vcpkg-cmake", "vcpkg-cmake-config", "--binarycaching", "--x-binarysource=clear;nuget,$NuGetRoot,readwrite"))
Run-Vcpkg -TestArgs ($commonArgs + @("install", "vcpkg-hello-world-1", "vcpkg-cmake", "vcpkg-cmake-config", "--x-binarysource=clear;nuget,$NuGetRoot,readwrite"))
Throw-IfFailed
}

# Test restoring from files archive
Remove-Item -Recurse -Force $installRoot
Remove-Item -Recurse -Force $buildtreesRoot
Run-Vcpkg -TestArgs ($commonArgs + @("install","vcpkg-hello-world-1", "vcpkg-cmake", "vcpkg-cmake-config","--binarycaching","--x-binarysource=clear;files,$ArchiveRoot,read"))
Run-Vcpkg -TestArgs ($commonArgs + @("install","vcpkg-hello-world-1", "vcpkg-cmake", "vcpkg-cmake-config", "--x-binarysource=clear;files,$ArchiveRoot,read"))
Throw-IfFailed
Require-FileExists "$installRoot/$Triplet/include/hello-1.h"
Require-FileNotExists "$buildtreesRoot/vcpkg-hello-world-1/src"
Expand All @@ -32,7 +32,7 @@ Require-FileExists "$buildtreesRoot/detect_compiler"
# Test --no-binarycaching
Remove-Item -Recurse -Force $installRoot
Remove-Item -Recurse -Force $buildtreesRoot
Run-Vcpkg -TestArgs ($commonArgs + @("install","vcpkg-hello-world-1", "vcpkg-cmake", "vcpkg-cmake-config","--no-binarycaching","--x-binarysource=clear;files,$ArchiveRoot,read"))
Run-Vcpkg -TestArgs ($commonArgs + @("install","vcpkg-hello-world-1", "vcpkg-cmake", "vcpkg-cmake-config", "--no-binarycaching", "--x-binarysource=clear;files,$ArchiveRoot,read"))
Throw-IfFailed
Require-FileExists "$installRoot/$Triplet/include/hello-1.h"
Require-FileExists "$buildtreesRoot/vcpkg-hello-world-1/src"
Expand All @@ -41,7 +41,7 @@ Require-FileExists "$buildtreesRoot/detect_compiler"
# Test --editable
Remove-Item -Recurse -Force $installRoot
Remove-Item -Recurse -Force $buildtreesRoot
Run-Vcpkg -TestArgs ($commonArgs + @("install","vcpkg-hello-world-1", "vcpkg-cmake", "vcpkg-cmake-config","--editable","--x-binarysource=clear;files,$ArchiveRoot,read"))
Run-Vcpkg -TestArgs ($commonArgs + @("install","vcpkg-hello-world-1", "vcpkg-cmake", "vcpkg-cmake-config", "--editable", "--x-binarysource=clear;files,$ArchiveRoot,read"))
Throw-IfFailed
Require-FileExists "$installRoot/$Triplet/include/hello-1.h"
Require-FileExists "$buildtreesRoot/vcpkg-hello-world-1/src"
Expand All @@ -51,7 +51,7 @@ if(-Not $IsLinux -and -Not $IsMacOS) {
# Test restoring from nuget
Remove-Item -Recurse -Force $installRoot
Remove-Item -Recurse -Force $buildtreesRoot
Run-Vcpkg -TestArgs ($commonArgs + @("install", "vcpkg-hello-world-1", "vcpkg-cmake", "vcpkg-cmake-config", "--binarycaching", "--x-binarysource=clear;nuget,$NuGetRoot"))
Run-Vcpkg -TestArgs ($commonArgs + @("install", "vcpkg-hello-world-1", "vcpkg-cmake", "vcpkg-cmake-config", "--x-binarysource=clear;nuget,$NuGetRoot"))
Throw-IfFailed
Require-FileExists "$installRoot/$Triplet/include/hello-1.h"
Require-FileNotExists "$buildtreesRoot/vcpkg-hello-world-1/src"
Expand All @@ -72,7 +72,7 @@ if(-Not $IsLinux -and -Not $IsMacOS) {
Throw-IfFailed
Remove-Item -Recurse -Force $NuGetRoot -ErrorAction SilentlyContinue
mkdir $NuGetRoot
Run-Vcpkg -TestArgs ($commonArgs + @("install", "vcpkg-hello-world-1", "vcpkg-hello-world-2", "vcpkg-cmake", "vcpkg-cmake-config", "--binarycaching", "--x-binarysource=clear;nuget,$NuGetRoot2;nuget,$NuGetRoot,write"))
Run-Vcpkg -TestArgs ($commonArgs + @("install", "vcpkg-hello-world-1", "vcpkg-hello-world-2", "vcpkg-cmake", "vcpkg-cmake-config", "--x-binarysource=clear;nuget,$NuGetRoot2;nuget,$NuGetRoot,write"))
Throw-IfFailed
Require-FileExists "$installRoot/$Triplet/include/hello-1.h"
Require-FileExists "$installRoot/$Triplet/include/hello-2.h"
Expand Down
36 changes: 36 additions & 0 deletions azure-pipelines/end-to-end-tests-dir/cli.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,42 @@ Throw-IfNotFailed
Run-Vcpkg -TestArgs ($commonArgs + @("install", "vcpkg-hello-world-1", "--fast")) # --fast is not a switch
Throw-IfNotFailed

# Test switching stdout vs. stderr for help topics and errors
[string]$out = Run-VcpkgAndCaptureOutput -TestArgs @('help')
Throw-IfFailed
if (-Not ($out.StartsWith('usage: vcpkg <command> [--switches] [--options=values] [arguments] @response_file')))
{
throw 'Bad help output'
}

$out = Run-VcpkgAndCaptureOutput -TestArgs @('help', 'help')
Throw-IfFailed
if (-Not ($out.StartsWith('Synopsis: Displays specific help topic')))
{
throw 'Bad help help output'
}

$out = Run-VcpkgAndCaptureStdErr -TestArgs @('help', 'not-a-topic')
Throw-IfNotFailed
if (-Not ($out.StartsWith('error: unknown topic not-a-topic')))
{
throw 'Bad help not-a-topic output'
}

$out = Run-VcpkgAndCaptureStdErr -TestArgs @('not-a-command')
Throw-IfNotFailed
if (-Not ($out.StartsWith('error: invalid command: not-a-command')))
{
throw 'Bad not-a-command output'
}

$out = Run-VcpkgAndCaptureStdErr -TestArgs @('install', '--not-a-switch')
Throw-IfNotFailed
if (-Not ($out.StartsWith('error: unexpected switch: --not-a-switch')))
{
throw 'Bad install --not-a-switch output'
}

if ($IsWindows) {
$warningText = 'In the September 2023 release'

Expand Down
41 changes: 21 additions & 20 deletions azure-pipelines/end-to-end-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,21 @@ if ([string]::IsNullOrWhitespace($VcpkgRoot)) {

$VcpkgRoot = (Get-Item $VcpkgRoot).FullName

[string]$executableExtension = ''
if ($IsWindows)
{
$executableExtension = '.exe'
}

if ([string]::IsNullOrEmpty($VcpkgExe))
{
if ($IsWindows)
{
$VcpkgExe = Get-Item './vcpkg.exe'
}
else
{
$VcpkgExe = Get-Item './vcpkg'
}
$VcpkgExe = "./vcpkg$executableExtension"
}

$VcpkgItem = Get-Item $VcpkgExe
$VcpkgExe = $VcpkgItem.FullName
$VcpkgPs1 = Join-Path $VcpkgItem.Directory "vcpkg.ps1"
$TestScriptAssetCacheExe = Join-Path $VcpkgItem.Directory "test-script-asset-cache"

[Array]$AllTests = Get-ChildItem $PSScriptRoot/end-to-end-tests-dir/*.ps1
if ($Filter -ne $Null) {
Expand All @@ -84,17 +84,18 @@ $n = 1
$m = $AllTests.Count

$envvars_clear = @(
"VCPKG_FORCE_SYSTEM_BINARIES",
"VCPKG_FORCE_DOWNLOADED_BINARIES",
"VCPKG_DEFAULT_HOST_TRIPLET",
"VCPKG_DEFAULT_TRIPLET",
"VCPKG_BINARY_SOURCES",
"VCPKG_OVERLAY_PORTS",
"VCPKG_OVERLAY_TRIPLETS",
"VCPKG_KEEP_ENV_VARS",
"VCPKG_ROOT",
"VCPKG_FEATURE_FLAGS",
"VCPKG_DISABLE_METRICS"
'VCPKG_BINARY_SOURCES',
'VCPKG_DEFAULT_HOST_TRIPLET',
'VCPKG_DEFAULT_TRIPLET',
'VCPKG_DISABLE_METRICS',
'VCPKG_FEATURE_FLAGS',
'VCPKG_FORCE_DOWNLOADED_BINARIES',
'VCPKG_FORCE_SYSTEM_BINARIES',
'VCPKG_KEEP_ENV_VARS',
'VCPKG_OVERLAY_PORTS',
'VCPKG_OVERLAY_TRIPLETS',
'VCPKG_ROOT',
'X_VCPKG_ASSET_SOURCES'
)
$envvars = $envvars_clear + @("VCPKG_DOWNLOADS", "X_VCPKG_REGISTRIES_CACHE", "PATH")

Expand Down Expand Up @@ -128,7 +129,7 @@ foreach ($Test in $AllTests)
{
foreach ($var in $envvars)
{
if ($envbackup[$var] -eq $null)
if ($null -eq $envbackup[$var])
{
if (Test-Path "Env:\$var")
{
Expand Down
Loading

0 comments on commit e10e97b

Please sign in to comment.