diff --git a/.vscode/settings.json b/.vscode/settings.json index 79a72d6597..f1da23c28e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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", diff --git a/CMakeLists.txt b/CMakeLists.txt index 61d9a7a0bb..f3a7ebec12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") @@ -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 === # ==================== @@ -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} @@ -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) @@ -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} @@ -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) @@ -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") @@ -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 === @@ -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() diff --git a/azure-pipelines/e2e-ports/vcpkg-test-x-script/portfile.cmake b/azure-pipelines/e2e-ports/vcpkg-test-x-script/portfile.cmake new file mode 100644 index 0000000000..3b193ceb28 --- /dev/null +++ b/azure-pipelines/e2e-ports/vcpkg-test-x-script/portfile.cmake @@ -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) diff --git a/azure-pipelines/e2e-ports/vcpkg-test-x-script/vcpkg.json b/azure-pipelines/e2e-ports/vcpkg-test-x-script/vcpkg.json new file mode 100644 index 0000000000..9dfc969999 --- /dev/null +++ b/azure-pipelines/e2e-ports/vcpkg-test-x-script/vcpkg.json @@ -0,0 +1,4 @@ +{ + "name": "vcpkg-test-x-script", + "version-string": "1.0.0" +} diff --git a/azure-pipelines/end-to-end-tests-dir/asset-caching.ps1 b/azure-pipelines/end-to-end-tests-dir/asset-caching.ps1 new file mode 100644 index 0000000000..b1d6616862 --- /dev/null +++ b/azure-pipelines/end-to-end-tests-dir/asset-caching.ps1 @@ -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 diff --git a/azure-pipelines/end-to-end-tests-dir/binarycaching.ps1 b/azure-pipelines/end-to-end-tests-dir/binary-caching.ps1 similarity index 84% rename from azure-pipelines/end-to-end-tests-dir/binarycaching.ps1 rename to azure-pipelines/end-to-end-tests-dir/binary-caching.ps1 index 30706e2547..fd0f151c34 100644 --- a/azure-pipelines/end-to-end-tests-dir/binarycaching.ps1 +++ b/azure-pipelines/end-to-end-tests-dir/binary-caching.ps1 @@ -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 @@ -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" @@ -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" @@ -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" @@ -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" @@ -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" diff --git a/azure-pipelines/end-to-end-tests-dir/cli.ps1 b/azure-pipelines/end-to-end-tests-dir/cli.ps1 index b2e4920b38..af098ccac1 100644 --- a/azure-pipelines/end-to-end-tests-dir/cli.ps1 +++ b/azure-pipelines/end-to-end-tests-dir/cli.ps1 @@ -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 [--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' diff --git a/azure-pipelines/end-to-end-tests.ps1 b/azure-pipelines/end-to-end-tests.ps1 index 3fb1e26030..bb25d51a33 100755 --- a/azure-pipelines/end-to-end-tests.ps1 +++ b/azure-pipelines/end-to-end-tests.ps1 @@ -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) { @@ -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") @@ -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") { diff --git a/azure-pipelines/localization.yml b/azure-pipelines/localization.yml index 29567a7d86..48bdd5da8e 100644 --- a/azure-pipelines/localization.yml +++ b/azure-pipelines/localization.yml @@ -5,52 +5,72 @@ pr: none variables: - name: GitEmbeddedBotArgs value: '-C $(Build.SourcesDirectory) -c user.email=embeddedbot@microsoft.com -c user.name="Embedded Bot"' +- name: TeamName + value: 'Visual-Cpp-vcpkg' -pool: - name: 'VSEngSS-MicroBuild2022-1ES' +resources: + repositories: + - repository: CustomPipelineTemplates + type: git + name: 1ESPipelineTemplates/MicroBuildTemplate -steps: -- task: OneLocBuild@2 - displayName: 'Build localization files' - env: - SYSTEM_ACCESSTOKEN: $(System.AccessToken) - inputs: - locProj: 'LocProject.json' - outDir: '$(Build.ArtifactStagingDirectory)' - isUseLfLineEndingsSelected: true - dependencyPackageSource: 'https://pkgs.dev.azure.com/devdiv/DevDiv/_packaging/vcpkg.localization/nuget/v3/index.json' - packageSourceAuth: 'patAuth' -- task: PublishBuildArtifacts@1 - displayName: 'Publish localization files' - inputs: - PathToPublish: '$(Build.ArtifactStagingDirectory)' - ArtifactName: 'drop' - publishLocation: 'Container' -- task: Powershell@2 - displayName: Format messages.*.json files - continueOnError: true - inputs: - pwsh: true - filePath: azure-pipelines/Format-LocalizationFiles.ps1 -- script: | - git $(GitEmbeddedBotArgs) add locales - git $(GitEmbeddedBotArgs) commit -m "[localization][automated][ci skip] update locale files" - displayName: Commit Changed Files - continueOnError: true -- task: DownloadSecureFile@1 - displayName: Download Deploy Key - name: githubDeployKey - inputs: - secureFile: id_vcpkg_tool - # GitHub has a large, regularly changing set of IP address, so ignore the - # hostname and allow anything with the right key. - # https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/about-githubs-ip-addresses - # This public key should have the well-known fingerprint documented below. - # SHA256:uNiVztksCsDhcc0u9e8BujQXVUpKZIDTMczCvj3tD2s - # https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/githubs-ssh-key-fingerprints -- script: mkdir %USERPROFILE%\.ssh && echo github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=>>%USERPROFILE%\.ssh\known_hosts - displayName: Store GitHub Public Key -- script: git $(GitEmbeddedBotArgs) push git@github.com:microsoft/vcpkg-tool HEAD:$(Build.SourceBranch) - env: - GIT_SSH_COMMAND: ssh -i "$(githubDeployKey.secureFilePath)" - displayName: Push Localization Files +extends: + template: azure-pipelines/MicroBuild.1ES.Official.yml@CustomPipelineTemplates + parameters: + pool: + name: 'VSEngSS-MicroBuild2022-1ES' + sdl: + sourceAnalysisPool: + name: VSEngSS-MicroBuild2022-1ES + image: server2022-microbuildVS2022-1es + os: windows + stages: + - stage: stage + displayName: Build Localization Files Stage + jobs: + - job: job + displayName: Build Localization Files Job + templateContext: + outputs: + - output: pipelineArtifact + targetPath: $(Build.ArtifactStagingDirectory) + artifactName: drop + steps: + - task: OneLocBuild@2 + displayName: 'Build localization files' + env: + SYSTEM_ACCESSTOKEN: $(System.AccessToken) + inputs: + locProj: 'LocProject.json' + outDir: '$(Build.ArtifactStagingDirectory)' + isUseLfLineEndingsSelected: true + dependencyPackageSource: 'https://pkgs.dev.azure.com/devdiv/DevDiv/_packaging/vcpkg.localization/nuget/v3/index.json' + packageSourceAuth: 'patAuth' + - task: Powershell@2 + displayName: Format messages.*.json files + continueOnError: true + inputs: + pwsh: true + filePath: azure-pipelines/Format-LocalizationFiles.ps1 + - script: | + git $(GitEmbeddedBotArgs) add locales + git $(GitEmbeddedBotArgs) commit -m "[localization][automated][ci skip] update locale files" + displayName: Commit Changed Files + continueOnError: true + - task: DownloadSecureFile@1 + displayName: Download Deploy Key + name: githubDeployKey + inputs: + secureFile: id_vcpkg_tool + # GitHub has a large, regularly changing set of IP address, so ignore the + # hostname and allow anything with the right key. + # https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/about-githubs-ip-addresses + # This public key should have the well-known fingerprint documented below. + # SHA256:uNiVztksCsDhcc0u9e8BujQXVUpKZIDTMczCvj3tD2s + # https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/githubs-ssh-key-fingerprints + - script: mkdir %USERPROFILE%\.ssh && echo github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=>>%USERPROFILE%\.ssh\known_hosts + displayName: Store GitHub Public Key + - script: git $(GitEmbeddedBotArgs) push git@github.com:microsoft/vcpkg-tool HEAD:$(Build.SourceBranch) + env: + GIT_SSH_COMMAND: ssh -i "$(githubDeployKey.secureFilePath)" + displayName: Push Localization Files diff --git a/include/vcpkg/base/cmd-parser.h b/include/vcpkg/base/cmd-parser.h index f89bc15927..12756780e1 100644 --- a/include/vcpkg/base/cmd-parser.h +++ b/include/vcpkg/base/cmd-parser.h @@ -46,13 +46,13 @@ namespace vcpkg struct CmdParser { - CmdParser(); + CmdParser() = default; explicit CmdParser(View inputs); explicit CmdParser(std::vector&& inputs); - CmdParser(const CmdParser&); - CmdParser(CmdParser&&); - CmdParser& operator=(const CmdParser&); - CmdParser& operator=(CmdParser&&); + CmdParser(const CmdParser&) = default; + CmdParser(CmdParser&&) = default; + CmdParser& operator=(const CmdParser&) = default; + CmdParser& operator=(CmdParser&&) = default; // Parses a switch from the input named switch_name, and stores the value if // encountered into value. Returns true if the switch was encountered. diff --git a/include/vcpkg/base/files.h b/include/vcpkg/base/files.h index abdc6c2d7b..bfb88e4758 100644 --- a/include/vcpkg/base/files.h +++ b/include/vcpkg/base/files.h @@ -76,6 +76,7 @@ namespace vcpkg long long tell() const noexcept; int eof() const noexcept; std::error_code error() const noexcept; + int error_raw() const noexcept; const Path& path() const; ExpectedL try_seek_to(long long offset); @@ -97,6 +98,9 @@ namespace vcpkg ExpectedL try_getc(); ExpectedL try_read_all_from(long long offset, void* buffer, std::uint32_t size); std::string read_to_end(std::error_code& ec); + // reads any remaining chunks of the file; used to implement read_to_end + void read_to_end_suffix( + std::string& output, std::error_code& ec, char* buffer, size_t buffer_size, size_t last_read); }; struct WriteFilePointer : FilePointer @@ -111,7 +115,7 @@ namespace vcpkg struct IExclusiveFileLock { - virtual ~IExclusiveFileLock(); + virtual ~IExclusiveFileLock() = default; }; uint64_t get_filesystem_stats(); @@ -135,6 +139,10 @@ namespace vcpkg ExpectedL try_read_contents(const Path& file_path) const; + // Tries to read `file_path`, and if the file starts with a shebang sequence #!, returns the contents of the + // file. If an I/O error occurs or the file does not start with a shebang sequence, returns an empty string. + virtual std::string best_effort_read_contents_if_shebang(const Path& file_path) const = 0; + virtual Path find_file_recursively_up(const Path& starting_dir, const Path& filename, std::error_code& ec) const = 0; diff --git a/include/vcpkg/base/fwd/system.process.h b/include/vcpkg/base/fwd/system.process.h index a11585881d..448af44d13 100644 --- a/include/vcpkg/base/fwd/system.process.h +++ b/include/vcpkg/base/fwd/system.process.h @@ -14,10 +14,15 @@ namespace vcpkg Utf16 }; + enum class CreateNewConsole + { + No, + Yes + }; + struct CMakeVariable; struct Command; struct CommandLess; struct ExitCodeAndOutput; struct Environment; - struct WorkingDirectory; } diff --git a/include/vcpkg/base/json.h b/include/vcpkg/base/json.h index 7897667b59..ff5ac07351 100644 --- a/include/vcpkg/base/json.h +++ b/include/vcpkg/base/json.h @@ -327,10 +327,8 @@ namespace vcpkg::Json JsonStyle style; }; - ExpectedT> parse_file(const ReadOnlyFilesystem&, - const Path&, - std::error_code& ec); - ExpectedT> parse(StringView text, StringView origin); + ExpectedL parse_file(const ReadOnlyFilesystem&, const Path&, std::error_code& ec); + ExpectedL parse(StringView text, StringView origin); ParsedJson parse_file(LineInfo li, const ReadOnlyFilesystem&, const Path&); ExpectedL parse_object(StringView text, StringView origin); diff --git a/include/vcpkg/base/message-data.inc.h b/include/vcpkg/base/message-data.inc.h index 3e9672d83c..c9eb7b5910 100644 --- a/include/vcpkg/base/message-data.inc.h +++ b/include/vcpkg/base/message-data.inc.h @@ -866,10 +866,6 @@ DECLARE_MESSAGE(CommandFailed, "{command_line}\n" "failed with the following results:") DECLARE_MESSAGE(CommunityTriplets, (), "", "Community Triplets:") -DECLARE_MESSAGE(ComparingUtf8Decoders, - (), - "", - "Comparing Utf8Decoders with different provenance; this is always an error") DECLARE_MESSAGE(CompressFolderFailed, (msg::path), "", "Failed to compress folder \"{path}\":") DECLARE_MESSAGE(ComputingInstallPlan, (), "", "Computing installation plan...") DECLARE_MESSAGE(ConfigurationErrorRegistriesWithoutBaseline, @@ -1344,10 +1340,7 @@ DECLARE_MESSAGE( (), "", "Environment variable VCPKG_FORCE_SYSTEM_BINARIES must be set on arm, s390x, ppc64le and riscv platforms.") -DECLARE_MESSAGE(FormattedParseMessageExpression, - (msg::value), - "Example of {value} is 'x64 & windows'", - "on expression: {value}") +DECLARE_MESSAGE(FormattedParseMessageExpressionPrefix, (), "", "on expression:") DECLARE_MESSAGE(ForMoreHelp, (), "Printed before a suggestion for the user to run `vcpkg help `", @@ -1702,7 +1695,6 @@ DECLARE_MESSAGE(IllegalPlatformSpec, (), "", "Platform qualifier is not allowed DECLARE_MESSAGE(ImproperShaLength, (msg::value), "{value} is a sha.", "SHA512's must be 128 hex characters: {value}") DECLARE_MESSAGE(IncorrectArchiveFileSignature, (), "", "Incorrect archive file signature") DECLARE_MESSAGE(IncorrectPESignature, (), "", "Incorrect PE signature") -DECLARE_MESSAGE(IncrementedUtf8Decoder, (), "", "Incremented Utf8Decoder at the end of the string") DECLARE_MESSAGE(InfoSetEnvVar, (msg::env_var), "In this context 'editor' means IDE", diff --git a/include/vcpkg/base/parallel-algorithms.h b/include/vcpkg/base/parallel-algorithms.h index 47b2472746..406683e278 100644 --- a/include/vcpkg/base/parallel-algorithms.h +++ b/include/vcpkg/base/parallel-algorithms.h @@ -1,85 +1,170 @@ #pragma once - +#if defined(_WIN32) +#include +#else // ^^^ _WIN32 / !_WIN32 vvv +#include +#include +#include +#include +#endif // ^^^ _WIN32 #include +#include + +#include #include -#include -#include namespace vcpkg { template - inline void execute_in_parallel(size_t work_count, F&& work) noexcept + struct WorkCallbackContext { - const size_t thread_count = static_cast(get_concurrency()); - const size_t num_threads = std::max(static_cast(1), std::min(thread_count, work_count)); + F work; + size_t work_count; + std::atomic next_offset; - std::vector> workers; - workers.reserve(num_threads - 1); + WorkCallbackContext(F init_f, size_t work_count) : work(init_f), work_count(work_count), next_offset(0) { } - for (size_t i = 0; i < num_threads - 1; ++i) + // pre: run() is called at most SIZE_MAX - work_count times + void run() { - workers.emplace_back(std::async(std::launch::async | std::launch::deferred, [&work]() { work(); })); + for (;;) + { + auto offset = next_offset.fetch_add(1, std::memory_order_relaxed); + if (offset >= work_count) + { + return; + } + + work(offset); + } } - work(); + }; - for (auto&& w : workers) +#if defined(_WIN32) + struct PtpWork + { + PtpWork(_In_ PTP_WORK_CALLBACK pfnwk, _Inout_opt_ PVOID pv, _In_opt_ PTP_CALLBACK_ENVIRON pcbe) + : ptp_work(CreateThreadpoolWork(pfnwk, pv, pcbe)) { - w.get(); } - } + PtpWork(const PtpWork&) = delete; + PtpWork& operator=(const PtpWork&) = delete; + ~PtpWork() + { + if (ptp_work) + { + ::WaitForThreadpoolWorkCallbacks(ptp_work, TRUE); + ::CloseThreadpoolWork(ptp_work); + } + } - template - void parallel_for_each(Container&& c, F cb) noexcept + explicit operator bool() { return ptp_work != nullptr; } + + void submit() { ::SubmitThreadpoolWork(ptp_work); } + + private: + PTP_WORK ptp_work; + }; + + template + inline void execute_in_parallel(size_t work_count, F work) noexcept { - if (c.size() == 0) + if (work_count == 0) { return; } - if (c.size() == 1) + + if (work_count == 1) { - cb(c[0]); - return; + work(size_t{}); } - std::atomic_size_t next{0}; - - execute_in_parallel(c.size(), [&]() { - size_t i = 0; - while (i < c.size()) + WorkCallbackContext context{work, work_count}; + PtpWork ptp_work([](PTP_CALLBACK_INSTANCE, + void* context, + PTP_WORK) noexcept { static_cast*>(context)->run(); }, + &context, + nullptr); + if (ptp_work) + { + auto max_threads = (std::min)(work_count, static_cast(get_concurrency())); + max_threads = (std::min)(max_threads, (SIZE_MAX - work_count) + 1u); // to avoid overflow in fetch_add + // start at 1 to account for the running thread + for (size_t i = 1; i < max_threads; ++i) { - if (next.compare_exchange_weak(i, i + 1, std::memory_order_relaxed)) - { - cb(c[i]); - } + ptp_work.submit(); } - }); + } + + context.run(); } +#else // ^^^ _WIN32 / !_WIN32 vvv + struct JThread + { + template>::value, int> = 0> + JThread(Arg0&& arg0) : m_thread(std::forward(arg0)) + { + } - template - void parallel_transform(const Container& c, RanItTarget out_begin, F&& cb) noexcept + ~JThread() { m_thread.join(); } + + JThread(const JThread&) = delete; + JThread& operator=(const JThread&) = delete; + JThread(JThread&&) = default; + JThread& operator=(JThread&&) = default; + + private: + std::thread m_thread; + }; + + template + inline void execute_in_parallel(size_t work_count, F work) noexcept { - if (c.size() == 0) + if (work_count == 0) { return; } - if (c.size() == 1) + + if (work_count == 1) { - *out_begin = cb(c[0]); + work(size_t{}); return; } - std::atomic_size_t next{0}; - - execute_in_parallel(c.size(), [&]() { - size_t i = 0; - while (i < c.size()) + WorkCallbackContext context{work, work_count}; + auto max_threads = std::min(work_count, static_cast(get_concurrency())); + max_threads = std::min(max_threads, (SIZE_MAX - work_count) + 1u); // to avoid overflow in fetch_add + auto bg_thread_count = max_threads - 1; + std::vector bg_threads; + bg_threads.reserve(bg_thread_count); + for (size_t i = 0; i < bg_thread_count; ++i) + { + try { - if (next.compare_exchange_weak(i, i + 1, std::memory_order_relaxed)) - { - *(out_begin + i) = cb(c[i]); - } + bg_threads.emplace_back([&]() { context.run(); }); } - }); + catch (const std::system_error&) + { + // ok, just give up trying to create threads + break; + } + } + + context.run(); + // destroying workers joins + } +#endif // ^^^ !_WIN32 + + template + void parallel_for_each(Container&& c, F cb) noexcept + { + execute_in_parallel(c.size(), [&](size_t offset) { cb(c[offset]); }); + } + + template + void parallel_transform(const Container& c, RanItTarget out_begin, F cb) noexcept + { + execute_in_parallel(c.size(), [&](size_t offset) { out_begin[offset] = cb(c[offset]); }); } } diff --git a/include/vcpkg/base/parse.h b/include/vcpkg/base/parse.h index bbdd7097f3..0f46a14010 100644 --- a/include/vcpkg/base/parse.h +++ b/include/vcpkg/base/parse.h @@ -9,43 +9,8 @@ #include -#include #include -namespace vcpkg -{ - struct ParseError - { - ParseError(std::string origin, int row, int column, int caret_col, std::string line, LocalizedString message) - : origin(std::move(origin)) - , row(row) - , column(column) - , caret_col(caret_col) - , line(std::move(line)) - , message(std::move(message)) - { - } - - const std::string origin; - const int row; - const int column; - const int caret_col; - const std::string line; - const LocalizedString message; - - std::string to_string() const; - }; - - constexpr struct ParseErrorFormatter - { - LocalizedString operator()(const std::unique_ptr& up) - { - return LocalizedString::from_raw(up->to_string()); - } - } parse_error_formatter; - -} // namespace vcpkg - namespace vcpkg { struct SourceLoc @@ -66,7 +31,7 @@ namespace vcpkg struct ParseMessages { - std::unique_ptr error; + Optional error; std::vector warnings; void exit_if_errors_or_warnings(StringView origin) const; @@ -141,8 +106,8 @@ namespace vcpkg void add_warning(LocalizedString&& message); void add_warning(LocalizedString&& message, const SourceLoc& loc); - const ParseError* get_error() const { return m_messages.error.get(); } - std::unique_ptr extract_error() { return std::move(m_messages.error); } + const LocalizedString* get_error() const& { return m_messages.error.get(); } + LocalizedString* get_error() && { return m_messages.error.get(); } const ParseMessages& messages() const { return m_messages; } ParseMessages&& extract_messages() { return std::move(m_messages); } diff --git a/include/vcpkg/base/path.h b/include/vcpkg/base/path.h index 1552b2afb7..6fd24ad605 100644 --- a/include/vcpkg/base/path.h +++ b/include/vcpkg/base/path.h @@ -8,12 +8,7 @@ namespace vcpkg { struct Path { - Path(); - Path(const Path&); - Path(Path&&); - Path& operator=(const Path&); - Path& operator=(Path&&); - + Path() = default; Path(const StringView sv); Path(const std::string& s); Path(std::string&& s); diff --git a/include/vcpkg/base/system.process.h b/include/vcpkg/base/system.process.h index 4a93139063..5a7378a46e 100644 --- a/include/vcpkg/base/system.process.h +++ b/include/vcpkg/base/system.process.h @@ -109,51 +109,53 @@ namespace vcpkg Environment get_modified_clean_environment(const std::unordered_map& extra_env, StringView prepend_to_path = {}); - struct WorkingDirectory + struct ProcessLaunchSettings { - Path working_directory; + Optional working_directory; + Optional environment; }; - extern const WorkingDirectory default_working_directory; - extern const Environment default_environment; + struct RedirectedProcessLaunchSettings + { + Optional working_directory; + Optional environment; + +#if defined(_WIN32) + // the encoding to use for standard streams of the child + Encoding encoding = Encoding::Utf8; + CreateNewConsole create_new_console = CreateNewConsole::No; +#endif // ^^^ _WIN32 + // whether to echo all read content to the enclosing terminal; + EchoInDebug echo_in_debug = EchoInDebug::Hide; + std::string stdin_content; + }; - ExpectedL cmd_execute(const Command& cmd_line, - const WorkingDirectory& wd = default_working_directory, - const Environment& env = default_environment); - ExpectedL cmd_execute_clean(const Command& cmd_line, const WorkingDirectory& wd = default_working_directory); + ExpectedL cmd_execute(const Command& cmd); + ExpectedL cmd_execute(const Command& cmd, const ProcessLaunchSettings& settings); #if defined(_WIN32) - Environment cmd_execute_and_capture_environment(const Command& cmd_line, - const Environment& env = default_environment); + Environment cmd_execute_and_capture_environment(const Command& cmd, const Environment& env); #endif void cmd_execute_background(const Command& cmd_line); - ExpectedL cmd_execute_and_capture_output(const Command& cmd_line, - const WorkingDirectory& wd = default_working_directory, - const Environment& env = default_environment, - Encoding encoding = Encoding::Utf8, - EchoInDebug echo_in_debug = EchoInDebug::Hide, - StringView stdin_content = {}); + ExpectedL cmd_execute_and_capture_output(const Command& cmd); + ExpectedL cmd_execute_and_capture_output(const Command& cmd, + const RedirectedProcessLaunchSettings& settings); + std::vector> cmd_execute_and_capture_output_parallel(View commands); std::vector> cmd_execute_and_capture_output_parallel( - View cmd_lines, - const WorkingDirectory& wd = default_working_directory, - const Environment& env = default_environment); - - ExpectedL cmd_execute_and_stream_lines(const Command& cmd_line, - const std::function& per_line_cb, - const WorkingDirectory& wd = default_working_directory, - const Environment& env = default_environment, - Encoding encoding = Encoding::Utf8, - StringView stdin_content = {}); - - ExpectedL cmd_execute_and_stream_data(const Command& cmd_line, - const std::function& data_cb, - const WorkingDirectory& wd = default_working_directory, - const Environment& env = default_environment, - Encoding encoding = Encoding::Utf8, - StringView stdin_content = {}); + View commands, const RedirectedProcessLaunchSettings& settings); + + ExpectedL cmd_execute_and_stream_lines(const Command& cmd, const std::function& per_line_cb); + ExpectedL cmd_execute_and_stream_lines(const Command& cmd, + const RedirectedProcessLaunchSettings& settings, + const std::function& per_line_cb); + + ExpectedL cmd_execute_and_stream_data(const Command& cmd, const std::function& data_cb); + ExpectedL cmd_execute_and_stream_data(const Command& cmd, + const RedirectedProcessLaunchSettings& settings, + const std::function& data_cb); uint64_t get_subproccess_stats(); diff --git a/include/vcpkg/base/unicode.h b/include/vcpkg/base/unicode.h index 75b163559a..d5dcc70438 100644 --- a/include/vcpkg/base/unicode.h +++ b/include/vcpkg/base/unicode.h @@ -6,16 +6,6 @@ namespace vcpkg::Unicode { - enum class Utf8CodeUnitKind - { - Invalid = -1, - Continue = 0, - StartOne = 1, - StartTwo = 2, - StartThree = 3, - StartFour = 4, - }; - constexpr static char32_t end_of_file = 0xFFFF'FFFF; enum class utf8_errc @@ -29,19 +19,12 @@ namespace vcpkg::Unicode UnexpectedEof = 6, }; - Utf8CodeUnitKind utf8_code_unit_kind(unsigned char code_unit) noexcept; - - constexpr int utf8_code_unit_count(Utf8CodeUnitKind kind) noexcept { return static_cast(kind); } - int utf8_code_unit_count(char code_unit) noexcept; - int utf8_encode_code_point(char (&array)[4], char32_t code_point) noexcept; - // returns {after-current-code-point, error}, - // and if error = NoError, then out = parsed code point. - // else, out = end_of_file. - std::pair utf8_decode_code_point(const char* first, - const char* last, - char32_t& out) noexcept; + // If possible, decodes one codepoint from the beginning of [first, last). If successful advances first after the + // last decoded encoding unit, stores the codepoint in out, and returns utf8_errc::NoError. + // Otherwise, advances first to last, stores end_of_file in out, and returns one of the utf8_errc values. + utf8_errc utf8_decode_code_point(const char*& first, const char* last, char32_t& out) noexcept; // uses the C++20 definition /* @@ -87,20 +70,20 @@ namespace vcpkg::Unicode bool utf8_is_valid_string(const char* first, const char* last) noexcept; - constexpr bool utf16_is_leading_surrogate_code_point(char32_t code_point) + constexpr bool utf16_is_leading_surrogate_code_point(char32_t code_point) noexcept { return code_point >= 0xD800 && code_point < 0xDC00; } - constexpr bool utf16_is_trailing_surrogate_code_point(char32_t code_point) + constexpr bool utf16_is_trailing_surrogate_code_point(char32_t code_point) noexcept { return code_point >= 0xDC00 && code_point < 0xE000; } - constexpr bool utf16_is_surrogate_code_point(char32_t code_point) + constexpr bool utf16_is_surrogate_code_point(char32_t code_point) noexcept { return code_point >= 0xD800 && code_point < 0xE000; } - char32_t utf16_surrogates_to_code_point(char32_t leading, char32_t trailing); + char32_t utf16_surrogates_to_code_point(char32_t leading, char32_t trailing) noexcept; /* There are two ways to parse utf-8: we could allow unpaired surrogates (as in [wtf-8]) -- this is important @@ -118,9 +101,13 @@ namespace vcpkg::Unicode */ struct Utf8Decoder { - constexpr Utf8Decoder() noexcept : current_(end_of_file), next_(nullptr), last_(nullptr) { } - explicit constexpr Utf8Decoder(StringView sv) : Utf8Decoder(sv.begin(), sv.end()) { } - constexpr Utf8Decoder(const char* first, const char* last) noexcept : current_(0), next_(first), last_(last) + constexpr Utf8Decoder() noexcept + : current_(end_of_file), pointer_to_current_(nullptr), next_(nullptr), last_(nullptr) + { + } + explicit constexpr Utf8Decoder(StringView sv) noexcept : Utf8Decoder(sv.begin(), sv.end()) { } + constexpr Utf8Decoder(const char* first, const char* last) noexcept + : current_(0), pointer_to_current_(first), next_(first), last_(last) { if (next_ != last_) { @@ -131,17 +118,35 @@ namespace vcpkg::Unicode current_ = end_of_file; } } + constexpr Utf8Decoder(StringView sv, utf8_errc& first_decode_error) noexcept + : Utf8Decoder(sv.begin(), sv.end(), first_decode_error) + { + } + constexpr Utf8Decoder(const char* first, const char* last, utf8_errc& first_decode_error) noexcept + : current_(0), pointer_to_current_(first), next_(first), last_(last) + { + if (next_ != last_) + { + first_decode_error = next(); + } + else + { + current_ = end_of_file; + first_decode_error = utf8_errc::NoError; + } + } + struct sentinel { }; constexpr inline bool is_eof() const noexcept { return current_ == end_of_file; } - [[nodiscard]] utf8_errc next(); + [[nodiscard]] utf8_errc next() noexcept; Utf8Decoder& operator=(sentinel) noexcept; - char const* pointer_to_current() const noexcept; + char const* pointer_to_current() const noexcept { return pointer_to_current_; } char32_t operator*() const noexcept { @@ -161,7 +166,24 @@ namespace vcpkg::Unicode constexpr sentinel end() const { return sentinel(); } - friend bool operator==(const Utf8Decoder& lhs, const Utf8Decoder& rhs) noexcept; + friend constexpr bool operator==(const Utf8Decoder& lhs, const Utf8Decoder& rhs) noexcept + { + if (lhs.last_ != rhs.last_) + { + // comparing decoders of different provenance is always an error + Checks::unreachable(VCPKG_LINE_INFO); + } + + return lhs.pointer_to_current_ == rhs.pointer_to_current_; + } + friend constexpr bool operator!=(const Utf8Decoder& lhs, const Utf8Decoder& rhs) noexcept + { + return !(lhs == rhs); + } + friend constexpr bool operator==(const Utf8Decoder& d, Utf8Decoder::sentinel) noexcept { return d.is_eof(); } + friend constexpr bool operator==(Utf8Decoder::sentinel s, const Utf8Decoder& d) noexcept { return d == s; } + friend constexpr bool operator!=(const Utf8Decoder& d, Utf8Decoder::sentinel) noexcept { return !d.is_eof(); } + friend constexpr bool operator!=(Utf8Decoder::sentinel s, const Utf8Decoder& d) noexcept { return d != s; } using difference_type = std::ptrdiff_t; using value_type = char32_t; @@ -171,14 +193,8 @@ namespace vcpkg::Unicode private: char32_t current_; + const char* pointer_to_current_; const char* next_; const char* last_; }; - - inline bool operator!=(const Utf8Decoder& lhs, const Utf8Decoder& rhs) noexcept { return !(lhs == rhs); } - - constexpr bool operator==(const Utf8Decoder& d, Utf8Decoder::sentinel) { return d.is_eof(); } - constexpr bool operator==(Utf8Decoder::sentinel s, const Utf8Decoder& d) { return d == s; } - constexpr bool operator!=(const Utf8Decoder& d, Utf8Decoder::sentinel) { return !d.is_eof(); } - constexpr bool operator!=(Utf8Decoder::sentinel s, const Utf8Decoder& d) { return d != s; } } diff --git a/include/vcpkg/base/util.h b/include/vcpkg/base/util.h index cb3f58160e..1b84d3d35a 100644 --- a/include/vcpkg/base/util.h +++ b/include/vcpkg/base/util.h @@ -487,13 +487,13 @@ namespace vcpkg::Util template E to_enum(bool b) { - return b ? E::YES : E::NO; + return b ? E::Yes : E::No; } template bool to_bool(E e) { - return e == E::YES; + return e == E::Yes; } } } diff --git a/include/vcpkg/binaryparagraph.h b/include/vcpkg/binaryparagraph.h index 08280c2f77..b9ad5b13c8 100644 --- a/include/vcpkg/binaryparagraph.h +++ b/include/vcpkg/binaryparagraph.h @@ -13,7 +13,7 @@ namespace vcpkg /// struct BinaryParagraph { - BinaryParagraph(); + BinaryParagraph() = default; BinaryParagraph(StringView origin, Paragraph&& fields); BinaryParagraph(const SourceParagraph& spgh, const std::vector& default_features, diff --git a/include/vcpkg/commands.build.h b/include/vcpkg/commands.build.h index 8929386791..10d9707584 100644 --- a/include/vcpkg/commands.build.h +++ b/include/vcpkg/commands.build.h @@ -3,9 +3,11 @@ #include #include +#include #include #include #include +#include #include #include @@ -19,7 +21,6 @@ #include #include #include -#include #include #include @@ -77,33 +78,33 @@ namespace vcpkg }; static constexpr BuildPackageOptions default_build_package_options{ - BuildMissing::YES, - UseHeadVersion::NO, - AllowDownloads::YES, - OnlyDownloads::NO, - CleanBuildtrees::YES, - CleanPackages::YES, - CleanDownloads::NO, - DownloadTool::BUILT_IN, - PurgeDecompressFailure::YES, - Editable::NO, - BackcompatFeatures::ALLOW, - PrintUsage::YES, + BuildMissing::Yes, + UseHeadVersion::No, + AllowDownloads::Yes, + OnlyDownloads::No, + CleanBuildtrees::Yes, + CleanPackages::Yes, + CleanDownloads::No, + DownloadTool::Builtin, + PurgeDecompressFailure::Yes, + Editable::No, + BackcompatFeatures::Allow, + PrintUsage::Yes, }; static constexpr BuildPackageOptions backcompat_prohibiting_package_options{ - BuildMissing::YES, - UseHeadVersion::NO, - AllowDownloads::YES, - OnlyDownloads::NO, - CleanBuildtrees::YES, - CleanPackages::YES, - CleanDownloads::NO, - DownloadTool::BUILT_IN, - PurgeDecompressFailure::YES, - Editable::NO, - BackcompatFeatures::PROHIBIT, - PrintUsage::YES, + BuildMissing::Yes, + UseHeadVersion::No, + AllowDownloads::Yes, + OnlyDownloads::No, + CleanBuildtrees::Yes, + CleanPackages::Yes, + CleanDownloads::No, + DownloadTool::Builtin, + PurgeDecompressFailure::Yes, + Editable::No, + BackcompatFeatures::Prohibit, + PrintUsage::Yes, }; struct BuildResultCounts @@ -223,16 +224,16 @@ namespace vcpkg enum class LinkageType : char { - DYNAMIC, - STATIC, + Dynamic, + Static, }; Optional to_linkage_type(StringView str); struct BuildInfo { - LinkageType crt_linkage = LinkageType::DYNAMIC; - LinkageType library_linkage = LinkageType::DYNAMIC; + LinkageType crt_linkage = LinkageType::Dynamic; + LinkageType library_linkage = LinkageType::Dynamic; Optional detected_head_version; diff --git a/include/vcpkg/commands.h b/include/vcpkg/commands.h index 12e6c5c30e..15673d0c55 100644 --- a/include/vcpkg/commands.h +++ b/include/vcpkg/commands.h @@ -32,6 +32,6 @@ namespace vcpkg std::vector get_all_commands_metadata(); - void print_zero_args_usage(); + std::string get_zero_args_usage(); void print_full_command_list(); } diff --git a/include/vcpkg/commands.set-installed.h b/include/vcpkg/commands.set-installed.h index 396496252f..8d17af3a90 100644 --- a/include/vcpkg/commands.set-installed.h +++ b/include/vcpkg/commands.set-installed.h @@ -19,7 +19,7 @@ namespace vcpkg enum class DryRun : bool { No, - Yes, + Yes }; extern const CommandMetadata CommandSetInstalledMetadata; diff --git a/include/vcpkg/commands.z-extract.h b/include/vcpkg/commands.z-extract.h index fed76b78fd..b68f46fe24 100644 --- a/include/vcpkg/commands.z-extract.h +++ b/include/vcpkg/commands.z-extract.h @@ -39,7 +39,7 @@ namespace vcpkg } }; - ExpectedL get_strip_setting(std::map> settings); + ExpectedL get_strip_setting(const std::map>& settings); struct ExtractedArchive { diff --git a/include/vcpkg/commands.z-generate-message-map.h b/include/vcpkg/commands.z-generate-message-map.h index ce010ddc4a..4c65224c99 100644 --- a/include/vcpkg/commands.z-generate-message-map.h +++ b/include/vcpkg/commands.z-generate-message-map.h @@ -1,11 +1,11 @@ #pragma once +#include #include -#include -#include +#include -#include +#include #include diff --git a/include/vcpkg/fwd/build.h b/include/vcpkg/fwd/build.h index c65ca91036..5b9fbe7b34 100644 --- a/include/vcpkg/fwd/build.h +++ b/include/vcpkg/fwd/build.h @@ -4,94 +4,96 @@ namespace vcpkg { enum class BuildResult { - SUCCEEDED, - BUILD_FAILED, - POST_BUILD_CHECKS_FAILED, - FILE_CONFLICTS, - CASCADED_DUE_TO_MISSING_DEPENDENCIES, - EXCLUDED, - CACHE_MISSING, - DOWNLOADED, - REMOVED + Succeeded, + BuildFailed, + PostBuildChecksFailed, + FileConflicts, + CascadedDueToMissingDependencies, + Excluded, + CacheMissing, + Downloaded, + Removed }; enum class UseHeadVersion { - NO = 0, - YES + No = 0, + Yes }; enum class AllowDownloads { - NO = 0, - YES + No = 0, + Yes }; enum class OnlyDownloads { - NO = 0, - YES + No = 0, + Yes }; enum class CleanBuildtrees { - NO = 0, - YES + No = 0, + Yes }; enum class CleanPackages { - NO = 0, - YES + No = 0, + Yes }; enum class CleanDownloads { - NO = 0, - YES + No = 0, + Yes }; enum class ConfigurationType { - DEBUG, - RELEASE, + Debug, + Release, }; enum class DownloadTool { - BUILT_IN, - ARIA2, + Builtin, + Aria2, }; + enum class PurgeDecompressFailure { - NO = 0, - YES + No = 0, + Yes }; enum class Editable { - NO = 0, - YES + No = 0, + Yes }; enum class BackcompatFeatures { - ALLOW = 0, - PROHIBIT + Allow = 0, + Prohibit }; enum class BuildMissing { - NO = 0, - YES + No = 0, + Yes }; enum class PrintUsage { - YES = 0, - NO + No = 0, + Yes }; + // These names are intended to match VCPKG_POLICY_Xxx constants settable in portfile.cmake enum class BuildPolicy { EMPTY_PACKAGE, diff --git a/include/vcpkg/platform-expression.h b/include/vcpkg/platform-expression.h index 25a66bdb71..a540daecd9 100644 --- a/include/vcpkg/platform-expression.h +++ b/include/vcpkg/platform-expression.h @@ -25,11 +25,11 @@ namespace vcpkg::PlatformExpression static Expr Or(std::vector&& exprs); // since ExprImpl is not yet defined, we need to define the ctor and dtor in the C++ file - Expr(); // always true + Expr() noexcept; // always true Expr(const Expr&); - Expr(Expr&&); + Expr(Expr&&) noexcept; Expr& operator=(const Expr& e); - Expr& operator=(Expr&&); + Expr& operator=(Expr&&) noexcept; explicit Expr(std::unique_ptr&& e); ~Expr(); diff --git a/include/vcpkg/portfileprovider.h b/include/vcpkg/portfileprovider.h index a2056aaf4a..1be1b46d58 100644 --- a/include/vcpkg/portfileprovider.h +++ b/include/vcpkg/portfileprovider.h @@ -13,7 +13,7 @@ namespace vcpkg { struct PortFileProvider { - virtual ~PortFileProvider(); + virtual ~PortFileProvider() = default; virtual ExpectedL get_control_file(const std::string& src_name) const = 0; virtual std::vector load_all_control_files() const = 0; }; @@ -33,7 +33,7 @@ namespace vcpkg struct IVersionedPortfileProvider { virtual View get_port_versions(StringView port_name) const = 0; - virtual ~IVersionedPortfileProvider(); + virtual ~IVersionedPortfileProvider() = default; virtual ExpectedL get_control_file( const VersionSpec& version_spec) const = 0; @@ -47,12 +47,12 @@ namespace vcpkg struct IBaselineProvider { virtual ExpectedL get_baseline_version(StringView port_name) const = 0; - virtual ~IBaselineProvider(); + virtual ~IBaselineProvider() = default; }; struct IOverlayProvider { - virtual ~IOverlayProvider(); + virtual ~IOverlayProvider() = default; virtual Optional get_control_file(StringView port_name) const = 0; }; diff --git a/include/vcpkg/statusparagraphs.h b/include/vcpkg/statusparagraphs.h index 320e3c4fc0..d8e2624099 100644 --- a/include/vcpkg/statusparagraphs.h +++ b/include/vcpkg/statusparagraphs.h @@ -15,7 +15,7 @@ namespace vcpkg /// struct StatusParagraphs { - StatusParagraphs(); + StatusParagraphs() = default; explicit StatusParagraphs(std::vector>&& ps); using container = std::vector>; diff --git a/include/vcpkg/vcpkgcmdarguments.h b/include/vcpkg/vcpkgcmdarguments.h index 52ee7edcbf..0ba820784b 100644 --- a/include/vcpkg/vcpkgcmdarguments.h +++ b/include/vcpkg/vcpkgcmdarguments.h @@ -22,9 +22,9 @@ namespace vcpkg { struct ParsedArguments { - std::set> switches; - std::map> settings; - std::map, std::less<>> multisettings; + std::set> switches; + std::map> settings; + std::map, std::less<>> multisettings; const std::string* read_setting(StringLiteral setting) const noexcept; @@ -181,7 +181,7 @@ namespace vcpkg LocalizedString get_example_text() const; }; - void print_usage(const CommandMetadata& command_metadata); + LocalizedString usage_for_command(const CommandMetadata& command_metadata); struct FeatureFlagSettings { @@ -197,10 +197,6 @@ namespace vcpkg std::string value; PortApplicableSetting(StringView setting); - PortApplicableSetting(const PortApplicableSetting&); - PortApplicableSetting(PortApplicableSetting&&); - PortApplicableSetting& operator=(const PortApplicableSetting&); - PortApplicableSetting& operator=(PortApplicableSetting&&); bool is_port_affected(StringView port_name) const noexcept; private: @@ -378,7 +374,7 @@ namespace vcpkg ParsedArguments parse_arguments(const CommandMetadata& command_metadata) const; void imbue_from_environment(); - void imbue_from_fake_environment(const std::map>& env); + void imbue_from_fake_environment(const std::map>& env); // Applies recursive settings from the environment or sets a global environment variable // to be consumed by subprocesses; may only be called once per process. @@ -394,12 +390,6 @@ namespace vcpkg const std::vector& get_forwardable_arguments() const noexcept; - VcpkgCmdArguments(const VcpkgCmdArguments&); - VcpkgCmdArguments(VcpkgCmdArguments&&); - VcpkgCmdArguments& operator=(const VcpkgCmdArguments&); - VcpkgCmdArguments& operator=(VcpkgCmdArguments&&); - ~VcpkgCmdArguments(); - private: VcpkgCmdArguments(CmdParser&& parser); @@ -412,7 +402,7 @@ namespace vcpkg Optional m_detected_ci_environment; - friend void print_usage(const CommandMetadata& command_metadata); + friend LocalizedString usage_for_command(const CommandMetadata& command_metadata); CmdParser parser; }; } diff --git a/locales/messages.cs.json b/locales/messages.cs.json index 6fe7f94dc8..22b1ea47b2 100644 --- a/locales/messages.cs.json +++ b/locales/messages.cs.json @@ -378,7 +378,6 @@ "CommandEnvExample2": "vcpkg env \"ninja -C \" --triplet x64-windows", "CommandFailed": "Příkaz:\n{command_line}\nselhal s následujícími výsledky:", "CommunityTriplets": "Trojčata komunity:", - "ComparingUtf8Decoders": "Porovnání kodérů Utf8Decoder s různými původy; toto je vždy chyba", "CompressFolderFailed": "Nepovedlo se zkomprimovat složku „{path}“:", "ComputingInstallPlan": "Počítá se plán instalace…", "ConfigurationErrorRegistriesWithoutBaseline": "Konfigurace definovaná v cestě {path} je neplatná.\n\n Použití registrů vyžaduje, aby byl pro výchozí registr nastaven směrný plán nebo aby výchozí registr byl null.\n\n Další podrobnosti najdete na adrese {url}.", @@ -550,7 +549,7 @@ "FailedToRunToolToDetermineVersion": "Nepodařilo se spustit {path} s cílem zjistit verzi {tool_name}.", "FailedToStoreBackToMirror": "Nepovedlo se uložit zpět na zrcadlení:", "FailedToStoreBinaryCache": "Nepovedlo se uložit binární mezipaměť {path}.", - "FailedToTakeFileSystemLock": "Failed to take the filesystem lock", + "FailedToTakeFileSystemLock": "Nepovedlo se uzamknout systém souborů.", "FailedToWriteManifest": "Nepovedlo se zapsat soubor manifestu {path}", "FailedVendorAuthentication": "Ověření nejméně jednoho zprostředkovatele přihlašovacích údajů {vendor} se nepovedlo. Další podrobnosti o tom, jak zadat přihlašovací údaje, najdete adrese {url}.", "FetchingBaselineInfo": "Načítá se informace o směrném plánu z {package_name}...", @@ -573,7 +572,7 @@ "FollowingPackagesUpgraded": "Následující balíčky jsou aktuální:", "ForMoreHelp": "Další pomoc", "ForceSystemBinariesOnWeirdPlatforms": "Proměnná prostředí VCPKG_FORCE_SYSTEM_BINARIES musí být nastavená na platformách arm, s390x, ppc64le a riscv.", - "FormattedParseMessageExpression": "výraz on: {value}", + "FormattedParseMessageExpressionPrefix": "výraz on:", "GHAParametersMissing": "Binární zdroj GHA vyžaduje nastavení proměnných prostředí ACTIONS_RUNTIME_TOKEN a ACTIONS_CACHE_URL. Podrobnosti najdete na adrese {url}.", "GeneratedConfiguration": "Vygenerovaná konfigurace {path}.", "GeneratedInstaller": "Instalační program {path} se vygeneroval.", @@ -676,7 +675,6 @@ "ImproperShaLength": "Algoritmy SHA512 musí mít 128 šestnáctkových znaků: {value}", "IncorrectArchiveFileSignature": "Nesprávný podpis souboru archivu", "IncorrectPESignature": "Nesprávný podpis PE", - "IncrementedUtf8Decoder": "Inkrementovaný Utf8Decoder na konci řetězce", "InfoSetEnvVar": "{env_var} můžete také nastavit ve vámi zvoleném editoru.", "InitRegistryFailedNoRepo": "Na cestě {path} se nepovedlo vytvořit registr, protože se nejedná o kořenový adresář úložiště GIT.\nPomocí příkazu git init {command_line} vytvořte v této složce úložiště GIT.", "InstallCopiedFile": "{path_source} -> {path_destination} dokončena", @@ -1038,7 +1036,7 @@ "UnexpectedPortversion": "Neočekávaná verze portu bez pole správy verzí", "UnexpectedSwitch": "neočekávaný příkaz switch: {option}", "UnexpectedToolOutput": "Nástroj {tool_name} ({path}) vygeneroval neočekávaný výstup při pokusu o určení verze:", - "UnexpectedWindowsArchitecture": "unexpected Windows host architecture: {actual}", + "UnexpectedWindowsArchitecture": "neočekávaná architektura hostitele s Windows: {actual}", "UnknownBaselineFileContent": "nerozpoznatelná položka směrného plánu; očekávalo se port:triplet=(fail|skip|pass)", "UnknownBinaryProviderType": "Neznámý typ binárního zprostředkovatele: platní zprostředkovatelé jsou clear, default, nuget, nugetconfig, nugettimeout, interactive, x-azblob, x-gcs, x-aws, x-aws-config, http a files.", "UnknownBooleanSetting": "neznámé nastavení logického operátoru pro možnost {option}: „{value}“. Platné hodnoty jsou 1, 0, ON, OFF, TRUE a FALSE, nebo prázdné.", diff --git a/locales/messages.de.json b/locales/messages.de.json index 5456722869..c16f62529d 100644 --- a/locales/messages.de.json +++ b/locales/messages.de.json @@ -378,7 +378,6 @@ "CommandEnvExample2": "vcpkg env „ninja -C “ --triplet x64-windows", "CommandFailed": "Befehl:\n{command_line}\nmit den folgenden Ergebnissen fehlgeschlagen:", "CommunityTriplets": "Community-Triplets:", - "ComparingUtf8Decoders": "Utf8Decoders mit unterschiedlicher Herkunft vergleichen; dies ist immer ein Fehler.", "CompressFolderFailed": "Fehler beim Komprimieren des Ordners \"{path}\":", "ComputingInstallPlan": "Installationsplan wird berechnet...", "ConfigurationErrorRegistriesWithoutBaseline": "Die in {path} definierte Konfiguration ist ungültig.\n\nDie Verwendung von Registrierungen erfordert, dass eine Baseline für die Standardregistrierung festgelegt ist, oder dass die Standardregistrierung NULL ist.\n\nWeitere Informationen finden Sie unter {url}.", @@ -550,7 +549,7 @@ "FailedToRunToolToDetermineVersion": "Fehler beim Ausführen von „{path}“ zum Bestimmen der {tool_name}-Version.", "FailedToStoreBackToMirror": "Fehler beim Speichern in der Spiegelung:", "FailedToStoreBinaryCache": "Fehler beim Speichern des binären Caches {path}", - "FailedToTakeFileSystemLock": "Failed to take the filesystem lock", + "FailedToTakeFileSystemLock": "Fehler beim Verarbeiten der Dateisystemsperre.", "FailedToWriteManifest": "Fehler beim Schreiben der Manifestdatei \"{path}\".", "FailedVendorAuthentication": "Mindestens ein {vendor}-Anmeldeinformationsanbieter konnte nicht authentifiziert werden. Weitere Informationen zum Bereitstellen von Anmeldeinformationen finden Sie unter \"{url}\".", "FetchingBaselineInfo": "Baselineinformationen werden von \"{package_name}\" abgerufen...", @@ -573,7 +572,7 @@ "FollowingPackagesUpgraded": "Die folgenden Pakete sind auf dem neuesten Stand:", "ForMoreHelp": "Weitere Hilfe", "ForceSystemBinariesOnWeirdPlatforms": "Die Umgebungsvariable VCPKG_FORCE_SYSTEM_BINARIES muss auf ARM-, S390x-, riscv- und ppc64le-Plattformen festgelegt werden.", - "FormattedParseMessageExpression": "beim Ausdruck: {value}", + "FormattedParseMessageExpressionPrefix": "on-Ausdruck:", "GHAParametersMissing": "Die binäre GHA-Quelle erfordert, dass die Umgebungsvariablen ACTIONS_RUNTIME_TOKEN und ACTIONS_CACHE_URL festgelegt werden. Weitere Informationen finden Sie unter {url}.", "GeneratedConfiguration": "Die Konfiguration \"{path}\" wurde generiert.", "GeneratedInstaller": "{path} Installationsprogramm wurde generiert.", @@ -676,7 +675,6 @@ "ImproperShaLength": "SHA512-Zeichen müssen 128 Hexadezimalzeichen umfassen: {value}", "IncorrectArchiveFileSignature": "Falsche Archivdateisignatur", "IncorrectPESignature": "Falsche PE-Signatur", - "IncrementedUtf8Decoder": "Erhöhter Utf8Decoder am Ende der Zeichenfolge", "InfoSetEnvVar": "Sie können {env_var} auch auf Ihren bevorzugten Editor festlegen.", "InitRegistryFailedNoRepo": "Unter {path} konnte keine Registrierung erstellt werden, da es sich nicht um einen Git-Repositorystamm handelt.\nVerwenden Sie „git init {command_line}“, um ein Git-Repository in diesem Ordner zu erstellen.", "InstallCopiedFile": "{path_source} -> {path_destination} abgeschlossen", @@ -1038,7 +1036,7 @@ "UnexpectedPortversion": "Unerwartete \"port-version\" ohne Versionsverwaltungsfeld", "UnexpectedSwitch": "Unerwarteter Schalter: {option}", "UnexpectedToolOutput": "{tool_name} ({path}) hat beim Versuch, die Version zu bestimmen, eine unerwartete Ausgabe erzeugt:", - "UnexpectedWindowsArchitecture": "unexpected Windows host architecture: {actual}", + "UnexpectedWindowsArchitecture": "Unerwartete Windows-Hostarchitektur: {actual}", "UnknownBaselineFileContent": "Nicht erkennbarer Baselineeintrag; erwartet \"port:triplet=(fail|skip)\".", "UnknownBinaryProviderType": "Unbekannter Binäranbietertyp: Gültige Anbieter sind \"clear\", \"default\", \"nuget\", \"nugetconfig\", \"nugettimeout\", \"interactive\", \"interactive\", \"x-azblob\", \"x-gcs\", \"x-aws\", \"x-aws-config\", \"http\" und \"files\"", "UnknownBooleanSetting": "unbekannte boolesche Einstellung für die Option {option}: „{value}“. Gültige Werte sind „,“, „1“, „0“, „ON“, „OFF“, „TRUE“ und „FALSE“.", diff --git a/locales/messages.es.json b/locales/messages.es.json index 838eee3b73..92993c7351 100644 --- a/locales/messages.es.json +++ b/locales/messages.es.json @@ -378,7 +378,6 @@ "CommandEnvExample2": "vcpkg env \"ninja -C \" --triplet x64-windows", "CommandFailed": "command:\n{command_line}\nha fallado con los siguientes resultados:", "CommunityTriplets": "Tripletes de la comunidad:", - "ComparingUtf8Decoders": "Comparación de Utf8Decoders con otra proveniencia; esto siempre es un error", "CompressFolderFailed": "No se pudo comprimir la carpeta \"{path}\":", "ComputingInstallPlan": "Calculando plan de instalación...", "ConfigurationErrorRegistriesWithoutBaseline": "La configuración definida en {path} no es válida.\n\nEl uso de registros requiere que se establezca una línea base para el registro predeterminado o que el registro predeterminado sea null.\n\nConsulte {url} para obtener más detalles.", @@ -550,7 +549,7 @@ "FailedToRunToolToDetermineVersion": "No se pudo ejecutar \"{path}\" para determinar la versión de {tool_name}.", "FailedToStoreBackToMirror": "no se pudo almacenar en el reflejo:", "FailedToStoreBinaryCache": "No se pudo almacenar la caché binaria {path}", - "FailedToTakeFileSystemLock": "Failed to take the filesystem lock", + "FailedToTakeFileSystemLock": "No se pudo realizar el bloqueo del sistema de archivos", "FailedToWriteManifest": "No se pudo escribir el archivo de manifiesto {path}", "FailedVendorAuthentication": "No se pudieron autenticar uno o varios proveedores de credenciales de {vendor}. Consulte \"{url}\" para obtener más detalles sobre cómo proporcionar credenciales.", "FetchingBaselineInfo": "Obteniendo información de referencia de {package_name}...", @@ -573,7 +572,7 @@ "FollowingPackagesUpgraded": "Los siguientes paquetes están actualizados:", "ForMoreHelp": "Para obtener más ayuda", "ForceSystemBinariesOnWeirdPlatforms": "La variable de entorno VCPKG_FORCE_SYSTEM_BINARIES debe establecerse en las plataformas arm, s390x, ppc64le y riscv.", - "FormattedParseMessageExpression": "en expresión: {value}", + "FormattedParseMessageExpressionPrefix": "en la expresión:", "GHAParametersMissing": "El origen binario GHA requiere que se establezcan las variables de entorno ACTIONS_RUNTIME_TOKEN y ACTIONS_CACHE_URL. Consulte {url} para obtener más detalles.", "GeneratedConfiguration": "{path} de configuración generada.", "GeneratedInstaller": "Se generó el instalador {path}.", @@ -676,7 +675,6 @@ "ImproperShaLength": "Sha512 debe tener 128 caracteres hexadecimales: {value}", "IncorrectArchiveFileSignature": "Firma de archivo incorrecta", "IncorrectPESignature": "Firma incorrecta del PE", - "IncrementedUtf8Decoder": "Utf8Decoder incrementado al final de la cadena", "InfoSetEnvVar": "También puede establecer {env_var} en el editor que prefiera.", "InitRegistryFailedNoRepo": "No se pudo crear un registro en {path} porque no es una raíz de repositorio git.\nUse \"git init {command_line}\" para crear un repositorio git en esta carpeta.", "InstallCopiedFile": "{path_source} -> {path_destination} listo", @@ -1038,7 +1036,7 @@ "UnexpectedPortversion": "\"port-version\" inesperado sin un campo de control de versión", "UnexpectedSwitch": "modificador inesperado: {option}", "UnexpectedToolOutput": "{tool_name} ({path}) produjo una salida inesperada al intentar determinar la versión:", - "UnexpectedWindowsArchitecture": "unexpected Windows host architecture: {actual}", + "UnexpectedWindowsArchitecture": "Arquitectura de host de Windows inesperada: {actual}", "UnknownBaselineFileContent": "entrada de base de referencia irreconocible; se esperaba 'port:triplet=(fail|skip|pass)'", "UnknownBinaryProviderType": "tipo de proveedor binario desconocido: los proveedores válidos son \"clear\", \"default\", \"nuget\", \"nugetconfig\", \"nugettimeout\", \"interactive\", \"x-azblob\", \"x-gcs\", \"x-aws\", \"x-aws-config\", \"http\" y \"files\".", "UnknownBooleanSetting": "valor booleano desconocido para {option}: \"{value}\". Los valores válidos son '', '1', '0', 'ON', 'OFF', 'TRUE' y 'FALSE'.", diff --git a/locales/messages.fr.json b/locales/messages.fr.json index 7873506bbd..fb6c844a2f 100644 --- a/locales/messages.fr.json +++ b/locales/messages.fr.json @@ -378,7 +378,6 @@ "CommandEnvExample2": "vcpkg env \"ninja -C \" --triplet x64-windows", "CommandFailed": "Commande : \n {command_line}\na échoué avec les résultats suivants :", "CommunityTriplets": "Triplets de la communauté :", - "ComparingUtf8Decoders": "Comparaison des Utf8Decoders avec une provenance différente ; il s’agit toujours d’une erreur", "CompressFolderFailed": "Échec de la compression du dossier « {path} » :", "ComputingInstallPlan": "Calcul du plan d’installation...", "ConfigurationErrorRegistriesWithoutBaseline": "La configuration définie dans {path} n’est pas valide.\n\nL’utilisation de registres nécessite qu’une ligne de base soit définie pour le Registre par défaut ou que le Registre par défaut soit null.\n\nPour plus d’informations, consultez {url}.", @@ -550,7 +549,7 @@ "FailedToRunToolToDetermineVersion": "Impossible d’exécuter {path} pour déterminer la version {tool_name}.", "FailedToStoreBackToMirror": "échec du stockage dans le miroir :", "FailedToStoreBinaryCache": "Échec du stockage du cache binaire {path}", - "FailedToTakeFileSystemLock": "Failed to take the filesystem lock", + "FailedToTakeFileSystemLock": "Échec de la prise du verrou du système de fichiers", "FailedToWriteManifest": "Échec de l’écriture du fichier manifeste {path}", "FailedVendorAuthentication": "Un ou plusieurs fournisseurs d’informations d’identification {vendor} n’ont pas pu s’authentifier. Consultez '{url}' pour plus d’informations sur la façon de fournir des informations d’identification.", "FetchingBaselineInfo": "Récupération des informations de référence à partir de {package_name}...", @@ -573,7 +572,7 @@ "FollowingPackagesUpgraded": "Les packages suivants sont mis à jour :", "ForMoreHelp": "Pour plus d’aide", "ForceSystemBinariesOnWeirdPlatforms": "La variable d’environnement VCPKG_FORCE_SYSTEM_BINARIES doit être définie sur les plateformes arm, s390x, ppc64le et riscv.", - "FormattedParseMessageExpression": "sur l’expression : {value}", + "FormattedParseMessageExpressionPrefix": "sur l’expression :", "GHAParametersMissing": "La source binaire GHA nécessite la définition des variables d’environnement ACTIONS_RUNTIME_TOKEN et ACTIONS_CACHE_URL. Pour plus d’informations, consultez {url}.", "GeneratedConfiguration": "Configuration générée {path}.", "GeneratedInstaller": "Le programme d’installation de {path} a été généré.", @@ -676,7 +675,6 @@ "ImproperShaLength": "SHA512 doit comporter 128 caractères hexadécimaux : {value}.", "IncorrectArchiveFileSignature": "Signature de fichier d’archive incorrecte", "IncorrectPESignature": "Signature PE incorrecte", - "IncrementedUtf8Decoder": "Utf8Decoder incrémenté à la fin de la chaîne", "InfoSetEnvVar": "Vous pouvez également définir {env_var} sur l’éditeur de votre choix.", "InitRegistryFailedNoRepo": "Impossible de créer un registre sur {path}, car il ne s’agit pas d’une racine de dépôt Git.\nUtilisez `git init {command_line}` pour créer un référentiel Git dans ce dossier.", "InstallCopiedFile": "{path_source} -> {path_destination} effectué", @@ -1038,7 +1036,7 @@ "UnexpectedPortversion": "« port-version » inattendu sans champ de contrôle de version", "UnexpectedSwitch": "commutateur inattendu : {option}", "UnexpectedToolOutput": "{tool_name} ({path}) a produit une sortie inattendue lors de la tentative de détermination de la version :", - "UnexpectedWindowsArchitecture": "unexpected Windows host architecture: {actual}", + "UnexpectedWindowsArchitecture": "architecture d’hôte Windows inattendue : {actual}", "UnknownBaselineFileContent": "entrée de base de référence non reconnaissable ; 'port:triplet=(fail|skip|pass)' attendu", "UnknownBinaryProviderType": "type de fournisseur binaire inconnu : les fournisseurs valides sont 'clear', 'default', 'nuget', 'nugetconfig', 'nugettimeout', 'interactive', 'x-azblob', 'x-gcs', 'x-aws', 'x-aws-config', 'http' et 'files'.", "UnknownBooleanSetting": "paramètre booléen inconnu pour {option} : \"{value}\". Les valeurs valides sont ' '', '1', '0', 'ON', 'OFF', 'TRUE' et 'FALSE'.", diff --git a/locales/messages.it.json b/locales/messages.it.json index 17c62dc9f8..2a226f67b6 100644 --- a/locales/messages.it.json +++ b/locales/messages.it.json @@ -378,7 +378,6 @@ "CommandEnvExample2": "vcpkg env \"ninja -C \" --triplet x64-windows", "CommandFailed": "Comando:\n{command_line}\nnon riuscito con i seguenti risultati:", "CommunityTriplets": "Triplette della community:", - "ComparingUtf8Decoders": "Confronto di Utf8Decoder con provenienza diversa; si tratta sempre di un errore", "CompressFolderFailed": "Impossibile comprimere la cartella “{path}”:", "ComputingInstallPlan": "Elaborazione del piano di installazione in corso...", "ConfigurationErrorRegistriesWithoutBaseline": "La configurazione definita in {path} non è valida.\n\nL'uso dei registri richiede che sia impostata una baseline per il Registro di sistema predefinito o che il Registro di sistema predefinito sia Null.\n\nPer altri dettagli, vedere {url}.", @@ -550,7 +549,7 @@ "FailedToRunToolToDetermineVersion": "Non è stato possibile eseguire {path} per determinare la versione {tool_name}.", "FailedToStoreBackToMirror": "non è stato possibile archiviare nuovamente nel mirror:", "FailedToStoreBinaryCache": "Non è stato possibile archiviare la cache binaria {path}", - "FailedToTakeFileSystemLock": "Failed to take the filesystem lock", + "FailedToTakeFileSystemLock": "Non è stato possibile accettare il blocco del file system", "FailedToWriteManifest": "Non è stato possibile scrivere il file manifesto {path}", "FailedVendorAuthentication": "Impossibile autenticare uno o più provider di credenziali {vendor}. Per altri dettagli su come fornire le credenziali, vedere '{url}'.", "FetchingBaselineInfo": "Recupero delle informazioni di base da {package_name}...", @@ -573,7 +572,7 @@ "FollowingPackagesUpgraded": "I pacchetti seguenti sono aggiornati:", "ForMoreHelp": "Per altra guida", "ForceSystemBinariesOnWeirdPlatforms": "La variabile di ambiente VCPKG_FORCE_SYSTEM_BINARIES deve essere impostata su piattaforme arm, s390x, ppc64le e riscv.", - "FormattedParseMessageExpression": "nell'espressione: {value}", + "FormattedParseMessageExpressionPrefix": "sull'espressione:", "GHAParametersMissing": "L'origine binaria BINARY DI AZURE richiede l'impostazione delle variabili di ambiente ACTIONS_RUNTIME_TOKEN e ACTIONS_CACHE_URL. Per informazioni dettagliate, vedere {url}.", "GeneratedConfiguration": "Configurazione {path} generata.", "GeneratedInstaller": "Il programma di installazione {path} è stato generato.", @@ -676,7 +675,6 @@ "ImproperShaLength": "I caratteri SHA512 devono essere composti da 128 caratteri esadecimali: {value}", "IncorrectArchiveFileSignature": "Firma del file di archivio non corretta", "IncorrectPESignature": "Firma PE non corretta", - "IncrementedUtf8Decoder": "Utf8Decoder incrementato alla fine della stringa", "InfoSetEnvVar": "Puoi anche impostare {env_var} sul tuo editor preferito.", "InitRegistryFailedNoRepo": "Non è stato possibile creare un Registro di sistema in {path} perché non si tratta di un repository Git root.\nUsa 'git init {command_line}' per creare un repository git in questa cartella.", "InstallCopiedFile": "{path_source} -> {path_destination} completato", @@ -1038,7 +1036,7 @@ "UnexpectedPortversion": "\"port-version\" imprevisto senza un campo di controllo delle versioni", "UnexpectedSwitch": "opzione imprevista: {option}", "UnexpectedToolOutput": "{tool_name} ({path}) ha prodotto un output imprevisto mentre tentava di determinare la versione:", - "UnexpectedWindowsArchitecture": "unexpected Windows host architecture: {actual}", + "UnexpectedWindowsArchitecture": "architettura host Windows imprevista: {actual}", "UnknownBaselineFileContent": "voce baseline non riconoscibile; previsto 'port:triplet=(fail|skip)'", "UnknownBinaryProviderType": "tipo di provider binario sconosciuto: i provider validi sono 'clear', 'default', 'nuget', 'nugetconfig', 'nugettimeout', 'interactive', 'x-azblob', 'x-gcs', 'x-aws', 'x-aws-config', 'http' e 'files'", "UnknownBooleanSetting": "impostazione booleana sconosciuta per {option}: \"{value}\". I valori validi sono '', '1', '0', 'ON', 'OFF', 'TRUE' e 'FALSE'.", diff --git a/locales/messages.ja.json b/locales/messages.ja.json index ce78bff280..4ca0e0f48d 100644 --- a/locales/messages.ja.json +++ b/locales/messages.ja.json @@ -378,7 +378,6 @@ "CommandEnvExample2": "vcpkg env \"ninja -C \" --triplet x64-windows", "CommandFailed": "コマンド: \n{command_line}\nに失敗しました。次の結果が返されました:", "CommunityTriplets": "コミュニティ トリプレット:", - "ComparingUtf8Decoders": "Utf8Decoders と異なる来歴との比較では、常にエラーが発生します", "CompressFolderFailed": "フォルダー \"{path}\":を圧縮できませんでした:", "ComputingInstallPlan": "インストール プランを計算しています...", "ConfigurationErrorRegistriesWithoutBaseline": "{path} で定義されている構成が無効です。\n\nレジストリを使用するには、既定のレジストリにベースラインが設定されているか、既定のレジストリが null である必要があります。\n\n詳細については、{url} を参照してください。", @@ -550,7 +549,7 @@ "FailedToRunToolToDetermineVersion": "\"{path}\" を実行して {tool_name} バージョンを特定できませんでした。", "FailedToStoreBackToMirror": "ミラーに保存できませんでした:", "FailedToStoreBinaryCache": "バイナリ キャッシュ {path} を格納できませんでした", - "FailedToTakeFileSystemLock": "Failed to take the filesystem lock", + "FailedToTakeFileSystemLock": "ファイル システム ロックを取得できませんでした", "FailedToWriteManifest": "マニフェスト ファイル {path} を書き込めませんでした", "FailedVendorAuthentication": "1 つ以上の {vendor} 資格情報プロバイダーを認証できませんでした。資格情報を提供する方法の詳細については、'{url}' を参照してください。", "FetchingBaselineInfo": "{package_name} からベースライン情報をフェッチしています...", @@ -573,7 +572,7 @@ "FollowingPackagesUpgraded": "次のパッケージは最新です:", "ForMoreHelp": "詳細なヘルプ", "ForceSystemBinariesOnWeirdPlatforms": "arm、s390x、ppc64le、riscv プラットフォームでは、環境変数 VCPKG_FORCE_SYSTEM_BINARIES を設定する必要があります。", - "FormattedParseMessageExpression": "式: {value}", + "FormattedParseMessageExpressionPrefix": "式について:", "GHAParametersMissing": "GHA バイナリ ソースでは、ACTIONS_RUNTIME_TOKEN環境変数とACTIONS_CACHE_URL環境変数を設定する必要があります。詳細については、{url} を参照してください。", "GeneratedConfiguration": "構成 {path} を生成しました。", "GeneratedInstaller": "{path} インストーラーが生成されました。", @@ -676,7 +675,6 @@ "ImproperShaLength": "SHA512 は 128 文字の 16 進文字である必要があります: {value}", "IncorrectArchiveFileSignature": "アーカイブ ファイルの署名が正しくありません", "IncorrectPESignature": "PE 署名が正しくありません", - "IncrementedUtf8Decoder": "文字列の末尾に増分された Utf8Decoder", "InfoSetEnvVar": "{env_var} を任意のエディターに設定することもできます。", "InitRegistryFailedNoRepo": "これは Git リポジトリのルートではないため、{path} にレジストリを作成できませんでした。\n'git init {command_line}' を使用して、このフォルダーに Git リポジトリを作成します。", "InstallCopiedFile": "{path_source} -> {path_destination} 完了", @@ -1038,7 +1036,7 @@ "UnexpectedPortversion": "バージョン管理フィールドのない予期しない \"port-version\" です", "UnexpectedSwitch": "予期しない切り替え: {option}", "UnexpectedToolOutput": "{tool_name} ({path}) は、バージョンを特定しようとしたときに予期しない出力を生成しました:", - "UnexpectedWindowsArchitecture": "unexpected Windows host architecture: {actual}", + "UnexpectedWindowsArchitecture": "予期しない Windows ホスト アーキテクチャ: {actual}", "UnknownBaselineFileContent": "認識できないベースライン エントリ;'port:triplet=(fail|skip|pass)' が必要です", "UnknownBinaryProviderType": "不明なバイナリ プロバイダー タイプ: 有効なプロバイダーは 'clear'、'default'、'nuget'、'nugetconfig'、'nugettimeout'、'interactive'、'x-azblob'、'x-gcs'、'x-aws'、'x-aws-config'、'http'、'files' です", "UnknownBooleanSetting": "{option} の不明なブール値の設定: \"{value}\"。有効な値は ''、'1'、'0'、'ON'、'OFF'、'TRUE'、および 'FALSE' です。", diff --git a/locales/messages.json b/locales/messages.json index 01a12a6aca..1bb0e51574 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -511,7 +511,6 @@ "CommandFailed": "command:\n{command_line}\nfailed with the following results:", "_CommandFailed.comment": "An example of {command_line} is vcpkg install zlib.", "CommunityTriplets": "Community Triplets:", - "ComparingUtf8Decoders": "Comparing Utf8Decoders with different provenance; this is always an error", "CompressFolderFailed": "Failed to compress folder \"{path}\":", "_CompressFolderFailed.comment": "An example of {path} is /foo/bar.", "ComputingInstallPlan": "Computing installation plan...", @@ -828,8 +827,7 @@ "ForMoreHelp": "For More Help", "_ForMoreHelp.comment": "Printed before a suggestion for the user to run `vcpkg help `", "ForceSystemBinariesOnWeirdPlatforms": "Environment variable VCPKG_FORCE_SYSTEM_BINARIES must be set on arm, s390x, ppc64le and riscv platforms.", - "FormattedParseMessageExpression": "on expression: {value}", - "_FormattedParseMessageExpression.comment": "Example of {value} is 'x64 & windows'", + "FormattedParseMessageExpressionPrefix": "on expression:", "GHAParametersMissing": "The GHA binary source requires the ACTIONS_RUNTIME_TOKEN and ACTIONS_CACHE_URL environment variables to be set. See {url} for details.", "_GHAParametersMissing.comment": "An example of {url} is https://github.com/microsoft/vcpkg.", "GeneratedConfiguration": "Generated configuration {path}.", @@ -972,7 +970,6 @@ "_ImproperShaLength.comment": "{value} is a sha.", "IncorrectArchiveFileSignature": "Incorrect archive file signature", "IncorrectPESignature": "Incorrect PE signature", - "IncrementedUtf8Decoder": "Incremented Utf8Decoder at the end of the string", "InfoSetEnvVar": "You can also set {env_var} to your editor of choice.", "_InfoSetEnvVar.comment": "In this context 'editor' means IDE An example of {env_var} is VCPKG_DEFAULT_TRIPLET.", "InitRegistryFailedNoRepo": "Could not create a registry at {path} because this is not a git repository root.\nUse `git init {command_line}` to create a git repository in this folder.", diff --git a/locales/messages.ko.json b/locales/messages.ko.json index 52d35e7d1b..8fdbc08a17 100644 --- a/locales/messages.ko.json +++ b/locales/messages.ko.json @@ -378,7 +378,6 @@ "CommandEnvExample2": "vcpkg env \"ninja -C <경로>\" --triplet x64-windows", "CommandFailed": "명령:\n{command_line}\n다음 결과와 함께 실패했습니다.", "CommunityTriplets": "커뮤니티 Triplets:", - "ComparingUtf8Decoders": "출처가 다른 Utf8Decoder 비교 중; 항상 오류입니다", "CompressFolderFailed": "폴더 \"{path}\"을(를) 압축하지 못했습니다.", "ComputingInstallPlan": "설치 계획을 계산하는 중...", "ConfigurationErrorRegistriesWithoutBaseline": "{path}에 정의된 구성이 잘못되었습니다.\n\n레지스트리를 사용하려면 기본 레지스트리에 대한 기준이 설정되어 있거나 기본 레지스트리가 null여야 합니다.\n\n자세한 내용은 {url}을(를) 참조하세요.", @@ -550,7 +549,7 @@ "FailedToRunToolToDetermineVersion": "{tool_name} 버전을 확인하기 위해 “{path}:을(를) 실행하지 못했습니다.", "FailedToStoreBackToMirror": "미러에 다시 저장하지 못했습니다:", "FailedToStoreBinaryCache": "이진 캐시 {path}을(를) 저장하지 못함", - "FailedToTakeFileSystemLock": "Failed to take the filesystem lock", + "FailedToTakeFileSystemLock": "파일 시스템 잠금을 가져오지 못함", "FailedToWriteManifest": "매니페스트 파일 {path}을(를) 쓰지 못함", "FailedVendorAuthentication": "하나 이상의 {vendor} 자격 증명 공급자가 인증에 실패했습니다. 자격 증명을 제공하는 방법에 대한 자세한 내용은 '{url}'을(를) 참조하세요.", "FetchingBaselineInfo": "{package_name}에서 기준 정보를 가져오는 중...", @@ -573,7 +572,7 @@ "FollowingPackagesUpgraded": "다음 패키지는 최신 상태입니다.", "ForMoreHelp": "추가 도움말", "ForceSystemBinariesOnWeirdPlatforms": "arm, s390x, ppc64le 및 riscv 플랫폼에서 환경 변수 VCPKG_FORCE_SYSTEM_BINARIES를 설정해야 합니다.", - "FormattedParseMessageExpression": "식: {value}", + "FormattedParseMessageExpressionPrefix": "on 식:", "GHAParametersMissing": "GHA 이진 원본을 사용하려면 ACTIONS_RUNTIME_TOKEN 및 ACTIONS_CACHE_URL 환경 변수를 설정해야 합니다. 자세한 내용은 {url}을(를) 참조하세요.", "GeneratedConfiguration": "생성된 구성 {path}입니다.", "GeneratedInstaller": "{path} 설치 프로그램이 생성되었습니다.", @@ -676,7 +675,6 @@ "ImproperShaLength": "SHA512는 128진수 문자여야 합니다. {value}", "IncorrectArchiveFileSignature": "잘못된 보관 파일 서명", "IncorrectPESignature": "잘못된 PE 서명", - "IncrementedUtf8Decoder": "문자열 끝에 증분된 Utf8Decoder", "InfoSetEnvVar": "{env_var}을(를) 선택한 편집기로 설정할 수도 있습니다.", "InitRegistryFailedNoRepo": "git 리포지토리 루트가 아니므로 {path}에 레지스트리를 만들 수 없습니다.\n`git init {command_line}`을(를) 사용하여 이 폴더에 git 리포지토리를 만듭니다.", "InstallCopiedFile": "{path_source} -> {path_destination} 완료", @@ -1038,7 +1036,7 @@ "UnexpectedPortversion": "버전 관리 필드가 없는 예기치 않은 \"port-version\"", "UnexpectedSwitch": "예기치 못한 전환: {option}", "UnexpectedToolOutput": "버전 확인을 시도할 때 {tool_name}({path})이(가) 예기치 않은 출력을 생성했습니다.", - "UnexpectedWindowsArchitecture": "unexpected Windows host architecture: {actual}", + "UnexpectedWindowsArchitecture": "예기치 않은 Windows 호스트 아키텍처: {actual}", "UnknownBaselineFileContent": "인식할 수 없는 기준 항목입니다; 'port:triplet=(fail|skip|pass)'가 필요합니다.", "UnknownBinaryProviderType": "알 수 없는 이진 파일 공급자 유형: 유효한 공급자는 'clear', 'default', 'nuget', 'nugetconfig','nugettimeout', 'interactive', 'x-azblob', 'x-gcs', 'x-aws', 'x-aws-config', 'http' 및 '파일'", "UnknownBooleanSetting": "{option}에 대한 알 수 없는 부울 설정입니다. \"{value}\". 유효한 값은 '', '1', '0', 'ON', 'OFF', 'TRUE' 및 'FALSE'입니다.", diff --git a/locales/messages.pl.json b/locales/messages.pl.json index aa9e7c1cc4..76764c3c98 100644 --- a/locales/messages.pl.json +++ b/locales/messages.pl.json @@ -378,7 +378,6 @@ "CommandEnvExample2": "vcpkg env „ninja -C ” --triplet x64-windows", "CommandFailed": "polecenie:\n{command_line}\nnie powiodło się z następującymi wynikami:", "CommunityTriplets": "Trójki społeczności:", - "ComparingUtf8Decoders": "Porównywanie Utf8Decoders z różnymi pochodzeniami; zawsze jest to błąd", "CompressFolderFailed": "Nie można skompresować folderu „{path}”:", "ComputingInstallPlan": "Trwa obliczanie planu instalacji...", "ConfigurationErrorRegistriesWithoutBaseline": "Konfiguracja zdefiniowana w ścieżce {path} jest nieprawidłowa.\n\nKorzystanie z rejestrów wymaga ustawienia punktu odniesienia dla rejestru domyślnego lub domyślnego rejestru o wartości null.\n\nZobacz {url}, aby uzyskać więcej szczegółów.", @@ -550,7 +549,7 @@ "FailedToRunToolToDetermineVersion": "Nie można uruchomić \"{path}\" w celu określenia wersji narzędzia {tool_name}.", "FailedToStoreBackToMirror": "nie można przechować z powrotem do dublowania:", "FailedToStoreBinaryCache": "Nie można zapisać binarnej pamięci podręcznej {path}", - "FailedToTakeFileSystemLock": "Failed to take the filesystem lock", + "FailedToTakeFileSystemLock": "Nie można zablokować systemu plików", "FailedToWriteManifest": "Nie można zapisać pliku manifestu {path}", "FailedVendorAuthentication": "Uwierzytelnienie co najmniej jednego dostawcy poświadczeń {vendor} nie powiodło się. Aby uzyskać więcej informacji na temat sposobu dostarczania poświadczeń, zobacz „{url}”.", "FetchingBaselineInfo": "Trwa pobieranie informacji o punkcie odniesienia z {package_name}...", @@ -573,7 +572,7 @@ "FollowingPackagesUpgraded": "Następujące pakiety są aktualne:", "ForMoreHelp": "Aby uzyskać dodatkową pomoc", "ForceSystemBinariesOnWeirdPlatforms": "Zmienna środowiskowa VCPKG_FORCE_SYSTEM_BINARIES musi być ustawiona na platformach ARM, s390x, ppc64le i RISCV.", - "FormattedParseMessageExpression": "w przypadku wyrażenia: {value}", + "FormattedParseMessageExpressionPrefix": "na wyrażeniu:", "GHAParametersMissing": "Źródło binarne GHA wymaga ustawienia zmiennych środowiskowych ACTIONS_RUNTIME_TOKEN i ACTIONS_CACHE_URL. Aby uzyskać szczegółowe informacje, zobacz {url}.", "GeneratedConfiguration": "Wygenerowano ścieżkę {path} konfiguracji.", "GeneratedInstaller": "Wygenerowano ścieżkę {path} instalatora.", @@ -676,7 +675,6 @@ "ImproperShaLength": "Zestaw SHA512 musi zawierać 128 znaków szesnastkowych: {value}", "IncorrectArchiveFileSignature": "Niepoprawny podpis pliku archiwum", "IncorrectPESignature": "Niepoprawny podpis PE", - "IncrementedUtf8Decoder": "Zwiększono Utf8Decoder na końcu ciągu", "InfoSetEnvVar": "Można również ustawić {env_var} na wybrany edytor.", "InitRegistryFailedNoRepo": "Nie można utworzyć rejestru w lokalizacji {path}, ponieważ nie jest to katalog główny repozytorium GIT.\nUżyj polecenia `git init {command_line}`, aby utworzyć repozytorium GIT w tym folderze.", "InstallCopiedFile": "{path_source} — > wykonano {path_destination}", @@ -1038,7 +1036,7 @@ "UnexpectedPortversion": "nieoczekiwany element „port-version” bez pola przechowywania wersji", "UnexpectedSwitch": "nieoczekiwany przełącznik: {option}", "UnexpectedToolOutput": "{tool_name} ({path}) wygenerował nieoczekiwane dane wyjściowe podczas próby określenia wersji:", - "UnexpectedWindowsArchitecture": "unexpected Windows host architecture: {actual}", + "UnexpectedWindowsArchitecture": "nieoczekiwana architektura hosta systemu Windows: {actual}", "UnknownBaselineFileContent": "nierozpoznawalny wpis punktu odniesienia; oczekiwano elementu „port:triplet=(fail|skip|pass)”", "UnknownBinaryProviderType": "nieznany typ dostawcy binarnego: prawidłowi dostawcy to „clear”, „default”, „nuget”, „nugetconfig”, „nugettimeout”, „interactive”, „x-azblob”, „x-gcs”, „x-aws”, „x-aws-config”, „http” i „files”", "UnknownBooleanSetting": "nieznane ustawienie wartości logicznej dla opcji {option}: „{value}”. Prawidłowe wartości to '', „1”, „0”, „ON”, „OFF”, „TRUE” i „FALSE”.", diff --git a/locales/messages.pt-BR.json b/locales/messages.pt-BR.json index db8a529ced..06e48d2659 100644 --- a/locales/messages.pt-BR.json +++ b/locales/messages.pt-BR.json @@ -378,7 +378,6 @@ "CommandEnvExample2": "vcpkg env \"ninja -C \" --triplet x64-windows", "CommandFailed": "o comando:\n{command_line}\nfalhou com os seguintes resultados:", "CommunityTriplets": "Tripletos da comunidade:", - "ComparingUtf8Decoders": "Comparação de Utf8Decoders com diferentes proveniências; isso é sempre um erro", "CompressFolderFailed": "Falha ao compactar a pasta \"{path}\":", "ComputingInstallPlan": "Plano de instalação de computação...", "ConfigurationErrorRegistriesWithoutBaseline": "A configuração definida em {path} é inválida.\n\nO uso de registros exige que uma linha de base seja definida para o registro padrão ou que o registro padrão seja nulo.\n\nConsulte {url} para obter mais detalhes.", @@ -550,7 +549,7 @@ "FailedToRunToolToDetermineVersion": "Falha ao executar \"{path}\" para determinar a versão de {tool_name}.", "FailedToStoreBackToMirror": "falha ao armazenar de volta ao espelho:", "FailedToStoreBinaryCache": "Falha ao armazenar o cache binário {path}", - "FailedToTakeFileSystemLock": "Failed to take the filesystem lock", + "FailedToTakeFileSystemLock": "Falha ao bloquear o sistema de arquivos", "FailedToWriteManifest": "Falha ao gravar o arquivo de manifesto {path}", "FailedVendorAuthentication": "Não foi possível autenticar um ou mais provedores de credenciais do {vendor}. Consulte '{url}' para obter mais detalhes sobre como fornecer credenciais.", "FetchingBaselineInfo": "Buscando informações de linha de base de {package_name}...", @@ -573,7 +572,7 @@ "FollowingPackagesUpgraded": "Os seguintes pacotes estão atualizados:", "ForMoreHelp": "Para obter mais ajuda", "ForceSystemBinariesOnWeirdPlatforms": "A variável de ambiente VCPKG_FORCE_SYSTEM_BINARIES deve ser definida nas plataformas arm, s390x, ppc64le e riscv.", - "FormattedParseMessageExpression": "na expressão: {value}", + "FormattedParseMessageExpressionPrefix": "na expressão:", "GHAParametersMissing": "A fonte binária GHA exige que as variáveis de ambiente ACTIONS_RUNTIME_TOKEN e ACTIONS_CACHE_URL sejam definidas. Confira {url} para obter mais informações.", "GeneratedConfiguration": "Configuração gerada {path}.", "GeneratedInstaller": "{path} instalador gerado.", @@ -676,7 +675,6 @@ "ImproperShaLength": "SHA512s devem ter 128 caracteres hexadecimais: {value}", "IncorrectArchiveFileSignature": "Assinatura incorreta do arquivo morto", "IncorrectPESignature": "Assinatura PE incorreta", - "IncrementedUtf8Decoder": "Incrementado Utf8Decoder no final da cadeia de caracteres", "InfoSetEnvVar": "Você também pode definir {env_var} para o editor da sua escolha.", "InitRegistryFailedNoRepo": "Não foi possível criar um registro em {path} porque este não é um repositório git root.\nUse 'git init {command_line}' para criar um repositório git nesta pasta.", "InstallCopiedFile": "{path_source} -> {path_destination} concluído", @@ -1038,7 +1036,7 @@ "UnexpectedPortversion": "\"port-version\" inesperado sem um campo de controle de versão", "UnexpectedSwitch": "opção inesperada: {option}", "UnexpectedToolOutput": "{tool_name} ({path}) produziu uma saída inesperada ao tentar determinar a versão:", - "UnexpectedWindowsArchitecture": "unexpected Windows host architecture: {actual}", + "UnexpectedWindowsArchitecture": "arquitetura inesperada do host do Windows: {actual}", "UnknownBaselineFileContent": "entrada de linha de base irreconhecível; esperado 'porta: tripleto=(fail|skip|pass)'", "UnknownBinaryProviderType": "tipo de provedor binário desconhecido: os provedores válidos são 'clear', 'default', 'nuget', 'nugetconfig','nugettimeout', 'interactive', 'x-azblob', 'x-gcs', 'x-aws', 'x-aws-config', 'http' e 'files'", "UnknownBooleanSetting": "configuração booleana desconhecida para {option}: \"{value}\". Os valores válidos são '', '1', '0', 'ON', 'OFF', 'TRUE' e 'FALSE'.", diff --git a/locales/messages.ru.json b/locales/messages.ru.json index 17f4ced438..07e795cf81 100644 --- a/locales/messages.ru.json +++ b/locales/messages.ru.json @@ -378,7 +378,6 @@ "CommandEnvExample2": "vcpkg env \"ninja -C <путь>\" --triplet x64-windows", "CommandFailed": "команда:\n{command_line}\nсбой со следующими результатами:", "CommunityTriplets": "Триплеты сообщества:", - "ComparingUtf8Decoders": "Сравнение Utf8Decoders с разным происхождением — это всегда ошибка", "CompressFolderFailed": "Сбой сжатия папки \"{path}\":", "ComputingInstallPlan": "Вычисление плана установки...", "ConfigurationErrorRegistriesWithoutBaseline": "Конфигурация, определенная в {path}, недопустима..\n\nПри использовании реестров необходимо, чтобы для стандартного реестра были настроены базовые показатели или чтобы стандартному реестру было присвоено значение NULL.\n\nДополнительные сведения: {url}.", @@ -550,7 +549,7 @@ "FailedToRunToolToDetermineVersion": "Сбой запуска \"{path}\" для определения версии {tool_name}.", "FailedToStoreBackToMirror": "не удалось сохранить обратно в зеркале:", "FailedToStoreBinaryCache": "Сбой сохранения двоичного кэша {path}", - "FailedToTakeFileSystemLock": "Failed to take the filesystem lock", + "FailedToTakeFileSystemLock": "Не удалось заблокировать файловую систему", "FailedToWriteManifest": "Не удалось записать файл манифеста {path}", "FailedVendorAuthentication": "Одному или нескольким поставщикам учетных данных {vendor} не удалось пройти аутентификацию. См. «{url}» для получения дополнительной информации о том, как предоставить учетные данные.", "FetchingBaselineInfo": "Извлечение базовой информации из {package_name}...", @@ -573,7 +572,7 @@ "FollowingPackagesUpgraded": "Следующие пакеты обновлены.", "ForMoreHelp": "Для получения дополнительной справки", "ForceSystemBinariesOnWeirdPlatforms": "Переменная среды VCPKG_FORCE_SYSTEM_BINARIES должна быть задана на платформах ARM, s390x, ppc64le и RISC.", - "FormattedParseMessageExpression": "в выражении: {value}", + "FormattedParseMessageExpressionPrefix": "в выражении:", "GHAParametersMissing": "Для двоичного источника GHA требуется настройка переменных среды ACTIONS_RUNTIME_TOKEN и ACTIONS_CACHE_URL. Дополнительные сведения: {url}.", "GeneratedConfiguration": "Созданная конфигурация {path}.", "GeneratedInstaller": "Установщик {path} создан.", @@ -676,7 +675,6 @@ "ImproperShaLength": "Длина SHA512 должна составлять 128 шестнадцатеричных символов: {value}", "IncorrectArchiveFileSignature": "Неверная подпись файла архива", "IncorrectPESignature": "Неверная подпись PE", - "IncrementedUtf8Decoder": "Добавочный Utf8Decoder в конце строки", "InfoSetEnvVar": "Вы также можете установить {env_var} в свой редактор.", "InitRegistryFailedNoRepo": "Не удалось создать реестр в {path}: это не корневой каталог репозитория Git.\nИспользуйте команду \"git init {command_line}\", чтобы создать репозиторий Git в этой папке.", "InstallCopiedFile": "{path_source} -> {path_destination}: готово", @@ -1038,7 +1036,7 @@ "UnexpectedPortversion": "неожиданный параметр \"port-version\" без поля управления версиями", "UnexpectedSwitch": "непредвиденный переключатель: {option}", "UnexpectedToolOutput": "Средство {tool_name} ({path}) отобразило непредвиденные выходные данные при попытке определить версию:", - "UnexpectedWindowsArchitecture": "unexpected Windows host architecture: {actual}", + "UnexpectedWindowsArchitecture": "неожиданная архитектура узла Windows: {actual}", "UnknownBaselineFileContent": "Базовая запись не распознана; ожидалось \"port:triplet=(fail|skip|pass)\".", "UnknownBinaryProviderType": "неизвестный тип бинарного провайдера: допустимыми провайдерами являются «clear», «default», «nuget», «nugetconfig», «nugettimeout», «interactive», «x-azblob», «x-gcs», «x-aws», «x-aws-config», «http» и «файлы»", "UnknownBooleanSetting": "неизвестная логическая настройка для {option}: \"{value}\". Допустимые значения: '', \"1\", \"0\", \"ВКЛ\", \"ВЫКЛ\", \"ИСТИНА\" и \"ЛОЖЬ\".", diff --git a/locales/messages.tr.json b/locales/messages.tr.json index cda68395b7..a7129969dd 100644 --- a/locales/messages.tr.json +++ b/locales/messages.tr.json @@ -378,7 +378,6 @@ "CommandEnvExample2": "vcpkg env \"ninja -C \" --triplet x64-windows", "CommandFailed": "command:\n{command_line}\n komutu aşağıdaki sonuçlarla başarısız oldu:", "CommunityTriplets": "Topluluk Üçlüleri:", - "ComparingUtf8Decoders": "Farklı kökene sahip Utf8Decoder'ların karşılaştırılması; bu her zaman bir hatadır", "CompressFolderFailed": "\"{path}\" klasörü sıkıştırılamadı:", "ComputingInstallPlan": "Yükleme planı işleniyor...", "ConfigurationErrorRegistriesWithoutBaseline": "{path} yolunda tanımlanan yapılandırma geçersiz.\n\nKayıt defterlerini kullanmak, varsayılan kayıt defteri için bir taban çizgisinin ayarlanmış veya varsayılan kayıt defterinin null olmasını gerektirir.\n\nDaha fazla ayrıntı için {url} adresine gidin.", @@ -550,7 +549,7 @@ "FailedToRunToolToDetermineVersion": "{tool_name} sürümünü belirlemek için \"{path}\" çalıştırılamadı.", "FailedToStoreBackToMirror": "yansıtmaya geri depolanamadı:", "FailedToStoreBinaryCache": "{path} ikili önbelleği depolanamadı", - "FailedToTakeFileSystemLock": "Failed to take the filesystem lock", + "FailedToTakeFileSystemLock": "Dosya sistemi kilidi alınamadı", "FailedToWriteManifest": "{path} manifest dosyası yazılamadı", "FailedVendorAuthentication": "Bir veya daha fazla {vendor} kimlik bilgisi sağlayıcısı kimlik doğrulaması yapamadı. Kimlik bilgilerini sağlama hakkında daha fazla ayrıntı için bkz. '{url}'.", "FetchingBaselineInfo": "Temel bilgiler {package_name}...", @@ -573,7 +572,7 @@ "FollowingPackagesUpgraded": "Aşağıdaki paketler günceldir:", "ForMoreHelp": "Daha Fazla Yardım Alın", "ForceSystemBinariesOnWeirdPlatforms": "VCPKG_FORCE_SYSTEM_BINARIES ortam değişkeni arm, s390x, ppc64le ve riscv platformlarında ayarlanmalıdır.", - "FormattedParseMessageExpression": "{value} ifadesinde", + "FormattedParseMessageExpressionPrefix": "ifadesinde:", "GHAParametersMissing": "GHA ikili kaynağı, ACTIONS_RUNTIME_TOKEN ve ACTIONS_CACHE_URL ortam değişkenlerinin ayarlanmasını gerektiriyor. Ayrıntılar için {url} adresine gidin.", "GeneratedConfiguration": "Oluşturulan yapılandırma {path}.", "GeneratedInstaller": "{path} yükleyicisi oluşturuldu.", @@ -676,7 +675,6 @@ "ImproperShaLength": "SHA512'ler 128 onaltılık karakter olmalıdır: {value}", "IncorrectArchiveFileSignature": "Yanlış arşiv dosyası imzası", "IncorrectPESignature": "Yanlış PE imzası", - "IncrementedUtf8Decoder": "Dize sonunda artan Utf8Decoder", "InfoSetEnvVar": "Ayrıca {env_var} ortam değişkenini istediğiniz düzenleyiciye ayarlayabilirsiniz.", "InitRegistryFailedNoRepo": "Bu bir git deposu kökü olmadığından {path} yolunda kayıt defteri oluşturulamadı.\nBu klasörde bir git deposu oluşturmak için 'git init {command_line}' kullanın.", "InstallCopiedFile": "{path_source} -> {path_destination} bitti", @@ -1038,7 +1036,7 @@ "UnexpectedPortversion": "sürüm oluşturma alanı olmadan \"port-version\" beklenmiyordu", "UnexpectedSwitch": "beklenmeyen geçiş: {option}", "UnexpectedToolOutput": "{tool_name} ({path}) sürümü belirlemeye çalışırken beklenmeyen bir çıktı üretti:", - "UnexpectedWindowsArchitecture": "unexpected Windows host architecture: {actual}", + "UnexpectedWindowsArchitecture": "beklenmeyen Windows konak mimarisi: {actual}", "UnknownBaselineFileContent": "tanınmayan taban çizgisi girdisi; 'port:triplet=(fail|skip|pass)' bekleniyordu", "UnknownBinaryProviderType": "bilinmeyen ikili sağlayıcı türü: geçerli sağlayıcılar: 'clear', 'default', 'nuget', 'nugetconfig','nugettimeout', 'interactive', 'x-azblob', 'x-gcs', 'x-aws', 'x-aws-config', 'http' ve 'files", "UnknownBooleanSetting": "{option} \"{value}\" için bilinmeyen boole ayarı. Geçerli değerler: '', '1', '0', 'ON', 'OFF', 'TRUE' ve 'FALSE'.", diff --git a/locales/messages.zh-Hans.json b/locales/messages.zh-Hans.json index e20c10bd4e..c151a32563 100644 --- a/locales/messages.zh-Hans.json +++ b/locales/messages.zh-Hans.json @@ -378,7 +378,6 @@ "CommandEnvExample2": "vcpkg env \"ninja -C \" --triplet x64-windows", "CommandFailed": "命令:\n{command_line}\n失败,结果如下:", "CommunityTriplets": "社区三元组:", - "ComparingUtf8Decoders": "比较具有不同来源的 Utf8Decoder;这始终是一个错误", "CompressFolderFailed": "无法压缩文件夹“{path}”:", "ComputingInstallPlan": "正在计算安装计划...", "ConfigurationErrorRegistriesWithoutBaseline": "{path} 中定义的配置无效。\n\n使用注册表需要为默认注册表设置基线,或者默认注册表为 null。\n\n有关更多详细信息,请参阅 {url}。", @@ -550,7 +549,7 @@ "FailedToRunToolToDetermineVersion": "无法运行“{path}”以确定 {tool_name} 版本。", "FailedToStoreBackToMirror": "无法存储回镜像:", "FailedToStoreBinaryCache": "无法存储二进制缓存 {path}", - "FailedToTakeFileSystemLock": "Failed to take the filesystem lock", + "FailedToTakeFileSystemLock": "未能获取文件系统锁", "FailedToWriteManifest": "未能写入清单文件 {path}", "FailedVendorAuthentication": "一个或多个 {vendor} 凭据提供程序无法进行身份验证。有关如何提供凭据的更多详细信息,请参阅“{url}”。", "FetchingBaselineInfo": "正在从 {package_name} 提取基线信息...", @@ -573,7 +572,7 @@ "FollowingPackagesUpgraded": "以下包是最新的:", "ForMoreHelp": "有关更多帮助", "ForceSystemBinariesOnWeirdPlatforms": "必须在 arm、s390x、ppc64le、riscv 平台上设置环境变量 VCPKG_FORCE_SYSTEM_BINARIES。", - "FormattedParseMessageExpression": "在表达式上: {value}", + "FormattedParseMessageExpressionPrefix": "表达式:", "GHAParametersMissing": "GHA 二进制源要求设置 ACTIONS_RUNTIME_TOKEN 和 ACTIONS_CACHE_URL 环境变量。有关详细信息,请参阅 {url}。", "GeneratedConfiguration": "生成的配置 {path}。", "GeneratedInstaller": "已生成 {path} 安装程序。", @@ -676,7 +675,6 @@ "ImproperShaLength": "SHA512 必须是 128 个十六进制字符: {value}", "IncorrectArchiveFileSignature": "存档文件签名不正确", "IncorrectPESignature": "PE 签名不正确", - "IncrementedUtf8Decoder": "字符串末尾的增量 Utf8Decoder", "InfoSetEnvVar": "还可以将 {env_var} 设置为所选编辑器。", "InitRegistryFailedNoRepo": "无法在 {path} 下创建注册表,因为这不是 git 存储库根路径。\n请使用“git init {command_line}”在此文件夹中创建 git 存储库。", "InstallCopiedFile": "{path_source} -> {path_destination} 已完成", @@ -1038,7 +1036,7 @@ "UnexpectedPortversion": "没有版本控制字段的意外 \"port-version\"", "UnexpectedSwitch": "意外开关: {option}", "UnexpectedToolOutput": "{tool_name} ({path}) 在尝试确定版本时生成了意外输出:", - "UnexpectedWindowsArchitecture": "unexpected Windows host architecture: {actual}", + "UnexpectedWindowsArchitecture": "意外的 Windows 主机体系结构: {actual}", "UnknownBaselineFileContent": "无法识别的基线条目;应为 “port:triplet=(fail|skip|pass)”", "UnknownBinaryProviderType": "未知的二进制提供程序类型: 有效提供程序为 “clear”、“default”、“nuget”、“nugetconfig”“nugettimeout”、“\"interactive”、“x-azblob”、“x-gcs”、“x-aws”、“x-aws-config”、“http” 和 “files”", "UnknownBooleanSetting": "{option} 的布尔值设置未知: \"{value}\"。有效值为 \"\"、\"1\"、\"0\"、\"ON\"、\"OFF\"、\"TRUE\" 和 \"FALSE\"。", diff --git a/locales/messages.zh-Hant.json b/locales/messages.zh-Hant.json index 7f97769f6b..860d8d44a2 100644 --- a/locales/messages.zh-Hant.json +++ b/locales/messages.zh-Hant.json @@ -378,7 +378,6 @@ "CommandEnvExample2": "vcpkg env \"ninja -C <路徑>\" --triplet x64-windows", "CommandFailed": "命令: \n{command_line}\n 失敗,結果如下:", "CommunityTriplets": "社群三元組:", - "ComparingUtf8Decoders": "將 Utf8Decoders 與不同起源比較; 這一律會是錯誤", "CompressFolderFailed": "無法壓縮資料夾 \"{path}\":", "ComputingInstallPlan": "正在計算安裝計畫...", "ConfigurationErrorRegistriesWithoutBaseline": "{path} 中定義的設定無效。\n\n使用登錄需要為預設登錄設定基準,或預設登錄為 Null。\n\n如需詳細資料,請參閱 {url}。", @@ -550,7 +549,7 @@ "FailedToRunToolToDetermineVersion": "無法執行 \"{path}\" 以判斷 {tool_name} 版本。", "FailedToStoreBackToMirror": "無法儲存回鏡像:", "FailedToStoreBinaryCache": "無法儲存二進位快取 {path}", - "FailedToTakeFileSystemLock": "Failed to take the filesystem lock", + "FailedToTakeFileSystemLock": "無法進行檔案系統鎖定", "FailedToWriteManifest": "無法寫入資訊清單檔案 {path}", "FailedVendorAuthentication": "無法驗證一或多個 {vendor} 認證提供者。如需如何提供認證的詳細資料,請參閱 '{url}'。", "FetchingBaselineInfo": "正在從 {package_name} 擷取基準資訊...", @@ -573,7 +572,7 @@ "FollowingPackagesUpgraded": "下列套件是最新的:", "ForMoreHelp": "更多協助", "ForceSystemBinariesOnWeirdPlatforms": "環境變數 VCPKG_FORCE_SYSTEM_BINARIES 必須在 s390x、ppc64le 和 riscv 平台上設定。", - "FormattedParseMessageExpression": "在運算式上: {value}", + "FormattedParseMessageExpressionPrefix": "在運算式上:", "GHAParametersMissing": "GHA 二進位來源需要設定 ACTIONS_RUNTIME_TOKEN 和 ACTIONS_CACHE_URL 環境變數。如需詳細資料,請參閱 {url}。", "GeneratedConfiguration": "已產生設定 {path}。", "GeneratedInstaller": "{path} 安裝程式已產生。", @@ -676,7 +675,6 @@ "ImproperShaLength": "SHA512 必須是 128 十六進位字元: {value}", "IncorrectArchiveFileSignature": "不正確的封存檔案簽章", "IncorrectPESignature": "不正確的 PE 簽章", - "IncrementedUtf8Decoder": "在字串結尾遞增 Utf8Decoder", "InfoSetEnvVar": "您也可以將 {env_var} 設為您所選擇的編輯器。", "InitRegistryFailedNoRepo": "無法在 {path} 建立登錄,因為這不是 GIT 儲存機制根路徑。\n使用 `git init {command_line}` 在此資料夾中建立 Git 存放庫。", "InstallCopiedFile": "{path_source} -> {path_destination} 完成", @@ -1038,7 +1036,7 @@ "UnexpectedPortversion": "未預期的 \"port-version\" 沒有版本設定欄位", "UnexpectedSwitch": "未預期的切換: {option}", "UnexpectedToolOutput": "{tool_name} ({path})嘗試判斷版本時產生未預期的輸出:", - "UnexpectedWindowsArchitecture": "unexpected Windows host architecture: {actual}", + "UnexpectedWindowsArchitecture": "未預期的 Windows 主機架構: {actual}", "UnknownBaselineFileContent": "無法辨識的基準項目; 預期為 'port:triplet=(fail|skip|pass)'", "UnknownBinaryProviderType": "未知的二進位提供者類型: 有效的提供者為 'clear', 'default', 'nuget', 'nugetconfig','nugettimeout', 'interactive', 'x-azblob', 'x-gcs', 'x-aws', 'x-aws-config', 'http', 和 'files'", "UnknownBooleanSetting": "{option} 的布林值設定未知: \"{value}\"。有效值為 ''、'1'、'0'、'ON'、'OFF'、'TRUE' 和 'FALSE'。", diff --git a/scripts/applocal.ps1 b/scripts/applocal.ps1 index 39de365d3b..0721170f1e 100644 --- a/scripts/applocal.ps1 +++ b/scripts/applocal.ps1 @@ -94,7 +94,7 @@ function resolve([string]$targetBinary) { $targetBinaryDir = Split-Path $targetBinaryPath -parent if (Get-Command "dumpbin" -ErrorAction SilentlyContinue) { - $a = $(dumpbin /DEPENDENTS $targetBinary | ? { $_ -match "^ [^ ].*\.dll" } | % { $_ -replace "^ ","" }) + $a = $(dumpbin /DEPENDENTS $targetBinaryPath| ? { $_ -match "^ [^ ].*\.dll" } | % { $_ -replace "^ ","" }) } elseif (Get-Command "llvm-objdump" -ErrorAction SilentlyContinue) { $a = $(llvm-objdump -p $targetBinary| ? { $_ -match "^ {4}DLL Name: .*\.dll" } | % { $_ -replace "^ {4}DLL Name: ","" }) } elseif (Get-Command "objdump" -ErrorAction SilentlyContinue) { diff --git a/src/localization/cs/messages.json.lcl b/src/localization/cs/messages.json.lcl index 66e81e1a60..bdfcfcf569 100644 --- a/src/localization/cs/messages.json.lcl +++ b/src/localization/cs/messages.json.lcl @@ -3913,15 +3913,6 @@ - - - - - - - - - @@ -5791,12 +5782,15 @@ - + - + - + + + + @@ -6028,15 +6022,12 @@ - + - + - + - - - @@ -7108,15 +7099,6 @@ - - - - - - - - - @@ -10897,6 +10879,15 @@ + + + + + + + + + diff --git a/src/localization/de/messages.json.lcl b/src/localization/de/messages.json.lcl index 77f4decef2..4b63147f7a 100644 --- a/src/localization/de/messages.json.lcl +++ b/src/localization/de/messages.json.lcl @@ -3913,15 +3913,6 @@ - - - - - - - - - @@ -5791,12 +5782,15 @@ - + - + - + + + + @@ -6028,15 +6022,12 @@ - + - + - + - - - @@ -7108,15 +7099,6 @@ - - - - - - - - - @@ -10894,6 +10876,15 @@ + + + + + + + + + diff --git a/src/localization/es/messages.json.lcl b/src/localization/es/messages.json.lcl index 54d82ea49f..e92a788a56 100644 --- a/src/localization/es/messages.json.lcl +++ b/src/localization/es/messages.json.lcl @@ -3913,15 +3913,6 @@ - - - - - - - - - @@ -5791,12 +5782,15 @@ - + - + - + + + + @@ -6028,15 +6022,12 @@ - + - + - + - - - @@ -7108,15 +7099,6 @@ - - - - - - - - - @@ -10894,6 +10876,15 @@ + + + + + + + + + diff --git a/src/localization/fr/messages.json.lcl b/src/localization/fr/messages.json.lcl index 3530bb7986..fd4c6ca2c7 100644 --- a/src/localization/fr/messages.json.lcl +++ b/src/localization/fr/messages.json.lcl @@ -3913,15 +3913,6 @@ - - - - - - - - - @@ -5791,12 +5782,15 @@ - + - + - + + + + @@ -6028,15 +6022,12 @@ - + - + - + - - - @@ -7108,15 +7099,6 @@ - - - - - - - - - @@ -10894,6 +10876,15 @@ + + + + + + + + + diff --git a/src/localization/it/messages.json.lcl b/src/localization/it/messages.json.lcl index 3ab2428c96..3d40786bf5 100644 --- a/src/localization/it/messages.json.lcl +++ b/src/localization/it/messages.json.lcl @@ -3913,15 +3913,6 @@ - - - - - - - - - @@ -5791,12 +5782,15 @@ - + - + - + + + + @@ -6028,15 +6022,12 @@ - + - + - + - - - @@ -7108,15 +7099,6 @@ - - - - - - - - - @@ -10897,6 +10879,15 @@ + + + + + + + + + diff --git a/src/localization/ja/messages.json.lcl b/src/localization/ja/messages.json.lcl index 60367af150..bfa2b72880 100644 --- a/src/localization/ja/messages.json.lcl +++ b/src/localization/ja/messages.json.lcl @@ -3913,15 +3913,6 @@ - - - - - - - - - @@ -5791,12 +5782,15 @@ - + - + - + + + + @@ -6028,15 +6022,12 @@ - + - + - + - - - @@ -7108,15 +7099,6 @@ - - - - - - - - - @@ -10897,6 +10879,15 @@ + + + + + + + + + diff --git a/src/localization/ko/messages.json.lcl b/src/localization/ko/messages.json.lcl index 975ff5f4cc..e1badbc94a 100644 --- a/src/localization/ko/messages.json.lcl +++ b/src/localization/ko/messages.json.lcl @@ -3913,15 +3913,6 @@ - - - - - - - - - @@ -5791,12 +5782,15 @@ - + - + - + + + + @@ -6028,15 +6022,12 @@ - + - + - + - - - @@ -7108,15 +7099,6 @@ - - - - - - - - - @@ -10894,6 +10876,15 @@ + + + + + + + + + diff --git a/src/localization/pl/messages.json.lcl b/src/localization/pl/messages.json.lcl index 11a342906e..732c456d2f 100644 --- a/src/localization/pl/messages.json.lcl +++ b/src/localization/pl/messages.json.lcl @@ -3913,15 +3913,6 @@ - - - - - - - - - @@ -5791,12 +5782,15 @@ - + - + - + + + + @@ -6028,15 +6022,12 @@ - + - + - + - - - @@ -7108,15 +7099,6 @@ - - - - - - - - - @@ -10894,6 +10876,15 @@ + + + + + + + + + diff --git a/src/localization/pt-BR/messages.json.lcl b/src/localization/pt-BR/messages.json.lcl index af8df843a9..aa8b1acb6e 100644 --- a/src/localization/pt-BR/messages.json.lcl +++ b/src/localization/pt-BR/messages.json.lcl @@ -3913,15 +3913,6 @@ - - - - - - - - - @@ -5791,12 +5782,15 @@ - + - + - + + + + @@ -6028,15 +6022,12 @@ - + - + - + - - - @@ -7108,15 +7099,6 @@ - - - - - - - - - @@ -10894,6 +10876,15 @@ + + + + + + + + + diff --git a/src/localization/ru/messages.json.lcl b/src/localization/ru/messages.json.lcl index 3dd2f64e42..7bc29ecc90 100644 --- a/src/localization/ru/messages.json.lcl +++ b/src/localization/ru/messages.json.lcl @@ -3913,15 +3913,6 @@ - - - - - - - - - @@ -5791,12 +5782,15 @@ - + - + - + + + + @@ -6028,15 +6022,12 @@ - + - + - + - - - @@ -7108,15 +7099,6 @@ - - - - - - - - - @@ -10897,6 +10879,15 @@ + + + + + + + + + diff --git a/src/localization/tr/messages.json.lcl b/src/localization/tr/messages.json.lcl index 8b25f85221..ddabc16524 100644 --- a/src/localization/tr/messages.json.lcl +++ b/src/localization/tr/messages.json.lcl @@ -3913,15 +3913,6 @@ - - - - - - - - - @@ -5791,12 +5782,15 @@ - + - + - + + + + @@ -6028,15 +6022,12 @@ - + - + - + - - - @@ -7108,15 +7099,6 @@ - - - - - - - - - @@ -10897,6 +10879,15 @@ + + + + + + + + + diff --git a/src/localization/zh-Hans/messages.json.lcl b/src/localization/zh-Hans/messages.json.lcl index 63957f3db2..abc6f80aa9 100644 --- a/src/localization/zh-Hans/messages.json.lcl +++ b/src/localization/zh-Hans/messages.json.lcl @@ -3913,15 +3913,6 @@ - - - - - - - - - @@ -5791,12 +5782,15 @@ - + - + - + + + + @@ -6028,15 +6022,12 @@ - + - + - + - - - @@ -7108,15 +7099,6 @@ - - - - - - - - - @@ -10897,6 +10879,15 @@ + + + + + + + + + diff --git a/src/localization/zh-Hant/messages.json.lcl b/src/localization/zh-Hant/messages.json.lcl index f502333484..6c1e77022d 100644 --- a/src/localization/zh-Hant/messages.json.lcl +++ b/src/localization/zh-Hant/messages.json.lcl @@ -3913,15 +3913,6 @@ - - - - - - - - - @@ -5791,12 +5782,15 @@ - + - + - + + + + @@ -6028,15 +6022,12 @@ - + - + - + - - - @@ -7108,15 +7099,6 @@ - - - - - - - - - @@ -10897,6 +10879,15 @@ + + + + + + + + + diff --git a/src/test-script-asset-cache.c b/src/test-script-asset-cache.c new file mode 100644 index 0000000000..0595ab13bb --- /dev/null +++ b/src/test-script-asset-cache.c @@ -0,0 +1,49 @@ +#define _CRT_SECURE_NO_WARNINGS + +#include +#include +#include + +static const char expected_uri[] = "https://example.com/hello-world.txt"; +static const char expected_sha[] = "09e1e2a84c92b56c8280f4a1203c7cffd61b162cfe987278d4d6be9afbf38c0e8934cdadf83751f4e99" + "d111352bffefc958e5a4852c8a7a29c95742ce59288a8"; + +static const char result_data[] = "Hello, world!\n"; + +int main(int argc, char** argv) +{ + if (argc != 4) + { + puts("Bad argument count; usage: test-script-asset-cache {url} {sha512} {dst}"); + return 1; + } + + if (strcmp(argv[1], expected_uri) != 0) + { + printf("Bad argument 1; expected url: %s, got %s\n", expected_uri, argv[1]); + return 1; + } + + if (strcmp(argv[2], expected_sha) != 0) + { + printf("Bad argument 2; expected sha512: %s, got %s\n", expected_sha, argv[2]); + return 1; + } + + FILE* fp = fopen(argv[3], "wb"); + if (!fp) + { + puts("fopen failed"); + return 1; + } + + if (fwrite(result_data, 1, sizeof(result_data) - 1, fp) != sizeof(result_data) - 1) + { + puts("fputs failed"); + fclose(fp); + return 1; + } + + fclose(fp); + return 0; +} diff --git a/src/vcpkg-fuzz/main.cpp b/src/vcpkg-fuzz/main.cpp index be6373d53b..6e37224d28 100644 --- a/src/vcpkg-fuzz/main.cpp +++ b/src/vcpkg-fuzz/main.cpp @@ -137,7 +137,7 @@ namespace auto res = Json::parse(text, origin); if (!res) { - Checks::exit_with_message(VCPKG_LINE_INFO, res.error()->to_string()); + Checks::msg_exit_with_message(VCPKG_LINE_INFO, res.error()); } Checks::exit_success(VCPKG_LINE_INFO); diff --git a/src/vcpkg-test/arguments.cpp b/src/vcpkg-test/arguments.cpp index 3c1abd7483..33f4d6df99 100644 --- a/src/vcpkg-test/arguments.cpp +++ b/src/vcpkg-test/arguments.cpp @@ -160,8 +160,8 @@ TEST_CASE ("Combine asset cache params", "[arguments]") v = VcpkgCmdArguments::create_from_arg_sequence(t.data(), t.data() + t.size()); REQUIRE(v.asset_sources_template() == "x-azurl,value"); - std::map> envmap = { - {VcpkgCmdArguments::ASSET_SOURCES_ENV.to_string(), "x-azurl,value1"}, + std::map> envmap = { + {VcpkgCmdArguments::ASSET_SOURCES_ENV, "x-azurl,value1"}, }; v = VcpkgCmdArguments::create_from_arg_sequence(nullptr, nullptr); v.imbue_from_fake_environment(envmap); diff --git a/src/vcpkg-test/ci-baseline.cpp b/src/vcpkg-test/ci-baseline.cpp index e89c883b4a..17407f3dcb 100644 --- a/src/vcpkg-test/ci-baseline.cpp +++ b/src/vcpkg-test/ci-baseline.cpp @@ -250,15 +250,14 @@ static void check_error(const std::string& input, const std::string& expected_er auto actual = parse_ci_baseline(input, "test", m); CHECK(actual.empty()); CHECK(m.warnings.empty()); - REQUIRE(m.error); - CHECK(m.error->to_string() == expected_error); + CHECK(m.error.value_or_exit(VCPKG_LINE_INFO) == LocalizedString::from_raw(expected_error)); } TEST_CASE ("Parse Errors", "[ci-baseline]") { check_error("hello", R"(test:1:6: error: expected ':' here on expression: hello - ^)"); + ^)"); check_error("hello\n:", R"(test:1:6: error: expected ':' here on expression: hello @@ -271,7 +270,7 @@ TEST_CASE ("Parse Errors", "[ci-baseline]") check_error("x64-windows:", R"(test:1:13: error: expected a triplet name here (must be lowercase, digits, '-') on expression: x64-windows: - ^)"); + ^)"); check_error("x64-windows:\nport:x64-windows=skip", R"(test:1:13: error: expected a triplet name here (must be lowercase, digits, '-') @@ -285,7 +284,7 @@ TEST_CASE ("Parse Errors", "[ci-baseline]") // clang-format off check_error(" \tx64-windows:", R"(test:1:21: error: expected a triplet name here (must be lowercase, digits, '-') on expression: )" "\t" R"(x64-windows: - )" "\t" R"( ^)"); + )" "\t" R"( ^)"); // clang-format on check_error("port:x64-windows\n=fail", R"(test:1:17: error: expected '=' here @@ -334,7 +333,7 @@ TEST_CASE ("format_ci_result 1", "[ci-baseline]") SECTION ("SUCCEEDED") { const auto test = [&](PackageSpec s, bool allow_unexpected_passing) { - return format_ci_result(s, BuildResult::SUCCEEDED, cidata, "cifile", allow_unexpected_passing, false); + return format_ci_result(s, BuildResult::Succeeded, cidata, "cifile", allow_unexpected_passing, false); }; CHECK(test({"pass", Test::X64_UWP}, true) == ""); CHECK(test({"pass", Test::X64_UWP}, false) == ""); @@ -348,7 +347,7 @@ TEST_CASE ("format_ci_result 1", "[ci-baseline]") SECTION ("BUILD_FAILED") { const auto test = [&](PackageSpec s) { - return format_ci_result(s, BuildResult::BUILD_FAILED, cidata, "cifile", false, false); + return format_ci_result(s, BuildResult::BuildFailed, cidata, "cifile", false, false); }; CHECK(test({"pass", Test::X64_UWP}) == fmt::format(failmsg, "pass:x64-uwp")); CHECK(test({"fail", Test::X64_UWP}) == ""); @@ -358,8 +357,7 @@ TEST_CASE ("format_ci_result 1", "[ci-baseline]") SECTION ("CASCADED_DUE_TO_MISSING_DEPENDENCIES") { const auto test = [&](PackageSpec s) { - return format_ci_result( - s, BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES, cidata, "cifile", false, false); + return format_ci_result(s, BuildResult::CascadedDueToMissingDependencies, cidata, "cifile", false, false); }; CHECK(test({"pass", Test::X64_UWP}) == fmt::format(cascademsg, "pass:x64-uwp")); CHECK(test({"fail", Test::X64_UWP}) == ""); diff --git a/src/vcpkg-test/commands.extract.cpp b/src/vcpkg-test/commands.extract.cpp index 85ed401587..917011c425 100644 --- a/src/vcpkg-test/commands.extract.cpp +++ b/src/vcpkg-test/commands.extract.cpp @@ -129,7 +129,7 @@ TEST_CASE ("Testing strip auto's get_common_prefix_count", "z-extract") TEST_CASE ("Testing get_strip_setting", "z-extract") { - std::map> settings; + std::map> settings; SECTION ("Test no strip") { diff --git a/src/vcpkg-test/dependencies.cpp b/src/vcpkg-test/dependencies.cpp index d5e6a34984..d1ae9e2102 100644 --- a/src/vcpkg-test/dependencies.cpp +++ b/src/vcpkg-test/dependencies.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -2466,14 +2467,14 @@ TEST_CASE ("dependency graph API snapshot: host and target") ActionPlan plan; plan.install_actions.push_back(std::move(install_a)); plan.install_actions.push_back(std::move(install_a_host)); - std::map> envmap = { - {VcpkgCmdArguments::GITHUB_JOB_ENV.to_string(), "123"}, - {VcpkgCmdArguments::GITHUB_RUN_ID_ENV.to_string(), "123"}, - {VcpkgCmdArguments::GITHUB_REF_ENV.to_string(), "refs/heads/main"}, - {VcpkgCmdArguments::GITHUB_REPOSITORY_ENV.to_string(), "owner/repo"}, - {VcpkgCmdArguments::GITHUB_SHA_ENV.to_string(), "abc123"}, - {VcpkgCmdArguments::GITHUB_TOKEN_ENV.to_string(), "abc"}, - {VcpkgCmdArguments::GITHUB_WORKFLOW_ENV.to_string(), "test"}, + std::map> envmap = { + {VcpkgCmdArguments::GITHUB_JOB_ENV, "123"}, + {VcpkgCmdArguments::GITHUB_RUN_ID_ENV, "123"}, + {VcpkgCmdArguments::GITHUB_REF_ENV, "refs/heads/main"}, + {VcpkgCmdArguments::GITHUB_REPOSITORY_ENV, "owner/repo"}, + {VcpkgCmdArguments::GITHUB_SHA_ENV, "abc123"}, + {VcpkgCmdArguments::GITHUB_TOKEN_ENV, "abc"}, + {VcpkgCmdArguments::GITHUB_WORKFLOW_ENV, "test"}, }; auto v = VcpkgCmdArguments::create_from_arg_sequence(nullptr, nullptr); v.imbue_from_fake_environment(envmap); diff --git a/src/vcpkg-test/json.cpp b/src/vcpkg-test/json.cpp index 044a14908e..5a0af93595 100644 --- a/src/vcpkg-test/json.cpp +++ b/src/vcpkg-test/json.cpp @@ -1,6 +1,7 @@ #include #include +#include #include @@ -18,7 +19,7 @@ static auto u8_string_to_char_string(const char8_t (&literal)[Sz]) -> const char #define U8_STR(s) (u8"" s) #endif -namespace Json = vcpkg::Json; +using namespace vcpkg; using Json::Value; TEST_CASE ("JSON stringify weird strings", "[json]") @@ -55,9 +56,9 @@ TEST_CASE ("JSON parse strings", "[json]") REQUIRE(res.get()->value.is_string()); REQUIRE(res.get()->value.string(VCPKG_LINE_INFO) == "\xED\xA0\x80"); - const auto make_json_string = [](vcpkg::StringView sv) { return '"' + sv.to_string() + '"'; }; - const vcpkg::StringView radical = U8_STR("⎷"); - const vcpkg::StringView grin = U8_STR("😁"); + const auto make_json_string = [](StringView sv) { return '"' + sv.to_string() + '"'; }; + const StringView radical = U8_STR("⎷"); + const StringView grin = U8_STR("😁"); res = Json::parse(R"("\uD83D\uDE01")", "test"); // paired surrogates for grin REQUIRE(res); @@ -212,14 +213,14 @@ TEST_CASE ("JSON parse objects", "[json]") TEST_CASE ("JSON parse full file", "[json]") { - vcpkg::StringView json = + StringView json = #include "large-json-document.json.inc" ; auto res = Json::parse(json, "test"); if (!res) { - std::cerr << res.error()->to_string() << '\n'; + std::cerr << res.error() << '\n'; } REQUIRE(res); } @@ -228,20 +229,19 @@ TEST_CASE ("JSON track newlines", "[json]") { auto res = Json::parse("{\n,", "filename"); REQUIRE(!res); - REQUIRE(res.error()->to_string() == - R"(filename:2:1: error: Unexpected character; expected property name + REQUIRE(res.error() == + LocalizedString::from_raw(R"(filename:2:1: error: Unexpected character; expected property name on expression: , - ^)"); + ^)")); } TEST_CASE ("JSON duplicated object keys", "[json]") { auto res = Json::parse("{\"name\": 1, \"name\": 2}", "filename"); REQUIRE(!res); - REQUIRE(res.error()->to_string() == - R"(filename:1:13: error: Duplicated key "name" in an object + REQUIRE(res.error() == LocalizedString::from_raw(R"(filename:1:13: error: Duplicated key "name" in an object on expression: {"name": 1, "name": 2} - ^)"); + ^)")); } TEST_CASE ("JSON support unicode characters in errors", "[json]") @@ -249,26 +249,23 @@ TEST_CASE ("JSON support unicode characters in errors", "[json]") // unicode characters w/ bytes >1 auto res = Json::parse(R"json("Δx/Δt" "")json", "filename"); REQUIRE(!res); - CHECK(res.error()->to_string() == - R"(filename:1:9: error: Unexpected character; expected EOF + CHECK(res.error() == LocalizedString::from_raw(R"(filename:1:9: error: Unexpected character; expected EOF on expression: "Δx/Δt" "" - ^)"); + ^)")); // full width unicode characters // note that the A is full width res = Json::parse(R"json("姐姐aA" "")json", "filename"); REQUIRE(!res); - CHECK(res.error()->to_string() == - R"(filename:1:8: error: Unexpected character; expected EOF + CHECK(res.error() == LocalizedString::from_raw(R"(filename:1:8: error: Unexpected character; expected EOF on expression: "姐姐aA" "" - ^)"); + ^)")); // incorrect errors in the face of combining characters // (this test should be fixed once the underlying bug is fixed) res = Json::parse(R"json("é" "")json", "filename"); REQUIRE(!res); - CHECK(res.error()->to_string() == - R"(filename:1:6: error: Unexpected character; expected EOF + CHECK(res.error() == LocalizedString::from_raw(R"(filename:1:6: error: Unexpected character; expected EOF on expression: "é" "" - ^)"); + ^)")); } diff --git a/src/vcpkg-test/manifests.cpp b/src/vcpkg-test/manifests.cpp index ce1fde2770..2bebac9bad 100644 --- a/src/vcpkg-test/manifests.cpp +++ b/src/vcpkg-test/manifests.cpp @@ -22,7 +22,7 @@ static Json::Object parse_json_object(StringView sv) { INFO("Error found while parsing JSON document:"); INFO(sv.to_string()); - FAIL(json.error()->to_string()); + FAIL(json.error()); return Json::Object{}; } } @@ -1179,13 +1179,13 @@ static bool license_is_parsable(StringView license) { ParseMessages messages; parse_spdx_license_expression(license, messages); - return messages.error == nullptr; + return !messages.error.has_value(); } static bool license_is_strict(StringView license) { ParseMessages messages; parse_spdx_license_expression(license, messages); - return messages.error == nullptr && messages.warnings.empty(); + return !messages.error.has_value() && messages.warnings.empty(); } static std::string test_format_parse_warning(const ParseMessage& msg) @@ -1242,32 +1242,32 @@ TEST_CASE ("license error messages", "[manifests][license]") { ParseMessages messages; parse_spdx_license_expression("", messages); - REQUIRE(messages.error); - CHECK(messages.error->to_string() == R"(:1:1: error: SPDX license expression was empty. + CHECK(messages.error.value_or_exit(VCPKG_LINE_INFO) == + LocalizedString::from_raw(R"(:1:1: error: SPDX license expression was empty. on expression: - ^)"); + ^)")); parse_spdx_license_expression("MIT ()", messages); - REQUIRE(messages.error); - CHECK(messages.error->to_string() == - R"(:1:5: error: Expected a compound or the end of the string, found a parenthesis. + CHECK(messages.error.value_or_exit(VCPKG_LINE_INFO) == + LocalizedString::from_raw( + R"(:1:5: error: Expected a compound or the end of the string, found a parenthesis. on expression: MIT () - ^)"); + ^)")); parse_spdx_license_expression("MIT +", messages); - REQUIRE(messages.error); CHECK( - messages.error->to_string() == - R"(:1:5: error: SPDX license expression contains an extra '+'. These are only allowed directly after a license identifier. + messages.error.value_or_exit(VCPKG_LINE_INFO) == + LocalizedString::from_raw( + R"(:1:5: error: SPDX license expression contains an extra '+'. These are only allowed directly after a license identifier. on expression: MIT + - ^)"); + ^)")); parse_spdx_license_expression("MIT AND", messages); - REQUIRE(messages.error); - CHECK(messages.error->to_string() == - R"(:1:8: error: Expected a license name, found the end of the string. + CHECK( + messages.error.value_or_exit(VCPKG_LINE_INFO) == + LocalizedString::from_raw(R"(:1:8: error: Expected a license name, found the end of the string. on expression: MIT AND - ^)"); + ^)")); parse_spdx_license_expression("MIT AND unknownlicense", messages); CHECK(!messages.error); diff --git a/src/vcpkg-test/system.cpp b/src/vcpkg-test/system.cpp index dff7017393..4d0e771d87 100644 --- a/src/vcpkg-test/system.cpp +++ b/src/vcpkg-test/system.cpp @@ -9,15 +9,7 @@ #include -using vcpkg::CPUArchitecture; -using vcpkg::get_environment_variable; -using vcpkg::guess_visual_studio_prompt_target_architecture; -using vcpkg::nullopt; -using vcpkg::Optional; -using vcpkg::set_environment_variable; -using vcpkg::StringView; -using vcpkg::to_cpu_architecture; -using vcpkg::ZStringView; +using namespace vcpkg; namespace { @@ -123,8 +115,6 @@ TEST_CASE ("guess_visual_studio_prompt", "[system]") TEST_CASE ("cmdlinebuilder", "[system]") { - using vcpkg::Command; - Command cmd; cmd.string_arg("relative/path.exe"); cmd.string_arg("abc"); @@ -146,23 +136,17 @@ TEST_CASE ("cmdlinebuilder", "[system]") TEST_CASE ("cmd_execute_and_capture_output_parallel", "[system]") { - std::vector vec; + std::vector vec; for (size_t i = 0; i < 50; ++i) { #if defined(_WIN32) - vcpkg::Command cmd("cmd.exe"); - cmd.string_arg("/d"); - cmd.string_arg("/c"); - cmd.string_arg(fmt::format("echo {}", i)); + vec.push_back(Command("cmd.exe").string_arg("/d").string_arg("/c").string_arg(fmt::format("echo {}", i))); #else - vcpkg::Command cmd("echo"); - const auto cmd_str = std::string(i, 'a'); - cmd.string_arg(cmd_str); + vec.push_back(Command("echo").string_arg(std::string(i, 'a'))); #endif - vec.emplace_back(std::move(cmd)); } - auto res = vcpkg::cmd_execute_and_capture_output_parallel(vcpkg::View(vec)); + auto res = cmd_execute_and_capture_output_parallel(vec); for (size_t i = 0; i != res.size(); ++i) { @@ -180,8 +164,6 @@ TEST_CASE ("cmd_execute_and_capture_output_parallel", "[system]") TEST_CASE ("append_shell_escaped", "[system]") { - using vcpkg::Command; - Command cmd; cmd.clear(); diff --git a/src/vcpkg-test/system.process.cpp b/src/vcpkg-test/system.process.cpp index 476a99dd5d..565f289d60 100644 --- a/src/vcpkg-test/system.process.cpp +++ b/src/vcpkg-test/system.process.cpp @@ -7,16 +7,15 @@ using namespace vcpkg; TEST_CASE ("captures-output", "[system.process]") { auto test_program = Path(get_exe_path_of_current_process().parent_path()) / "reads-stdin"; - Command cmd{test_program}; - cmd.string_arg("this is printed when something is read"); + auto cmd = Command{test_program}.string_arg("this is printed when something is read"); static constexpr std::size_t minimum_size = 1'000'000; // to exceed OS pipe buffer size constexpr StringLiteral example = "example"; constexpr auto examples = (minimum_size / example.size()) + 1; - std::string input; constexpr auto input_size = examples * example.size(); + RedirectedProcessLaunchSettings settings; for (std::size_t idx = 0; idx < examples; ++idx) { - input.append(example.data(), example.size()); + settings.stdin_content.append(example.data(), example.size()); } std::string expected; @@ -37,9 +36,7 @@ TEST_CASE ("captures-output", "[system.process]") #endif // ^^^ _WIN32 expected.push_back('\n'); - auto run = cmd_execute_and_capture_output( - cmd, default_working_directory, default_environment, Encoding::Utf8, EchoInDebug::Hide, input) - .value_or_exit(VCPKG_LINE_INFO); + auto run = cmd_execute_and_capture_output(cmd, settings).value_or_exit(VCPKG_LINE_INFO); REQUIRE(run.exit_code == 0); REQUIRE(run.output == expected); } @@ -47,14 +44,9 @@ TEST_CASE ("captures-output", "[system.process]") TEST_CASE ("no closes-stdin crash", "[system.process]") { auto test_program = Path(get_exe_path_of_current_process().parent_path()) / "closes-stdin"; - Command cmd{test_program}; - auto run = cmd_execute_and_capture_output(cmd, - default_working_directory, - default_environment, - Encoding::Utf8, - EchoInDebug::Hide, - "this is some input that will be intentionally not read") - .value_or_exit(VCPKG_LINE_INFO); + RedirectedProcessLaunchSettings settings; + settings.stdin_content = "this is some input that will be intentionally not read"; + auto run = cmd_execute_and_capture_output(Command{test_program}, settings).value_or_exit(VCPKG_LINE_INFO); REQUIRE(run.exit_code == 0); REQUIRE(run.output.empty()); } @@ -62,14 +54,9 @@ TEST_CASE ("no closes-stdin crash", "[system.process]") TEST_CASE ("no closes-stdout crash", "[system.process]") { auto test_program = Path(get_exe_path_of_current_process().parent_path()) / "closes-stdout"; - Command cmd{test_program}; - auto run = cmd_execute_and_capture_output(cmd, - default_working_directory, - default_environment, - Encoding::Utf8, - EchoInDebug::Hide, - "this is some input that will be read") - .value_or_exit(VCPKG_LINE_INFO); + RedirectedProcessLaunchSettings settings; + settings.stdin_content = "this is some input that will be intentionally not read"; + auto run = cmd_execute_and_capture_output(Command{test_program}, settings).value_or_exit(VCPKG_LINE_INFO); REQUIRE(run.exit_code == 0); REQUIRE(run.output == "hello world"); } diff --git a/src/vcpkg-test/unicode.cpp b/src/vcpkg-test/unicode.cpp new file mode 100644 index 0000000000..aec94f19c9 --- /dev/null +++ b/src/vcpkg-test/unicode.cpp @@ -0,0 +1,147 @@ +#include + +#include + +#include + +using namespace vcpkg::Unicode; + +TEST_CASE ("Utf8Decoder valid", "[unicode]") +{ + const char32_t* expected = U""; + const char* input = ""; + SECTION ("hello") + { + expected = U"hello"; + input = "hello"; + } + + SECTION ("all types of code points") + { + expected = U"one: a two: \u00E9 three: \u672C four: \U0001F3C8"; + input = "one: a two: \xC3\xA9 three: \xE6\x9C\xAC four: \xF0\x9F\x8F\x88"; + } + + SECTION ("wtf-8 leading") + { + // U+1F3C8 as WTF-8 + static constexpr char32_t storage[] = {0xD83C, 0}; + expected = storage; + input = "\xED\xA0\xBC"; + } + + SECTION ("wtf-8 trailing") + { + // U+1F3C8 as WTF-8 + static constexpr char32_t storage[] = {0xDFC8, 0}; + expected = storage; + input = "\xED\xBF\x88"; + } + + auto input_end = input + strlen(input); + Utf8Decoder decode(input); + // strlen for char32_t: + size_t expected_size = 0; + for (auto* e = expected; *e; ++e) + { + ++expected_size; + } + + auto decode_at_end = std::next(decode, expected_size); + for (size_t idx = 0; idx < expected_size; ++idx) + { + REQUIRE(decode != decode.end()); // compare sentinel + REQUIRE(decode != decode_at_end); // compare iterator + REQUIRE(*decode == expected[idx]); + REQUIRE(!decode.is_eof()); + char32_t decoded; + auto pointer_to_current = decode.pointer_to_current(); + const auto original_pointer_to_current = pointer_to_current; + REQUIRE(utf8_decode_code_point(pointer_to_current, input_end, decoded) == utf8_errc::NoError); + REQUIRE(decoded == expected[idx]); + char encoded[4]; + auto encoded_size = utf8_encode_code_point(encoded, decoded); + REQUIRE(std::equal(encoded, encoded + encoded_size, original_pointer_to_current)); + ++decode; + } + + REQUIRE(decode == decode.end()); + REQUIRE(decode == decode_at_end); +} + +TEST_CASE ("Utf8Decoder first decode empty", "[unicode]") +{ + utf8_errc err; + Utf8Decoder uut("", err); + REQUIRE(err == utf8_errc::NoError); + REQUIRE(uut.is_eof()); + REQUIRE(uut == uut.end()); + REQUIRE(uut == uut); +} + +TEST_CASE ("Utf8Decoder invalid", "[unicode]") +{ + utf8_errc err; + // clang-format off + Utf8Decoder uut(GENERATE( + "hello \xFF too big", + "hello \xC3\xBF\xBF\xBF also too big", + "hello \x9C continuation", + "hello \xE0\x28 overlong", + "hello \xED\xA0\xBC\xED\xBF\x88 paired WTF-8", + "missing two: \xC3", + "missing three one: \xE6\x9C", + "missing three two: \xE6", + "missing four one: \xF0\x9F\x8F", + "missing four two: \xF0\x9F", + "missing four three: \xF0" + ), err); + // clang-format on + while (err == utf8_errc::NoError) + { + REQUIRE(!uut.is_eof()); + err = uut.next(); + } + + REQUIRE(uut.is_eof()); +} + +TEST_CASE ("Utf8Decoder empty current", "[unicode]") +{ + char storage[] = ""; + Utf8Decoder uut(storage); + REQUIRE(uut.pointer_to_current() == storage); + REQUIRE(uut.is_eof()); +} + +TEST_CASE ("utf8_is_valid_string fails", "[unicode]") +{ + const char* test = GENERATE("hello \xFF too big", + "hello \xC3\xBF\xBF\xBF also too big", + "hello \x9C continuation", + "hello \xE0\x28 overlong", + "hello \xED\xA0\xBC\xED\xBF\x88 paired WTF-8", + "missing two: \xC3", + "missing three one: \xE6\x9C", + "missing three two: \xE6", + "missing four one: \xF0\x9F\x8F", + "missing four two: \xF0\x9F", + "missing four three: \xF0"); + REQUIRE(!utf8_is_valid_string(test, test + strlen(test))); +} + +TEST_CASE ("utf8_is_valid_string fails at end", "[unicode]") +{ + const char* test = GENERATE("\xFF", + "\xC3\xBF\xBF\xBF", + "\x9C", + "\xE0\x28", + "\xED\xA0\xBC\xED\xBF\x88", + "\xC3", + "\xE6\x9C", + "\xE6", + "\xF0\x9F\x8F", + "\xF0\x9F", + "\xF0"); + REQUIRE(!utf8_is_valid_string(test, test + strlen(test))); +} \ No newline at end of file diff --git a/src/vcpkg-test/xunitwriter.cpp b/src/vcpkg-test/xunitwriter.cpp index 7b71409696..1a902ff1fb 100644 --- a/src/vcpkg-test/xunitwriter.cpp +++ b/src/vcpkg-test/xunitwriter.cpp @@ -10,7 +10,7 @@ TEST_CASE ("Simple XunitWriter", "[xunitwriter]") time_t time = {0}; Triplet t = Triplet::from_canonical_name("triplet"); PackageSpec spec("name", t); - x.add_test_results(spec, BuildResult::BUILD_FAILED, {}, std::chrono::system_clock::from_time_t(time), "", {}); + x.add_test_results(spec, BuildResult::BuildFailed, {}, std::chrono::system_clock::from_time_t(time), "", {}); CHECK(x.build_xml(t) == R"( @@ -36,11 +36,11 @@ TEST_CASE ("XunitWriter Two", "[xunitwriter]") PackageSpec spec("name", t); PackageSpec spec2("name", t2); PackageSpec spec3("other", t2); - x.add_test_results(spec, BuildResult::SUCCEEDED, {}, std::chrono::system_clock::from_time_t(time), "abihash", {}); + x.add_test_results(spec, BuildResult::Succeeded, {}, std::chrono::system_clock::from_time_t(time), "abihash", {}); x.add_test_results( - spec2, BuildResult::POST_BUILD_CHECKS_FAILED, {}, std::chrono::system_clock::from_time_t(time), "", {}); + spec2, BuildResult::PostBuildChecksFailed, {}, std::chrono::system_clock::from_time_t(time), "", {}); x.add_test_results( - spec3, BuildResult::SUCCEEDED, {}, std::chrono::system_clock::from_time_t(time), "", {"core", "feature"}); + spec3, BuildResult::Succeeded, {}, std::chrono::system_clock::from_time_t(time), "", {"core", "feature"}); CHECK(x.build_xml(t3) == R"( diff --git a/src/vcpkg.cpp b/src/vcpkg.cpp index 958dcaef4f..76e6ddacce 100644 --- a/src/vcpkg.cpp +++ b/src/vcpkg.cpp @@ -47,7 +47,7 @@ namespace LocalizedString::from_raw(ErrorPrefix) .append(msgVcpkgInvalidCommand, msg::command_name = args.get_command()) .append_raw('\n')); - print_zero_args_usage(); + msg::write_unlocalized_text_to_stderr(Color::none, get_zero_args_usage()); Checks::exit_fail(VCPKG_LINE_INFO); } @@ -99,7 +99,7 @@ namespace if (args.get_command().empty()) { - print_zero_args_usage(); + msg::write_unlocalized_text_to_stderr(Color::none, get_zero_args_usage()); Checks::exit_fail(VCPKG_LINE_INFO); } diff --git a/src/vcpkg/archives.cpp b/src/vcpkg/archives.cpp index a49061af8d..d53db08120 100644 --- a/src/vcpkg/archives.cpp +++ b/src/vcpkg/archives.cpp @@ -32,23 +32,23 @@ namespace StringView nugetid{stem.begin(), dot_after_name}; StringView version{dot_after_name + 1, stem.end()}; - Command nuget_command{nuget_exe}; - nuget_command.string_arg("install") - .string_arg(nugetid) - .string_arg("-Version") - .string_arg(version) - .string_arg("-OutputDirectory") - .string_arg(to_path) - .string_arg("-Source") - .string_arg(archive.parent_path()) - .string_arg("-nocache") - .string_arg("-DirectDownload") - .string_arg("-NonInteractive") - .string_arg("-ForceEnglishOutput") - .string_arg("-PackageSaveMode") - .string_arg("nuspec"); - - const auto result = flatten(cmd_execute_and_capture_output(nuget_command), Tools::NUGET); + auto cmd = Command{nuget_exe} + .string_arg("install") + .string_arg(nugetid) + .string_arg("-Version") + .string_arg(version) + .string_arg("-OutputDirectory") + .string_arg(to_path) + .string_arg("-Source") + .string_arg(archive.parent_path()) + .string_arg("-nocache") + .string_arg("-DirectDownload") + .string_arg("-NonInteractive") + .string_arg("-ForceEnglishOutput") + .string_arg("-PackageSaveMode") + .string_arg("nuspec"); + + const auto result = flatten(cmd_execute_and_capture_output(cmd), Tools::NUGET); if (!result) { Checks::msg_exit_with_message( @@ -65,21 +65,20 @@ namespace { // msiexec is a WIN32/GUI application, not a console application and so needs special attention to wait // until it finishes (wrap in cmd /c). - const auto maybe_code_and_output = cmd_execute_and_capture_output( - Command{"cmd"} - .string_arg("/c") - .string_arg("msiexec") - // "/a" is administrative mode, which unpacks without modifying the system - .string_arg("/a") - .string_arg(archive) - .string_arg("/qn") - // msiexec requires quotes to be after "TARGETDIR=": - // TARGETDIR="C:\full\path\to\dest" - .raw_arg(Strings::concat("TARGETDIR=", Command{to_path}.extract())), - default_working_directory, - default_environment, - Encoding::Utf16); - + auto cmd = Command{"cmd"} + .string_arg("/c") + .string_arg("msiexec") + // "/a" is administrative mode, which unpacks without modifying the system + .string_arg("/a") + .string_arg(archive) + .string_arg("/qn") + // msiexec requires quotes to be after "TARGETDIR=": + // TARGETDIR="C:\full\path\to\dest" + .raw_arg(Strings::concat("TARGETDIR=", Command{to_path}.extract())); + + RedirectedProcessLaunchSettings settings; + settings.encoding = Encoding::Utf16; + const auto maybe_code_and_output = cmd_execute_and_capture_output(cmd, settings); if (auto code_and_output = maybe_code_and_output.get()) { if (code_and_output->exit_code == 0) @@ -112,7 +111,6 @@ namespace .string_arg(fmt::format("-o{}", to_path)) .string_arg("-y")), Tools::SEVEN_ZIP); - if (!maybe_output) { Checks::msg_exit_with_message( @@ -198,9 +196,10 @@ namespace vcpkg if (ext_type == ExtractionType::Zip) { - const auto code = - cmd_execute(Command{"unzip"}.string_arg("-qqo").string_arg(archive), WorkingDirectory{to_path}) - .value_or_exit(VCPKG_LINE_INFO); + ProcessLaunchSettings settings; + settings.working_directory = to_path; + const auto code = cmd_execute(Command{"unzip"}.string_arg("-qqo").string_arg(archive), settings) + .value_or_exit(VCPKG_LINE_INFO); Checks::msg_check_exit(VCPKG_LINE_INFO, code == 0, msgPackageFailedtWhileExtracting, @@ -304,8 +303,9 @@ namespace vcpkg void extract_tar(const Path& tar_tool, const Path& archive, const Path& to_path) { - const auto code = - cmd_execute(Command{tar_tool}.string_arg("xzf").string_arg(archive), WorkingDirectory{to_path}); + ProcessLaunchSettings settings; + settings.working_directory = to_path; + const auto code = cmd_execute(Command{tar_tool}.string_arg("xzf").string_arg(archive), settings); Checks::msg_check_exit(VCPKG_LINE_INFO, succeeded(code), msgPackageFailedtWhileExtracting, @@ -316,9 +316,10 @@ namespace vcpkg void extract_tar_cmake(const Path& cmake_tool, const Path& archive, const Path& to_path) { // Note that CMake's built in tar can extract more archive types than many system tars; e.g. 7z - const auto code = - cmd_execute(Command{cmake_tool}.string_arg("-E").string_arg("tar").string_arg("xzf").string_arg(archive), - WorkingDirectory{to_path}); + ProcessLaunchSettings settings; + settings.working_directory = to_path; + const auto code = cmd_execute( + Command{cmake_tool}.string_arg("-E").string_arg("tar").string_arg("xzf").string_arg(archive), settings); Checks::msg_check_exit(VCPKG_LINE_INFO, succeeded(code), msgPackageFailedtWhileExtracting, @@ -344,12 +345,14 @@ namespace vcpkg { fs.remove(destination, VCPKG_LINE_INFO); #if defined(_WIN32) + RedirectedProcessLaunchSettings settings; + settings.environment = get_clean_environment(); return flatten(cmd_execute_and_capture_output( - Command{seven_zip}.string_arg("a").string_arg(destination).string_arg(source / "*"), - default_working_directory, - get_clean_environment()), + Command{seven_zip}.string_arg("a").string_arg(destination).string_arg(source / "*")), Tools::SEVEN_ZIP); #else + RedirectedProcessLaunchSettings settings; + settings.working_directory = source; return flatten(cmd_execute_and_capture_output(Command{"zip"} .string_arg("--quiet") .string_arg("-y") @@ -358,7 +361,7 @@ namespace vcpkg .string_arg("*") .string_arg("--exclude") .string_arg(".DS_Store"), - WorkingDirectory{source}), + settings), "zip"); #endif } @@ -396,9 +399,9 @@ namespace vcpkg std::vector> decompress_in_parallel(View jobs) { - auto results = - cmd_execute_and_capture_output_parallel(jobs, default_working_directory, get_clean_environment()); - + RedirectedProcessLaunchSettings settings; + settings.environment = get_clean_environment(); + auto results = cmd_execute_and_capture_output_parallel(jobs, settings); std::vector> filtered_results; filtered_results.reserve(jobs.size()); for (std::size_t idx = 0; idx < jobs.size(); ++idx) diff --git a/src/vcpkg/base/cmd-parser.cpp b/src/vcpkg/base/cmd-parser.cpp index 2c3a9cdee7..ab07bb3895 100644 --- a/src/vcpkg/base/cmd-parser.cpp +++ b/src/vcpkg/base/cmd-parser.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -392,8 +393,6 @@ namespace vcpkg bool OptionTableKey::operator<(const OptionTableKey& rhs) const { return switch_name < rhs.switch_name; } - CmdParser::CmdParser() = default; - CmdParser::CmdParser(View inputs) : argument_strings(inputs.begin(), inputs.end()) , argument_strings_lowercase() @@ -414,11 +413,6 @@ namespace vcpkg insert_lowercase_strings(argument_strings_lowercase, argument_strings); } - CmdParser::CmdParser(const CmdParser&) = default; - CmdParser::CmdParser(CmdParser&&) = default; - CmdParser& CmdParser::operator=(const CmdParser&) = default; - CmdParser& CmdParser::operator=(CmdParser&&) = default; - bool CmdParser::parse_switch(StringView switch_name, StabilityTag stability, bool& value) { std::size_t found = 0; @@ -1010,14 +1004,11 @@ namespace vcpkg return; } - for (auto&& error : errors) - { - msg::write_unlocalized_text(Color::error, error.append_raw("\n")); - } + msg::write_unlocalized_text_to_stderr(Color::error, Strings::join("\n", errors).append("\n")); example.append_raw('\n'); append_options_table(example); - msg::println(Color::none, example); + stderr_sink.println(Color::none, example); Checks::exit_with_code(VCPKG_LINE_INFO, 1); } } diff --git a/src/vcpkg/base/downloads.cpp b/src/vcpkg/base/downloads.cpp index 608e210698..3c060bdcb3 100644 --- a/src/vcpkg/base/downloads.cpp +++ b/src/vcpkg/base/downloads.cpp @@ -379,12 +379,11 @@ namespace vcpkg const size_t start_size = out->size(); - Command cmd; - cmd.string_arg("curl") - .string_arg("--head") - .string_arg("--location") - .string_arg("-w") - .string_arg(guid_marker.to_string() + " %{http_code}\\n"); + auto cmd = Command{"curl"} + .string_arg("--head") + .string_arg("--location") + .string_arg("-w") + .string_arg(guid_marker.to_string() + " %{http_code}\\n"); for (auto&& header : headers) { cmd.string_arg("-H").string_arg(header); @@ -450,12 +449,11 @@ namespace vcpkg size_t start_size = out->size(); static constexpr StringLiteral guid_marker = "5ec47b8e-6776-4d70-b9b3-ac2a57bc0a1c"; - Command cmd; - cmd.string_arg("curl") - .string_arg("--create-dirs") - .string_arg("--location") - .string_arg("-w") - .string_arg(guid_marker.to_string() + " %{http_code}\\n"); + auto cmd = Command{"curl"} + .string_arg("--create-dirs") + .string_arg("--location") + .string_arg("-w") + .string_arg(guid_marker.to_string() + " %{http_code}\\n"); for (StringView header : headers) { cmd.string_arg("-H").string_arg(header); @@ -524,8 +522,7 @@ namespace vcpkg { static constexpr StringLiteral guid_marker = "fcfad8a3-bb68-4a54-ad00-dab1ff671ed2"; - Command cmd; - cmd.string_arg("curl"); + auto cmd = Command{"curl"}; cmd.string_arg("-w").string_arg("\\n" + guid_marker.to_string() + "%{http_code}"); cmd.string_arg("-X").string_arg("POST"); cmd.string_arg("-H").string_arg("Accept: application/vnd.github+json"); @@ -536,23 +533,20 @@ namespace vcpkg cmd.string_arg(Strings::concat( "https://api.github.com/repos/", url_encode_spaces(github_repository), "/dependency-graph/snapshots")); cmd.string_arg("-d").string_arg("@-"); + + RedirectedProcessLaunchSettings settings; + settings.stdin_content = Json::stringify(snapshot); int code = 0; - auto result = cmd_execute_and_stream_lines( - cmd, - [&code](StringView line) { - if (Strings::starts_with(line, guid_marker)) - { - code = std::strtol(line.data() + guid_marker.size(), nullptr, 10); - } - else - { - Debug::println(line); - } - }, - default_working_directory, - default_environment, - Encoding::Utf8, - Json::stringify(snapshot)); + auto result = cmd_execute_and_stream_lines(cmd, settings, [&code](StringView line) { + if (Strings::starts_with(line, guid_marker)) + { + code = std::strtol(line.data() + guid_marker.size(), nullptr, 10); + } + else + { + Debug::println(line); + } + }); auto r = result.get(); if (r && *r == 0 && code >= 200 && code < 300) @@ -574,11 +568,10 @@ namespace vcpkg if (Strings::starts_with(url, "ftp://")) { // HTTP headers are ignored for FTP clients - Command cmd; - cmd.string_arg("curl"); - cmd.string_arg(url_encode_spaces(url)); - cmd.string_arg("-T").string_arg(file); - auto maybe_res = cmd_execute_and_capture_output(cmd); + auto ftp_cmd = Command{"curl"}; + ftp_cmd.string_arg(url_encode_spaces(url)); + ftp_cmd.string_arg("-T").string_arg(file); + auto maybe_res = cmd_execute_and_capture_output(ftp_cmd); if (auto res = maybe_res.get()) { if (res->exit_code == 0) @@ -595,19 +588,17 @@ namespace vcpkg return std::move(maybe_res).error(); } - Command cmd; - cmd.string_arg("curl").string_arg("-X").string_arg(method); - + auto http_cmd = Command{"curl"}.string_arg("-X").string_arg(method); for (auto&& header : headers) { - cmd.string_arg("-H").string_arg(header); + http_cmd.string_arg("-H").string_arg(header); } - cmd.string_arg("-w").string_arg("\\n" + guid_marker.to_string() + "%{http_code}"); - cmd.string_arg(url); - cmd.string_arg("-T").string_arg(file); + http_cmd.string_arg("-w").string_arg("\\n" + guid_marker.to_string() + "%{http_code}"); + http_cmd.string_arg(url); + http_cmd.string_arg("-T").string_arg(file); int code = 0; - auto res = cmd_execute_and_stream_lines(cmd, [&code](StringView line) { + auto res = cmd_execute_and_stream_lines(http_cmd, [&code](StringView line) { if (Strings::starts_with(line, guid_marker)) { code = std::strtol(line.data() + guid_marker.size(), nullptr, 10); @@ -644,8 +635,7 @@ namespace vcpkg StringView url, StringView data) { - Command cmd; - cmd.string_arg("curl").string_arg("-s").string_arg("-L"); + auto cmd = Command{"curl"}.string_arg("-s").string_arg("-L"); cmd.string_arg("-H").string_arg( fmt::format("User-Agent: vcpkg/{}-{} (curl)", VCPKG_BASE_VERSION_AS_STRING, VCPKG_VERSION_AS_STRING)); @@ -831,37 +821,31 @@ namespace vcpkg } } #endif - Command cmd; - cmd.string_arg("curl") - .string_arg("--fail") - .string_arg("-L") - .string_arg(url_encode_spaces(url)) - .string_arg("--create-dirs") - .string_arg("--output") - .string_arg(download_path_part_path); + auto cmd = Command{"curl"} + .string_arg("--fail") + .string_arg("-L") + .string_arg(url_encode_spaces(url)) + .string_arg("--create-dirs") + .string_arg("--output") + .string_arg(download_path_part_path); for (auto&& header : headers) { cmd.string_arg("-H").string_arg(header); } std::string non_progress_content; - auto maybe_exit_code = cmd_execute_and_stream_lines( - cmd, - [&](StringView line) { - const auto maybe_parsed = try_parse_curl_progress_data(line); - if (const auto parsed = maybe_parsed.get()) - { - progress_sink.print(Color::none, fmt::format("{}%\n", parsed->total_percent)); - } - else - { - non_progress_content.append(line.data(), line.size()); - non_progress_content.push_back('\n'); - } - }, - default_working_directory, - default_environment, - Encoding::Utf8); + auto maybe_exit_code = cmd_execute_and_stream_lines(cmd, [&](StringView line) { + const auto maybe_parsed = try_parse_curl_progress_data(line); + if (const auto parsed = maybe_parsed.get()) + { + progress_sink.print(Color::none, fmt::format("{}%\n", parsed->total_percent)); + } + else + { + non_progress_content.append(line.data(), line.size()); + non_progress_content.push_back('\n'); + } + }); const auto sanitized_url = replace_secrets(url, secrets); if (const auto exit_code = maybe_exit_code.get()) @@ -975,28 +959,26 @@ namespace vcpkg const auto escaped_url = Command(urls[0]).extract(); const auto escaped_sha512 = Command(*hash).extract(); const auto escaped_dpath = Command(download_path_part_path).extract(); - auto cmd = api_stable_format(*script, [&](std::string& out, StringView key) { - if (key == "url") - { - Strings::append(out, escaped_url); - } - else if (key == "sha512") - { - Strings::append(out, escaped_sha512); - } - else if (key == "dst") - { - Strings::append(out, escaped_dpath); - } - }).value_or_exit(VCPKG_LINE_INFO); - - auto maybe_res = flatten(cmd_execute_and_capture_output(Command{}.raw_arg(cmd), - default_working_directory, - get_clean_environment(), - Encoding::Utf8, - EchoInDebug::Show), - ""); - + Command cmd; + cmd.raw_arg(api_stable_format(*script, [&](std::string& out, StringView key) { + if (key == "url") + { + Strings::append(out, escaped_url); + } + else if (key == "sha512") + { + Strings::append(out, escaped_sha512); + } + else if (key == "dst") + { + Strings::append(out, escaped_dpath); + } + }).value_or_exit(VCPKG_LINE_INFO)); + + RedirectedProcessLaunchSettings settings; + settings.environment = get_clean_environment(); + settings.echo_in_debug = EchoInDebug::Show; + auto maybe_res = flatten(cmd_execute_and_capture_output(cmd, settings), ""); if (maybe_res) { auto maybe_success = diff --git a/src/vcpkg/base/files.cpp b/src/vcpkg/base/files.cpp index ae29d99629..b305e9f2f1 100644 --- a/src/vcpkg/base/files.cpp +++ b/src/vcpkg/base/files.cpp @@ -952,12 +952,6 @@ namespace vcpkg IgnoreErrors::operator std::error_code&() { return ec; } - Path::Path() = default; - Path::Path(const Path&) = default; - Path::Path(Path&&) = default; - Path& Path::operator=(const Path&) = default; - Path& Path::operator=(Path&&) = default; - Path::Path(const StringView sv) : m_str(sv.to_string()) { } Path::Path(const std::string& s) : m_str(s) { } Path::Path(std::string&& s) : m_str(std::move(s)) { } @@ -1361,6 +1355,8 @@ namespace vcpkg return std::error_code(::ferror(m_fs), std::generic_category()); } + int FilePointer::error_raw() const noexcept { return ::ferror(m_fs); } + const Path& FilePointer::path() const { return m_path; } ExpectedL FilePointer::try_seek_to(long long offset) { return try_seek_to(offset, SEEK_SET); } @@ -1459,28 +1455,72 @@ namespace vcpkg std::string output; constexpr std::size_t buffer_size = 1024 * 32; char buffer[buffer_size]; - do + auto this_read = this->read(buffer, 1, buffer_size); + if (this_read != buffer_size) { - const auto this_read = this->read(buffer, 1, buffer_size); - if (this_read != 0) + auto maybe_error = ::ferror(m_fs); + if (maybe_error) { - output.append(buffer, this_read); + ec.assign(maybe_error, std::generic_category()); + return output; } - else if ((ec = this->error())) + + if (!this->eof()) { - return std::string(); + Checks::unreachable(VCPKG_LINE_INFO, "Got a partial read without an error or end"); } - } while (!this->eof()); + } - if (Strings::starts_with(output, "\xEF\xBB\xBF")) { - // remove byte-order mark from the beginning of the string - output.erase(output.begin(), output.begin() + 3); + const char* to_append = buffer; + size_t to_append_size = this_read; + if (to_append_size >= 3 && ::memcmp(to_append, "\xEF\xBB\xBF", 3) == 0) + { + // remove byte-order mark from the beginning of the string + to_append_size -= 3; + to_append += 3; + } + + output.append(to_append, to_append_size); } + read_to_end_suffix(output, ec, buffer, buffer_size, this_read); return output; } + void ReadFilePointer::read_to_end_suffix( + std::string& output, std::error_code& ec, char* buffer, size_t buffer_size, size_t last_read) + { + if (last_read == buffer_size) + { + for (;;) + { + last_read = this->read(buffer, 1, buffer_size); + if (last_read != buffer_size) + { + break; + } + + output.append(buffer, last_read); + } + + if (auto maybe_error = ::ferror(m_fs)) + { + ec.assign(maybe_error, std::generic_category()); + output.clear(); + return; + } + + output.append(buffer, last_read); + if (!this->eof()) + { + Checks::unreachable(VCPKG_LINE_INFO, "Got a partial read without an error or end"); + } + } + + ec.clear(); + } + WriteFilePointer::WriteFilePointer() noexcept = default; WriteFilePointer::WriteFilePointer(WriteFilePointer&&) noexcept = default; @@ -2210,6 +2250,58 @@ namespace vcpkg return file.read_to_end(ec); } + + virtual std::string best_effort_read_contents_if_shebang(const Path& file_path) const override + { + std::error_code ec; + StatsTimer t(g_us_filesystem_stats); + ReadFilePointer file{file_path, ec}; + std::string output; + if (ec) + { + Debug::print("Failed to open: ", file_path, '\n'); + return output; + } + + constexpr std::size_t buffer_size = 1024 * 32; + char buffer[buffer_size]; + auto this_read = file.read(buffer, 1, buffer_size); + if (this_read != buffer_size) + { + if (file.error_raw()) + { + return output; + } + + if (!file.eof()) + { + Checks::unreachable(VCPKG_LINE_INFO, "Got a partial read without an error or end"); + } + } + + { + const char* to_append = buffer; + size_t to_append_size = this_read; + if (to_append_size >= 3 && ::memcmp(to_append, "\xEF\xBB\xBF", 3) == 0) + { + // remove byte-order mark from the beginning of the string + to_append_size -= 3; + to_append += 3; + } + + if (to_append_size < 2 || ::memcmp(to_append, "#!", 2) != 0) + { + // doesn't start with shebang + return output; + } + + output.append(to_append, to_append_size); + } + + file.read_to_end_suffix(output, ec, buffer, buffer_size, this_read); + return output; + } + virtual ExpectedL> read_lines(const Path& file_path) const override { StatsTimer t(g_us_filesystem_stats); @@ -2231,6 +2323,7 @@ namespace vcpkg { output.on_data({buffer, this_read}); } + else if ((ec = file.error())) { return format_filesystem_call_error(ec, "read_lines_read", {file_path}); @@ -3738,8 +3831,6 @@ namespace vcpkg msg_sink.print(ls); } - IExclusiveFileLock::~IExclusiveFileLock() = default; - uint64_t get_filesystem_stats() { return g_us_filesystem_stats.load(); } #ifdef _WIN32 diff --git a/src/vcpkg/base/git.cpp b/src/vcpkg/base/git.cpp index 568225e235..9b9ccffb6d 100644 --- a/src/vcpkg/base/git.cpp +++ b/src/vcpkg/base/git.cpp @@ -194,9 +194,9 @@ namespace vcpkg ExpectedL is_shallow_clone(const GitConfig& config) { - auto cmd = git_cmd_builder(config).string_arg("rev-parse").string_arg("--is-shallow-repository"); - return flatten_out(cmd_execute_and_capture_output(cmd), Tools::GIT).map([](std::string&& output) { - return "true" == Strings::trim(std::move(output)); - }); + return flatten_out(cmd_execute_and_capture_output( + git_cmd_builder(config).string_arg("rev-parse").string_arg("--is-shallow-repository")), + Tools::GIT) + .map([](std::string&& output) { return "true" == Strings::trim(std::move(output)); }); } } diff --git a/src/vcpkg/base/json.cpp b/src/vcpkg/base/json.cpp index 0d9518085e..2bcd4318b9 100644 --- a/src/vcpkg/base/json.cpp +++ b/src/vcpkg/base/json.cpp @@ -992,7 +992,7 @@ namespace vcpkg::Json } } - static ExpectedT> parse(StringView json, StringView origin) + static ExpectedL parse(StringView json, StringView origin) { StatsTimer t(g_json_parsing_stats); @@ -1004,16 +1004,14 @@ namespace vcpkg::Json if (!parser.at_eof()) { parser.add_error(msg::format(msgUnexpectedEOFExpectedChar)); - return parser.extract_error(); } - else if (parser.get_error()) - { - return parser.extract_error(); - } - else + + if (const auto maybe_error = std::move(parser).get_error()) { - return ParsedJson{std::move(val), parser.style()}; + return std::move(*maybe_error); } + + return ParsedJson{std::move(val), parser.style()}; } JsonStyle style() const noexcept { return style_; } @@ -1100,14 +1098,12 @@ namespace vcpkg::Json return true; } - ExpectedT> parse_file(const ReadOnlyFilesystem& fs, - const Path& json_file, - std::error_code& ec) + ExpectedL parse_file(const ReadOnlyFilesystem& fs, const Path& json_file, std::error_code& ec) { auto res = fs.read_contents(json_file, ec); if (ec) { - return std::unique_ptr(); + return format_filesystem_call_error(ec, "read_contents", {json_file}); } return parse(res, json_file); @@ -1116,7 +1112,7 @@ namespace vcpkg::Json ParsedJson parse_file(vcpkg::LineInfo li, const ReadOnlyFilesystem& fs, const Path& json_file) { std::error_code ec; - auto ret = parse_file(fs, json_file, ec).map_error(parse_error_formatter); + auto ret = parse_file(fs, json_file, ec); if (ec) { Checks::msg_exit_with_error(li, format_filesystem_call_error(ec, "read_contents", {json_file})); @@ -1124,26 +1120,19 @@ namespace vcpkg::Json return std::move(ret).value_or_exit(VCPKG_LINE_INFO); } - ExpectedT> parse(StringView json, StringView origin) - { - return Parser::parse(json, origin); - } + ExpectedL parse(StringView json, StringView origin) { return Parser::parse(json, origin); } ExpectedL parse_object(StringView text, StringView origin) { - auto maybeValueIsh = parse(text, origin); - if (auto asValueIsh = maybeValueIsh.get()) - { - auto& asValue = asValueIsh->value; + return parse(text, origin).then([&](ParsedJson&& mabeValueIsh) -> ExpectedL { + auto& asValue = mabeValueIsh.value; if (asValue.is_object()) { return std::move(asValue).object(VCPKG_LINE_INFO); } return msg::format(msgJsonErrorMustBeAnObject, msg::path = origin); - } - - return LocalizedString::from_raw(maybeValueIsh.error()->to_string()); + }); } // } auto parse() diff --git a/src/vcpkg/base/parse.cpp b/src/vcpkg/base/parse.cpp index bdadabf937..1c069789fe 100644 --- a/src/vcpkg/base/parse.cpp +++ b/src/vcpkg/base/parse.cpp @@ -22,53 +22,53 @@ namespace vcpkg } } - std::string ParseError::to_string() const + static void append_caret_line(LocalizedString& res, const SourceLoc& loc) { - auto decoder = Unicode::Utf8Decoder(line.data(), line.data() + line.size()); - ParseMessage as_message; - as_message.location = SourceLoc{std::next(decoder, caret_col), decoder, row, column}; - as_message.message = message; - return as_message.format(origin, MessageKind::Error).extract_data(); - } - - LocalizedString ParseMessage::format(StringView origin, MessageKind kind) const - { - LocalizedString res; - if (!origin.empty()) - { - res.append_raw(fmt::format("{}:{}:{}: ", origin, location.row, location.column)); - } - - res.append_raw(kind == MessageKind::Warning ? WarningPrefix : ErrorPrefix); - res.append(message); - res.append_raw('\n'); - - auto line_end = Util::find_if(location.it, ParserBase::is_lineend); + auto line_end = Util::find_if(loc.it, ParserBase::is_lineend); StringView line = StringView{ - location.start_of_line.pointer_to_current(), + loc.start_of_line.pointer_to_current(), line_end.pointer_to_current(), }; - res.append_indent().append(msgFormattedParseMessageExpression, msg::value = line); - res.append_raw('\n'); - auto caret_point = StringView{location.start_of_line.pointer_to_current(), location.it.pointer_to_current()}; - auto formatted_caret_point = msg::format(msgFormattedParseMessageExpression, msg::value = caret_point); + LocalizedString line_prefix = msg::format(msgFormattedParseMessageExpressionPrefix); + size_t line_prefix_space = 1; // for the space after the prefix + for (char32_t ch : Unicode::Utf8Decoder(line_prefix)) + { + line_prefix_space += 1 + Unicode::is_double_width_code_point(ch); + } + + res.append_indent().append(line_prefix).append_raw(' ').append_raw(line).append_raw('\n'); std::string caret_string; - caret_string.reserve(formatted_caret_point.data().size()); - for (char32_t ch : Unicode::Utf8Decoder(formatted_caret_point)) + caret_string.append(line_prefix_space, ' '); + // note *it is excluded because it is where the ^ goes + for (auto it = loc.start_of_line; it != loc.it; ++it) { - if (ch == '\t') + if (*it == '\t') caret_string.push_back('\t'); - else if (Unicode::is_double_width_code_point(ch)) - caret_string.append(" "); + else if (Unicode::is_double_width_code_point(*it)) + caret_string.append(2, ' '); else caret_string.push_back(' '); } + caret_string.push_back('^'); res.append_indent().append_raw(caret_string); + } + + LocalizedString ParseMessage::format(StringView origin, MessageKind kind) const + { + LocalizedString res; + if (!origin.empty()) + { + res.append_raw(fmt::format("{}:{}:{}: ", origin, location.row, location.column)); + } + res.append_raw(kind == MessageKind::Warning ? WarningPrefix : ErrorPrefix); + res.append(message); + res.append_raw('\n'); + append_caret_line(res, location); return res; } @@ -79,9 +79,9 @@ namespace vcpkg msg::println(warning.format(origin, MessageKind::Warning)); } - if (error) + if (auto e = error.get()) { - Checks::msg_exit_with_message(VCPKG_LINE_INFO, LocalizedString::from_raw(error->to_string())); + Checks::msg_exit_with_message(VCPKG_LINE_INFO, *e); } if (!warnings.empty()) @@ -186,19 +186,16 @@ namespace vcpkg // avoid cascading errors by only saving the first if (!m_messages.error) { - // find end of line - auto line_end = loc.it; - while (line_end != line_end.end() && *line_end != '\n' && *line_end != '\r') + auto& res = m_messages.error.emplace(); + if (!m_origin.empty()) { - ++line_end; + res.append_raw(fmt::format("{}:{}:{}: ", m_origin, loc.row, loc.column)); } - m_messages.error = std::make_unique( - m_origin.to_string(), - loc.row, - loc.column, - static_cast(std::distance(loc.start_of_line, loc.it)), - std::string(loc.start_of_line.pointer_to_current(), line_end.pointer_to_current()), - std::move(message)); + + res.append_raw(ErrorPrefix); + res.append(message); + res.append_raw('\n'); + append_caret_line(res, loc); } // Avoid error loops by skipping to the end diff --git a/src/vcpkg/base/system.cpp b/src/vcpkg/base/system.cpp index 18af868a03..6a685efd54 100644 --- a/src/vcpkg/base/system.cpp +++ b/src/vcpkg/base/system.cpp @@ -9,6 +9,10 @@ #include #endif +#if defined(__linux__) +#include +#endif + #if defined(_WIN32) #include #include @@ -686,6 +690,15 @@ namespace vcpkg } else { +#if defined(__linux__) + // Get the number of threads we are allowed to run on, + // this might be less than the number of hardware threads. + cpu_set_t set; + if (sched_getaffinity(getpid(), sizeof(set), &set) == 0) + { + return static_cast(CPU_COUNT(&set)) + 1; + } +#endif return std::thread::hardware_concurrency() + 1; } }(); diff --git a/src/vcpkg/base/system.process.cpp b/src/vcpkg/base/system.process.cpp index 7661a8db6c..4c034055db 100644 --- a/src/vcpkg/base/system.process.cpp +++ b/src/vcpkg/base/system.process.cpp @@ -326,8 +326,8 @@ namespace } explicit operator bool() const noexcept { return snapshot != INVALID_HANDLE_VALUE; } - BOOL Process32First(PPROCESSENTRY32W entry) const noexcept { return Process32FirstW(snapshot, entry); } - BOOL Process32Next(PPROCESSENTRY32W entry) const noexcept { return Process32NextW(snapshot, entry); } + BOOL Process32First(PPROCESSENTRY32W entry) const noexcept { return ::Process32FirstW(snapshot, entry); } + BOOL Process32Next(PPROCESSENTRY32W entry) const noexcept { return ::Process32NextW(snapshot, entry); } private: HANDLE snapshot; @@ -666,26 +666,22 @@ namespace vcpkg return clean_env; } - const WorkingDirectory default_working_directory; - const Environment default_environment; + std::vector> cmd_execute_and_capture_output_parallel(View commands) + { + RedirectedProcessLaunchSettings default_redirected_process_launch_settings; + return cmd_execute_and_capture_output_parallel(commands, default_redirected_process_launch_settings); + } - std::vector> cmd_execute_and_capture_output_parallel(View cmd_lines, - const WorkingDirectory& wd, - const Environment& env) + std::vector> cmd_execute_and_capture_output_parallel( + View commands, const RedirectedProcessLaunchSettings& settings) { - std::vector> res(cmd_lines.size(), LocalizedString{}); + std::vector> res(commands.size(), LocalizedString{}); - parallel_transform(cmd_lines, res.begin(), [&](const Command& cmd_line) { - return cmd_execute_and_capture_output(cmd_line, wd, env); - }); + parallel_transform( + commands, res.begin(), [&](const Command& cmd) { return cmd_execute_and_capture_output(cmd, settings); }); return res; } - - ExpectedL cmd_execute_clean(const Command& cmd_line, const WorkingDirectory& wd) - { - return cmd_execute(cmd_line, wd, get_clean_environment()); - } } // namespace vcpkg namespace @@ -723,36 +719,37 @@ namespace } }; - /// If non-null, an environment block to use for the new process. If null, the - /// new process will inherit the current environment. ExpectedL windows_create_process(std::int32_t debug_id, ProcessInfo& process_info, - StringView cmd_line, - const WorkingDirectory& wd, - const Environment& env, + StringView command_line, + const Optional& working_directory, + const Optional& environment, BOOL bInheritHandles, DWORD dwCreationFlags, STARTUPINFOEXW& startup_info) noexcept { - Debug::print(fmt::format("{}: CreateProcessW({})\n", debug_id, cmd_line)); + Debug::print(fmt::format("{}: CreateProcessW({})\n", debug_id, command_line)); // Flush stdout before launching external process fflush(nullptr); - std::wstring working_directory; - if (!wd.working_directory.empty()) - { + Optional working_directory_wide = working_directory.map([](const Path& wd) { // this only fails if we can't get the current working directory of vcpkg, and we assume that we have that, // so it's fine anyways - working_directory = Strings::to_utf16(real_filesystem.absolute(wd.working_directory, VCPKG_LINE_INFO)); + return Strings::to_utf16(real_filesystem.absolute(wd, VCPKG_LINE_INFO)); + }); + + LPCWSTR working_directory_arg = nullptr; + if (auto wd = working_directory_wide.get()) + { + working_directory_arg = wd->c_str(); } - auto&& env_unpacked = env.get(); std::wstring environment_block; LPVOID call_environment = nullptr; - if (!env_unpacked.empty()) + if (auto env_unpacked = environment.get()) { - environment_block = env_unpacked; + environment_block = env_unpacked->get(); environment_block.push_back('\0'); call_environment = environment_block.data(); } @@ -761,14 +758,14 @@ namespace // /analyze can't tell that we transferred ownership here VCPKG_MSVC_WARNING(suppress : 6335) if (!CreateProcessW(nullptr, - Strings::to_utf16(cmd_line).data(), + Strings::to_utf16(command_line).data(), nullptr, nullptr, bInheritHandles, IDLE_PRIORITY_CLASS | CREATE_UNICODE_ENVIRONMENT | EXTENDED_STARTUPINFO_PRESENT | dwCreationFlags, call_environment, - working_directory.empty() ? nullptr : working_directory.data(), + working_directory_arg, &startup_info.StartupInfo, &process_info)) { @@ -1071,65 +1068,6 @@ namespace return child_exit_code; } }; - - ExpectedL windows_create_process_redirect(std::int32_t debug_id, - RedirectedProcessInfo& ret, - StringView cmd_line, - const WorkingDirectory& wd, - const Environment& env, - DWORD dwCreationFlags) noexcept - { - STARTUPINFOEXW startup_info_ex{}; - startup_info_ex.StartupInfo.cb = sizeof(STARTUPINFOEXW); - startup_info_ex.StartupInfo.dwFlags |= STARTF_USESTDHANDLES; - - // Create a pipe for the child process's STDIN. - auto stdin_create = ret.stdin_pipe.create(debug_id); - if (!stdin_create) - { - return std::move(stdin_create).error(); - } - - startup_info_ex.StartupInfo.hStdInput = ret.stdin_pipe.read_pipe; - - // Create a pipe for the child process's STDOUT/STDERR. - auto stdout_create = ret.stdout_pipe.create(); - if (!stdout_create) - { - return std::move(stdout_create).error(); - } - - startup_info_ex.StartupInfo.hStdOutput = ret.stdout_pipe.write_pipe; - startup_info_ex.StartupInfo.hStdError = ret.stdout_pipe.write_pipe; - - ProcAttributeList proc_attribute_list; - auto proc_attribute_list_create = proc_attribute_list.create(1); - if (!proc_attribute_list_create) - { - return std::move(proc_attribute_list_create).error(); - } - - HANDLE handles_to_inherit[2] = {startup_info_ex.StartupInfo.hStdOutput, startup_info_ex.StartupInfo.hStdInput}; - auto maybe_error = proc_attribute_list.update_attribute( - PROC_THREAD_ATTRIBUTE_HANDLE_LIST, handles_to_inherit, 2 * sizeof(HANDLE)); - if (!maybe_error.has_value()) - { - return maybe_error.error(); - } - startup_info_ex.lpAttributeList = proc_attribute_list.get(); - - auto process_create = - windows_create_process(debug_id, ret.proc_info, cmd_line, wd, env, TRUE, dwCreationFlags, startup_info_ex); - - if (!process_create) - { - return std::move(process_create).error(); - } - - close_handle_mark_invalid(ret.stdin_pipe.read_pipe); - close_handle_mark_invalid(ret.stdout_pipe.write_pipe); - return Unit{}; - } #else // ^^^ _WIN32 // !_WIN32 vvv struct AnonymousPipe { @@ -1247,15 +1185,19 @@ namespace namespace vcpkg { #if defined(_WIN32) - Environment cmd_execute_and_capture_environment(const Command& cmd_line, const Environment& env) + Environment cmd_execute_and_capture_environment(const Command& cmd, const Environment& env) { static StringLiteral magic_string = "cdARN4xjKueKScMy9C6H"; - auto actual_cmd_line = cmd_line; - actual_cmd_line.raw_arg(Strings::concat(" & echo ", magic_string, " & set")); + Command actual_cmd = cmd; + actual_cmd.raw_arg(Strings::concat(" & echo ", magic_string, " & set")); + + Debug::print("command line: ", actual_cmd.command_line(), "\n"); - Debug::print("command line: ", actual_cmd_line.command_line(), "\n"); - auto maybe_rc_output = cmd_execute_and_capture_output(actual_cmd_line, default_working_directory, env); + RedirectedProcessLaunchSettings settings; + settings.environment = env; + settings.create_new_console = CreateNewConsole::Yes; + auto maybe_rc_output = cmd_execute_and_capture_output(actual_cmd, settings); if (!maybe_rc_output) { Checks::msg_exit_with_error( @@ -1324,10 +1266,10 @@ namespace vcpkg auto process_create = windows_create_process(debug_id, process_info, cmd_line.command_line(), - default_working_directory, - default_environment, + nullopt, + nullopt, FALSE, - CREATE_NEW_CONSOLE | CREATE_NO_WINDOW | CREATE_BREAKAWAY_FROM_JOB, + CREATE_NEW_CONSOLE | CREATE_BREAKAWAY_FROM_JOB, startup_info_ex); if (!process_create) { @@ -1361,10 +1303,9 @@ namespace vcpkg #endif // ^^^ !_WIN32 } - static ExpectedL cmd_execute_impl(const int32_t debug_id, - const Command& cmd_line, - const WorkingDirectory& wd, - const Environment& env) + static ExpectedL cmd_execute_impl(const Command& cmd, + const ProcessLaunchSettings& settings, + const int32_t debug_id) { #if defined(_WIN32) STARTUPINFOEXW startup_info_ex; @@ -1397,8 +1338,14 @@ namespace vcpkg SpawnProcessGuard spawn_process_guard; ProcessInfo process_info; - auto process_create = - windows_create_process(debug_id, process_info, cmd_line.command_line(), wd, env, TRUE, 0, startup_info_ex); + auto process_create = windows_create_process(debug_id, + process_info, + cmd.command_line(), + settings.working_directory, + settings.environment, + TRUE, + 0, + startup_info_ex); if (!process_create) { return std::move(process_create).error(); @@ -1408,21 +1355,20 @@ namespace vcpkg if (long_exit_code > INT_MAX) long_exit_code = INT_MAX; return static_cast(long_exit_code); #else - (void)env; Command real_command_line_builder; - if (!wd.working_directory.empty()) + if (const auto wd = settings.working_directory.get()) { real_command_line_builder.string_arg("cd"); - real_command_line_builder.string_arg(wd.working_directory); + real_command_line_builder.string_arg(*wd); real_command_line_builder.raw_arg("&&"); } - if (!env.get().empty()) + if (const auto env = settings.environment.get()) { - real_command_line_builder.raw_arg(env.get()); + real_command_line_builder.raw_arg(env->get()); } - real_command_line_builder.raw_arg(cmd_line.command_line()); + real_command_line_builder.raw_arg(cmd.command_line()); std::string real_command_line = std::move(real_command_line_builder).extract(); Debug::print(fmt::format("{}: system({})\n", debug_id, real_command_line)); @@ -1432,11 +1378,17 @@ namespace vcpkg #endif } - ExpectedL cmd_execute(const Command& cmd_line, const WorkingDirectory& wd, const Environment& env) + ExpectedL cmd_execute(const Command& cmd) + { + ProcessLaunchSettings default_process_launch_settings; + return cmd_execute(cmd, default_process_launch_settings); + } + + ExpectedL cmd_execute(const Command& cmd, const ProcessLaunchSettings& settings) { const ElapsedTimer timer; const auto debug_id = debug_id_counter.fetch_add(1, std::memory_order_relaxed); - auto maybe_result = cmd_execute_impl(debug_id, cmd_line, wd, env); + auto maybe_result = cmd_execute_impl(cmd, settings, debug_id); const auto elapsed = timer.us_64(); g_subprocess_stats += elapsed; if (auto result = maybe_result.get()) @@ -1452,16 +1404,19 @@ namespace vcpkg return maybe_result; } - ExpectedL cmd_execute_and_stream_lines(const Command& cmd_line, - const std::function& per_line_cb, - const WorkingDirectory& wd, - const Environment& env, - Encoding encoding, - StringView stdin_content) + ExpectedL cmd_execute_and_stream_lines(const Command& cmd, const std::function& per_line_cb) + { + RedirectedProcessLaunchSettings default_redirected_process_launch_settings; + return cmd_execute_and_stream_lines(cmd, default_redirected_process_launch_settings, per_line_cb); + } + + ExpectedL cmd_execute_and_stream_lines(const Command& cmd, + const RedirectedProcessLaunchSettings& settings, + const std::function& per_line_cb) { Strings::LinesStream lines; - auto rc = cmd_execute_and_stream_data( - cmd_line, [&](const StringView sv) { lines.on_data(sv, per_line_cb); }, wd, env, encoding, stdin_content); + auto rc = + cmd_execute_and_stream_data(cmd, settings, [&](const StringView sv) { lines.on_data(sv, per_line_cb); }); lines.on_end(per_line_cb); return rc; } @@ -1500,17 +1455,15 @@ namespace }; #endif // ^^^ !_WIN32 - ExpectedL cmd_execute_and_stream_data_impl(const Command& cmd_line, - uint32_t debug_id, + ExpectedL cmd_execute_and_stream_data_impl(const Command& cmd, + const RedirectedProcessLaunchSettings& settings, const std::function& data_cb, - const WorkingDirectory& wd, - const Environment& env, - Encoding encoding, - StringView stdin_content) + uint32_t debug_id) { #if defined(_WIN32) std::wstring as_utf16; - if (encoding == Encoding::Utf16) + StringView stdin_content = settings.stdin_content; + if (!stdin_content.empty() && settings.encoding == Encoding::Utf16) { as_utf16 = Strings::to_utf16(stdin_content); stdin_content = @@ -1527,19 +1480,84 @@ namespace SpawnProcessGuard spawn_process_guard; RedirectedProcessInfo process_info; - auto process_create = - windows_create_process_redirect(debug_id, process_info, cmd_line.command_line(), wd, env, 0); + DWORD dwCreationFlags = 0; + STARTUPINFOEXW startup_info_ex{}; + startup_info_ex.StartupInfo.cb = sizeof(STARTUPINFOEXW); + startup_info_ex.StartupInfo.dwFlags = STARTF_USESTDHANDLES; + switch (settings.create_new_console) + { + case CreateNewConsole::No: break; + case CreateNewConsole::Yes: + dwCreationFlags |= CREATE_NEW_CONSOLE; + startup_info_ex.StartupInfo.dwFlags |= STARTF_USESHOWWINDOW; + startup_info_ex.StartupInfo.wShowWindow = SW_HIDE; + break; + default: Checks::unreachable(VCPKG_LINE_INFO); + } + + // Create a pipe for the child process's STDIN. + auto stdin_create = process_info.stdin_pipe.create(debug_id); + if (!stdin_create) + { + return std::move(stdin_create).error(); + } + + startup_info_ex.StartupInfo.hStdInput = process_info.stdin_pipe.read_pipe; + + // Create a pipe for the child process's STDOUT/STDERR. + auto stdout_create = process_info.stdout_pipe.create(); + if (!stdout_create) + { + return std::move(stdout_create).error(); + } + + startup_info_ex.StartupInfo.hStdOutput = process_info.stdout_pipe.write_pipe; + startup_info_ex.StartupInfo.hStdError = process_info.stdout_pipe.write_pipe; + + ProcAttributeList proc_attribute_list; + auto proc_attribute_list_create = proc_attribute_list.create(1); + if (!proc_attribute_list_create) + { + return std::move(proc_attribute_list_create).error(); + } + + HANDLE handles_to_inherit[2] = {startup_info_ex.StartupInfo.hStdOutput, startup_info_ex.StartupInfo.hStdInput}; + auto maybe_error = proc_attribute_list.update_attribute( + PROC_THREAD_ATTRIBUTE_HANDLE_LIST, handles_to_inherit, 2 * sizeof(HANDLE)); + if (!maybe_error.has_value()) + { + return maybe_error.error(); + } + startup_info_ex.lpAttributeList = proc_attribute_list.get(); + + auto process_create = windows_create_process(debug_id, + process_info.proc_info, + cmd.command_line(), + settings.working_directory, + settings.environment, + TRUE, + dwCreationFlags, + startup_info_ex); + if (!process_create) { return std::move(process_create).error(); } + close_handle_mark_invalid(process_info.stdin_pipe.read_pipe); + close_handle_mark_invalid(process_info.stdout_pipe.write_pipe); + std::function raw_cb; - switch (encoding) + switch (settings.encoding) { case Encoding::Utf8: raw_cb = [&](char* buf, size_t bytes_read) { std::replace(buf, buf + bytes_read, '\0', '?'); + if (settings.echo_in_debug == EchoInDebug::Show && Debug::g_debugging) + { + msg::write_unlocalized_text_to_stdout(Color::none, StringView{buf, bytes_read}); + } + data_cb(StringView{buf, bytes_read}); }; break; @@ -1550,6 +1568,11 @@ namespace std::string encoded; Strings::to_utf8(encoded, reinterpret_cast(buf), bytes_read / 2); std::replace(encoded.begin(), encoded.end(), '\0', '?'); + if (settings.echo_in_debug == EchoInDebug::Show && Debug::g_debugging) + { + msg::write_unlocalized_text_to_stdout(Color::none, StringView{encoded}); + } + data_cb(StringView{encoded}); }; break; @@ -1559,23 +1582,21 @@ namespace return process_info.wait_and_stream_output(debug_id, stdin_content.data(), stdin_content_size, raw_cb); #else // ^^^ _WIN32 // !_WIN32 vvv - Checks::check_exit(VCPKG_LINE_INFO, encoding == Encoding::Utf8); std::string actual_cmd_line; - if (!wd.working_directory.empty()) + if (auto wd = settings.working_directory.get()) { actual_cmd_line.append("cd "); - append_shell_escaped(actual_cmd_line, wd.working_directory); + append_shell_escaped(actual_cmd_line, *wd); actual_cmd_line.append(" && "); } - const auto& env_text = env.get(); - if (!env_text.empty()) + if (auto env_unpacked = settings.environment.get()) { - actual_cmd_line.append(env_text); + actual_cmd_line.append(env_unpacked->get()); actual_cmd_line.push_back(' '); } - const auto unwrapped_to_execute = cmd_line.command_line(); + const auto unwrapped_to_execute = cmd.command_line(); actual_cmd_line.append(unwrapped_to_execute.data(), unwrapped_to_execute.size()); Debug::print(fmt::format("{}: execute_process({})\n", debug_id, actual_cmd_line)); @@ -1631,8 +1652,8 @@ namespace close_mark_invalid(child_output.pipefd[1]); char buf[1024]; - ChildStdinTracker stdin_tracker{stdin_content, 0}; - if (stdin_content.empty()) + ChildStdinTracker stdin_tracker{settings.stdin_content, 0}; + if (settings.stdin_content.empty()) { close_mark_invalid(child_input.pipefd[1]); } @@ -1708,7 +1729,12 @@ namespace Checks::unreachable(VCPKG_LINE_INFO); } - data_cb(StringView{buf, static_cast(read_amount)}); + StringView this_read_data{buf, static_cast(read_amount)}; + data_cb(this_read_data); + if (settings.echo_in_debug == EchoInDebug::Show && Debug::g_debugging) + { + msg::write_unlocalized_text(Color::none, this_read_data); + } } } } @@ -1735,7 +1761,12 @@ namespace break; } - data_cb(StringView{buf, static_cast(read_amount)}); + StringView this_read_data{buf, static_cast(read_amount)}; + data_cb(this_read_data); + if (settings.echo_in_debug == EchoInDebug::Show && Debug::g_debugging) + { + msg::write_unlocalized_text(Color::none, this_read_data); + } } return pid.wait_for_termination(); @@ -1745,17 +1776,19 @@ namespace namespace vcpkg { - ExpectedL cmd_execute_and_stream_data(const Command& cmd_line, - const std::function& data_cb, - const WorkingDirectory& wd, - const Environment& env, - Encoding encoding, - StringView stdin_content) + ExpectedL cmd_execute_and_stream_data(const Command& cmd, const std::function& data_cb) + { + RedirectedProcessLaunchSettings default_redirected_process_launch_settings; + return cmd_execute_and_stream_data(cmd, default_redirected_process_launch_settings, data_cb); + } + + ExpectedL cmd_execute_and_stream_data(const Command& cmd, + const RedirectedProcessLaunchSettings& settings, + const std::function& data_cb) { const ElapsedTimer timer; const auto debug_id = debug_id_counter.fetch_add(1, std::memory_order_relaxed); - auto maybe_exit_code = - cmd_execute_and_stream_data_impl(cmd_line, debug_id, data_cb, wd, env, encoding, stdin_content); + auto maybe_exit_code = cmd_execute_and_stream_data_impl(cmd, settings, data_cb, debug_id); const auto elapsed = timer.us_64(); g_subprocess_stats += elapsed; if (const auto exit_code = maybe_exit_code.get()) @@ -1769,27 +1802,17 @@ namespace vcpkg return maybe_exit_code; } - ExpectedL cmd_execute_and_capture_output(const Command& cmd_line, - const WorkingDirectory& wd, - const Environment& env, - Encoding encoding, - EchoInDebug echo_in_debug, - StringView stdin_content) + ExpectedL cmd_execute_and_capture_output(const Command& cmd) + { + RedirectedProcessLaunchSettings default_redirected_process_launch_settings; + return cmd_execute_and_capture_output(cmd, default_redirected_process_launch_settings); + } + + ExpectedL cmd_execute_and_capture_output(const Command& cmd, + const RedirectedProcessLaunchSettings& settings) { std::string output; - return cmd_execute_and_stream_data( - cmd_line, - [&](StringView sv) { - Strings::append(output, sv); - if (echo_in_debug == EchoInDebug::Show && Debug::g_debugging) - { - msg::write_unlocalized_text(Color::none, sv); - } - }, - wd, - env, - encoding, - stdin_content) + return cmd_execute_and_stream_data(cmd, settings, [&](StringView sv) { Strings::append(output, sv); }) .map([&](int exit_code) { return ExitCodeAndOutput{exit_code, std::move(output)}; }); diff --git a/src/vcpkg/base/unicode.cpp b/src/vcpkg/base/unicode.cpp index 5613be895b..94a4a08c3b 100644 --- a/src/vcpkg/base/unicode.cpp +++ b/src/vcpkg/base/unicode.cpp @@ -3,178 +3,189 @@ namespace vcpkg::Unicode { - Utf8CodeUnitKind utf8_code_unit_kind(unsigned char code_unit) noexcept - { - if (code_unit < 0b1000'0000) - { - return Utf8CodeUnitKind::StartOne; - } - else if (code_unit < 0b1100'0000) - { - return Utf8CodeUnitKind::Continue; - } - else if (code_unit < 0b1110'0000) - { - return Utf8CodeUnitKind::StartTwo; - } - else if (code_unit < 0b1111'0000) - { - return Utf8CodeUnitKind::StartThree; - } - else if (code_unit < 0b1111'1000) - { - return Utf8CodeUnitKind::StartFour; - } - else - { - return Utf8CodeUnitKind::Invalid; - } - } - - int utf8_code_unit_count(char code_unit) noexcept - { - return utf8_code_unit_count(utf8_code_unit_kind(static_cast(code_unit))); - } - - static constexpr int utf8_encode_code_unit_count(char32_t code_point) noexcept + int utf8_encode_code_point(char (&array)[4], char32_t code_point) noexcept { if (code_point < 0x80) { + array[0] = static_cast(code_point); return 1; } - else if (code_point < 0x800) + + if (code_point < 0x800) { + array[0] = static_cast(0b1100'0000u | (code_point >> 6)); + array[1] = static_cast(0b1000'0000u | (code_point & 0b0011'1111u)); return 2; } - else if (code_point < 0x10000) + + if (code_point < 0x10000) { + // clang-format off + array[0] = static_cast(0b1110'0000u | (code_point >> 12)); + array[1] = static_cast(0b1000'0000u | ((code_point >> 6) & 0b0011'1111u)); + array[2] = static_cast(0b1000'0000u | (code_point & 0b0011'1111u)); + // clang-format on return 3; } - else if (code_point < 0x110000) + + if (code_point < 0x110000) { + // clang-format off + array[0] = static_cast(0b1111'0000u | (code_point >> 18)); + array[1] = static_cast(0b1000'0000u | ((code_point >> 12) & 0b0011'1111u)); + array[2] = static_cast(0b1000'0000u | ((code_point >> 6) & 0b0011'1111u)); + array[3] = static_cast(0b1000'0000u | (code_point & 0b0011'1111u)); + // clang-format on return 4; } - else - { - vcpkg::Checks::msg_exit_with_message( - VCPKG_LINE_INFO, - msg::format(msgInvalidCodePoint).append_raw(fmt::format("({:x})", static_cast(code_point)))); - } + + vcpkg::Checks::msg_exit_with_message( + VCPKG_LINE_INFO, + msg::format(msgInvalidCodePoint).append_raw(fmt::format("({:x})", static_cast(code_point)))); } - int utf8_encode_code_point(char (&array)[4], char32_t code_point) noexcept + static utf8_errc check_trailing(unsigned char code_unit) noexcept { - // count \in {2, 3, 4} - const auto start_code_point = [](char32_t code_point, int count) { - const unsigned char and_mask = 0xFF >> (count + 1); - const unsigned char or_mask = (0xFF << (8 - count)) & 0xFF; - const int shift = 6 * (count - 1); - return static_cast(or_mask | ((code_point >> shift) & and_mask)); - }; - // count \in {2, 3, 4}, byte \in {1, 2, 3} - const auto continue_code_point = [](char32_t code_point, int count, int byte) { - constexpr unsigned char and_mask = 0xFF >> 2; - constexpr unsigned char or_mask = (0xFF << 7) & 0xFF; - const int shift = 6 * (count - byte - 1); - return static_cast(or_mask | ((code_point >> shift) & and_mask)); - }; - - int count = utf8_encode_code_unit_count(code_point); - if (count == 1) + if ((code_unit & 0b1100'0000u) != 0b1000'0000u) { - array[0] = static_cast(code_point); - return 1; - } + if (code_unit >= 0b1111'1000u) + { + return utf8_errc::InvalidCodeUnit; + } - array[0] = start_code_point(code_point, count); - for (int i = 1; i < count; ++i) - { - array[i] = continue_code_point(code_point, count, i); + return utf8_errc::UnexpectedStart; } - return count; + return utf8_errc::NoError; } - std::pair utf8_decode_code_point(const char* first, - const char* last, - char32_t& out) noexcept + utf8_errc utf8_decode_code_point(const char*& first, const char* last, char32_t& out) noexcept { - out = end_of_file; if (first == last) { - return {last, utf8_errc::NoError}; + out = end_of_file; + return utf8_errc::NoError; } - auto code_unit = *first; - auto kind = utf8_code_unit_kind(static_cast(code_unit)); - const int count = utf8_code_unit_count(kind); - - const char* it = first + 1; - - if (kind == Utf8CodeUnitKind::Invalid) - { - return {it, utf8_errc::InvalidCodeUnit}; - } - else if (kind == Utf8CodeUnitKind::Continue) + auto code_unit = static_cast(*first); + if (code_unit < 0b1000'0000u) { - return {it, utf8_errc::UnexpectedContinue}; + out = code_unit; + ++first; + return utf8_errc::NoError; } - else if (count > last - first) + + if (code_unit < 0b1100'0000u) { - return {last, utf8_errc::UnexpectedEof}; + out = end_of_file; + first = last; + return utf8_errc::UnexpectedContinue; } - if (count == 1) + if (code_unit < 0b1110'0000u) { - out = static_cast(code_unit); - return {it, utf8_errc::NoError}; - } + if (2 > last - first) + { + out = end_of_file; + first = last; + return utf8_errc::UnexpectedEof; + } - // 2 -> 0b0001'1111, 6 - // 3 -> 0b0000'1111, 12 - // 4 -> 0b0000'0111, 18 - const auto start_mask = static_cast(0xFF >> (count + 1)); - const int start_shift = 6 * (count - 1); - char32_t code_point = static_cast(code_unit & start_mask) << start_shift; + utf8_errc out_error; + if ((out_error = check_trailing(static_cast(first[1]))) != utf8_errc::NoError) + { + out = end_of_file; + first = last; + return out_error; + } - constexpr unsigned char continue_mask = 0b0011'1111; - for (int byte = 1; byte < count; ++byte) - { - code_unit = *it++; + out = ((code_unit & 0b0001'1111) << 6) | (static_cast(first[1]) & 0b0011'1111u); + first += 2; + return utf8_errc::NoError; + } - kind = utf8_code_unit_kind(code_unit); - if (kind == Utf8CodeUnitKind::Invalid) + if (code_unit < 0b1111'0000u) + { + if (3 > last - first) { - return {it, utf8_errc::InvalidCodeUnit}; + out = end_of_file; + first = last; + return utf8_errc::UnexpectedEof; } - else if (kind != Utf8CodeUnitKind::Continue) + + utf8_errc out_error; + if ((out_error = check_trailing(static_cast(first[1]))) != utf8_errc::NoError || + (out_error = check_trailing(static_cast(first[2]))) != utf8_errc::NoError) { - return {it, utf8_errc::UnexpectedStart}; + out = end_of_file; + first = last; + return out_error; } - const int shift = 6 * (count - byte - 1); - code_point |= (code_unit & continue_mask) << shift; + // clang-format off + out = ((code_unit & 0b0000'1111) << 12) + | ((static_cast(first[1]) & 0b0011'1111u) << 6) + | (static_cast(first[2]) & 0b0011'1111u); + // clang-format on + first += 3; + return utf8_errc::NoError; } - if (code_point > 0x10'FFFF) + if (code_unit < 0b1111'1000u) { - return {it, utf8_errc::InvalidCodePoint}; + if (4 > last - first) + { + out = end_of_file; + first = last; + return utf8_errc::UnexpectedEof; + } + + utf8_errc out_error; + if ((out_error = check_trailing(static_cast(first[1]))) != utf8_errc::NoError || + (out_error = check_trailing(static_cast(first[2]))) != utf8_errc::NoError || + (out_error = check_trailing(static_cast(first[3]))) != utf8_errc::NoError) + { + out = end_of_file; + first = last; + return out_error; + } + + // clang-format off + out = ((code_unit & 0b0000'0111) << 18) + | ((static_cast(first[1]) & 0b0011'1111u) << 12) + | ((static_cast(first[2]) & 0b0011'1111u) << 6) + | (static_cast(first[3]) & 0b0011'1111u); + // clang-format on + + if (out > 0x10'FFFF) + { + out = end_of_file; + first = last; + return utf8_errc::InvalidCodePoint; + } + + first += 4; + return utf8_errc::NoError; } - out = code_point; - return {it, utf8_errc::NoError}; + out = end_of_file; + first = last; + return utf8_errc::InvalidCodeUnit; } bool utf8_is_valid_string(const char* first, const char* last) noexcept { - utf8_errc err = utf8_errc::NoError; - for (auto dec = Utf8Decoder(first, last); dec != dec.end(); err = dec.next()) + utf8_errc err; + Utf8Decoder dec(first, last, err); + while (!dec.is_eof()) { + err = dec.next(); } + return err == utf8_errc::NoError; } - char32_t utf16_surrogates_to_code_point(char32_t leading, char32_t trailing) + char32_t utf16_surrogates_to_code_point(char32_t leading, char32_t trailing) noexcept { vcpkg::Checks::check_exit(VCPKG_LINE_INFO, utf16_is_leading_surrogate_code_point(leading)); vcpkg::Checks::check_exit(VCPKG_LINE_INFO, utf16_is_trailing_surrogate_code_point(trailing)); @@ -201,46 +212,42 @@ namespace vcpkg::Unicode } } - char const* Utf8Decoder::pointer_to_current() const noexcept + utf8_errc Utf8Decoder::next() noexcept { if (is_eof()) { - return last_; + // incremented Utf8Decoder at the end of the string + Checks::unreachable(VCPKG_LINE_INFO); } - auto count = utf8_encode_code_unit_count(current_); - return next_ - count; - } - - utf8_errc Utf8Decoder::next() - { - if (is_eof()) - { - vcpkg::Checks::msg_exit_with_message(VCPKG_LINE_INFO, msgIncrementedUtf8Decoder); - } - - if (next_ == last_) + const auto old_next = next_; + const auto last = last_; + if (old_next == last) { current_ = end_of_file; + pointer_to_current_ = last; return utf8_errc::NoError; } char32_t code_point; - auto new_next = utf8_decode_code_point(next_, last_, code_point); - if (new_next.second != utf8_errc::NoError) + auto err = utf8_decode_code_point(next_, last, code_point); + if (err != utf8_errc::NoError) { - *this = sentinel(); - return new_next.second; + current_ = end_of_file; + pointer_to_current_ = last; + return err; } if (utf16_is_trailing_surrogate_code_point(code_point) && utf16_is_leading_surrogate_code_point(current_)) { - *this = sentinel(); + current_ = end_of_file; + pointer_to_current_ = last; + next_ = last; return utf8_errc::PairedSurrogates; } - next_ = new_next.first; current_ = code_point; + pointer_to_current_ = old_next; return utf8_errc::NoError; } @@ -258,18 +265,9 @@ namespace vcpkg::Unicode Utf8Decoder& Utf8Decoder::operator=(sentinel) noexcept { - next_ = last_; current_ = end_of_file; + pointer_to_current_ = last_; + next_ = last_; return *this; } - - bool operator==(const Utf8Decoder& lhs, const Utf8Decoder& rhs) noexcept - { - if (lhs.last_ != rhs.last_) - { - Checks::msg_exit_with_message(VCPKG_LINE_INFO, msgComparingUtf8Decoders); - } - - return lhs.next_ == rhs.next_; - } } diff --git a/src/vcpkg/binarycaching.cpp b/src/vcpkg/binarycaching.cpp index c37e546183..f62d797cf8 100644 --- a/src/vcpkg/binarycaching.cpp +++ b/src/vcpkg/binarycaching.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -344,7 +345,7 @@ namespace auto archive_path = m_dir / files_archive_subpath(abi_tag); if (m_fs.exists(archive_path, IgnoreErrors{})) { - auto to_remove = actions[i]->build_options.purge_decompress_failure == PurgeDecompressFailure::YES + auto to_remove = actions[i]->build_options.purge_decompress_failure == PurgeDecompressFailure::Yes ? RemoveWhen::on_fail : RemoveWhen::nothing; out_zip_paths[i].emplace(std::move(archive_path), to_remove); @@ -519,7 +520,7 @@ namespace private: Command subcommand(StringLiteral sub) const { - Command cmd = m_cmd; + auto cmd = m_cmd; cmd.string_arg(sub).string_arg("-ForceEnglishOutput").string_arg("-Verbosity").string_arg("detailed"); if (!m_interactive) cmd.string_arg("-NonInteractive"); return cmd; @@ -527,7 +528,7 @@ namespace Command install_cmd(StringView packages_config, const Path& out_dir, const NuGetSource& src) const { - Command cmd = subcommand("install"); + auto cmd = subcommand("install"); cmd.string_arg(packages_config) .string_arg("-OutputDirectory") .string_arg(out_dir) @@ -559,11 +560,11 @@ namespace .string_arg(src.value); } - ExpectedL run_nuget_commandline(const Command& cmdline, MessageSink& msg_sink) const + ExpectedL run_nuget_commandline(const Command& cmd, MessageSink& msg_sink) const { if (m_interactive) { - return cmd_execute(cmdline).then([](int exit_code) -> ExpectedL { + return cmd_execute(cmd).then([](int exit_code) -> ExpectedL { if (exit_code == 0) { return {Unit{}}; @@ -573,52 +574,46 @@ namespace }); } - return cmd_execute_and_capture_output(cmdline).then([&](ExitCodeAndOutput&& res) -> ExpectedL { - if (Debug::g_debugging) - { - msg_sink.print(Color::error, res.output); - } - - if (res.output.find("Authentication may require manual action.") != std::string::npos) - { - msg_sink.println(Color::warning, msgAuthenticationMayRequireManualAction, msg::vendor = "Nuget"); - } - - if (res.exit_code == 0) - { - return {Unit{}}; - } - - if (res.output.find("Response status code does not indicate success: 401 (Unauthorized)") != - std::string::npos) - { - msg_sink.println(Color::warning, - msgFailedVendorAuthentication, - msg::vendor = "NuGet", - msg::url = docs::binarycaching_url); - } - else if (res.output.find("for example \"-ApiKey AzureDevOps\"") != std::string::npos) - { - auto real_cmdline = cmdline; - real_cmdline.string_arg("-ApiKey").string_arg("AzureDevOps"); - return cmd_execute_and_capture_output(real_cmdline) - .then([&](ExitCodeAndOutput&& res) -> ExpectedL { - if (Debug::g_debugging) - { - msg_sink.print(Color::error, res.output); - } + RedirectedProcessLaunchSettings show_in_debug_settings; + show_in_debug_settings.echo_in_debug = EchoInDebug::Show; + return cmd_execute_and_capture_output(cmd, show_in_debug_settings) + .then([&](ExitCodeAndOutput&& res) -> ExpectedL { + if (res.output.find("Authentication may require manual action.") != std::string::npos) + { + msg_sink.println( + Color::warning, msgAuthenticationMayRequireManualAction, msg::vendor = "Nuget"); + } - if (res.exit_code == 0) - { - return {Unit{}}; - } + if (res.exit_code == 0) + { + return {Unit{}}; + } - return LocalizedString::from_raw(std::move(res).output); - }); - } + if (res.output.find("Response status code does not indicate success: 401 (Unauthorized)") != + std::string::npos) + { + msg_sink.println(Color::warning, + msgFailedVendorAuthentication, + msg::vendor = "NuGet", + msg::url = docs::binarycaching_url); + } + else if (res.output.find("for example \"-ApiKey AzureDevOps\"") != std::string::npos) + { + auto real_cmd = cmd; + real_cmd.string_arg("-ApiKey").string_arg("AzureDevOps"); + return cmd_execute_and_capture_output(real_cmd, show_in_debug_settings) + .then([&](ExitCodeAndOutput&& res) -> ExpectedL { + if (res.exit_code == 0) + { + return {Unit{}}; + } + + return LocalizedString::from_raw(std::move(res).output); + }); + } - return LocalizedString::from_raw(std::move(res).output); - }); + return LocalizedString::from_raw(std::move(res).output); + }); } Command m_cmd; @@ -1081,27 +1076,30 @@ namespace return msg::format(msgRestoredPackagesFromGCS, msg::count = count, msg::elapsed = ElapsedTime(elapsed)); } - Command command() const { return m_tool; } - ExpectedL stat(StringView url) const override { - const auto cmd = command().string_arg("-q").string_arg("stat").string_arg(url); - return flatten(cmd_execute_and_capture_output(cmd), Tools::GSUTIL); + return flatten( + cmd_execute_and_capture_output(Command{m_tool}.string_arg("-q").string_arg("stat").string_arg(url)), + Tools::GSUTIL); } ExpectedL download_file(StringView object, const Path& archive) const override { - const auto cmd = command().string_arg("-q").string_arg("cp").string_arg(object).string_arg(archive); - return flatten(cmd_execute_and_capture_output(cmd), Tools::GSUTIL); + return flatten( + cmd_execute_and_capture_output( + Command{m_tool}.string_arg("-q").string_arg("cp").string_arg(object).string_arg(archive)), + Tools::GSUTIL); } ExpectedL upload_file(StringView object, const Path& archive) const override { - const auto cmd = command().string_arg("-q").string_arg("cp").string_arg(archive).string_arg(object); - return flatten(cmd_execute_and_capture_output(cmd), Tools::GSUTIL); + return flatten( + cmd_execute_and_capture_output( + Command{m_tool}.string_arg("-q").string_arg("cp").string_arg(archive).string_arg(object)), + Tools::GSUTIL); } - Command m_tool; + Path m_tool; }; struct AwsStorageTool : IObjectStorageTool @@ -1117,11 +1115,9 @@ namespace return msg::format(msgRestoredPackagesFromAWS, msg::count = count, msg::elapsed = ElapsedTime(elapsed)); } - Command command() const { return m_tool; } - ExpectedL stat(StringView url) const override { - auto cmd = command().string_arg("s3").string_arg("ls").string_arg(url); + auto cmd = Command{m_tool}.string_arg("s3").string_arg("ls").string_arg(url); if (m_no_sign_request) { cmd.string_arg("--no-sign-request"); @@ -1135,7 +1131,7 @@ namespace auto r = stat(object); if (!r) return r; - auto cmd = command().string_arg("s3").string_arg("cp").string_arg(object).string_arg(archive); + auto cmd = Command{m_tool}.string_arg("s3").string_arg("cp").string_arg(object).string_arg(archive); if (m_no_sign_request) { cmd.string_arg("--no-sign-request"); @@ -1146,7 +1142,7 @@ namespace ExpectedL upload_file(StringView object, const Path& archive) const override { - auto cmd = command().string_arg("s3").string_arg("cp").string_arg(archive).string_arg(object); + auto cmd = Command{m_tool}.string_arg("s3").string_arg("cp").string_arg(archive).string_arg(object); if (m_no_sign_request) { cmd.string_arg("--no-sign-request"); @@ -1154,7 +1150,7 @@ namespace return flatten(cmd_execute_and_capture_output(cmd), Tools::AWSCLI); } - Command m_tool; + Path m_tool; bool m_no_sign_request; }; @@ -1168,27 +1164,27 @@ namespace return msg::format(msgRestoredPackagesFromCOS, msg::count = count, msg::elapsed = ElapsedTime(elapsed)); } - Command command() const { return m_tool; } - ExpectedL stat(StringView url) const override { - const auto cmd = command().string_arg("ls").string_arg(url); - return flatten(cmd_execute_and_capture_output(cmd), Tools::COSCLI); + return flatten(cmd_execute_and_capture_output(Command{m_tool}.string_arg("ls").string_arg(url)), + Tools::COSCLI); } ExpectedL download_file(StringView object, const Path& archive) const override { - const auto cmd = command().string_arg("cp").string_arg(object).string_arg(archive); - return flatten(cmd_execute_and_capture_output(cmd), Tools::COSCLI); + return flatten( + cmd_execute_and_capture_output(Command{m_tool}.string_arg("cp").string_arg(object).string_arg(archive)), + Tools::COSCLI); } ExpectedL upload_file(StringView object, const Path& archive) const override { - const auto cmd = command().string_arg("cp").string_arg(archive).string_arg(object); - return flatten(cmd_execute_and_capture_output(cmd), Tools::COSCLI); + return flatten( + cmd_execute_and_capture_output(Command{m_tool}.string_arg("cp").string_arg(archive).string_arg(object)), + Tools::COSCLI); } - Command m_tool; + Path m_tool; }; ExpectedL default_cache_path_impl() @@ -2198,7 +2194,7 @@ namespace vcpkg msgStoredBinariesToDestinations, msg::count = num_destinations, msg::elapsed = timer.elapsed()); } } - if (action.build_options.clean_packages == CleanPackages::YES) + if (action.build_options.clean_packages == CleanPackages::Yes) { m_fs.remove_all(action.package_dir.value_or_exit(VCPKG_LINE_INFO), VCPKG_LINE_INFO); } @@ -2356,14 +2352,14 @@ ExpectedL vcpkg::parse_binary_provider_configs(const st default_parser.parse(); if (auto err = default_parser.get_error()) { - return LocalizedString::from_raw(err->message); + return *err; } BinaryConfigParser env_parser(env_string, "VCPKG_BINARY_SOURCES", &s); env_parser.parse(); if (auto err = env_parser.get_error()) { - return LocalizedString::from_raw(err->to_string()); + return *err; } for (auto&& arg : args) @@ -2372,7 +2368,7 @@ ExpectedL vcpkg::parse_binary_provider_configs(const st arg_parser.parse(); if (auto err = arg_parser.get_error()) { - return LocalizedString::from_raw(err->to_string()); + return *err; } } diff --git a/src/vcpkg/binaryparagraph.cpp b/src/vcpkg/binaryparagraph.cpp index a6211ca2d0..5ac0d7a5b0 100644 --- a/src/vcpkg/binaryparagraph.cpp +++ b/src/vcpkg/binaryparagraph.cpp @@ -27,8 +27,6 @@ namespace vcpkg static constexpr StringLiteral DEFAULT_FEATURES = "Default-Features"; } - BinaryParagraph::BinaryParagraph() = default; - BinaryParagraph::BinaryParagraph(StringView origin, Paragraph&& fields) { ParagraphParser parser(origin, std::move(fields)); diff --git a/src/vcpkg/ci-baseline.cpp b/src/vcpkg/ci-baseline.cpp index f4df2b1156..a6dc1453a7 100644 --- a/src/vcpkg/ci-baseline.cpp +++ b/src/vcpkg/ci-baseline.cpp @@ -208,9 +208,9 @@ namespace vcpkg { switch (result) { - case BuildResult::BUILD_FAILED: - case BuildResult::POST_BUILD_CHECKS_FAILED: - case BuildResult::FILE_CONFLICTS: + case BuildResult::BuildFailed: + case BuildResult::PostBuildChecksFailed: + case BuildResult::FileConflicts: if (!cidata.expected_failures.contains(spec)) { if (is_independent) @@ -228,13 +228,13 @@ namespace vcpkg } } break; - case BuildResult::SUCCEEDED: + case BuildResult::Succeeded: if (!allow_unexpected_passing && cidata.expected_failures.contains(spec)) { return msg::format(msgCiBaselineUnexpectedPass, msg::spec = spec, msg::path = cifile); } break; - case BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES: + case BuildResult::CascadedDueToMissingDependencies: if (cidata.required_success.contains(spec)) { return msg::format(msgCiBaselineDisallowedCascade, msg::spec = spec, msg::path = cifile); diff --git a/src/vcpkg/cmakevars.cpp b/src/vcpkg/cmakevars.cpp index 9b19154959..e023a4cf61 100644 --- a/src/vcpkg/cmakevars.cpp +++ b/src/vcpkg/cmakevars.cpp @@ -257,22 +257,19 @@ endfunction() static constexpr StringLiteral BLOCK_START_GUID = "c35112b6-d1ba-415b-aa5d-81de856ef8eb"; static constexpr StringLiteral BLOCK_END_GUID = "e1e74b5c-18cb-4474-a6bd-5c1c8bc81f3f"; - const auto cmd_launch_cmake = vcpkg::make_cmake_cmd(paths, script_path, {}); + auto cmd = vcpkg::make_cmake_cmd(paths, script_path, {}); std::vector lines; - auto const exit_code = cmd_execute_and_stream_lines( - cmd_launch_cmake, - [&](StringView sv) { lines.emplace_back(sv.begin(), sv.end()); }, - default_working_directory) - .value_or_exit(VCPKG_LINE_INFO); + auto const exit_code = cmd_execute_and_stream_lines(cmd, [&](StringView sv) { + lines.emplace_back(sv.begin(), sv.end()); + }).value_or_exit(VCPKG_LINE_INFO); if (exit_code != 0) { - Checks::msg_exit_with_message( - VCPKG_LINE_INFO, - msg::format(msgCommandFailed, msg::command_line = cmd_launch_cmake.command_line()) - .append_raw('\n') - .append_raw(Strings::join(", ", lines))); + Checks::msg_exit_with_message(VCPKG_LINE_INFO, + msg::format(msgCommandFailed, msg::command_line = cmd.command_line()) + .append_raw('\n') + .append_raw(Strings::join(", ", lines))); } const auto end = lines.cend(); diff --git a/src/vcpkg/commands.build.cpp b/src/vcpkg/commands.build.cpp index 4532230711..eb68868ff2 100644 --- a/src/vcpkg/commands.build.cpp +++ b/src/vcpkg/commands.build.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -153,15 +154,15 @@ namespace vcpkg } action->build_options = default_build_package_options; - action->build_options.editable = Editable::YES; - action->build_options.clean_buildtrees = CleanBuildtrees::NO; - action->build_options.clean_packages = CleanPackages::NO; + action->build_options.editable = Editable::Yes; + action->build_options.clean_buildtrees = CleanBuildtrees::No; + action->build_options.clean_packages = CleanPackages::No; auto binary_cache = BinaryCache::make(args, paths, out_sink).value_or_exit(VCPKG_LINE_INFO); const ElapsedTimer build_timer; const auto result = build_package(args, paths, *action, build_logs_recorder, status_db); msg::print(msgElapsedForPackage, msg::spec = spec, msg::elapsed = build_timer); - if (result.code == BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES) + if (result.code == BuildResult::CascadedDueToMissingDependencies) { LocalizedString errorMsg = msg::format_error(msgBuildDependenciesMissing); for (const auto& p : result.unmet_dependencies) @@ -172,9 +173,9 @@ namespace vcpkg Checks::msg_exit_with_message(VCPKG_LINE_INFO, errorMsg); } - Checks::check_exit(VCPKG_LINE_INFO, result.code != BuildResult::EXCLUDED); + Checks::check_exit(VCPKG_LINE_INFO, result.code != BuildResult::Excluded); - if (result.code != BuildResult::SUCCEEDED) + if (result.code != BuildResult::Succeeded) { LocalizedString warnings; for (auto&& msg : action->build_failure_messages) @@ -271,8 +272,8 @@ namespace vcpkg { switch (tool) { - case DownloadTool::BUILT_IN: return NAME_BUILTIN_DOWNLOAD; - case DownloadTool::ARIA2: return NAME_ARIA2_DOWNLOAD; + case DownloadTool::Builtin: return NAME_BUILTIN_DOWNLOAD; + case DownloadTool::Aria2: return NAME_ARIA2_DOWNLOAD; default: Checks::unreachable(VCPKG_LINE_INFO); } } @@ -281,8 +282,8 @@ namespace vcpkg Optional to_linkage_type(StringView str) { - if (str == "dynamic") return LinkageType::DYNAMIC; - if (str == "static") return LinkageType::STATIC; + if (str == "dynamic") return LinkageType::Dynamic; + if (str == "static") return LinkageType::Static; return nullopt; } @@ -679,9 +680,9 @@ namespace vcpkg }; get_generic_cmake_build_args(paths, triplet, toolset, cmake_args); - auto command = vcpkg::make_cmake_cmd(paths, paths.ports_cmake, std::move(cmake_args)); - - const auto& env = paths.get_action_env(pre_build_info, toolset); + auto cmd = vcpkg::make_cmake_cmd(paths, paths.ports_cmake, std::move(cmake_args)); + RedirectedProcessLaunchSettings settings; + settings.environment.emplace(paths.get_action_env(pre_build_info, toolset)); auto& fs = paths.get_filesystem(); fs.create_directory(buildpath, VCPKG_LINE_INFO); auto stdoutlog = buildpath / ("stdout-" + triplet.canonical_name() + ".log"); @@ -691,35 +692,31 @@ namespace vcpkg ExpectedL rc = LocalizedString(); { const auto out_file = fs.open_for_write(stdoutlog, VCPKG_LINE_INFO); - rc = cmd_execute_and_stream_lines( - command, - [&](StringView s) { - static constexpr StringLiteral s_hash_marker = "#COMPILER_HASH#"; - if (Strings::starts_with(s, s_hash_marker)) - { - compiler_info.hash = s.substr(s_hash_marker.size()).to_string(); - } - static constexpr StringLiteral s_version_marker = "#COMPILER_CXX_VERSION#"; - if (Strings::starts_with(s, s_version_marker)) - { - compiler_info.version = s.substr(s_version_marker.size()).to_string(); - } - static constexpr StringLiteral s_id_marker = "#COMPILER_CXX_ID#"; - if (Strings::starts_with(s, s_id_marker)) - { - compiler_info.id = s.substr(s_id_marker.size()).to_string(); - } - Debug::println(s); - const auto old_buf_size = buf.size(); - Strings::append(buf, s, '\n'); - const auto write_size = buf.size() - old_buf_size; - Checks::msg_check_exit(VCPKG_LINE_INFO, - out_file.write(buf.c_str() + old_buf_size, 1, write_size) == write_size, - msgErrorWhileWriting, - msg::path = stdoutlog); - }, - default_working_directory, - env); + rc = cmd_execute_and_stream_lines(cmd, settings, [&](StringView s) { + static constexpr StringLiteral s_hash_marker = "#COMPILER_HASH#"; + if (Strings::starts_with(s, s_hash_marker)) + { + compiler_info.hash = s.substr(s_hash_marker.size()).to_string(); + } + static constexpr StringLiteral s_version_marker = "#COMPILER_CXX_VERSION#"; + if (Strings::starts_with(s, s_version_marker)) + { + compiler_info.version = s.substr(s_version_marker.size()).to_string(); + } + static constexpr StringLiteral s_id_marker = "#COMPILER_CXX_ID#"; + if (Strings::starts_with(s, s_id_marker)) + { + compiler_info.id = s.substr(s_id_marker.size()).to_string(); + } + Debug::println(s); + const auto old_buf_size = buf.size(); + Strings::append(buf, s, '\n'); + const auto write_size = buf.size() - old_buf_size; + Checks::msg_check_exit(VCPKG_LINE_INFO, + out_file.write(buf.c_str() + old_buf_size, 1, write_size) == write_size, + msgErrorWhileWriting, + msg::path = stdoutlog); + }); } // close out_file if (compiler_info.hash.empty() || !succeeded(rc)) @@ -766,7 +763,7 @@ namespace vcpkg {"Z_VCPKG_CHAINLOAD_TOOLCHAIN_FILE", action.pre_build_info(VCPKG_LINE_INFO).toolchain_file()}, }; - if (action.build_options.download_tool == DownloadTool::ARIA2) + if (action.build_options.download_tool == DownloadTool::Aria2) { variables.emplace_back("ARIA2", paths.get_tool_exe(Tools::ARIA2, out_sink)); } @@ -794,7 +791,7 @@ namespace vcpkg variables.emplace_back(cmake_arg); } - if (action.build_options.backcompat_features == BackcompatFeatures::PROHIBIT) + if (action.build_options.backcompat_features == BackcompatFeatures::Prohibit) { variables.emplace_back("_VCPKG_PROHIBIT_BACKCOMPAT_FEATURES", "1"); } @@ -950,11 +947,14 @@ namespace vcpkg msg::println(msgInstallingFromLocation, msg::path = scfl.port_directory()); } + const auto& abi_info = action.abi_info.value_or_exit(VCPKG_LINE_INFO); + const ElapsedTimer timer; - auto command = vcpkg::make_cmake_cmd(paths, paths.ports_cmake, get_cmake_build_args(args, paths, action)); + auto cmd = vcpkg::make_cmake_cmd(paths, paths.ports_cmake, get_cmake_build_args(args, paths, action)); - const auto& abi_info = action.abi_info.value_or_exit(VCPKG_LINE_INFO); - auto env = paths.get_action_env(*abi_info.pre_build_info, abi_info.toolset.value_or_exit(VCPKG_LINE_INFO)); + RedirectedProcessLaunchSettings settings; + auto& env = settings.environment.emplace( + paths.get_action_env(*abi_info.pre_build_info, abi_info.toolset.value_or_exit(VCPKG_LINE_INFO))); auto buildpath = paths.build_dir(action.spec); fs.create_directory(buildpath, VCPKG_LINE_INFO); @@ -963,17 +963,13 @@ namespace vcpkg ExpectedL return_code = LocalizedString(); { auto out_file = fs.open_for_write(stdoutlog, VCPKG_LINE_INFO); - return_code = cmd_execute_and_stream_data( - command, - [&](StringView sv) { - msg::write_unlocalized_text(Color::none, sv); - Checks::msg_check_exit(VCPKG_LINE_INFO, - out_file.write(sv.data(), 1, sv.size()) == sv.size(), - msgErrorWhileWriting, - msg::path = stdoutlog); - }, - default_working_directory, - env); + return_code = cmd_execute_and_stream_data(cmd, settings, [&](StringView sv) { + msg::write_unlocalized_text(Color::none, sv); + Checks::msg_check_exit(VCPKG_LINE_INFO, + out_file.write(sv.data(), 1, sv.size()) == sv.size(), + msgErrorWhileWriting, + msg::path = stdoutlog); + }); } // close out_file const auto buildtimeus = timer.microseconds(); @@ -983,11 +979,11 @@ namespace vcpkg if (build_failed) { // With the exception of empty or helper ports, builds in "Download Mode" result in failure. - if (action.build_options.only_downloads == OnlyDownloads::YES) + if (action.build_options.only_downloads == OnlyDownloads::Yes) { // TODO: Capture executed command output and evaluate whether the failure was intended. // If an unintended error occurs then return a BuildResult::DOWNLOAD_FAILURE status. - return ExtendedBuildResult{BuildResult::DOWNLOADED}; + return ExtendedBuildResult{BuildResult::Downloaded}; } } @@ -1003,7 +999,7 @@ namespace vcpkg get_global_metrics_collector().track_submission(std::move(metrics)); if (!all_dependencies_satisfied) { - return ExtendedBuildResult{BuildResult::DOWNLOADED}; + return ExtendedBuildResult{BuildResult::Downloaded}; } if (build_failed) @@ -1015,7 +1011,7 @@ namespace vcpkg error_logs = fs.read_lines(logs).value_or_exit(VCPKG_LINE_INFO); Util::erase_remove_if(error_logs, [](const auto& line) { return line.empty(); }); } - return ExtendedBuildResult{BuildResult::BUILD_FAILED, stdoutlog, std::move(error_logs)}; + return ExtendedBuildResult{BuildResult::BuildFailed, stdoutlog, std::move(error_logs)}; } const BuildInfo build_info = read_build_info(fs, paths.build_info_file_path(action.spec)); @@ -1026,16 +1022,16 @@ namespace vcpkg error_count = perform_post_build_lint_checks( action.spec, paths, pre_build_info, build_info, scfl.port_directory(), combo_sink); }; - if (error_count != 0 && action.build_options.backcompat_features == BackcompatFeatures::PROHIBIT) + if (error_count != 0 && action.build_options.backcompat_features == BackcompatFeatures::Prohibit) { - return ExtendedBuildResult{BuildResult::POST_BUILD_CHECKS_FAILED}; + return ExtendedBuildResult{BuildResult::PostBuildChecksFailed}; } std::unique_ptr bcf = create_binary_control_file(action, build_info); write_sbom(paths, action, abi_info.heuristic_resources); write_binary_control_file(paths.get_filesystem(), action.package_dir.value_or_exit(VCPKG_LINE_INFO), *bcf); - return {BuildResult::SUCCEEDED, std::move(bcf)}; + return {BuildResult::Succeeded, std::move(bcf)}; } static ExtendedBuildResult do_build_package_and_clean_buildtrees(const VcpkgCmdArguments& args, @@ -1045,7 +1041,7 @@ namespace vcpkg { auto result = do_build_package(args, paths, action, all_dependencies_satisfied); - if (action.build_options.clean_buildtrees == CleanBuildtrees::YES) + if (action.build_options.clean_buildtrees == CleanBuildtrees::Yes) { auto& fs = paths.get_filesystem(); // Will keep the logs, which are regular files @@ -1128,12 +1124,12 @@ namespace vcpkg abi_info.pre_build_info = std::move(proto_pre_build_info); abi_info.toolset.emplace(toolset); - if (action.build_options.use_head_version == UseHeadVersion::YES) + if (action.build_options.use_head_version == UseHeadVersion::Yes) { Debug::print("Binary caching for package ", action.spec, " is disabled due to --head\n"); return; } - if (action.build_options.editable == Editable::YES) + if (action.build_options.editable == Editable::Yes) { Debug::print("Binary caching for package ", action.spec, " is disabled due to --editable\n"); return; @@ -1353,10 +1349,10 @@ namespace vcpkg const bool all_dependencies_satisfied = missing_fspecs.empty(); if (!all_dependencies_satisfied && !Util::Enum::to_bool(action.build_options.only_downloads)) { - return {BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES, std::move(missing_fspecs)}; + return {BuildResult::CascadedDueToMissingDependencies, std::move(missing_fspecs)}; } - if (action.build_options.only_downloads == OnlyDownloads::NO) + if (action.build_options.only_downloads == OnlyDownloads::No) { for (auto&& pspec : action.package_dependencies) { @@ -1389,15 +1385,15 @@ namespace vcpkg { switch (build_result) { - case BuildResult::SUCCEEDED: ++succeeded; return; - case BuildResult::BUILD_FAILED: ++build_failed; return; - case BuildResult::POST_BUILD_CHECKS_FAILED: ++post_build_checks_failed; return; - case BuildResult::FILE_CONFLICTS: ++file_conflicts; return; - case BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES: ++cascaded_due_to_missing_dependencies; return; - case BuildResult::EXCLUDED: ++excluded; return; - case BuildResult::CACHE_MISSING: ++cache_missing; return; - case BuildResult::DOWNLOADED: ++downloaded; return; - case BuildResult::REMOVED: ++removed; return; + case BuildResult::Succeeded: ++succeeded; return; + case BuildResult::BuildFailed: ++build_failed; return; + case BuildResult::PostBuildChecksFailed: ++post_build_checks_failed; return; + case BuildResult::FileConflicts: ++file_conflicts; return; + case BuildResult::CascadedDueToMissingDependencies: ++cascaded_due_to_missing_dependencies; return; + case BuildResult::Excluded: ++excluded; return; + case BuildResult::CacheMissing: ++cache_missing; return; + case BuildResult::Downloaded: ++downloaded; return; + case BuildResult::Removed: ++removed; return; default: Checks::unreachable(VCPKG_LINE_INFO); } } @@ -1431,15 +1427,15 @@ namespace vcpkg { switch (build_result) { - case BuildResult::SUCCEEDED: return "SUCCEEDED"; - case BuildResult::BUILD_FAILED: return "BUILD_FAILED"; - case BuildResult::POST_BUILD_CHECKS_FAILED: return "POST_BUILD_CHECKS_FAILED"; - case BuildResult::FILE_CONFLICTS: return "FILE_CONFLICTS"; - case BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES: return "CASCADED_DUE_TO_MISSING_DEPENDENCIES"; - case BuildResult::EXCLUDED: return "EXCLUDED"; - case BuildResult::CACHE_MISSING: return "CACHE_MISSING"; - case BuildResult::DOWNLOADED: return "DOWNLOADED"; - case BuildResult::REMOVED: return "REMOVED"; + case BuildResult::Succeeded: return "SUCCEEDED"; + case BuildResult::BuildFailed: return "BUILD_FAILED"; + case BuildResult::PostBuildChecksFailed: return "POST_BUILD_CHECKS_FAILED"; + case BuildResult::FileConflicts: return "FILE_CONFLICTS"; + case BuildResult::CascadedDueToMissingDependencies: return "CASCADED_DUE_TO_MISSING_DEPENDENCIES"; + case BuildResult::Excluded: return "EXCLUDED"; + case BuildResult::CacheMissing: return "CACHE_MISSING"; + case BuildResult::Downloaded: return "DOWNLOADED"; + case BuildResult::Removed: return "REMOVED"; default: Checks::unreachable(VCPKG_LINE_INFO); } } @@ -1448,16 +1444,16 @@ namespace vcpkg { switch (build_result) { - case BuildResult::SUCCEEDED: return msg::format(msgBuildResultSucceeded); - case BuildResult::BUILD_FAILED: return msg::format(msgBuildResultBuildFailed); - case BuildResult::POST_BUILD_CHECKS_FAILED: return msg::format(msgBuildResultPostBuildChecksFailed); - case BuildResult::FILE_CONFLICTS: return msg::format(msgBuildResultFileConflicts); - case BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES: + case BuildResult::Succeeded: return msg::format(msgBuildResultSucceeded); + case BuildResult::BuildFailed: return msg::format(msgBuildResultBuildFailed); + case BuildResult::PostBuildChecksFailed: return msg::format(msgBuildResultPostBuildChecksFailed); + case BuildResult::FileConflicts: return msg::format(msgBuildResultFileConflicts); + case BuildResult::CascadedDueToMissingDependencies: return msg::format(msgBuildResultCascadeDueToMissingDependencies); - case BuildResult::EXCLUDED: return msg::format(msgBuildResultExcluded); - case BuildResult::CACHE_MISSING: return msg::format(msgBuildResultCacheMissing); - case BuildResult::DOWNLOADED: return msg::format(msgBuildResultDownloaded); - case BuildResult::REMOVED: return msg::format(msgBuildResultRemoved); + case BuildResult::Excluded: return msg::format(msgBuildResultExcluded); + case BuildResult::CacheMissing: return msg::format(msgBuildResultCacheMissing); + case BuildResult::Downloaded: return msg::format(msgBuildResultDownloaded); + case BuildResult::Removed: return msg::format(msgBuildResultRemoved); default: Checks::unreachable(VCPKG_LINE_INFO); } } @@ -1468,7 +1464,7 @@ namespace vcpkg msg::spec = spec, msg::build_result = to_string_locale_invariant(build_result.code)); - if (build_result.code == BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES) + if (build_result.code == BuildResult::CascadedDueToMissingDependencies) { res.append_raw('\n').append_indent().append(msgBuildingPackageFailedDueToMissingDeps); @@ -1483,9 +1479,9 @@ namespace vcpkg void append_log(const Path& path, const std::string& log, size_t max_log_length, std::string& out) { - StringLiteral details_start = "
{}\n\n```\n"; - StringLiteral skipped_msg = "\n...\nSkipped {} lines\n..."; - StringLiteral details_end = "\n```\n
\n\n"; + static constexpr StringLiteral details_start = "
{}\n\n```\n"; + static constexpr StringLiteral skipped_msg = "\n...\nSkipped {} lines\n..."; + static constexpr StringLiteral details_end = "\n```\n
\n\n"; const size_t context_size = path.native().size() + details_start.size() + details_end.size() + skipped_msg.size() + 6 /* digits for skipped count */; const size_t minimum_log_size = std::min(size_t{100}, log.size()); @@ -1833,9 +1829,9 @@ namespace vcpkg if (variable_value.empty()) build_type = nullopt; else if (Strings::case_insensitive_ascii_equals(variable_value, "debug")) - build_type = ConfigurationType::DEBUG; + build_type = ConfigurationType::Debug; else if (Strings::case_insensitive_ascii_equals(variable_value, "release")) - build_type = ConfigurationType::RELEASE; + build_type = ConfigurationType::Release; else Checks::msg_exit_with_message( VCPKG_LINE_INFO, msgUnknownSettingForBuildType, msg::option = variable_value); diff --git a/src/vcpkg/commands.ci.cpp b/src/vcpkg/commands.ci.cpp index 90199ea1f8..ed152c156d 100644 --- a/src/vcpkg/commands.ci.cpp +++ b/src/vcpkg/commands.ci.cpp @@ -38,7 +38,7 @@ namespace const PackageSpec& spec, BuildResult result) const override { - if (result == BuildResult::SUCCEEDED) + if (result == BuildResult::Succeeded) { return; } @@ -187,20 +187,20 @@ namespace if (is_excluded(p->spec)) { ret->action_state_string.emplace_back("skip"); - ret->known.emplace(p->spec, BuildResult::EXCLUDED); + ret->known.emplace(p->spec, BuildResult::Excluded); will_fail.emplace(p->spec); } else if (Util::any_of(p->package_dependencies, [&](const PackageSpec& spec) { return Util::Sets::contains(will_fail, spec); })) { ret->action_state_string.emplace_back("cascade"); - ret->known.emplace(p->spec, BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES); + ret->known.emplace(p->spec, BuildResult::CascadedDueToMissingDependencies); will_fail.emplace(p->spec); } else if (precheck_results[action_idx] == CacheAvailability::available) { ret->action_state_string.emplace_back("pass"); - ret->known.emplace(p->spec, BuildResult::SUCCEEDED); + ret->known.emplace(p->spec, BuildResult::Succeeded); } else { @@ -232,7 +232,7 @@ namespace if (Util::Sets::contains(to_keep, it->spec)) { - if (it_known != known.end() && it_known->second == BuildResult::EXCLUDED) + if (it_known != known.end() && it_known->second == BuildResult::Excluded) { it->plan_type = InstallPlanType::EXCLUDED; } @@ -249,7 +249,7 @@ namespace }); } - void parse_exclusions(const std::map>& settings, + void parse_exclusions(const std::map>& settings, StringLiteral opt, Triplet triplet, ExclusionsMap& exclusions_map) @@ -425,8 +425,8 @@ namespace vcpkg { bool supp = supported_for_triplet(var_provider, provider, spec.package_spec); split_specs->known.emplace(spec.package_spec, - supp ? BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES - : BuildResult::EXCLUDED); + supp ? BuildResult::CascadedDueToMissingDependencies + : BuildResult::Excluded); if (cidata.expected_failures.contains(spec.package_spec)) { diff --git a/src/vcpkg/commands.cpp b/src/vcpkg/commands.cpp index 5187b62bef..d70ab16afb 100644 --- a/src/vcpkg/commands.cpp +++ b/src/vcpkg/commands.cpp @@ -53,6 +53,7 @@ #include #include #include +#include namespace vcpkg { @@ -156,7 +157,7 @@ namespace vcpkg } } - void print_zero_args_usage() + std::string get_zero_args_usage() { HelpTableFormatter table; table.example(msg::format(msgVcpkgUsage)); @@ -212,7 +213,7 @@ namespace vcpkg table.example(msg::format(msgHelpExampleCommand)); table.m_str.push_back('\n'); - msg::write_unlocalized_text_to_stderr(Color::none, table.m_str); + return table.m_str; } void print_full_command_list() diff --git a/src/vcpkg/commands.create.cpp b/src/vcpkg/commands.create.cpp index c7c317bc80..b7f88ef30d 100644 --- a/src/vcpkg/commands.create.cpp +++ b/src/vcpkg/commands.create.cpp @@ -65,8 +65,10 @@ namespace vcpkg cmake_args.emplace_back("FILENAME", zip_file_name); } - auto cmd_launch_cmake = make_cmake_cmd(paths, paths.ports_cmake, std::move(cmake_args)); - return cmd_execute_clean(cmd_launch_cmake).value_or_exit(VCPKG_LINE_INFO); + ProcessLaunchSettings settings; + settings.environment = get_clean_environment(); + return cmd_execute(make_cmake_cmd(paths, paths.ports_cmake, std::move(cmake_args)), settings) + .value_or_exit(VCPKG_LINE_INFO); } void command_create_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths) diff --git a/src/vcpkg/commands.edit.cpp b/src/vcpkg/commands.edit.cpp index ce8cd1930f..27ab2d1947 100644 --- a/src/vcpkg/commands.edit.cpp +++ b/src/vcpkg/commands.edit.cpp @@ -230,15 +230,19 @@ namespace vcpkg candidate_paths.emplace_back("/usr/share/code/bin/code"); candidate_paths.emplace_back("/usr/bin/code"); - if (succeeded(cmd_execute(Command("command").string_arg("-v").string_arg("xdg-mime")))) + if (succeeded(cmd_execute({Command("command").string_arg("-v").string_arg("xdg-mime")}))) { - auto mime_qry = Command("xdg-mime").string_arg("query").string_arg("default").string_arg("text/plain"); - auto maybe_output = flatten_out(cmd_execute_and_capture_output(mime_qry), "xdg-mime"); + auto maybe_output = + flatten_out(cmd_execute_and_capture_output( + Command("xdg-mime").string_arg("query").string_arg("default").string_arg("text/plain")), + "xdg-mime"); const auto output = maybe_output.get(); if (output && !output->empty()) { - mime_qry = Command("command").string_arg("-v").string_arg(output->substr(0, output->find('.'))); - auto maybe_output2 = flatten_out(cmd_execute_and_capture_output(mime_qry), "xdg-mime"); + auto maybe_output2 = + flatten_out(cmd_execute_and_capture_output(Command("command").string_arg("-v").string_arg( + output->substr(0, output->find('.')))), + "xdg-mime"); const auto output2 = maybe_output2.get(); if (output2 && !output2->empty()) { @@ -263,18 +267,18 @@ namespace vcpkg const Path& env_editor = *it; const std::vector arguments = create_editor_arguments(paths, options, ports); const auto args_as_string = Strings::join(" ", arguments); - auto cmd_line = Command(env_editor).raw_arg(args_as_string).string_arg("-n"); + auto cmd = Command(env_editor).raw_arg(args_as_string).string_arg("-n"); #if defined(_WIN32) auto editor_exe = env_editor.filename(); if (editor_exe == "Code.exe" || editor_exe == "Code - Insiders.exe") { // note that we are invoking cmd silently but Code.exe is relaunched from there cmd_execute_background(Command("cmd").string_arg("/d").string_arg("/c").raw_arg( - Strings::concat('"', cmd_line.command_line(), R"( #include #include +#include #include #include @@ -176,8 +177,9 @@ namespace .string_arg(output_dir) .string_arg("-NoDefaultExcludes"); - return flatten(cmd_execute_and_capture_output(cmd, default_working_directory, get_clean_environment()), - Tools::NUGET) + RedirectedProcessLaunchSettings settings; + settings.environment = get_clean_environment(); + return flatten(cmd_execute_and_capture_output(cmd, settings), Tools::NUGET) .map([&](Unit) { return output_dir / (nuget_id + "." + nuget_version + ".nupkg"); }) .value_or_exit(VCPKG_LINE_INFO); } @@ -224,18 +226,19 @@ namespace const auto exported_archive_filename = fmt::format("{}.{}", exported_dir_filename, format.extension()); const auto exported_archive_path = output_dir / exported_archive_filename; - Command cmd; - cmd.string_arg(cmake_exe) - .string_arg("-E") - .string_arg("tar") - .string_arg("cf") - .string_arg(exported_archive_path) - .string_arg(Strings::concat("--format=", format.cmake_option())) - .string_arg("--") - .string_arg(raw_exported_dir); - - const int exit_code = - cmd_execute_clean(cmd, WorkingDirectory{raw_exported_dir.parent_path()}).value_or_exit(VCPKG_LINE_INFO); + auto cmd = Command{cmake_exe} + .string_arg("-E") + .string_arg("tar") + .string_arg("cf") + .string_arg(exported_archive_path) + .string_arg(Strings::concat("--format=", format.cmake_option())) + .string_arg("--") + .string_arg(raw_exported_dir); + + ProcessLaunchSettings settings; + settings.working_directory = raw_exported_dir.parent_path(); + settings.environment = get_clean_environment(); + const int exit_code = cmd_execute(cmd, settings).value_or_exit(VCPKG_LINE_INFO); Checks::msg_check_exit(VCPKG_LINE_INFO, exit_code == 0, msgCreationFailed, msg::path = exported_archive_path); return exported_archive_path; } diff --git a/src/vcpkg/commands.format-manifest.cpp b/src/vcpkg/commands.format-manifest.cpp index dff60d3535..cc0a65cae5 100644 --- a/src/vcpkg/commands.format-manifest.cpp +++ b/src/vcpkg/commands.format-manifest.cpp @@ -32,7 +32,7 @@ namespace auto parsed_json_opt = Json::parse(contents, manifest_path); if (!parsed_json_opt) { - msg::println(Color::error, LocalizedString::from_raw(parsed_json_opt.error()->to_string())); + msg::println(Color::error, parsed_json_opt.error()); return nullopt; } diff --git a/src/vcpkg/commands.help.cpp b/src/vcpkg/commands.help.cpp index 173e0bff68..743d13bc0d 100644 --- a/src/vcpkg/commands.help.cpp +++ b/src/vcpkg/commands.help.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -20,7 +21,7 @@ namespace void (*print)(const VcpkgPaths&); }; - void help_topics(const VcpkgPaths&); + LocalizedString help_topics(); void help_topic_versioning(const VcpkgPaths&) { @@ -70,12 +71,12 @@ namespace {"assetcaching", [](const VcpkgPaths&) { msg::println(format_help_topic_asset_caching()); }}, {"binarycaching", [](const VcpkgPaths&) { msg::println(format_help_topic_binary_caching()); }}, {"commands", [](const VcpkgPaths&) { print_full_command_list(); }}, - {"topics", help_topics}, + {"topics", [](const VcpkgPaths&) { msg::print(help_topics()); }}, {"triplet", [](const VcpkgPaths& paths) { help_topic_valid_triplet(paths.get_triplet_db()); }}, {"versioning", help_topic_versioning}, }; - void help_topics(const VcpkgPaths&) + LocalizedString help_topics() { std::vector all_topic_names; for (auto&& topic : topics) @@ -94,7 +95,7 @@ namespace result.append(msgAvailableHelpTopics); result.append_floating_list(1, all_topic_names); result.append_raw('\n'); - msg::print(result); + return result; } } // unnamed namespace @@ -116,9 +117,9 @@ namespace vcpkg void help_topic_valid_triplet(const TripletDatabase& database) { std::map> triplets_per_location; - vcpkg::Util::group_by(database.available_triplets, - &triplets_per_location, - [](const TripletFile& triplet_file) -> StringView { return triplet_file.location; }); + Util::group_by(database.available_triplets, + &triplets_per_location, + [](const TripletFile& triplet_file) -> StringView { return triplet_file.location; }); LocalizedString result; result.append(msgBuiltInTriplets).append_raw('\n'); @@ -155,7 +156,7 @@ namespace vcpkg if (parsed.command_arguments.empty()) { - print_zero_args_usage(); + msg::write_unlocalized_text_to_stdout(Color::none, get_zero_args_usage()); Checks::exit_success(VCPKG_LINE_INFO); } const auto& topic = parsed.command_arguments[0]; @@ -181,14 +182,14 @@ namespace vcpkg { if (Strings::case_insensitive_ascii_equals(command_metadata->name, topic)) { - print_usage(*command_metadata); + msg::print(usage_for_command(*command_metadata)); get_global_metrics_collector().track_string(StringMetric::CommandContext, command_metadata->name); Checks::exit_success(VCPKG_LINE_INFO); } } - msg::println_error(msgUnknownTopic, msg::value = topic); - help_topics(paths); + stderr_sink.println_error(msgUnknownTopic, msg::value = topic); + stderr_sink.print(help_topics()); get_global_metrics_collector().track_string(StringMetric::CommandContext, "unknown"); Checks::exit_fail(VCPKG_LINE_INFO); } diff --git a/src/vcpkg/commands.install.cpp b/src/vcpkg/commands.install.cpp index e82f2b8087..5a2e05c040 100644 --- a/src/vcpkg/commands.install.cpp +++ b/src/vcpkg/commands.install.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -334,7 +335,7 @@ namespace vcpkg msg::println(Color::warning, msgAlreadyInstalledNotHead, msg::spec = action.spec); else msg::println(Color::success, msgAlreadyInstalled, msg::spec = action.spec); - return ExtendedBuildResult{BuildResult::SUCCEEDED}; + return ExtendedBuildResult{BuildResult::Succeeded}; } if (plan_type == InstallPlanType::BUILD_AND_INSTALL) @@ -346,9 +347,9 @@ namespace vcpkg fs, action.package_dir.value_or_exit(VCPKG_LINE_INFO), action.spec); bcf = std::make_unique(std::move(maybe_bcf).value_or_exit(VCPKG_LINE_INFO)); } - else if (action.build_options.build_missing == BuildMissing::NO) + else if (action.build_options.build_missing == BuildMissing::No) { - return ExtendedBuildResult{BuildResult::CACHE_MISSING}; + return ExtendedBuildResult{BuildResult::CacheMissing}; } else { @@ -357,13 +358,13 @@ namespace vcpkg auto result = build_package(args, paths, action, build_logs_recorder, status_db); - if (BuildResult::DOWNLOADED == result.code) + if (BuildResult::Downloaded == result.code) { msg::println(Color::success, msgDownloadedSources, msg::spec = action.display_name()); return result; } - if (result.code != BuildResult::SUCCEEDED) + if (result.code != BuildResult::Succeeded) { LocalizedString warnings; for (auto&& msg : action.build_failure_messages) @@ -389,13 +390,13 @@ namespace vcpkg BuildResult code; switch (install_result) { - case InstallResult::SUCCESS: code = BuildResult::SUCCEEDED; break; - case InstallResult::FILE_CONFLICTS: code = BuildResult::FILE_CONFLICTS; break; + case InstallResult::SUCCESS: code = BuildResult::Succeeded; break; + case InstallResult::FILE_CONFLICTS: code = BuildResult::FileConflicts; break; default: Checks::unreachable(VCPKG_LINE_INFO); } binary_cache.push_success(action); - if (action.build_options.clean_downloads == CleanDownloads::YES) + if (action.build_options.clean_downloads == CleanDownloads::Yes) { for (auto& p : fs.get_regular_files_non_recursive(paths.downloads, IgnoreErrors{})) { @@ -409,7 +410,7 @@ namespace vcpkg if (plan_type == InstallPlanType::EXCLUDED) { msg::println(Color::warning, msgExcludedPackage, msg::spec = action.spec); - return ExtendedBuildResult{BuildResult::EXCLUDED}; + return ExtendedBuildResult{BuildResult::Excluded}; } Checks::unreachable(VCPKG_LINE_INFO); @@ -456,7 +457,7 @@ namespace vcpkg for (const SpecSummary& result : this->results) { - if (result.build_result.value_or_exit(VCPKG_LINE_INFO).code != BuildResult::SUCCEEDED) + if (result.build_result.value_or_exit(VCPKG_LINE_INFO).code != BuildResult::Succeeded) { msg::println(format_result_row(result)); } @@ -470,15 +471,15 @@ namespace vcpkg { switch (result.build_result.value_or_exit(VCPKG_LINE_INFO).code) { - case BuildResult::SUCCEEDED: - case BuildResult::REMOVED: - case BuildResult::DOWNLOADED: - case BuildResult::EXCLUDED: continue; - case BuildResult::BUILD_FAILED: - case BuildResult::POST_BUILD_CHECKS_FAILED: - case BuildResult::FILE_CONFLICTS: - case BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES: - case BuildResult::CACHE_MISSING: return true; + case BuildResult::Succeeded: + case BuildResult::Removed: + case BuildResult::Downloaded: + case BuildResult::Excluded: continue; + case BuildResult::BuildFailed: + case BuildResult::PostBuildChecksFailed: + case BuildResult::FileConflicts: + case BuildResult::CascadedDueToMissingDependencies: + case BuildResult::CacheMissing: return true; default: Checks::unreachable(VCPKG_LINE_INFO); } } @@ -525,7 +526,7 @@ namespace vcpkg void print_abi_hash() const { auto bpgh = current_summary.get_binary_paragraph(); - if (bpgh) + if (bpgh && !bpgh->abi.empty()) { msg::println(msgPackageAbi, msg::spec = bpgh->display_name(), msg::package_abi = bpgh->abi); } @@ -574,7 +575,7 @@ namespace vcpkg { TrackedPackageInstallGuard this_install(action_index++, action_count, results, action); remove_package(fs, paths.installed(), action.spec, status_db); - results.back().build_result.emplace(BuildResult::REMOVED); + results.back().build_result.emplace(BuildResult::Removed); } for (auto&& action : action_plan.already_installed) @@ -588,7 +589,7 @@ namespace vcpkg TrackedPackageInstallGuard this_install(action_index++, action_count, results, action); auto result = perform_install_plan_action(args, paths, action, status_db, binary_cache, build_logs_recorder); - if (result.code != BuildResult::SUCCEEDED && keep_going == KeepGoing::NO) + if (result.code != BuildResult::Succeeded && keep_going == KeepGoing::NO) { this_install.print_elapsed_time(); print_user_troubleshooting_message(action, paths, result.stdoutlog.then([&](auto&) -> Optional { @@ -1058,7 +1059,7 @@ namespace vcpkg ? UnsupportedPortAction::Warn : UnsupportedPortAction::Error; const PrintUsage print_cmake_usage = - Util::Sets::contains(options.switches, OPTION_NO_PRINT_USAGE) ? PrintUsage::NO : PrintUsage::YES; + Util::Sets::contains(options.switches, OPTION_NO_PRINT_USAGE) ? PrintUsage::No : PrintUsage::Yes; get_global_metrics_collector().track_bool(BoolMetric::InstallManifestMode, paths.manifest_mode_enabled()); @@ -1084,7 +1085,7 @@ namespace vcpkg if (failure) { msg::println(msgUsingManifestAt, msg::path = p->path); - print_usage(CommandInstallMetadataManifest); + msg::print(usage_for_command(CommandInstallMetadataManifest)); Checks::exit_fail(VCPKG_LINE_INFO); } @@ -1110,15 +1111,15 @@ namespace vcpkg } if (failure) { - print_usage(CommandInstallMetadataClassic); + msg::write_unlocalized_text_to_stderr(Color::none, usage_for_command(CommandInstallMetadataClassic)); Checks::exit_fail(VCPKG_LINE_INFO); } } auto& fs = paths.get_filesystem(); - DownloadTool download_tool = DownloadTool::BUILT_IN; - if (use_aria2) download_tool = DownloadTool::ARIA2; + DownloadTool download_tool = DownloadTool::Builtin; + if (use_aria2) download_tool = DownloadTool::Aria2; const BuildPackageOptions install_plan_options = { Util::Enum::to_enum(!no_build_missing), @@ -1129,9 +1130,9 @@ namespace vcpkg Util::Enum::to_enum(clean_after_build || clean_packages_after_build), Util::Enum::to_enum(clean_after_build || clean_downloads_after_build), download_tool, - PurgeDecompressFailure::NO, + PurgeDecompressFailure::No, Util::Enum::to_enum(is_editable), - prohibit_backcompat_features ? BackcompatFeatures::PROHIBIT : BackcompatFeatures::ALLOW, + prohibit_backcompat_features ? BackcompatFeatures::Prohibit : BackcompatFeatures::Allow, print_cmake_usage}; auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths); @@ -1260,8 +1261,8 @@ namespace vcpkg for (InstallPlanAction& action : install_plan.install_actions) { action.build_options = install_plan_options; - action.build_options.use_head_version = UseHeadVersion::NO; - action.build_options.editable = Editable::NO; + action.build_options.use_head_version = UseHeadVersion::No; + action.build_options.editable = Editable::No; } // If the manifest refers to itself, it will be added to the install plan. @@ -1312,8 +1313,8 @@ namespace vcpkg action.build_options = install_plan_options; if (action.request_type != RequestType::USER_REQUESTED) { - action.build_options.use_head_version = UseHeadVersion::NO; - action.build_options.editable = Editable::NO; + action.build_options.use_head_version = UseHeadVersion::No; + action.build_options.editable = Editable::No; } } @@ -1408,7 +1409,7 @@ namespace vcpkg fs.write_contents(it_xunit->second, xwriter.build_xml(default_triplet), VCPKG_LINE_INFO); } - if (install_plan_options.print_usage == PrintUsage::YES) + if (install_plan_options.print_usage == PrintUsage::Yes) { std::set printed_usages; for (auto&& result : summary.results) diff --git a/src/vcpkg/commands.integrate.cpp b/src/vcpkg/commands.integrate.cpp index 4e29d42005..edb26cb925 100644 --- a/src/vcpkg/commands.integrate.cpp +++ b/src/vcpkg/commands.integrate.cpp @@ -379,19 +379,20 @@ namespace vcpkg nuspec_file_path, create_nuspec_file_contents(paths.root, nuget_id, nupkg_version), VCPKG_LINE_INFO); // Using all forward slashes for the command line - auto cmd_line = Command(nuget_exe) - .string_arg("pack") - .string_arg("-OutputDirectory") - .string_arg(paths.original_cwd) - .string_arg(nuspec_file_path); + auto cmd = Command(nuget_exe) + .string_arg("pack") + .string_arg("-OutputDirectory") + .string_arg(paths.original_cwd) + .string_arg(nuspec_file_path); + RedirectedProcessLaunchSettings settings; + settings.environment = get_clean_environment(); - const auto maybe_nuget_output = flatten( - cmd_execute_and_capture_output(cmd_line, default_working_directory, get_clean_environment()), Tools::NUGET); + const auto maybe_nuget_output = flatten(cmd_execute_and_capture_output(cmd, settings), Tools::NUGET); if (!maybe_nuget_output) { Checks::msg_exit_with_message(VCPKG_LINE_INFO, - msg::format(msgCommandFailed, msg::command_line = cmd_line.command_line()) + msg::format(msgCommandFailed, msg::command_line = cmd.command_line()) .append_raw('\n') .append(maybe_nuget_output.error())); } @@ -422,13 +423,13 @@ namespace vcpkg const auto script_path = paths.scripts / "addPoshVcpkgToPowershellProfile.ps1"; const auto& ps = paths.get_tool_exe("powershell-core", out_sink); - auto cmd = Command(ps) - .string_arg("-NoProfile") - .string_arg("-ExecutionPolicy") - .string_arg("Bypass") - .string_arg("-Command") - .string_arg(fmt::format("& {{& '{}' }}", script_path)); - const int rc = cmd_execute(cmd).value_or_exit(VCPKG_LINE_INFO); + const int rc = cmd_execute(Command{ps} + .string_arg("-NoProfile") + .string_arg("-ExecutionPolicy") + .string_arg("Bypass") + .string_arg("-Command") + .string_arg(fmt::format("& {{& '{}' }}", script_path))) + .value_or_exit(VCPKG_LINE_INFO); if (rc) { msg::println_error(msg::format(msgCommandFailed, msg::command_line = TITLE) diff --git a/src/vcpkg/commands.portsdiff.cpp b/src/vcpkg/commands.portsdiff.cpp index 65f6e4102a..def776f9dd 100644 --- a/src/vcpkg/commands.portsdiff.cpp +++ b/src/vcpkg/commands.portsdiff.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -39,18 +40,23 @@ namespace const auto checkout_this_dir = fmt::format("./{}", ports_dir_name); // Must be relative to the root of the repository - auto cmd = paths.git_cmd_builder(dot_git_dir, temp_checkout_path) - .string_arg("checkout") - .string_arg(git_commit_id) - .string_arg("-f") - .string_arg("-q") - .string_arg("--") - .string_arg(checkout_this_dir) - .string_arg(".vcpkg-root"); - cmd_execute_and_capture_output(cmd, default_working_directory, get_clean_environment()); - cmd_execute_and_capture_output(paths.git_cmd_builder(dot_git_dir, temp_checkout_path).string_arg("reset"), - default_working_directory, - get_clean_environment()); + RedirectedProcessLaunchSettings settings; + settings.environment = get_clean_environment(); + flatten(cmd_execute_and_capture_output(paths.git_cmd_builder(dot_git_dir, temp_checkout_path) + .string_arg("checkout") + .string_arg(git_commit_id) + .string_arg("-f") + .string_arg("-q") + .string_arg("--") + .string_arg(checkout_this_dir) + .string_arg(".vcpkg-root"), + settings), + Tools::GIT) + .value_or_exit(VCPKG_LINE_INFO); + flatten(cmd_execute_and_capture_output( + paths.git_cmd_builder(dot_git_dir, temp_checkout_path).string_arg("reset"), settings), + Tools::GIT) + .value_or_exit(VCPKG_LINE_INFO); const auto ports_at_commit = Paragraphs::load_overlay_ports(fs, temp_checkout_path / ports_dir_name); fs.remove_all(temp_checkout_path, VCPKG_LINE_INFO); @@ -66,13 +72,13 @@ namespace void check_commit_exists(const VcpkgPaths& paths, StringView git_commit_id) { static constexpr StringLiteral VALID_COMMIT_OUTPUT = "commit\n"; - auto cmd = paths.git_cmd_builder(paths.root / ".git", paths.root) - .string_arg("cat-file") - .string_arg("-t") - .string_arg(git_commit_id); Checks::msg_check_exit(VCPKG_LINE_INFO, - cmd_execute_and_capture_output(cmd).value_or_exit(VCPKG_LINE_INFO).output == - VALID_COMMIT_OUTPUT, + cmd_execute_and_capture_output(paths.git_cmd_builder(paths.root / ".git", paths.root) + .string_arg("cat-file") + .string_arg("-t") + .string_arg(git_commit_id)) + .value_or_exit(VCPKG_LINE_INFO) + .output == VALID_COMMIT_OUTPUT, msgInvalidCommitId, msg::commit_sha = git_commit_id); } diff --git a/src/vcpkg/commands.remove.cpp b/src/vcpkg/commands.remove.cpp index 15def992a4..9e489dfd35 100644 --- a/src/vcpkg/commands.remove.cpp +++ b/src/vcpkg/commands.remove.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/src/vcpkg/commands.set-installed.cpp b/src/vcpkg/commands.set-installed.cpp index a018b48f85..e4040698f8 100644 --- a/src/vcpkg/commands.set-installed.cpp +++ b/src/vcpkg/commands.set-installed.cpp @@ -258,7 +258,7 @@ namespace vcpkg } } - if (print_cmake_usage == PrintUsage::YES) + if (print_cmake_usage == PrintUsage::Yes) { std::set printed_usages; for (auto&& ur_spec : user_requested_specs) @@ -301,7 +301,7 @@ namespace vcpkg ? KeepGoing::YES : KeepGoing::NO; const PrintUsage print_cmake_usage = - Util::Sets::contains(options.switches, OPTION_NO_PRINT_USAGE) ? PrintUsage::NO : PrintUsage::YES; + Util::Sets::contains(options.switches, OPTION_NO_PRINT_USAGE) ? PrintUsage::No : PrintUsage::Yes; const auto unsupported_port_action = Util::Sets::contains(options.switches, OPTION_ALLOW_UNSUPPORTED_PORT) ? UnsupportedPortAction::Warn : UnsupportedPortAction::Error; @@ -331,7 +331,7 @@ namespace vcpkg { action.build_options = default_build_package_options; action.build_options.backcompat_features = - (prohibit_backcompat_features ? BackcompatFeatures::PROHIBIT : BackcompatFeatures::ALLOW); + (prohibit_backcompat_features ? BackcompatFeatures::Prohibit : BackcompatFeatures::Allow); } command_set_installed_and_exit_ex(args, diff --git a/src/vcpkg/commands.z-applocal.cpp b/src/vcpkg/commands.z-applocal.cpp index 4f19f7e5b4..9dd8e5efee 100644 --- a/src/vcpkg/commands.z-applocal.cpp +++ b/src/vcpkg/commands.z-applocal.cpp @@ -18,7 +18,7 @@ using namespace vcpkg; namespace { - WriteFilePointer maybe_create_log(const std::map>& settings, + WriteFilePointer maybe_create_log(const std::map>& settings, StringLiteral setting, const Filesystem& fs) { diff --git a/src/vcpkg/commands.z-changelog.cpp b/src/vcpkg/commands.z-changelog.cpp index d61d3530e1..35c9f80160 100644 --- a/src/vcpkg/commands.z-changelog.cpp +++ b/src/vcpkg/commands.z-changelog.cpp @@ -44,7 +44,8 @@ namespace vcpkg result.append("|x64-uwp|Building...|\n"); result.append("|arm64-windows|Building...|\n"); result.append("|arm64-uwp|Building...|\n"); - result.append("|**x64-osx**|Building...|\n"); + result.append("|**arm64-osx**|Building...|\n"); + result.append("|x64-osx|Building...|\n"); result.append("|**x64-linux**|Building...|\n"); result.append("|arm-neon-android|Building...|\n"); result.append("|x64-android|Building...|\n"); diff --git a/src/vcpkg/commands.z-extract.cpp b/src/vcpkg/commands.z-extract.cpp index d09f96d8a4..5d6ac633bc 100644 --- a/src/vcpkg/commands.z-extract.cpp +++ b/src/vcpkg/commands.z-extract.cpp @@ -33,7 +33,7 @@ namespace vcpkg nullptr, }; - ExpectedL get_strip_setting(std::map> settings) + ExpectedL get_strip_setting(const std::map>& settings) { auto iter = settings.find(OPTION_STRIP); if (iter == settings.end()) diff --git a/src/vcpkg/commands.z-generate-message-map.cpp b/src/vcpkg/commands.z-generate-message-map.cpp index f3cb71060f..c8de01a4a0 100644 --- a/src/vcpkg/commands.z-generate-message-map.cpp +++ b/src/vcpkg/commands.z-generate-message-map.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -5,6 +6,7 @@ #include #include +#include using namespace vcpkg; diff --git a/src/vcpkg/configuration.cpp b/src/vcpkg/configuration.cpp index 342372888f..16e192eb03 100644 --- a/src/vcpkg/configuration.cpp +++ b/src/vcpkg/configuration.cpp @@ -883,7 +883,7 @@ namespace vcpkg auto conf = Json::parse(contents, origin); if (!conf) { - messageSink.println(Color::error, LocalizedString::from_raw(conf.error()->to_string())); + messageSink.println(Color::error, conf.error()); return nullopt; } diff --git a/src/vcpkg/configure-environment.cpp b/src/vcpkg/configure-environment.cpp index 5f13e0231d..f1cdd13ad7 100644 --- a/src/vcpkg/configure-environment.cpp +++ b/src/vcpkg/configure-environment.cpp @@ -79,7 +79,8 @@ namespace constexpr const StringLiteral* ArtifactTargetPlatformSwitchNamesStorage[] = { &SWITCH_TARGET_X86, &SWITCH_TARGET_X64, &SWITCH_TARGET_ARM, &SWITCH_TARGET_ARM64}; - bool more_than_one_mapped(View candidates, const std::set>& switches) + bool more_than_one_mapped(View candidates, + const std::set>& switches) { bool seen = false; for (auto&& candidate : candidates) @@ -185,12 +186,12 @@ namespace vcpkg auto temp_directory = fs.create_or_get_temp_directory(VCPKG_LINE_INFO); - Command cmd_run(paths.get_tool_exe(Tools::NODE, out_sink)); - cmd_run.string_arg(vcpkg_artifacts_main_path); - cmd_run.forwarded_args(args); + auto cmd = Command{paths.get_tool_exe(Tools::NODE, out_sink)}; + cmd.string_arg(vcpkg_artifacts_main_path); + cmd.forwarded_args(args); if (Debug::g_debugging) { - cmd_run.string_arg("--debug"); + cmd.string_arg("--debug"); } Optional maybe_telemetry_file_path; @@ -198,28 +199,30 @@ namespace vcpkg { auto& p = maybe_telemetry_file_path.emplace(temp_directory / (generate_random_UUID() + "_artifacts_telemetry.txt")); - cmd_run.string_arg("--z-telemetry-file").string_arg(p); + cmd.string_arg("--z-telemetry-file").string_arg(p); } - cmd_run.string_arg("--vcpkg-root").string_arg(paths.root); - cmd_run.string_arg("--z-vcpkg-command").string_arg(get_exe_path_of_current_process()); + cmd.string_arg("--vcpkg-root").string_arg(paths.root); + cmd.string_arg("--z-vcpkg-command").string_arg(get_exe_path_of_current_process()); - cmd_run.string_arg("--z-vcpkg-artifacts-root").string_arg(paths.artifacts()); - cmd_run.string_arg("--z-vcpkg-downloads").string_arg(paths.downloads); - cmd_run.string_arg("--z-vcpkg-registries-cache").string_arg(paths.registries_cache()); - cmd_run.string_arg("--z-next-previous-environment") + cmd.string_arg("--z-vcpkg-artifacts-root").string_arg(paths.artifacts()); + cmd.string_arg("--z-vcpkg-downloads").string_arg(paths.downloads); + cmd.string_arg("--z-vcpkg-registries-cache").string_arg(paths.registries_cache()); + cmd.string_arg("--z-next-previous-environment") .string_arg(temp_directory / (generate_random_UUID() + "_previous_environment.txt")); - cmd_run.string_arg("--z-global-config").string_arg(paths.global_config()); + cmd.string_arg("--z-global-config").string_arg(paths.global_config()); auto maybe_file = msg::get_loaded_file(); if (!maybe_file.empty()) { auto temp_file = temp_directory / "messages.json"; fs.write_contents(temp_file, maybe_file, VCPKG_LINE_INFO); - cmd_run.string_arg("--language").string_arg(temp_file); + cmd.string_arg("--language").string_arg(temp_file); } - auto result = cmd_execute(cmd_run, WorkingDirectory{paths.original_cwd}).value_or_exit(VCPKG_LINE_INFO); + ProcessLaunchSettings settings; + settings.working_directory = paths.original_cwd; + auto result = cmd_execute(cmd, settings).value_or_exit(VCPKG_LINE_INFO); if (auto telemetry_file_path = maybe_telemetry_file_path.get()) { track_telemetry(fs, *telemetry_file_path); diff --git a/src/vcpkg/dependencies.cpp b/src/vcpkg/dependencies.cpp index d3ae209503..6d5644a7bc 100644 --- a/src/vcpkg/dependencies.cpp +++ b/src/vcpkg/dependencies.cpp @@ -431,7 +431,7 @@ namespace vcpkg static void format_plan_row(LocalizedString& out, const InstallPlanAction& action, const Path& builtin_ports_dir) { out.append_raw(request_type_indent(action.request_type)).append_raw(action.display_name()); - if (action.build_options.use_head_version == UseHeadVersion::YES) + if (action.build_options.use_head_version == UseHeadVersion::Yes) { out.append_raw(" (+HEAD)"); } diff --git a/src/vcpkg/export.chocolatey.cpp b/src/vcpkg/export.chocolatey.cpp index 4142c327ad..599771d6e5 100644 --- a/src/vcpkg/export.chocolatey.cpp +++ b/src/vcpkg/export.chocolatey.cpp @@ -217,14 +217,15 @@ if (Test-Path $installedDir) const auto chocolatey_uninstall_file_path = per_package_dir_path / "tools" / "chocolateyUninstall.ps1"; fs.write_contents(chocolatey_uninstall_file_path, chocolatey_uninstall_content, VCPKG_LINE_INFO); - auto cmd_line = Command(nuget_exe) - .string_arg("pack") - .string_arg("-OutputDirectory") - .string_arg(exported_dir_path) - .string_arg(nuspec_file_path) - .string_arg("-NoDefaultExcludes"); - - flatten(cmd_execute_and_capture_output(cmd_line, default_working_directory, get_clean_environment()), + RedirectedProcessLaunchSettings settings; + settings.environment = get_clean_environment(); + flatten(cmd_execute_and_capture_output(Command(nuget_exe) + .string_arg("pack") + .string_arg("-OutputDirectory") + .string_arg(exported_dir_path) + .string_arg(nuspec_file_path) + .string_arg("-NoDefaultExcludes"), + settings), Tools::NUGET) .value_or_exit(VCPKG_LINE_INFO); } diff --git a/src/vcpkg/export.ifw.cpp b/src/vcpkg/export.ifw.cpp index a214c9b189..ff6706236d 100644 --- a/src/vcpkg/export.ifw.cpp +++ b/src/vcpkg/export.ifw.cpp @@ -363,11 +363,13 @@ namespace vcpkg::IFW const Filesystem& fs = paths.get_filesystem(); fs.remove_all(repository_dir, VCPKG_LINE_INFO); - auto cmd_line = - Command(repogen_exe).string_arg("--packages").string_arg(packages_dir).string_arg(repository_dir); - - flatten(cmd_execute_and_capture_output(cmd_line, default_working_directory, get_clean_environment()), - repogen_exe) + RedirectedProcessLaunchSettings settings; + settings.environment = get_clean_environment(); + flatten( + cmd_execute_and_capture_output( + Command(repogen_exe).string_arg("--packages").string_arg(packages_dir).string_arg(repository_dir), + settings), + repogen_exe) .value_or_exit(VCPKG_LINE_INFO); } @@ -381,32 +383,31 @@ namespace vcpkg::IFW const auto installer_file = get_installer_file_path(export_id, ifw_options, paths); msg::println(msgGeneratingInstaller, msg::path = installer_file); - Command cmd_line; - + Command cmd; std::string ifw_repo_url = ifw_options.maybe_repository_url.value_or(""); if (!ifw_repo_url.empty()) { - cmd_line = Command(binarycreator_exe) - .string_arg("--online-only") - .string_arg("--config") - .string_arg(config_file) - .string_arg("--repository") - .string_arg(repository_dir) - .string_arg(installer_file); + cmd.string_arg(binarycreator_exe) + .string_arg("--online-only") + .string_arg("--config") + .string_arg(config_file) + .string_arg("--repository") + .string_arg(repository_dir) + .string_arg(installer_file); } else { - cmd_line = Command(binarycreator_exe) - .string_arg("--config") - .string_arg(config_file) - .string_arg("--packages") - .string_arg(packages_dir) - .string_arg(installer_file); + cmd.string_arg(binarycreator_exe) + .string_arg("--config") + .string_arg(config_file) + .string_arg("--packages") + .string_arg(packages_dir) + .string_arg(installer_file); } - flatten(cmd_execute_and_capture_output(cmd_line, default_working_directory, get_clean_environment()), - binarycreator_exe) - .value_or_exit(VCPKG_LINE_INFO); + RedirectedProcessLaunchSettings settings; + settings.environment = get_clean_environment(); + flatten(cmd_execute_and_capture_output(cmd, settings), binarycreator_exe).value_or_exit(VCPKG_LINE_INFO); msg::println(Color::success, msgGeneratedInstaller, msg::path = installer_file); } } diff --git a/src/vcpkg/export.prefab.cpp b/src/vcpkg/export.prefab.cpp index d8d17d66bd..8a08f72ecf 100644 --- a/src/vcpkg/export.prefab.cpp +++ b/src/vcpkg/export.prefab.cpp @@ -216,15 +216,19 @@ namespace vcpkg::Prefab msg::println(Color::warning, msgDeprecatedPrefabDebugOption); } Debug::print("Installing POM and AAR file to ~/.m2"); - auto cmd_line = Command(Tools::MAVEN); + auto cmd = Command{Tools::MAVEN}; if (!prefab_options.enable_debug) { - cmd_line.string_arg("-q"); + cmd.string_arg("-q"); } - cmd_line.string_arg("install:install-file") + + cmd.string_arg("install:install-file") .string_arg(Strings::concat("-Dfile=", aar)) .string_arg(Strings::concat("-DpomFile=", pom)); - const int exit_code = cmd_execute_clean(cmd_line).value_or_exit(VCPKG_LINE_INFO); + + ProcessLaunchSettings settings; + settings.environment = get_clean_environment(); + const int exit_code = cmd_execute(cmd, settings).value_or_exit(VCPKG_LINE_INFO); if (!(exit_code == 0)) { @@ -275,11 +279,11 @@ namespace vcpkg::Prefab std::unordered_map triplet_abi_map; std::unordered_map triplet_api_map; - for (auto& triplet_file : triplet_db.available_triplets) + for (const auto& triplet_file : triplet_db.available_triplets) { if (triplet_file.name.size() > 0) { - Triplet triplet = Triplet::from_canonical_name(std::move(triplet_file.name)); + Triplet triplet = Triplet::from_canonical_name(triplet_file.name); auto triplet_build_info = build_info_from_triplet(paths, provider, triplet); if (is_supported(*triplet_build_info)) { diff --git a/src/vcpkg/platform-expression.cpp b/src/vcpkg/platform-expression.cpp index 14e15e32d0..8bb46ef614 100644 --- a/src/vcpkg/platform-expression.cpp +++ b/src/vcpkg/platform-expression.cpp @@ -414,9 +414,9 @@ namespace vcpkg::PlatformExpression using namespace detail; - Expr::Expr() = default; - Expr::Expr(Expr&& other) = default; - Expr& Expr::operator=(Expr&& other) = default; + Expr::Expr() noexcept = default; + Expr::Expr(Expr&& other) noexcept = default; + Expr& Expr::operator=(Expr&& other) noexcept = default; Expr::Expr(const Expr& other) { @@ -645,7 +645,7 @@ namespace vcpkg::PlatformExpression ExpressionParser parser(expression, multiple_binary_operators); auto res = parser.parse(); - if (auto p = parser.extract_error()) + if (auto p = parser.get_error()) { return LocalizedString::from_raw(p->to_string()); } diff --git a/src/vcpkg/portfileprovider.cpp b/src/vcpkg/portfileprovider.cpp index bfaed5f32b..65d67bd73a 100644 --- a/src/vcpkg/portfileprovider.cpp +++ b/src/vcpkg/portfileprovider.cpp @@ -35,8 +35,6 @@ namespace namespace vcpkg { - PortFileProvider::~PortFileProvider() = default; - MapPortFileProvider::MapPortFileProvider(const std::unordered_map& map) : ports(map) { @@ -54,12 +52,6 @@ namespace vcpkg return Util::fmap(ports, [](auto&& kvpair) -> const SourceControlFileAndLocation* { return &kvpair.second; }); } - IVersionedPortfileProvider::~IVersionedPortfileProvider() = default; - - IBaselineProvider::~IBaselineProvider() = default; - - IOverlayProvider::~IOverlayProvider() = default; - PathsPortFileProvider::PathsPortFileProvider(const ReadOnlyFilesystem& fs, const RegistrySet& registry_set, std::unique_ptr&& overlay) diff --git a/src/vcpkg/postbuildlint.cpp b/src/vcpkg/postbuildlint.cpp index 390fbc05a4..3effd2326e 100644 --- a/src/vcpkg/postbuildlint.cpp +++ b/src/vcpkg/postbuildlint.cpp @@ -681,8 +681,8 @@ namespace vcpkg const auto requested_arch = expected_architecture == "x64" ? "x86_64" : expected_architecture; for (const Path& file : files) { - auto cmd_line = Command("lipo").string_arg("-archs").string_arg(file); - auto maybe_output = flatten_out(cmd_execute_and_capture_output(cmd_line), "lipo"); + auto cmd = Command{"lipo"}.string_arg("-archs").string_arg(file); + auto maybe_output = flatten_out(cmd_execute_and_capture_output(cmd), "lipo"); if (const auto output = maybe_output.get()) { if (!Util::Vectors::contains(Strings::split(Strings::trim(*output), ' '), requested_arch)) @@ -694,7 +694,7 @@ namespace vcpkg { msg_sink.println_error(msg::format(msgFailedToDetermineArchitecture, msg::path = file, - msg::command_line = cmd_line.command_line()) + msg::command_line = cmd.command_line()) .append_raw('\n') .append(maybe_output.error())); } @@ -974,7 +974,7 @@ namespace vcpkg { switch (linkage) { - case LinkageType::DYNAMIC: + case LinkageType::Dynamic: if (release) { return msg::format(msgLinkageDynamicRelease); @@ -984,7 +984,7 @@ namespace vcpkg return msg::format(msgLinkageDynamicDebug); } break; - case LinkageType::STATIC: + case LinkageType::Static: if (release) { return msg::format(msgLinkageStaticRelease); @@ -1059,11 +1059,11 @@ namespace vcpkg switch (build_info.crt_linkage) { - case LinkageType::DYNAMIC: + case LinkageType::Dynamic: fail |= this_lib.has_static_debug; fail |= this_lib.has_static_release; break; - case LinkageType::STATIC: + case LinkageType::Static: fail |= this_lib.has_dynamic_debug; fail |= this_lib.has_dynamic_release; break; @@ -1245,19 +1245,10 @@ namespace vcpkg if (extension.empty()) { - std::error_code ec; - ReadFilePointer read_file(file, ec); - if (ec) return false; - char buffer[5]; - if (read_file.read(buffer, 1, sizeof(buffer)) < sizeof(buffer)) return false; - if (Strings::starts_with(StringView(buffer, sizeof(buffer)), "#!") || - Strings::starts_with(StringView(buffer, sizeof(buffer)), "\xEF\xBB\xBF#!") /* ignore byte-order mark */) - { - const auto contents = fs.read_contents(file, IgnoreErrors{}); - return Strings::contains_any_ignoring_hash_comments(contents, searcher_paths); - } - return false; + const auto contents = fs.best_effort_read_contents_if_shebang(file); + return Strings::contains_any_ignoring_hash_comments(contents, searcher_paths); } + return false; } @@ -1287,22 +1278,25 @@ namespace vcpkg string_paths, [](std::string& s) { return Strings::boyer_moore_horspool_searcher(s.begin(), s.end()); }); std::vector failing_files; - std::mutex mtx; - auto files = fs.get_regular_files_recursive(dir, IgnoreErrors{}); + { + std::mutex mtx; + auto files = fs.get_regular_files_recursive(dir, IgnoreErrors{}); - parallel_for_each(files, [&](const Path& file) { - if (file_contains_absolute_paths(fs, file, searcher_paths)) - { - std::lock_guard lock{mtx}; - failing_files.push_back(file); - } - }); + parallel_for_each(files, [&](const Path& file) { + if (file_contains_absolute_paths(fs, file, searcher_paths)) + { + std::lock_guard lock{mtx}; + failing_files.push_back(file); + } + }); + } // destroy mtx if (failing_files.empty()) { return LintStatus::SUCCESS; } + Util::sort(failing_files); auto error_message = msg::format(msgFilesContainAbsolutePath1); for (auto&& absolute_path : absolute_paths) { @@ -1427,7 +1421,7 @@ namespace vcpkg switch (build_info.library_linkage) { - case LinkageType::DYNAMIC: + case LinkageType::Dynamic: { if (!pre_build_info.build_type && !build_info.policies.is_enabled(BuildPolicy::MISMATCHED_NUMBER_OF_BINARIES)) @@ -1447,7 +1441,7 @@ namespace vcpkg } } break; - case LinkageType::STATIC: + case LinkageType::Static: { auto& dlls = debug_dlls; dlls.insert(dlls.end(), diff --git a/src/vcpkg/registries.cpp b/src/vcpkg/registries.cpp index 36e34520b1..9a3e901035 100644 --- a/src/vcpkg/registries.cpp +++ b/src/vcpkg/registries.cpp @@ -1371,7 +1371,7 @@ namespace auto maybe_value = Json::parse(contents, origin); if (!maybe_value) { - return LocalizedString::from_raw(maybe_value.error()->to_string()); + return std::move(maybe_value).error(); } auto& value = *maybe_value.get(); diff --git a/src/vcpkg/statusparagraphs.cpp b/src/vcpkg/statusparagraphs.cpp index 1bb9bd90a9..208c2e31aa 100644 --- a/src/vcpkg/statusparagraphs.cpp +++ b/src/vcpkg/statusparagraphs.cpp @@ -6,8 +6,6 @@ namespace vcpkg { - StatusParagraphs::StatusParagraphs() = default; - StatusParagraphs::StatusParagraphs(std::vector>&& ps) : paragraphs(std::move(ps)) { } diff --git a/src/vcpkg/tools.cpp b/src/vcpkg/tools.cpp index 2bc7924a4e..cf3208d1ae 100644 --- a/src/vcpkg/tools.cpp +++ b/src/vcpkg/tools.cpp @@ -146,12 +146,13 @@ namespace vcpkg static ExpectedL run_to_extract_version(StringLiteral tool_name, const Path& exe_path, Command&& cmd) { - return flatten_out(cmd_execute_and_capture_output(cmd), exe_path).map_error([&](LocalizedString&& output) { - return msg::format_error( - msgFailedToRunToolToDetermineVersion, msg::tool_name = tool_name, msg::path = exe_path) - .append_raw('\n') - .append(output); - }); + return flatten_out(cmd_execute_and_capture_output({std::move(cmd)}), exe_path) + .map_error([&](LocalizedString&& output) { + return msg::format_error( + msgFailedToRunToolToDetermineVersion, msg::tool_name = tool_name, msg::path = exe_path) + .append_raw('\n') + .append(output); + }); } ExpectedL extract_prefixed_nonwhitespace(StringLiteral prefix, @@ -584,7 +585,7 @@ namespace vcpkg virtual bool is_acceptable(const Path& exe_path) const override { return flatten(cmd_execute_and_capture_output( - Command(exe_path).string_arg("-m").string_arg("venv").string_arg("-h")), + {Command(exe_path).string_arg("-m").string_arg("venv").string_arg("-h")}), Tools::PYTHON3) .has_value(); } diff --git a/src/vcpkg/vcpkgcmdarguments.cpp b/src/vcpkg/vcpkgcmdarguments.cpp index 7d45d2578e..c05cd87e84 100644 --- a/src/vcpkg/vcpkgcmdarguments.cpp +++ b/src/vcpkg/vcpkgcmdarguments.cpp @@ -84,16 +84,16 @@ namespace for (const auto& switch_ : command_metadata.options.switches) { bool parse_result; - auto name = switch_.name.to_string(); + ZStringView name = switch_.name; StabilityTag tag = StabilityTag::Standard; if (Strings::starts_with(name, "x-")) { - name.erase(0, 2); + name = name.substr(2); tag = StabilityTag::Experimental; } else if (Strings::starts_with(name, "z-")) { - name.erase(0, 2); + name = name.substr(2); tag = StabilityTag::ImplementationDetail; } @@ -101,14 +101,14 @@ namespace { if (cmd_parser.parse_switch(name, tag, parse_result, switch_.helpmsg.to_string()) && parse_result) { - output.switches.emplace(switch_.name.to_string()); + output.switches.emplace(switch_.name); } } else { if (cmd_parser.parse_switch(name, tag, parse_result) && parse_result) { - output.switches.emplace(switch_.name.to_string()); + output.switches.emplace(switch_.name); } } } @@ -117,16 +117,16 @@ namespace std::string maybe_parse_result; for (const auto& option : command_metadata.options.settings) { - auto name = option.name.to_string(); + ZStringView name = option.name; StabilityTag tag = StabilityTag::Standard; if (Strings::starts_with(name, "x-")) { - name.erase(0, 2); + name = name.substr(2); tag = StabilityTag::Experimental; } else if (Strings::starts_with(name, "z-")) { - name.erase(0, 2); + name = name.substr(2); tag = StabilityTag::ImplementationDetail; } @@ -134,14 +134,14 @@ namespace { if (cmd_parser.parse_option(name, tag, maybe_parse_result, option.helpmsg.to_string())) { - output.settings.emplace(option.name.to_string(), std::move(maybe_parse_result)); + output.settings.emplace(option.name, std::move(maybe_parse_result)); } } else { if (cmd_parser.parse_option(name, tag, maybe_parse_result)) { - output.settings.emplace(option.name.to_string(), std::move(maybe_parse_result)); + output.settings.emplace(option.name, std::move(maybe_parse_result)); } } } @@ -149,16 +149,16 @@ namespace for (const auto& option : command_metadata.options.multisettings) { - auto name = option.name.to_string(); + ZStringView name = option.name; StabilityTag tag = StabilityTag::Standard; if (Strings::starts_with(name, "x-")) { - name.erase(0, 2); + name = name.substr(2); tag = StabilityTag::Experimental; } else if (Strings::starts_with(name, "z-")) { - name.erase(0, 2); + name = name.substr(2); tag = StabilityTag::ImplementationDetail; } @@ -167,14 +167,14 @@ namespace { if (cmd_parser.parse_multi_option(name, tag, maybe_parse_result, option.helpmsg.to_string())) { - output.multisettings.emplace(option.name.to_string(), std::move(maybe_parse_result)); + output.multisettings.emplace(option.name, std::move(maybe_parse_result)); } } else { if (cmd_parser.parse_multi_option(name, tag, maybe_parse_result)) { - output.multisettings.emplace(option.name.to_string(), std::move(maybe_parse_result)); + output.multisettings.emplace(option.name, std::move(maybe_parse_result)); } } } @@ -288,11 +288,6 @@ namespace vcpkg } } - PortApplicableSetting::PortApplicableSetting(const PortApplicableSetting&) = default; - PortApplicableSetting::PortApplicableSetting(PortApplicableSetting&&) = default; - PortApplicableSetting& PortApplicableSetting::operator=(const PortApplicableSetting&) = default; - PortApplicableSetting& PortApplicableSetting::operator=(PortApplicableSetting&&) = default; - bool PortApplicableSetting::is_port_affected(StringView port_name) const noexcept { return affected_ports.empty() || std::binary_search(affected_ports.begin(), affected_ports.end(), port_name); @@ -453,12 +448,6 @@ namespace vcpkg return forwardable_arguments; } - VcpkgCmdArguments::VcpkgCmdArguments(const VcpkgCmdArguments&) = default; - VcpkgCmdArguments::VcpkgCmdArguments(VcpkgCmdArguments&&) = default; - VcpkgCmdArguments& VcpkgCmdArguments::operator=(const VcpkgCmdArguments&) = default; - VcpkgCmdArguments& VcpkgCmdArguments::operator=(VcpkgCmdArguments&&) = default; - VcpkgCmdArguments::~VcpkgCmdArguments() = default; - VcpkgCmdArguments::VcpkgCmdArguments(CmdParser&& parser_) : parser(std::move(parser_)) { } LocalizedString CommandMetadata::get_example_text() const @@ -480,7 +469,7 @@ namespace vcpkg return result; } - void print_usage(const CommandMetadata& command_metadata) + LocalizedString usage_for_command(const CommandMetadata& command_metadata) { auto with_common_options = VcpkgCmdArguments::create_from_arg_sequence(nullptr, nullptr); ParsedArguments throwaway; @@ -517,7 +506,7 @@ namespace vcpkg with_common_options.parser.append_options_table(result); result.append_raw('\n'); - msg::write_unlocalized_text_to_stderr(Color::error, result); + return result; } static void from_env(const std::function(ZStringView)>& f, @@ -530,7 +519,7 @@ namespace vcpkg } void VcpkgCmdArguments::imbue_from_environment() { imbue_from_environment_impl(&vcpkg::get_environment_variable); } - void VcpkgCmdArguments::imbue_from_fake_environment(const std::map>& env) + void VcpkgCmdArguments::imbue_from_fake_environment(const std::map>& env) { imbue_from_environment_impl([&env](ZStringView var) -> Optional { auto it = env.find(var); @@ -646,10 +635,7 @@ namespace vcpkg auto maybe_vcpkg_recursive_data = get_environment_variable(RECURSIVE_DATA_ENV); if (auto vcpkg_recursive_data = maybe_vcpkg_recursive_data.get()) { - auto rec_doc = Json::parse(*vcpkg_recursive_data, RECURSIVE_DATA_ENV) - .map_error(parse_error_formatter) - .value_or_exit(VCPKG_LINE_INFO) - .value; + auto rec_doc = Json::parse(*vcpkg_recursive_data, RECURSIVE_DATA_ENV).value_or_exit(VCPKG_LINE_INFO).value; const auto& obj = rec_doc.object(VCPKG_LINE_INFO); if (auto entry = obj.get(VCPKG_ROOT_ARG_NAME)) diff --git a/src/vcpkg/vcpkgpaths.cpp b/src/vcpkg/vcpkgpaths.cpp index 042ce572b6..7d48e87932 100644 --- a/src/vcpkg/vcpkgpaths.cpp +++ b/src/vcpkg/vcpkgpaths.cpp @@ -509,7 +509,7 @@ namespace } else { - Debug::print("Failed to load lockfile:\n", maybe_lock_contents.error()->to_string()); + Debug::print("Failed to load lockfile:\n", maybe_lock_contents.error()); return ret; } } @@ -847,14 +847,14 @@ namespace vcpkg else { const auto dot_git_dir = root / ".git"; - Command showcmd = git_cmd_builder(dot_git_dir, dot_git_dir) - .string_arg("show") - .string_arg("--pretty=format:%h %cd (%cr)") - .string_arg("-s") - .string_arg("--date=short") - .string_arg("HEAD"); - - const auto maybe_output = flatten_out(cmd_execute_and_capture_output(showcmd), Tools::GIT); + auto cmd = git_cmd_builder(dot_git_dir, dot_git_dir) + .string_arg("show") + .string_arg("--pretty=format:%h %cd (%cr)") + .string_arg("-s") + .string_arg("--date=short") + .string_arg("HEAD"); + + const auto maybe_output = flatten_out(cmd_execute_and_capture_output(cmd), Tools::GIT); if (const auto output = maybe_output.get()) { Strings::append(ret, " vcpkg-scripts version: ", *output, "\n"); @@ -909,12 +909,15 @@ namespace vcpkg { return {*sha, expected_left_tag}; } - auto cmd = git_cmd_builder(this->root / ".git", this->root); - cmd.string_arg("rev-parse").string_arg("HEAD"); - return flatten_out(cmd_execute_and_capture_output(cmd), Tools::GIT).map([](std::string&& output) { - Strings::inplace_trim(output); - return std::move(output); - }); + + return flatten_out( + cmd_execute_and_capture_output( + git_cmd_builder(this->root / ".git", this->root).string_arg("rev-parse").string_arg("HEAD")), + Tools::GIT) + .map([](std::string&& output) { + Strings::inplace_trim(output); + return std::move(output); + }); } LocalizedString VcpkgPaths::get_current_git_sha_baseline_message() const @@ -968,22 +971,22 @@ namespace vcpkg { // All git commands are run with: --git-dir={dot_git_dir} --work-tree={work_tree_temp} // git clone --no-checkout --local {vcpkg_root} {dot_git_dir} - Command showcmd = git_cmd_builder(dot_git_dir, dot_git_dir).string_arg("show").string_arg(treeish); - return flatten_out(cmd_execute_and_capture_output(showcmd), Tools::GIT); + return flatten_out(cmd_execute_and_capture_output( + git_cmd_builder(dot_git_dir, dot_git_dir).string_arg("show").string_arg(treeish)), + Tools::GIT); } ExpectedL>> VcpkgPaths::git_get_local_port_treeish_map() const { const auto local_repo = this->root / ".git"; - const auto git_cmd = git_cmd_builder({}, {}) - .string_arg("-C") - .string_arg(this->builtin_ports_directory()) - .string_arg("ls-tree") - .string_arg("-d") - .string_arg("HEAD") - .string_arg("--"); - - auto maybe_output = flatten_out(cmd_execute_and_capture_output(git_cmd), Tools::GIT); + auto cmd = git_cmd_builder({}, {}) + .string_arg("-C") + .string_arg(this->builtin_ports_directory()) + .string_arg("ls-tree") + .string_arg("-d") + .string_arg("HEAD") + .string_arg("--"); + auto maybe_output = flatten_out(cmd_execute_and_capture_output(cmd), Tools::GIT); if (const auto output = maybe_output.get()) { std::map> ret; @@ -997,8 +1000,7 @@ namespace vcpkg if (split_line.size() != 2) { Debug::println("couldn't split by tabs"); - return msg::format_error(msgGitUnexpectedCommandOutputCmd, - msg::command_line = git_cmd.command_line()) + return msg::format_error(msgGitUnexpectedCommandOutputCmd, msg::command_line = cmd.command_line()) .append_raw('\n') .append_raw(line); } @@ -1007,8 +1009,7 @@ namespace vcpkg if (file_info_section.size() != 3) { Debug::println("couldn't split by spaces"); - return msg::format_error(msgGitUnexpectedCommandOutputCmd, - msg::command_line = git_cmd.command_line()) + return msg::format_error(msgGitUnexpectedCommandOutputCmd, msg::command_line = cmd.command_line()) .append_raw('\n') .append_raw(line); } @@ -1018,7 +1019,7 @@ namespace vcpkg return ret; } - return msg::format(msgGitCommandFailed, msg::command_line = git_cmd.command_line()) + return msg::format(msgGitCommandFailed, msg::command_line = cmd.command_line()) .append_raw('\n') .append(std::move(maybe_output).error()) .append_raw('\n') @@ -1034,11 +1035,11 @@ namespace vcpkg fs.create_directories(work_tree, VCPKG_LINE_INFO); const auto& dot_git_dir = m_pimpl->m_registries_dot_git_dir; - Command init_registries_git_dir = git_cmd_builder(dot_git_dir, work_tree).string_arg("init"); - auto maybe_init_output = flatten(cmd_execute_and_capture_output(init_registries_git_dir), Tools::GIT); + auto init_cmd = git_cmd_builder(dot_git_dir, work_tree).string_arg("init"); + auto maybe_init_output = flatten(cmd_execute_and_capture_output(init_cmd), Tools::GIT); if (!maybe_init_output) { - return msg::format_error(msgGitCommandFailed, msg::command_line = init_registries_git_dir.command_line()) + return msg::format_error(msgGitCommandFailed, msg::command_line = init_cmd.command_line()) .append_raw('\n') .append(maybe_init_output.error()); } @@ -1046,12 +1047,12 @@ namespace vcpkg auto lock_file = work_tree / ".vcpkg-lock"; auto guard = fs.take_exclusive_file_lock(lock_file, stderr_sink, IgnoreErrors{}); - Command fetch_git_ref = git_cmd_builder(dot_git_dir, work_tree) - .string_arg("fetch") - .string_arg("--update-shallow") - .string_arg("--") - .string_arg(repo) - .string_arg(treeish); + auto fetch_git_ref = git_cmd_builder(dot_git_dir, work_tree) + .string_arg("fetch") + .string_arg("--update-shallow") + .string_arg("--") + .string_arg(repo) + .string_arg(treeish); auto maybe_fetch_output = flatten(cmd_execute_and_capture_output(fetch_git_ref), Tools::GIT); if (!maybe_fetch_output) @@ -1063,8 +1064,7 @@ namespace vcpkg .append(std::move(maybe_fetch_output).error()); } - Command get_fetch_head = - git_cmd_builder(dot_git_dir, work_tree).string_arg("rev-parse").string_arg("FETCH_HEAD"); + auto get_fetch_head = git_cmd_builder(dot_git_dir, work_tree).string_arg("rev-parse").string_arg("FETCH_HEAD"); return flatten_out(cmd_execute_and_capture_output(get_fetch_head), Tools::GIT) .map([](std::string&& output) { return Strings::trim(output).to_string(); }) .map_error([&](LocalizedString&& err) { @@ -1087,7 +1087,7 @@ namespace vcpkg const auto& dot_git_dir = m_pimpl->m_registries_dot_git_dir; - Command init_registries_git_dir = git_cmd_builder(dot_git_dir, work_tree).string_arg("init"); + auto init_registries_git_dir = git_cmd_builder(dot_git_dir, work_tree).string_arg("init"); auto maybe_init_output = flatten(cmd_execute_and_capture_output(init_registries_git_dir), Tools::GIT); if (!maybe_init_output) { @@ -1098,12 +1098,12 @@ namespace vcpkg .append(std::move(maybe_init_output).error()); } - Command fetch_git_ref = git_cmd_builder(dot_git_dir, work_tree) - .string_arg("fetch") - .string_arg("--update-shallow") - .string_arg("--") - .string_arg(repo) - .string_arg(treeish); + auto fetch_git_ref = git_cmd_builder(dot_git_dir, work_tree) + .string_arg("fetch") + .string_arg("--update-shallow") + .string_arg("--") + .string_arg(repo) + .string_arg(treeish); auto maybe_fetch_output = flatten(cmd_execute_and_capture_output(fetch_git_ref), Tools::GIT); if (!maybe_fetch_output) @@ -1123,24 +1123,25 @@ namespace vcpkg ExpectedL VcpkgPaths::git_show_from_remote_registry(StringView hash, const Path& relative_path) const { auto revision = fmt::format("{}:{}", hash, relative_path.generic_u8string()); - Command git_show = git_cmd_builder(m_pimpl->m_registries_dot_git_dir, m_pimpl->m_registries_work_tree_dir) - .string_arg("show") - .string_arg(revision); - - return flatten_out(cmd_execute_and_capture_output(git_show), Tools::GIT); + return flatten_out(cmd_execute_and_capture_output( + git_cmd_builder(m_pimpl->m_registries_dot_git_dir, m_pimpl->m_registries_work_tree_dir) + .string_arg("show") + .string_arg(revision)), + Tools::GIT); } ExpectedL VcpkgPaths::git_find_object_id_for_remote_registry_path(StringView hash, const Path& relative_path) const { auto revision = fmt::format("{}:{}", hash, relative_path.generic_u8string()); - Command git_rev_parse = git_cmd_builder(m_pimpl->m_registries_dot_git_dir, m_pimpl->m_registries_work_tree_dir) - .string_arg("rev-parse") - .string_arg(revision); - - return flatten_out(cmd_execute_and_capture_output(git_rev_parse), Tools::GIT).map([](std::string&& output) { - Strings::inplace_trim(output); - return std::move(output); - }); + return flatten_out(cmd_execute_and_capture_output( + git_cmd_builder(m_pimpl->m_registries_dot_git_dir, m_pimpl->m_registries_work_tree_dir) + .string_arg("rev-parse") + .string_arg(revision)), + Tools::GIT) + .map([](std::string&& output) { + Strings::inplace_trim(output); + return std::move(output); + }); } ExpectedL VcpkgPaths::git_read_tree(const Path& destination, StringView tree, const Path& dot_git_dir) const @@ -1178,17 +1179,18 @@ namespace vcpkg return format_filesystem_call_error(ec, "remove_all", {destination}); } - Command git_archive = git_cmd_builder(dot_git_dir, git_tree_temp) - .string_arg("read-tree") - .string_arg("-m") - .string_arg("-u") - .string_arg(tree); + auto git_archive = git_cmd_builder(dot_git_dir, git_tree_temp) + .string_arg("read-tree") + .string_arg("-m") + .string_arg("-u") + .string_arg(tree); - auto env = default_environment; + RedirectedProcessLaunchSettings git_archive_settings; + auto& env = git_archive_settings.environment.emplace(); env.add_entry("GIT_INDEX_FILE", git_tree_index.native()); auto maybe_git_read_tree_output = - flatten(cmd_execute_and_capture_output(git_archive, default_working_directory, env), Tools::GIT); + flatten(cmd_execute_and_capture_output(git_archive, git_archive_settings), Tools::GIT); if (!maybe_git_read_tree_output) { auto error = msg::format_error(msgGitCommandFailed, msg::command_line = git_archive.command_line()); diff --git a/src/vcpkg/visualstudio.cpp b/src/vcpkg/visualstudio.cpp index 1f9934177a..8df820b598 100644 --- a/src/vcpkg/visualstudio.cpp +++ b/src/vcpkg/visualstudio.cpp @@ -268,7 +268,7 @@ namespace vcpkg::VisualStudio { toolset_version = V_142; } - else if (toolset_version_prefix[3] == '3') + else if (toolset_version_prefix[3] == '3' || toolset_version_prefix[3] == '4') { toolset_version = V_143; } diff --git a/src/vcpkg/xunitwriter.cpp b/src/vcpkg/xunitwriter.cpp index c95643f156..246ff6fd28 100644 --- a/src/vcpkg/xunitwriter.cpp +++ b/src/vcpkg/xunitwriter.cpp @@ -25,12 +25,12 @@ namespace StringLiteral result_string = ""; switch (test.result) { - case BuildResult::POST_BUILD_CHECKS_FAILED: - case BuildResult::FILE_CONFLICTS: - case BuildResult::BUILD_FAILED: result_string = "Fail"; break; - case BuildResult::EXCLUDED: - case BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES: result_string = "Skip"; break; - case BuildResult::SUCCEEDED: result_string = "Pass"; break; + case BuildResult::PostBuildChecksFailed: + case BuildResult::FileConflicts: + case BuildResult::BuildFailed: result_string = "Fail"; break; + case BuildResult::Excluded: + case BuildResult::CascadedDueToMissingDependencies: result_string = "Skip"; break; + case BuildResult::Succeeded: result_string = "Pass"; break; default: Checks::unreachable(VCPKG_LINE_INFO); } diff --git a/vcpkg-artifacts/constants.ts b/vcpkg-artifacts/constants.ts index 582496b76b..7eb4f48e43 100644 --- a/vcpkg-artifacts/constants.ts +++ b/vcpkg-artifacts/constants.ts @@ -20,7 +20,7 @@ export const defaultConfig = { "kind": "artifact", "name": "arm", - "location": "https://artifacts.keil.arm.com/vcpkg-ce-registry/registry.zip" + "location": "https://artifacts.tools.arm.com/vcpkg-registry" } ] } diff --git a/vcpkg-init/vcpkg-scripts-sha.txt b/vcpkg-init/vcpkg-scripts-sha.txt index c427af6966..cbd6e9f4b9 100644 --- a/vcpkg-init/vcpkg-scripts-sha.txt +++ b/vcpkg-init/vcpkg-scripts-sha.txt @@ -1 +1 @@ -000d1bda1ffa95a73e0b40334fa4103d6f4d3d48 +66b4b34d99ab272fcf21f2bd12b616e371c6bb31