aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBilly O'Neal <bion@microsoft.com>2020-06-03 19:31:28 -0700
committerGitHub <noreply@github.com>2020-06-03 19:31:28 -0700
commit4fb225608532e9fb2fd2f5f1dbe9ec092cdc7c93 (patch)
treed4ccfc78c9043c6c136dc2ec72a3f005366564a3
parent20e6626d8758f5e46c1777e3e1ff4d98ed5d2e7a (diff)
downloadvcpkg-4fb225608532e9fb2fd2f5f1dbe9ec092cdc7c93.tar.gz
vcpkg-4fb225608532e9fb2fd2f5f1dbe9ec092cdc7c93.zip
[vcpkg] Allow CI to pass in all relevant directories and remove use of symbolic links (#11483)
-rw-r--r--ports/libpq/CONTROL4
-rw-r--r--ports/libpq/portfile.cmake19
-rw-r--r--ports/qt5-base/CONTROL2
-rw-r--r--ports/qt5-base/cmake/find_qt_mkspec.cmake6
-rw-r--r--ports/shiva-sfml/CONTROL2
-rw-r--r--ports/shiva-sfml/portfile.cmake70
-rw-r--r--ports/spirv-tools/CONTROL2
-rw-r--r--ports/spirv-tools/portfile.cmake2
-rw-r--r--scripts/azure-pipelines/linux/azure-pipelines.yml24
-rwxr-xr-xscripts/azure-pipelines/linux/initialize-environment.sh8
-rw-r--r--scripts/azure-pipelines/osx/azure-pipelines.yml10
-rwxr-xr-xscripts/azure-pipelines/osx/initialize-environment.sh17
-rw-r--r--scripts/azure-pipelines/windows/azure-pipelines.yml21
-rw-r--r--scripts/azure-pipelines/windows/initialize-environment.ps144
-rw-r--r--scripts/buildsystems/msbuild/vcpkg.targets26
-rw-r--r--scripts/buildsystems/vcpkg.cmake8
-rw-r--r--scripts/cmake/vcpkg_build_cmake.cmake4
-rw-r--r--scripts/cmake/vcpkg_build_make.cmake26
-rw-r--r--scripts/cmake/vcpkg_build_msbuild.cmake1
-rw-r--r--scripts/cmake/vcpkg_configure_cmake.cmake2
-rw-r--r--scripts/cmake/vcpkg_install_msbuild.cmake1
-rw-r--r--scripts/ports.cmake26
-rw-r--r--toolsrc/include/vcpkg/base/files.h4
-rw-r--r--toolsrc/include/vcpkg/commands.h9
-rw-r--r--toolsrc/include/vcpkg/help.h16
-rw-r--r--toolsrc/include/vcpkg/metrics.h3
-rw-r--r--toolsrc/include/vcpkg/vcpkgcmdarguments.h43
-rw-r--r--toolsrc/include/vcpkg/vcpkgpaths.h14
-rw-r--r--toolsrc/src/vcpkg-test/arguments.cpp16
-rw-r--r--toolsrc/src/vcpkg.cpp119
-rw-r--r--toolsrc/src/vcpkg/base/files.cpp26
-rw-r--r--toolsrc/src/vcpkg/base/system.cpp6
-rw-r--r--toolsrc/src/vcpkg/base/system.process.cpp12
-rw-r--r--toolsrc/src/vcpkg/binarycaching.cpp22
-rw-r--r--toolsrc/src/vcpkg/build.cpp63
-rw-r--r--toolsrc/src/vcpkg/commands.buildexternal.cpp2
-rw-r--r--toolsrc/src/vcpkg/commands.cache.cpp4
-rw-r--r--toolsrc/src/vcpkg/commands.ci.cpp2
-rw-r--r--toolsrc/src/vcpkg/commands.contact.cpp5
-rw-r--r--toolsrc/src/vcpkg/commands.cpp4
-rw-r--r--toolsrc/src/vcpkg/commands.create.cpp4
-rw-r--r--toolsrc/src/vcpkg/commands.dependinfo.cpp2
-rw-r--r--toolsrc/src/vcpkg/commands.edit.cpp2
-rw-r--r--toolsrc/src/vcpkg/commands.env.cpp2
-rw-r--r--toolsrc/src/vcpkg/commands.import.cpp2
-rw-r--r--toolsrc/src/vcpkg/commands.integrate.cpp38
-rw-r--r--toolsrc/src/vcpkg/commands.list.cpp2
-rw-r--r--toolsrc/src/vcpkg/commands.owns.cpp2
-rw-r--r--toolsrc/src/vcpkg/commands.porthistory.cpp2
-rw-r--r--toolsrc/src/vcpkg/commands.portsdiff.cpp2
-rw-r--r--toolsrc/src/vcpkg/commands.search.cpp2
-rw-r--r--toolsrc/src/vcpkg/commands.setinstalled.cpp2
-rw-r--r--toolsrc/src/vcpkg/commands.upgrade.cpp2
-rw-r--r--toolsrc/src/vcpkg/commands.version.cpp4
-rw-r--r--toolsrc/src/vcpkg/commands.xvsinstances.cpp2
-rw-r--r--toolsrc/src/vcpkg/export.cpp2
-rw-r--r--toolsrc/src/vcpkg/export.prefab.cpp28
-rw-r--r--toolsrc/src/vcpkg/help.cpp114
-rw-r--r--toolsrc/src/vcpkg/install.cpp2
-rw-r--r--toolsrc/src/vcpkg/metrics.cpp4
-rw-r--r--toolsrc/src/vcpkg/portfileprovider.cpp2
-rw-r--r--toolsrc/src/vcpkg/remove.cpp2
-rw-r--r--toolsrc/src/vcpkg/update.cpp2
-rw-r--r--toolsrc/src/vcpkg/vcpkgcmdarguments.cpp262
-rw-r--r--toolsrc/src/vcpkg/vcpkgpaths.cpp176
65 files changed, 675 insertions, 684 deletions
diff --git a/ports/libpq/CONTROL b/ports/libpq/CONTROL
index 8b2c9f249..b4e4abcfe 100644
--- a/ports/libpq/CONTROL
+++ b/ports/libpq/CONTROL
@@ -1,5 +1,5 @@
Source: libpq
-Version: 12.2-1
+Version: 12.2-2
Build-Depends: libpq[bonjour] (osx)
Supports: !uwp
Homepage: https://www.postgresql.org/
@@ -80,4 +80,4 @@ Build-Depends: libxslt
Description: Build with libxslt (--with-libxslt)
Feature: client
-Description: Build all client tools and libraries.
+Description: Build all client tools and libraries.
diff --git a/ports/libpq/portfile.cmake b/ports/libpq/portfile.cmake
index 84cd6c8a2..86281f71b 100644
--- a/ports/libpq/portfile.cmake
+++ b/ports/libpq/portfile.cmake
@@ -111,7 +111,7 @@ if(VCPKG_TARGET_IS_WINDOWS)
file(COPY ${SOURCE_FILE} DESTINATION "${BUILDPATH_${_buildtype}}")
endforeach()
message(STATUS "Copying libpq source files... done")
-
+
vcpkg_apply_patches(
SOURCE_PATH "${BUILDPATH_${_buildtype}}"
PATCHES patches/windows/Solution_${_buildtype}.patch
@@ -119,15 +119,15 @@ if(VCPKG_TARGET_IS_WINDOWS)
)
message(STATUS "Patches applied!")
file(COPY "${CURRENT_PORT_DIR}/config.pl" DESTINATION "${BUILDPATH_${_buildtype}}/src/tools/msvc")
-
+
set(MSPROJ_PERL "${BUILDPATH_${_buildtype}}/src/tools/msvc/MSBuildProject.pm")
file(READ "${MSPROJ_PERL}" _contents)
string(REPLACE "perl" "\"${PERL}\"" _contents "${_contents}")
file(WRITE "${MSPROJ_PERL}" "${_contents}")
-
+
set(CONFIG_FILE "${BUILDPATH_${_buildtype}}/src/tools/msvc/config.pl")
file(READ "${CONFIG_FILE}" _contents)
-
+
## ldap => undef, # --with-ldap ##done
## extraver => undef, # --with-extra-version=<string>
## gss => undef, # --with-gssapi=<path>
@@ -143,7 +143,7 @@ if(VCPKG_TARGET_IS_WINDOWS)
## xslt => undef, # --with-libxslt=<path> ##done
## iconv => undef, # (not in configure, path to iconv) ##done (needed by xml)
## zlib => undef # --with-zlib=<path> ##done
-
+
## Setup external dependencies
##"-DFEATURES=core;openssl;zlib" "-DALL_FEATURES=openssl;zlib;readline;libedit;perl;python;tcl;nls;kerberos;systemd;ldap;bsd;pam;llvm;icu;bonjour;uuid;xml;xslt;"
if("${FEATURES}" MATCHES "ldap")
@@ -183,7 +183,7 @@ if(VCPKG_TARGET_IS_WINDOWS)
if("${FEATURES}" MATCHES "zlib")
string(REPLACE "zlib => undef" "zlib => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}")
endif()
-
+
file(WRITE "${CONFIG_FILE}" "${_contents}")
file(WRITE "${BUILDPATH_${_buildtype}}/src/tools/msvc/buildenv.pl" "${buildenv_contents}")
vcpkg_get_windows_sdk(VCPKG_TARGET_PLATFORM_VERSION)
@@ -193,7 +193,8 @@ if(VCPKG_TARGET_IS_WINDOWS)
/p:WindowsTargetPlatformVersion=${VCPKG_TARGET_PLATFORM_VERSION}
/m
/p:ForceImportBeforeCppTargets=\"${SCRIPTS}/buildsystems/msbuild/vcpkg.targets\"
- /p:VcpkgTriplet=${TARGET_TRIPLET}"
+ /p:VcpkgTriplet=${TARGET_TRIPLET}
+ /p:VcpkgCurrentInstalledDir=\"${CURRENT_INSTALLED_DIR}\""
)
if(HAS_TOOLS)
if(VCPKG_TARGET_ARCHITECTURE STREQUAL x86)
@@ -241,7 +242,7 @@ if(VCPKG_TARGET_IS_WINDOWS)
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin)
endif()
-
+
if(NOT HAS_TOOLS)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/tools)
else()
@@ -290,7 +291,7 @@ endif()
#vcpkg_copy_pdbs()
#if(EXISTS "${CURRENT_PACKAGES_DIR}/debug/lib/libpq.lib")
- #RENAME debug library due to CMake. In general that is a bad idea but it will have consquences for the generated cmake targets
+ #RENAME debug library due to CMake. In general that is a bad idea but it will have consquences for the generated cmake targets
# of other ports if not renamed. Maybe a vcpkg_cmake_wrapper is required here to correct the target information if the rename is removed?
# file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/libpq.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/libpqd.lib")
#endif()
diff --git a/ports/qt5-base/CONTROL b/ports/qt5-base/CONTROL
index a27fe040c..71f4fe588 100644
--- a/ports/qt5-base/CONTROL
+++ b/ports/qt5-base/CONTROL
@@ -1,5 +1,5 @@
Source: qt5-base
-Version: 5.12.8-3
+Version: 5.12.8-4
Homepage: https://www.qt.io/
Description: Qt5 Application Framework Base Module. Includes Core, GUI, Widgets, Networking, SQL, Concurrent and other essential qt components.
Build-Depends: zlib, libjpeg-turbo, libpng, freetype, pcre2, harfbuzz, sqlite3, libpq, double-conversion, openssl, angle (!windows), egl-registry, icu (!uwp), fontconfig (!windows)
diff --git a/ports/qt5-base/cmake/find_qt_mkspec.cmake b/ports/qt5-base/cmake/find_qt_mkspec.cmake
index 035aec1ad..08fae07cf 100644
--- a/ports/qt5-base/cmake/find_qt_mkspec.cmake
+++ b/ports/qt5-base/cmake/find_qt_mkspec.cmake
@@ -77,10 +77,10 @@ function(find_qt_mkspec TARGET_PLATFORM_MKSPEC_OUT HOST_PLATFORM_MKSPEC_OUT EXT_
else()
endif()
foreach(_triplet ${_test_triplets})
- find_program(QMAKE_PATH qmake PATHS ${VCPKG_ROOT_DIR}/installed/${_triplet}/tools/qt5/bin NO_DEFAULT_PATHS)
- message(STATUS "Checking: ${VCPKG_ROOT_DIR}/installed/${_triplet}/tools/qt5/bin. ${QMAKE_PATH}")
+ find_program(QMAKE_PATH qmake PATHS ${_VCPKG_INSTALLED_DIR}/${_triplet}/tools/qt5/bin NO_DEFAULT_PATHS)
+ message(STATUS "Checking: ${_VCPKG_INSTALLED_DIR}/${_triplet}/tools/qt5/bin. ${QMAKE_PATH}")
if(QMAKE_PATH)
- set(_tmp_host_root "${VCPKG_ROOT_DIR}/installed/${_triplet}/tools/qt5")
+ set(_tmp_host_root "${_VCPKG_INSTALLED_DIR}/${_triplet}/tools/qt5")
set(_tmp_host_qmake ${QMAKE_PATH} PARENT_SCOPE)
message(STATUS "Qt host tools root dir within vcpkg: ${_tmp_host_root}")
break()
diff --git a/ports/shiva-sfml/CONTROL b/ports/shiva-sfml/CONTROL
index 0bd2f08c2..af5ad7b7a 100644
--- a/ports/shiva-sfml/CONTROL
+++ b/ports/shiva-sfml/CONTROL
@@ -1,4 +1,4 @@
Source: shiva-sfml
-Version: 1.0
+Version: 1.0-1
Description: shiva-sfml plugins of shiva C++ engine
Build-Depends: sfml (windows), shiva
diff --git a/ports/shiva-sfml/portfile.cmake b/ports/shiva-sfml/portfile.cmake
index d3b8d7d71..ea6969d04 100644
--- a/ports/shiva-sfml/portfile.cmake
+++ b/ports/shiva-sfml/portfile.cmake
@@ -12,7 +12,7 @@ vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
- -DSHIVA_BUILD_TESTS=OFF -DSHIVA_USE_SFML_AS_RENDERER=ON -DSHIVA_INSTALL_PLUGINS=ON -DSHIVA_BUILD_EXAMPLES=OFF
+ -DSHIVA_BUILD_TESTS=OFF -DSHIVA_USE_SFML_AS_RENDERER=ON -DSHIVA_INSTALL_PLUGINS=ON -DSHIVA_BUILD_EXAMPLES=OFF
)
vcpkg_install_cmake()
@@ -67,22 +67,22 @@ file(COPY ${PLUGINS_RELEASE} DESTINATION ${CURRENT_PACKAGES_DIR}/${SUFFIX_BINARY
file(COPY ${PLUGINS_DEBUG} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/${SUFFIX_BINARY}/shiva/plugins/shiva-sfml/Debug)
if (NOT VCPKG_CMAKE_SYSTEM_NAME)
- find_file(LUADLL lua.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/bin)
- find_file(FMTDLL fmt.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/bin)
- find_file(FLACDLL FLAC.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/bin)
- find_file(FREETYPEDLL freetype.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/bin)
- find_file(LIBBZ2DLL libbz2.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/bin)
- find_file(LIBPNG16DLL libpng16.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/bin)
- find_file(OGGDLL ogg.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/bin)
- find_file(OPENAL32DLL OpenAL32.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/bin)
- find_file(SFMLAUDIO2DLL sfml-audio-2.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/bin)
- find_file(SFMLGRAPHICS2DLL sfml-graphics-2.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/bin)
- find_file(SFMLSYSTEM2DLL sfml-system-2.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/bin)
- find_file(SFMLWINDOW2DLL sfml-window-2.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/bin)
- find_file(VORBISDLL vorbis.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/bin)
- find_file(VORBISENCDLL vorbisenc.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/bin)
- find_file(VORBISFILEDLL vorbisfile.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/bin)
- find_file(ZLIB1DLL zlib1.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/bin)
+ find_file(LUADLL lua.dll PATHS ${CURRENT_INSTALLED_DIR}/bin)
+ find_file(FMTDLL fmt.dll PATHS ${CURRENT_INSTALLED_DIR}/bin)
+ find_file(FLACDLL FLAC.dll PATHS ${CURRENT_INSTALLED_DIR}/bin)
+ find_file(FREETYPEDLL freetype.dll PATHS ${CURRENT_INSTALLED_DIR}/bin)
+ find_file(LIBBZ2DLL libbz2.dll PATHS ${CURRENT_INSTALLED_DIR}/bin)
+ find_file(LIBPNG16DLL libpng16.dll PATHS ${CURRENT_INSTALLED_DIR}/bin)
+ find_file(OGGDLL ogg.dll PATHS ${CURRENT_INSTALLED_DIR}/bin)
+ find_file(OPENAL32DLL OpenAL32.dll PATHS ${CURRENT_INSTALLED_DIR}/bin)
+ find_file(SFMLAUDIO2DLL sfml-audio-2.dll PATHS ${CURRENT_INSTALLED_DIR}/bin)
+ find_file(SFMLGRAPHICS2DLL sfml-graphics-2.dll PATHS ${CURRENT_INSTALLED_DIR}/bin)
+ find_file(SFMLSYSTEM2DLL sfml-system-2.dll PATHS ${CURRENT_INSTALLED_DIR}/bin)
+ find_file(SFMLWINDOW2DLL sfml-window-2.dll PATHS ${CURRENT_INSTALLED_DIR}/bin)
+ find_file(VORBISDLL vorbis.dll PATHS ${CURRENT_INSTALLED_DIR}/bin)
+ find_file(VORBISENCDLL vorbisenc.dll PATHS ${CURRENT_INSTALLED_DIR}/bin)
+ find_file(VORBISFILEDLL vorbisfile.dll PATHS ${CURRENT_INSTALLED_DIR}/bin)
+ find_file(ZLIB1DLL zlib1.dll PATHS ${CURRENT_INSTALLED_DIR}/bin)
set(DEPENDANCIES_RELEASE_DLL
${LUADLL}
${FMTDLL}
@@ -100,23 +100,23 @@ if (NOT VCPKG_CMAKE_SYSTEM_NAME)
${VORBISENCDLL}
${VORBISFILEDLL}
${ZLIB1DLL})
-
- find_file(LUADLL_D lua.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/debug/bin)
- find_file(FMTDLL_D fmtd.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/debug/bin)
- find_file(FLACDLL_D FLAC.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/debug/bin)
- find_file(FREETYPEDLL_D freetyped.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/debug/bin)
- find_file(LIBBZ2DLL_D libbz2d.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/debug/bin)
- find_file(LIBPNG16DLL_D libpng16d.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/debug/bin)
- find_file(OGGDLL_D ogg.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/debug/bin)
- find_file(OPENAL32DLL_D OpenAL32.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/debug/bin)
- find_file(SFMLAUDIO2DLL_D sfml-audio-d-2.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/debug/bin)
- find_file(SFMLGRAPHICS2DLL_D sfml-graphics-d-2.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/debug/bin)
- find_file(SFMLSYSTEM2DLL_D sfml-system-d-2.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/debug/bin)
- find_file(SFMLWINDOW2DLL_D sfml-window-d-2.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/debug/bin)
- find_file(VORBISDLL_D vorbis.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/debug/bin)
- find_file(VORBISENCDLL_D vorbisenc.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/debug/bin)
- find_file(VORBISFILEDLL_D vorbisfile.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/debug/bin)
- find_file(ZLIB1DLL_D zlibd1.dll PATHS ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}/debug/bin)
+
+ find_file(LUADLL_D lua.dll PATHS ${CURRENT_INSTALLED_DIR}/debug/bin)
+ find_file(FMTDLL_D fmtd.dll PATHS ${CURRENT_INSTALLED_DIR}/debug/bin)
+ find_file(FLACDLL_D FLAC.dll PATHS ${CURRENT_INSTALLED_DIR}/debug/bin)
+ find_file(FREETYPEDLL_D freetyped.dll PATHS ${CURRENT_INSTALLED_DIR}/debug/bin)
+ find_file(LIBBZ2DLL_D libbz2d.dll PATHS ${CURRENT_INSTALLED_DIR}/debug/bin)
+ find_file(LIBPNG16DLL_D libpng16d.dll PATHS ${CURRENT_INSTALLED_DIR}/debug/bin)
+ find_file(OGGDLL_D ogg.dll PATHS ${CURRENT_INSTALLED_DIR}/debug/bin)
+ find_file(OPENAL32DLL_D OpenAL32.dll PATHS ${CURRENT_INSTALLED_DIR}/debug/bin)
+ find_file(SFMLAUDIO2DLL_D sfml-audio-d-2.dll PATHS ${CURRENT_INSTALLED_DIR}/debug/bin)
+ find_file(SFMLGRAPHICS2DLL_D sfml-graphics-d-2.dll PATHS ${CURRENT_INSTALLED_DIR}/debug/bin)
+ find_file(SFMLSYSTEM2DLL_D sfml-system-d-2.dll PATHS ${CURRENT_INSTALLED_DIR}/debug/bin)
+ find_file(SFMLWINDOW2DLL_D sfml-window-d-2.dll PATHS ${CURRENT_INSTALLED_DIR}/debug/bin)
+ find_file(VORBISDLL_D vorbis.dll PATHS ${CURRENT_INSTALLED_DIR}/debug/bin)
+ find_file(VORBISENCDLL_D vorbisenc.dll PATHS ${CURRENT_INSTALLED_DIR}/debug/bin)
+ find_file(VORBISFILEDLL_D vorbisfile.dll PATHS ${CURRENT_INSTALLED_DIR}/debug/bin)
+ find_file(ZLIB1DLL_D zlibd1.dll PATHS ${CURRENT_INSTALLED_DIR}/debug/bin)
set(DEPENDANCIES_DEBUG_DLL
${LUADLL_D}
${FMTDLL_D}
@@ -135,7 +135,7 @@ if (NOT VCPKG_CMAKE_SYSTEM_NAME)
${VORBISFILEDLL_D}
${ZLIB1DLL_D}
)
-
+
file(COPY ${DEPENDANCIES_RELEASE_DLL} DESTINATION ${CURRENT_PACKAGES_DIR}/${SUFFIX_BINARY}/shiva/plugins/shiva-sfml/Release)
file(COPY ${DEPENDANCIES_DEBUG_DLL} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/${SUFFIX_BINARY}/shiva/plugins/shiva-sfml/Debug)
endif()
diff --git a/ports/spirv-tools/CONTROL b/ports/spirv-tools/CONTROL
index a075b87c5..3acb8e4f8 100644
--- a/ports/spirv-tools/CONTROL
+++ b/ports/spirv-tools/CONTROL
@@ -1,5 +1,5 @@
Source: spirv-tools
-Version: 2020.1
+Version: 2020.1-1
Homepage: https://github.com/KhronosGroup/SPIRV-Tools
Description: API and commands for processing SPIR-V modules
Build-Depends: spirv-headers \ No newline at end of file
diff --git a/ports/spirv-tools/portfile.cmake b/ports/spirv-tools/portfile.cmake
index 4741a206f..305a3fde5 100644
--- a/ports/spirv-tools/portfile.cmake
+++ b/ports/spirv-tools/portfile.cmake
@@ -20,7 +20,7 @@ vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
- -DSPIRV-Headers_SOURCE_DIR=${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET}
+ -DSPIRV-Headers_SOURCE_DIR=${CURRENT_INSTALLED_DIR}
-DSPIRV_WERROR=OFF
-DENABLE_SPIRV_TOOLS_INSTALL=ON
)
diff --git a/scripts/azure-pipelines/linux/azure-pipelines.yml b/scripts/azure-pipelines/linux/azure-pipelines.yml
index 022fc70e4..fc0977697 100644
--- a/scripts/azure-pipelines/linux/azure-pipelines.yml
+++ b/scripts/azure-pipelines/linux/azure-pipelines.yml
@@ -10,28 +10,26 @@ jobs:
clean: resources
timeoutInMinutes: 1440 # 1 day
steps:
- - bash: |
- df -h
- displayName: 'Report on Disk Space Before Environment'
- condition: always()
- - task: Bash@3
- displayName: 'Initialize Environment'
- inputs:
- filePath: scripts/azure-pipelines/linux/initialize-environment.sh
+ - bash: df -h
+ displayName: 'Report on Disk Space'
- bash: |
sudo mkdir /home/agent -m=777
sudo chown `id -u` /home/agent
exit 0
displayName: 'Create /home/agent'
+ # Note: /mnt is the Azure machines' temporary disk.
- bash: |
- df -h
- displayName: 'Report on Disk Space After Environment'
- condition: always()
+ sudo mkdir /mnt/vcpkg-ci -m=777
+ sudo mkdir /mnt/vcpkg-ci/downloads -m=777
+ exit 0
+ displayName: 'Create /mnt/vcpkg-ci/downloads'
- task: Bash@3
displayName: 'Build vcpkg'
inputs:
filePath: bootstrap-vcpkg.sh
arguments: "-buildTests"
+ env:
+ VCPKG_DOWNLOADS: '/mnt/vcpkg-ci/downloads'
- bash: toolsrc/build.rel/vcpkg-test
displayName: 'Run vcpkg tests'
- powershell: |
@@ -39,14 +37,14 @@ jobs:
$skipList = ./scripts/azure-pipelines/generate-skip-list.ps1 -Triplet "x64-linux" -BaselineFile "$(System.DefaultWorkingDirectory)/scripts/ci.baseline.txt"
mkdir $(System.ArtifactsDirectory)/xml-results
$env:HOME = '/home/agent'
- ./vcpkg ci x64-linux --x-xunit="$(System.ArtifactsDirectory)/xml-results/x64-linux.xml" --exclude=$skipList --binarycaching
+ ./vcpkg ci x64-linux --x-xunit="$(System.ArtifactsDirectory)/xml-results/x64-linux.xml" --exclude=$skipList --binarycaching --x-binarysource=clear`;files`,/archives`,upload --x-buildtrees-root=/mnt/vcpkg-ci/buildtrees --x-install-root=/mnt/vcpkg-ci/install --x-packages-root=/mnt/vcpkg-ci/packages --downloads-root=/mnt/vcpkg-ci/downloads
displayName: '** Test Modified Ports **'
- task: PowerShell@2
displayName: 'Analyze results and prepare test logs'
inputs:
failOnStderr: true
filePath: 'scripts/azure-pipelines/analyze-test-results.ps1'
- arguments: '-baselineFile $(System.DefaultWorkingDirectory)/scripts/ci.baseline.txt -logDir "$(System.ArtifactsDirectory)/xml-results" -outputDir "$(Build.ArtifactStagingDirectory)" -failurelogDir "archives/fail" -triplets "x64-linux" -errorOnRegression'
+ arguments: '-baselineFile $(System.DefaultWorkingDirectory)/scripts/ci.baseline.txt -logDir "$(System.ArtifactsDirectory)/xml-results" -outputDir "$(Build.ArtifactStagingDirectory)" -failurelogDir "/archives/fail" -triplets "x64-linux" -errorOnRegression'
- bash: |
df -h
displayName: 'Report on Disk Space After Build'
diff --git a/scripts/azure-pipelines/linux/initialize-environment.sh b/scripts/azure-pipelines/linux/initialize-environment.sh
deleted file mode 100755
index 1cbdd3326..000000000
--- a/scripts/azure-pipelines/linux/initialize-environment.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-# Copyright (c) Microsoft Corporation.
-# SPDX-License-Identifier: MIT
-
-# Cleans up the environment to prevent contamination across builds.
-if [ ! -d "archives" ]; then
- ln -s /archives archives
-fi
diff --git a/scripts/azure-pipelines/osx/azure-pipelines.yml b/scripts/azure-pipelines/osx/azure-pipelines.yml
index e51698c45..be410e6a2 100644
--- a/scripts/azure-pipelines/osx/azure-pipelines.yml
+++ b/scripts/azure-pipelines/osx/azure-pipelines.yml
@@ -33,20 +33,22 @@ jobs:
inputs:
filePath: bootstrap-vcpkg.sh
arguments: '-buildTests'
+ env:
+ VCPKG_DOWNLOADS: '/Users/vagrant/Data/downloads'
- bash: toolsrc/build.rel/vcpkg-test
displayName: 'Run vcpkg tests'
- powershell: |
- ./vcpkg x-ci-clean
- $skip_list = ./scripts/azure-pipelines/generate-skip-list.ps1 -Triplet "x64-osx" -BaselineFile "$(System.DefaultWorkingDirectory)/scripts/ci.baseline.txt"
+ ./vcpkg x-ci-clean --x-buildtrees-root=/Users/vagrant/Data/buildtrees --x-install-root=/Users/vagrant/Data/installed --x-packages-root=/Users/vagrant/Data/packages --downloads-root=/Users/vagrant/Data/downloads
+ $skipList = ./scripts/azure-pipelines/generate-skip-list.ps1 -Triplet "x64-osx" -BaselineFile "$(System.DefaultWorkingDirectory)/scripts/ci.baseline.txt"
mkdir $(System.ArtifactsDirectory)/xml-results
- ./vcpkg ci x64-osx --x-xunit="$(System.ArtifactsDirectory)/xml-results/x64-osx.xml" --exclude=$skip_list --binarycaching
+ ./vcpkg ci x64-osx --x-xunit="$(System.ArtifactsDirectory)/xml-results/x64-osx.xml" --exclude=$skipList --binarycaching --x-binarysource=clear`;files`,/Users/vagrant/Data/archives`,upload --x-buildtrees-root=/Users/vagrant/Data/buildtrees --x-install-root=/Users/vagrant/Data/installed --x-packages-root=/Users/vagrant/Data/packages --downloads-root=/Users/vagrant/Data/downloads
displayName: '** Test Modified Ports **'
- task: PowerShell@2
displayName: 'Analyze results and prepare test logs'
inputs:
failOnStderr: true
filePath: 'scripts/azure-pipelines/analyze-test-results.ps1'
- arguments: '-baselineFile $(System.DefaultWorkingDirectory)/scripts/ci.baseline.txt -logDir "$(System.ArtifactsDirectory)/xml-results" -outputDir "$(Build.ArtifactStagingDirectory)" -failurelogDir ~/Data/archives/fail -triplets "x64-osx" -errorOnRegression'
+ arguments: '-baselineFile $(System.DefaultWorkingDirectory)/scripts/ci.baseline.txt -logDir "$(System.ArtifactsDirectory)/xml-results" -outputDir "$(Build.ArtifactStagingDirectory)" -failurelogDir /Users/vagrant/Data/archives/fail -triplets "x64-osx" -errorOnRegression'
- bash: |
df -h
displayName: 'Report on Disk Space After Build'
diff --git a/scripts/azure-pipelines/osx/initialize-environment.sh b/scripts/azure-pipelines/osx/initialize-environment.sh
index 6f42a809a..e94790668 100755
--- a/scripts/azure-pipelines/osx/initialize-environment.sh
+++ b/scripts/azure-pipelines/osx/initialize-environment.sh
@@ -4,20 +4,5 @@
# Sets up the environment for MacOS runs of vcpkg CI
-mkdir -p ~/Data/installed || true
-ln -s ~/Data/installed
-
-mkdir -p ~/Data/buildtrees || true
-ln -s ~/Data/buildtrees
-
-mkdir -p ~/Data/packages || true
-ln -s ~/Data/packages
-
-rm archives || rm -rf archives || true
-ln -s ~/Data/archives
-
-mkdir -p ~/Data/downloads || true
-ln -s ~/Data/downloads
-
#delete downloaded files that have not been used in 7 days
-find downloads/ -maxdepth 1 -type f ! -atime 7 -exec rm -f {} \;
+find ~/Data/downloads/ -maxdepth 1 -type f ! -atime 7 -exec rm -f {} \;
diff --git a/scripts/azure-pipelines/windows/azure-pipelines.yml b/scripts/azure-pipelines/windows/azure-pipelines.yml
index 48f3908d2..f2b14657b 100644
--- a/scripts/azure-pipelines/windows/azure-pipelines.yml
+++ b/scripts/azure-pipelines/windows/azure-pipelines.yml
@@ -15,33 +15,32 @@ jobs:
displayName: 'Initialize Environment'
inputs:
filePath: 'scripts/azure-pipelines/windows/initialize-environment.ps1'
- - task: BatchScript@1
+ # Note: D: is the Azure machines' temporary disk.
+ - task: CmdLine@2
displayName: 'Build vcpkg'
inputs:
- filename: 'bootstrap-vcpkg.bat'
+ script: |
+ set VCPKG_DOWNLOADS=D:\downloads
+ .\bootstrap-vcpkg.bat
- powershell: |
- .\vcpkg.exe x-ci-clean
- $skipList = ./scripts/azure-pipelines/generate-skip-list.ps1 -Triplet "${{ parameters.triplet }}" -BaselineFile "$(System.DefaultWorkingDirectory)\scripts\ci.baseline.txt"
+ .\vcpkg.exe x-ci-clean --binarycaching --x-binarysource=clear`;files`,W:\`,upload --x-buildtrees-root=E:\buildtrees --x-install-root=E:\install --x-packages-root=E:\packages --downloads-root=D:\downloads
+ $skipList = ./scripts/azure-pipelines/generate-skip-list.ps1 -Triplet "${{ parameters.triplet }}" -BaselineFile .\scripts\ci.baseline.txt
mkdir $(System.ArtifactsDirectory)\xml-results
# WORKAROUND: the x86-windows flavors of these are needed for all cross-compilation, but they are not auto-installed.
# Install them so the CI succeeds:
if ( "${{ parameters.triplet }}" -notmatch "x86-windows" -and "${{ parameters.triplet }}" -notmatch "x64-windows" ) {
- .\vcpkg.exe install protobuf:x86-windows boost-build:x86-windows sqlite3:x86-windows
+ .\vcpkg.exe install protobuf:x86-windows boost-build:x86-windows sqlite3:x86-windows --binarycaching --x-binarysource=clear`;files`,W:\`,upload --x-buildtrees-root=E:\buildtrees --x-install-root=E:\install --x-packages-root=E:\packages --downloads-root=D:\downloads
}
- $command = ".\vcpkg.exe ci ${{ parameters.triplet }} --x-xunit=`"$(System.ArtifactsDirectory)\xml-results\${{ parameters.triplet }}.xml`" --exclude=$skipList --binarycaching"
+ .\vcpkg.exe ci ${{ parameters.triplet }} --x-xunit=`"$(System.ArtifactsDirectory)\xml-results\${{ parameters.triplet }}.xml`" --exclude=$skipList --binarycaching --x-binarysource=clear`;files`,W:\`,upload --x-buildtrees-root=E:\buildtrees --x-install-root=E:\install --x-packages-root=E:\packages --downloads-root=D:\downloads
Set-Content -Path 'run_ci.cmd' -Value $command -Encoding ASCII
- displayName: 'Write Test Modified Ports Batch File'
- - task: BatchScript@1
displayName: '** Test Modified Ports **'
- inputs:
- filename: 'run_ci.cmd'
- task: PowerShell@2
displayName: 'Analyze results and prepare test logs'
inputs:
failOnStderr: true
filePath: 'scripts/azure-pipelines/analyze-test-results.ps1'
- arguments: '-baselineFile "$(System.DefaultWorkingDirectory)\scripts\ci.baseline.txt" -logDir "$(System.ArtifactsDirectory)\xml-results" -failurelogDir "archives\fail" -outputDir "$(Build.ArtifactStagingDirectory)" -errorOnRegression -triplets "${{ parameters.triplet }}"'
+ arguments: '-baselineFile .\scripts\ci.baseline.txt -logDir "$(System.ArtifactsDirectory)\xml-results" -failurelogDir "W:\fail" -outputDir "$(Build.ArtifactStagingDirectory)" -errorOnRegression -triplets "${{ parameters.triplet }}"'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: ${{ parameters.triplet }} port build failure logs'
inputs:
diff --git a/scripts/azure-pipelines/windows/initialize-environment.ps1 b/scripts/azure-pipelines/windows/initialize-environment.ps1
index 4211a228a..4a252df49 100644
--- a/scripts/azure-pipelines/windows/initialize-environment.ps1
+++ b/scripts/azure-pipelines/windows/initialize-environment.ps1
@@ -22,13 +22,6 @@ Param(
$StorageAccountName = $env:StorageAccountName
$StorageAccountKey = $env:StorageAccountKey
-function Remove-DirectorySymlink {
- Param([string]$Path)
- if (Test-Path $Path) {
- [System.IO.Directory]::Delete($Path, $true)
- }
-}
-
Write-Host 'Setting up archives mount'
if (-Not (Test-Path W:)) {
net use W: "\\$StorageAccountName.file.core.windows.net\archives" /u:"AZURE\$StorageAccountName" $StorageAccountKey
@@ -52,40 +45,3 @@ if( Test-Path D:\downloads\tools\msys2 )
Write-Host "removing previously installed msys2"
Remove-Item D:\downloads\tools\msys2 -Recurse -Force
}
-
-Write-Host 'Setting up archives path...'
-if ([string]::IsNullOrWhiteSpace($ForceAllPortsToRebuildKey))
-{
- $archivesPath = 'W:\'
-}
-else
-{
- $archivesPath = "W:\force\$ForceAllPortsToRebuildKey"
- if (-Not (Test-Path $fullPath)) {
- Write-Host 'Creating $archivesPath'
- mkdir $archivesPath
- }
-}
-
-Write-Host "Linking archives => $archivesPath"
-if (-Not (Test-Path archives)) {
- cmd /c "mklink /D archives $archivesPath"
-}
-
-Write-Host 'Linking installed => E:\installed'
-if (-Not (Test-Path E:\installed)) {
- mkdir E:\installed
-}
-
-if (-Not (Test-Path installed)) {
- cmd /c "mklink /D installed E:\installed"
-}
-
-Write-Host 'Linking downloads => D:\downloads'
-if (-Not (Test-Path D:\downloads)) {
- mkdir D:\downloads
-}
-
-if (-Not (Test-Path downloads)) {
- cmd /c "mklink /D downloads D:\downloads"
-}
diff --git a/scripts/buildsystems/msbuild/vcpkg.targets b/scripts/buildsystems/msbuild/vcpkg.targets
index f956a4f33..de7334d09 100644
--- a/scripts/buildsystems/msbuild/vcpkg.targets
+++ b/scripts/buildsystems/msbuild/vcpkg.targets
@@ -54,7 +54,13 @@
<VcpkgNormalizedConfiguration Condition="$(VcpkgConfiguration.StartsWith('Debug'))">Debug</VcpkgNormalizedConfiguration>
<VcpkgNormalizedConfiguration Condition="$(VcpkgConfiguration.StartsWith('Release')) or '$(VcpkgConfiguration)' == 'RelWithDebInfo' or '$(VcpkgConfiguration)' == 'MinSizeRel'">Release</VcpkgNormalizedConfiguration>
<VcpkgRoot Condition="'$(VcpkgRoot)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), .vcpkg-root))\</VcpkgRoot>
- <VcpkgCurrentInstalledDir Condition="'$(VcpkgCurrentInstalledDir)' == ''">$(VcpkgRoot)installed\$(VcpkgTriplet)\</VcpkgCurrentInstalledDir>
+ <!-- We add a trailing slash if it is missing in a different property because msbuild's default behavior does not
+ allow us to override a console provided property here. -->
+ <VcpkgRootSanitized>$(VcpkgRoot)</VcpkgRootSanitized>
+ <VcpkgRootSanitized Condition="!$(VcpkgRootSanitized.EndsWith('\'))">$(VcpkgRootSanitized)\</VcpkgRootSanitized>
+ <VcpkgCurrentInstalledDirSanitized>$(VcpkgCurrentInstalledDir)</VcpkgCurrentInstalledDirSanitized>
+ <VcpkgCurrentInstalledDirSanitized Condition="'$(VcpkgCurrentInstalledDirSanitized)' == ''">$(VcpkgRootSanitized)installed\$(VcpkgTriplet)\</VcpkgCurrentInstalledDirSanitized>
+ <VcpkgCurrentInstalledDirSanitized Condition="!$(VcpkgCurrentInstalledDirSanitized.EndsWith('\'))">$(VcpkgCurrentInstalledDirSanitized)\</VcpkgCurrentInstalledDirSanitized>
<VcpkgApplocalDeps Condition="'$(VcpkgApplocalDeps)' == ''">true</VcpkgApplocalDeps>
<!-- Deactivate Autolinking if lld is used as a linker. (Until a better way to solve the problem is found!).
Tried to add /lib as a parameter to the linker call but was unable to find a way to pass it as the first parameter. -->
@@ -63,21 +69,21 @@
<ItemDefinitionGroup Condition="'$(VcpkgEnabled)' == 'true'">
<Link>
- <AdditionalDependencies Condition="'$(VcpkgNormalizedConfiguration)' == 'Debug' and '$(VcpkgAutoLink)' != 'false'">%(AdditionalDependencies);$(VcpkgCurrentInstalledDir)debug\lib\*.lib</AdditionalDependencies>
- <AdditionalDependencies Condition="'$(VcpkgNormalizedConfiguration)' == 'Release' and '$(VcpkgAutoLink)' != 'false'">%(AdditionalDependencies);$(VcpkgCurrentInstalledDir)lib\*.lib</AdditionalDependencies>
- <AdditionalLibraryDirectories Condition="'$(VcpkgNormalizedConfiguration)' == 'Release'">%(AdditionalLibraryDirectories);$(VcpkgCurrentInstalledDir)lib;$(VcpkgCurrentInstalledDir)lib\manual-link</AdditionalLibraryDirectories>
- <AdditionalLibraryDirectories Condition="'$(VcpkgNormalizedConfiguration)' == 'Debug'">%(AdditionalLibraryDirectories);$(VcpkgCurrentInstalledDir)debug\lib;$(VcpkgCurrentInstalledDir)debug\lib\manual-link</AdditionalLibraryDirectories>
+ <AdditionalDependencies Condition="'$(VcpkgNormalizedConfiguration)' == 'Debug' and '$(VcpkgAutoLink)' != 'false'">%(AdditionalDependencies);$(VcpkgCurrentInstalledDirSanitized)debug\lib\*.lib</AdditionalDependencies>
+ <AdditionalDependencies Condition="'$(VcpkgNormalizedConfiguration)' == 'Release' and '$(VcpkgAutoLink)' != 'false'">%(AdditionalDependencies);$(VcpkgCurrentInstalledDirSanitized)lib\*.lib</AdditionalDependencies>
+ <AdditionalLibraryDirectories Condition="'$(VcpkgNormalizedConfiguration)' == 'Release'">%(AdditionalLibraryDirectories);$(VcpkgCurrentInstalledDirSanitized)lib;$(VcpkgCurrentInstalledDirSanitized)lib\manual-link</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories Condition="'$(VcpkgNormalizedConfiguration)' == 'Debug'">%(AdditionalLibraryDirectories);$(VcpkgCurrentInstalledDirSanitized)debug\lib;$(VcpkgCurrentInstalledDirSanitized)debug\lib\manual-link</AdditionalLibraryDirectories>
</Link>
<ClCompile>
- <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(VcpkgCurrentInstalledDir)include</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(VcpkgCurrentInstalledDirSanitized)include</AdditionalIncludeDirectories>
</ClCompile>
<ResourceCompile>
- <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(VcpkgCurrentInstalledDir)include</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(VcpkgCurrentInstalledDirSanitized)include</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<Target Name="VcpkgTripletSelection" BeforeTargets="ClCompile">
- <Message Text="Using triplet &quot;$(VcpkgTriplet)&quot; from &quot;$(VcpkgCurrentInstalledDir)&quot;" Importance="Normal" Condition="'$(VcpkgEnabled)' == 'true'"/>
+ <Message Text="Using triplet &quot;$(VcpkgTriplet)&quot; from &quot;$(VcpkgCurrentInstalledDirSanitized)&quot;" Importance="Normal" Condition="'$(VcpkgEnabled)' == 'true'"/>
<Message Text="Not using Vcpkg because VcpkgEnabled is &quot;$(VcpkgEnabled)&quot;" Importance="Normal" Condition="'$(VcpkgEnabled)' != 'true'"/>
<Message Text="Vcpkg is unable to link because we cannot decide between Release and Debug libraries. Please define the property VcpkgConfiguration to be 'Release' or 'Debug' (currently '$(VcpkgConfiguration)')." Importance="High" Condition="'$(VcpkgEnabled)' == 'true' and '$(VcpkgNormalizedConfiguration)' == ''"/>
</Target>
@@ -87,11 +93,11 @@
File="$(TLogLocation)$(ProjectName).write.1u.tlog"
Lines="^$(TargetPath);$([System.IO.Path]::Combine($(ProjectDir),$(IntDir)))vcpkg.applocal.log" Encoding="Unicode"/>
<Exec Condition="$(VcpkgConfiguration.StartsWith('Debug'))"
- Command="$(SystemRoot)\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -noprofile -File %22$(MSBuildThisFileDirectory)applocal.ps1%22 %22$(TargetPath)%22 %22$(VcpkgCurrentInstalledDir)debug\bin%22 %22$(TLogLocation)$(ProjectName).write.1u.tlog%22 %22$(IntDir)vcpkg.applocal.log%22"
+ Command="$(SystemRoot)\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -noprofile -File %22$(MSBuildThisFileDirectory)applocal.ps1%22 %22$(TargetPath)%22 %22$(VcpkgCurrentInstalledDirSanitized)debug\bin%22 %22$(TLogLocation)$(ProjectName).write.1u.tlog%22 %22$(IntDir)vcpkg.applocal.log%22"
StandardOutputImportance="Normal">
</Exec>
<Exec Condition="$(VcpkgConfiguration.StartsWith('Release'))"
- Command="$(SystemRoot)\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -noprofile -File %22$(MSBuildThisFileDirectory)applocal.ps1%22 %22$(TargetPath)%22 %22$(VcpkgCurrentInstalledDir)bin%22 %22$(TLogLocation)$(ProjectName).write.1u.tlog%22 %22$(IntDir)vcpkg.applocal.log%22"
+ Command="$(SystemRoot)\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -noprofile -File %22$(MSBuildThisFileDirectory)applocal.ps1%22 %22$(TargetPath)%22 %22$(VcpkgCurrentInstalledDirSanitized)bin%22 %22$(TLogLocation)$(ProjectName).write.1u.tlog%22 %22$(IntDir)vcpkg.applocal.log%22"
StandardOutputImportance="Normal">
</Exec>
<ReadLinesFromFile File="$(IntDir)vcpkg.applocal.log">
diff --git a/scripts/buildsystems/vcpkg.cmake b/scripts/buildsystems/vcpkg.cmake
index 66f9ec921..03926336b 100644
--- a/scripts/buildsystems/vcpkg.cmake
+++ b/scripts/buildsystems/vcpkg.cmake
@@ -1,7 +1,7 @@
# Mark variables as used so cmake doesn't complain about them
mark_as_advanced(CMAKE_TOOLCHAIN_FILE)
-# VCPKG toolchain options.
+# VCPKG toolchain options.
option(VCPKG_VERBOSE "Enables messages from the VCPKG toolchain for debugging purposes." OFF)
mark_as_advanced(VCPKG_VERBOSE)
@@ -28,7 +28,7 @@ endif()
#If CMake does not have a mapping for MinSizeRel and RelWithDebInfo in imported targets
#it will map those configuration to the first valid configuration in CMAKE_CONFIGURATION_TYPES or the targets IMPORTED_CONFIGURATIONS.
-#In most cases this is the debug configuration which is wrong.
+#In most cases this is the debug configuration which is wrong.
if(NOT DEFINED CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL)
set(CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL "MinSizeRel;Release;")
if(VCPKG_VERBOSE)
@@ -151,7 +151,9 @@ if(NOT DEFINED _VCPKG_ROOT_DIR)
endwhile()
set(_VCPKG_ROOT_DIR ${_VCPKG_ROOT_DIR_CANDIDATE} CACHE INTERNAL "Vcpkg root directory")
endif()
-set(_VCPKG_INSTALLED_DIR ${_VCPKG_ROOT_DIR}/installed)
+if (NOT DEFINED _VCPKG_INSTALLED_DIR)
+ set(_VCPKG_INSTALLED_DIR ${_VCPKG_ROOT_DIR}/installed)
+endif()
if(NOT EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" AND NOT _CMAKE_IN_TRY_COMPILE AND NOT VCPKG_SUPPRESS_INSTALLED_LIBRARIES_WARNING)
message(WARNING "There are no libraries installed for the Vcpkg triplet ${VCPKG_TARGET_TRIPLET}.")
diff --git a/scripts/cmake/vcpkg_build_cmake.cmake b/scripts/cmake/vcpkg_build_cmake.cmake
index d049c907b..5274c29da 100644
--- a/scripts/cmake/vcpkg_build_cmake.cmake
+++ b/scripts/cmake/vcpkg_build_cmake.cmake
@@ -75,9 +75,9 @@ function(vcpkg_build_cmake)
if(_bc_ADD_BIN_TO_PATH)
set(_BACKUP_ENV_PATH "$ENV{PATH}")
if(BUILDTYPE STREQUAL "debug")
- vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/bin")
+ vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}/debug/bin")
else()
- vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin")
+ vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}/bin")
endif()
endif()
diff --git a/scripts/cmake/vcpkg_build_make.cmake b/scripts/cmake/vcpkg_build_make.cmake
index 5d1b8d636..17a755890 100644
--- a/scripts/cmake/vcpkg_build_make.cmake
+++ b/scripts/cmake/vcpkg_build_make.cmake
@@ -86,7 +86,7 @@ function(vcpkg_build_make)
set(MAKE_OPTS ${_bc_MAKE_OPTIONS} V=1 -j ${VCPKG_CONCURRENCY} -f Makefile ${_bc_BUILD_TARGET})
set(INSTALL_OPTS -j ${VCPKG_CONCURRENCY} install DESTDIR=${CURRENT_PACKAGES_DIR})
endif()
-
+
# Backup enviromnent variables
set(C_FLAGS_BACKUP "$ENV{CFLAGS}")
set(CXX_FLAGS_BACKUP "$ENV{CXXFLAGS}")
@@ -98,7 +98,7 @@ function(vcpkg_build_make)
_vcpkg_backup_env_variable(LD_LIBRARY_PATH)
_vcpkg_backup_env_variable(LIBRARY_PATH)
set(LIBPATH_BACKUP "$ENV{LIBPATH}")
-
+
# Setup include enviromnent
set(ENV{INCLUDE} "${_VCPKG_INSTALLED}/include${VCPKG_HOST_PATH_SEPARATOR}${INCLUDE_BACKUP}")
set(ENV{INCLUDE_PATH} "${_VCPKG_INSTALLED}/include${VCPKG_HOST_PATH_SEPARATOR}${INCLUDE_PATH_BACKUP}")
@@ -141,7 +141,7 @@ function(vcpkg_build_make)
endif()
set(CMAKE_BUILDTYPE "RELEASE")
endif()
-
+
set(WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}${SHORT_BUILDTYPE}")
message(STATUS "Building ${TARGET_TRIPLET}${SHORT_BUILDTYPE}")
@@ -149,9 +149,9 @@ function(vcpkg_build_make)
if(_bc_ADD_BIN_TO_PATH)
set(_BACKUP_ENV_PATH "$ENV{PATH}")
if(BUILDTYPE STREQUAL "debug")
- vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/bin")
+ vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}/debug/bin")
else()
- vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin")
+ vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}/bin")
endif()
endif()
@@ -159,15 +159,15 @@ function(vcpkg_build_make)
set(TMP_CFLAGS "${C_FLAGS_GLOBAL} ${VCPKG_C_FLAGS_${CMAKE_BUILDTYPE}}")
string(REGEX REPLACE "[ \t]+/" " -" TMP_CFLAGS "${TMP_CFLAGS}")
set(ENV{CFLAGS} ${TMP_CFLAGS})
-
+
set(TMP_CXXFLAGS "${CXX_FLAGS_GLOBAL} ${VCPKG_CXX_FLAGS_${CMAKE_BUILDTYPE}}")
string(REGEX REPLACE "[ \t]+/" " -" TMP_CXXFLAGS "${TMP_CXXFLAGS}")
set(ENV{CXXFLAGS} ${TMP_CXXFLAGS})
-
+
set(TMP_LDFLAGS "${LD_FLAGS_GLOBAL} ${VCPKG_LINKER_FLAGS_${CMAKE_BUILDTYPE}}")
string(REGEX REPLACE "[ \t]+/" " -" TMP_LDFLAGS "${TMP_LDFLAGS}")
set(ENV{LDFLAGS} ${TMP_LDFLAGS})
-
+
string(REPLACE " " "\ " _VCPKG_INSTALLED_PKGCONF "${CURRENT_INSTALLED_DIR}")
string(REGEX REPLACE "([a-zA-Z]):/" "/\\1/" _VCPKG_INSTALLED_PKGCONF "${_VCPKG_INSTALLED_PKGCONF}")
string(REPLACE "\\" "/" _VCPKG_INSTALLED_PKGCONF "${_VCPKG_INSTALLED_PKGCONF}")
@@ -176,7 +176,7 @@ function(vcpkg_build_make)
else()
set(ENV{VCPKG_PKG_PREFIX} ${_VCPKG_INSTALLED_PKGCONF})
endif()
-
+
else()
set(ENV{CFLAGS} "${C_FLAGS_GLOBAL} ${VCPKG_C_FLAGS_${CMAKE_BUILDTYPE}}")
set(ENV{CXXFLAGS} "${CXX_FLAGS_GLOBAL} ${VCPKG_CXX_FLAGS_${CMAKE_BUILDTYPE}}")
@@ -226,15 +226,15 @@ function(vcpkg_build_make)
set(SHORT_BUILDTYPE "-rel")
endif()
endif()
-
+
message(STATUS "Installing ${TARGET_TRIPLET}${SHORT_BUILDTYPE}")
-
+
if(MAKE_BASH)
set(MAKE_CMD_LINE "${MAKE_COMMAND} ${INSTALL_OPTS}")
else()
set(MAKE_CMD_LINE ${MAKE_COMMAND} ${INSTALL_OPTS})
endif()
-
+
set(WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}${SHORT_BUILDTYPE}")
vcpkg_execute_build_process(
COMMAND ${MAKE_BASH} ${MAKE_CMD_LINE}
@@ -266,6 +266,6 @@ function(vcpkg_build_make)
if (CMAKE_HOST_WIN32)
set(ENV{PATH} "${PATH_GLOBAL}")
endif()
-
+
endfunction()
diff --git a/scripts/cmake/vcpkg_build_msbuild.cmake b/scripts/cmake/vcpkg_build_msbuild.cmake
index cfd429da2..67ff3d3ae 100644
--- a/scripts/cmake/vcpkg_build_msbuild.cmake
+++ b/scripts/cmake/vcpkg_build_msbuild.cmake
@@ -110,6 +110,7 @@ function(vcpkg_build_msbuild)
APPEND _csc_OPTIONS
/p:ForceImportBeforeCppTargets=${SCRIPTS}/buildsystems/msbuild/vcpkg.targets
"/p:VcpkgTriplet=${TARGET_TRIPLET}"
+ "/p:VcpkgCurrentInstalledDir=${CURRENT_INSTALLED_DIR}"
)
endif()
diff --git a/scripts/cmake/vcpkg_configure_cmake.cmake b/scripts/cmake/vcpkg_configure_cmake.cmake
index ab65a5683..4debcb718 100644
--- a/scripts/cmake/vcpkg_configure_cmake.cmake
+++ b/scripts/cmake/vcpkg_configure_cmake.cmake
@@ -236,6 +236,8 @@ function(vcpkg_configure_cmake)
"-DVCPKG_TARGET_ARCHITECTURE=${VCPKG_TARGET_ARCHITECTURE}"
"-DCMAKE_INSTALL_LIBDIR:STRING=lib"
"-DCMAKE_INSTALL_BINDIR:STRING=bin"
+ "-D_VCPKG_ROOT_DIR=${VCPKG_ROOT_DIR}"
+ "-D_VCPKG_INSTALLED_DIR=${_VCPKG_INSTALLED_DIR}"
)
if(DEFINED ARCH)
diff --git a/scripts/cmake/vcpkg_install_msbuild.cmake b/scripts/cmake/vcpkg_install_msbuild.cmake
index 01bf49f02..8fc0298e0 100644
--- a/scripts/cmake/vcpkg_install_msbuild.cmake
+++ b/scripts/cmake/vcpkg_install_msbuild.cmake
@@ -137,6 +137,7 @@ function(vcpkg_install_msbuild)
/p:UseIntelMKL=No
/p:WindowsTargetPlatformVersion=${_csc_TARGET_PLATFORM_VERSION}
/p:VcpkgTriplet=${TARGET_TRIPLET}
+ "/p:VcpkgCurrentInstalledDir=${CURRENT_INSTALLED_DIR}"
/m
)
diff --git a/scripts/ports.cmake b/scripts/ports.cmake
index fcec5ad2f..9b33745f9 100644
--- a/scripts/ports.cmake
+++ b/scripts/ports.cmake
@@ -6,34 +6,20 @@ macro(debug_message)
endif()
endmacro()
-#Detect .vcpkg-root to figure VCPKG_ROOT_DIR, starting from triplet folder.
-set(VCPKG_ROOT_DIR_CANDIDATE ${CMAKE_CURRENT_LIST_DIR})
-
-if(DEFINED VCPKG_ROOT_PATH)
- set(VCPKG_ROOT_DIR_CANDIDATE ${VCPKG_ROOT_PATH})
-else()
+if((NOT DEFINED VCPKG_ROOT_DIR)
+ OR (NOT DEFINED DOWNLOADS)
+ OR (NOT DEFINED _VCPKG_INSTALLED_DIR)
+ OR (NOT DEFINED PACKAGES_DIR)
+ OR (NOT DEFINED BUILDTREES_DIR))
message(FATAL_ERROR [[
Your vcpkg executable is outdated and is not compatible with the current CMake scripts.
Please re-build vcpkg by running bootstrap-vcpkg.
]])
endif()
-# fixup Windows drive letter to uppercase.
-get_filename_component(VCPKG_ROOT_DIR_CANDIDATE ${VCPKG_ROOT_DIR_CANDIDATE} ABSOLUTE)
-
-# Validate VCPKG_ROOT_DIR_CANDIDATE
-if (NOT EXISTS "${VCPKG_ROOT_DIR_CANDIDATE}/.vcpkg-root")
- message(FATAL_ERROR "Could not find .vcpkg-root")
-endif()
-
-set(VCPKG_ROOT_DIR ${VCPKG_ROOT_DIR_CANDIDATE})
-
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
-set(CURRENT_INSTALLED_DIR ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET} CACHE PATH "Location to install final packages")
-set(DOWNLOADS ${VCPKG_ROOT_DIR}/downloads CACHE PATH "Location to download sources and tools")
+set(CURRENT_INSTALLED_DIR ${_VCPKG_INSTALLED_DIR}/${TARGET_TRIPLET} CACHE PATH "Location to install final packages")
set(SCRIPTS ${CMAKE_CURRENT_LIST_DIR} CACHE PATH "Location to stored scripts")
-set(PACKAGES_DIR ${VCPKG_ROOT_DIR}/packages CACHE PATH "Location to store package images")
-set(BUILDTREES_DIR ${VCPKG_ROOT_DIR}/buildtrees CACHE PATH "Location to perform actual extract+config+build")
if(PORT)
set(CURRENT_BUILDTREES_DIR ${BUILDTREES_DIR}/${PORT})
diff --git a/toolsrc/include/vcpkg/base/files.h b/toolsrc/include/vcpkg/base/files.h
index 0fba3a55f..909029b55 100644
--- a/toolsrc/include/vcpkg/base/files.h
+++ b/toolsrc/include/vcpkg/base/files.h
@@ -19,10 +19,10 @@ namespace fs
#endif
using stdfs::copy_options;
+ using stdfs::directory_iterator;
using stdfs::path;
using stdfs::perms;
using stdfs::u8path;
- using stdfs::directory_iterator;
#if defined(_WIN32)
enum class file_type
@@ -166,6 +166,8 @@ namespace vcpkg::Files
fs::path canonical(const fs::path& path, ignore_errors_t) const;
virtual fs::path current_path(std::error_code&) const = 0;
fs::path current_path(LineInfo li) const;
+ virtual void current_path(const fs::path& path, std::error_code&) = 0;
+ void current_path(const fs::path& path, LineInfo li);
virtual std::vector<fs::path> find_from_PATH(const std::string& name) const = 0;
};
diff --git a/toolsrc/include/vcpkg/commands.h b/toolsrc/include/vcpkg/commands.h
index 55d6bd7aa..c4b231433 100644
--- a/toolsrc/include/vcpkg/commands.h
+++ b/toolsrc/include/vcpkg/commands.h
@@ -14,7 +14,7 @@ namespace vcpkg::Commands
{
using CommandTypeA = void (*)(const VcpkgCmdArguments& args, const VcpkgPaths& paths, Triplet default_triplet);
using CommandTypeB = void (*)(const VcpkgCmdArguments& args, const VcpkgPaths& paths);
- using CommandTypeC = void (*)(const VcpkgCmdArguments& args);
+ using CommandTypeC = void (*)(const VcpkgCmdArguments& args, Files::Filesystem& fs);
namespace BuildExternal
{
@@ -92,10 +92,11 @@ namespace vcpkg::Commands
namespace Integrate
{
- extern const char* const INTEGRATE_COMMAND_HELPSTRING;
extern const CommandStructure COMMAND_STRUCTURE;
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths);
+ void append_helpstring(HelpTableFormatter& table);
+ std::string get_helpstring();
}
namespace PortsDiff
@@ -118,14 +119,14 @@ namespace vcpkg::Commands
const char* base_version();
const std::string& version();
void warn_if_vcpkg_version_mismatch(const VcpkgPaths& paths);
- void perform_and_exit(const VcpkgCmdArguments& args);
+ void perform_and_exit(const VcpkgCmdArguments& args, Files::Filesystem& fs);
}
namespace Contact
{
extern const CommandStructure COMMAND_STRUCTURE;
const std::string& email();
- void perform_and_exit(const VcpkgCmdArguments& args);
+ void perform_and_exit(const VcpkgCmdArguments& args, Files::Filesystem& fs);
}
namespace X_VSInstances
diff --git a/toolsrc/include/vcpkg/help.h b/toolsrc/include/vcpkg/help.h
index 87ce60b76..97bc11864 100644
--- a/toolsrc/include/vcpkg/help.h
+++ b/toolsrc/include/vcpkg/help.h
@@ -12,20 +12,4 @@ namespace vcpkg::Help
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths);
void help_topic_valid_triplet(const VcpkgPaths& paths);
-
- void print_usage();
-
- std::string create_example_string(const std::string& command_and_arguments);
-
- struct HelpTableFormatter
- {
- void format(StringView col1, StringView col2);
-
- std::string m_str;
-
- private:
- void newline_indent();
- void indent();
- };
-
}
diff --git a/toolsrc/include/vcpkg/metrics.h b/toolsrc/include/vcpkg/metrics.h
index c56a227f3..832da90ce 100644
--- a/toolsrc/include/vcpkg/metrics.h
+++ b/toolsrc/include/vcpkg/metrics.h
@@ -1,6 +1,7 @@
#pragma once
#include <vcpkg/base/util.h>
+#include <vcpkg/base/files.h>
#include <string>
@@ -21,7 +22,7 @@ namespace vcpkg::Metrics
bool metrics_enabled();
void upload(const std::string& payload);
- void flush();
+ void flush(Files::Filesystem& fs);
};
extern Util::LockGuarded<Metrics> g_metrics;
diff --git a/toolsrc/include/vcpkg/vcpkgcmdarguments.h b/toolsrc/include/vcpkg/vcpkgcmdarguments.h
index f8602b1e9..4856f6db1 100644
--- a/toolsrc/include/vcpkg/vcpkgcmdarguments.h
+++ b/toolsrc/include/vcpkg/vcpkgcmdarguments.h
@@ -3,6 +3,7 @@
#include <vcpkg/base/optional.h>
#include <vcpkg/base/span.h>
#include <vcpkg/base/stringliteral.h>
+#include <vcpkg/base/files.h>
#include <memory>
#include <unordered_map>
@@ -72,7 +73,8 @@ namespace vcpkg
std::vector<std::string> (*valid_arguments)(const VcpkgPaths& paths);
};
- void display_usage(const CommandStructure& command_structure);
+ void print_usage();
+ void print_usage(const CommandStructure& command_structure);
#if defined(_WIN32)
using CommandLineCharType = wchar_t;
@@ -80,33 +82,62 @@ namespace vcpkg
using CommandLineCharType = char;
#endif
+ std::string create_example_string(const std::string& command_and_arguments);
+
+ std::string format_environment_variable(StringLiteral lit);
+
+ struct HelpTableFormatter
+ {
+ void format(StringView col1, StringView col2);
+ void example(StringView example_text);
+ void header(StringView name);
+ void blank();
+
+ std::string m_str;
+ };
+
struct VcpkgCmdArguments
{
- static VcpkgCmdArguments create_from_command_line(const int argc, const CommandLineCharType* const* const argv);
+ static VcpkgCmdArguments create_from_command_line(const Files::Filesystem& fs,
+ const int argc,
+ const CommandLineCharType* const* const argv);
static VcpkgCmdArguments create_from_arg_sequence(const std::string* arg_begin, const std::string* arg_end);
+ static void append_common_options(HelpTableFormatter& target);
+
std::unique_ptr<std::string> vcpkg_root_dir;
+
+ std::unique_ptr<std::string> buildtrees_root_dir;
+ std::unique_ptr<std::string> downloads_root_dir;
std::unique_ptr<std::string> install_root_dir;
+ std::unique_ptr<std::string> packages_root_dir;
std::unique_ptr<std::string> scripts_root_dir;
+
+ std::unique_ptr<std::string> default_visual_studio_path;
+
std::unique_ptr<std::string> triplet;
std::unique_ptr<std::vector<std::string>> overlay_ports;
std::unique_ptr<std::vector<std::string>> overlay_triplets;
+
std::vector<std::string> binarysources;
+
Optional<bool> debug = nullopt;
- Optional<bool> sendmetrics = nullopt;
+ Optional<bool> send_metrics = nullopt;
// fully disable metrics -- both printing and sending
Optional<bool> disable_metrics = nullopt;
- Optional<bool> printmetrics = nullopt;
+ Optional<bool> print_metrics = nullopt;
// feature flags
- Optional<bool> featurepackages = nullopt;
- Optional<bool> binarycaching = nullopt;
+ Optional<bool> feature_packages = nullopt;
+ Optional<bool> binary_caching = nullopt;
std::string command;
std::vector<std::string> command_arguments;
ParsedArguments parse_arguments(const CommandStructure& command_structure) const;
+ void imbue_from_environment();
+
private:
std::unordered_map<std::string, Optional<std::vector<std::string>>> optional_command_arguments;
};
diff --git a/toolsrc/include/vcpkg/vcpkgpaths.h b/toolsrc/include/vcpkg/vcpkgpaths.h
index 2588abf4d..2b7faffd9 100644
--- a/toolsrc/include/vcpkg/vcpkgpaths.h
+++ b/toolsrc/include/vcpkg/vcpkgpaths.h
@@ -3,6 +3,7 @@
#include <vcpkg/binaryparagraph.h>
#include <vcpkg/packagespec.h>
#include <vcpkg/tools.h>
+#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/base/cache.h>
#include <vcpkg/base/expected.h>
@@ -57,12 +58,7 @@ namespace vcpkg
TripletFile(const std::string& name, const fs::path& location) : name(name), location(location) {}
};
- static Expected<VcpkgPaths> create(const fs::path& vcpkg_root_dir,
- const Optional<fs::path>& install_root_dir,
- const Optional<fs::path>& vcpkg_scripts_root_dir,
- const std::string& default_vs_path,
- const std::vector<std::string>* triplets_dirs,
- fs::path original_cwd);
+ VcpkgPaths(Files::Filesystem& filesystem, const VcpkgCmdArguments& args);
fs::path package_dir(const PackageSpec& spec) const;
fs::path build_info_file_path(const PackageSpec& spec) const;
@@ -75,14 +71,16 @@ namespace vcpkg
fs::path original_cwd;
fs::path root;
- fs::path packages;
+
fs::path buildtrees;
fs::path downloads;
+ fs::path packages;
fs::path ports;
fs::path installed;
fs::path triplets;
fs::path community_triplets;
fs::path scripts;
+ fs::path prefab;
fs::path tools;
fs::path buildsystems;
@@ -114,6 +112,8 @@ namespace vcpkg
fs::path default_vs_path;
std::vector<fs::path> triplets_dirs;
+ Files::Filesystem* fsPtr;
+
mutable std::unique_ptr<ToolCache> m_tool_cache;
mutable vcpkg::Cache<Triplet, fs::path> m_triplets_cache;
};
diff --git a/toolsrc/src/vcpkg-test/arguments.cpp b/toolsrc/src/vcpkg-test/arguments.cpp
index c63a31396..448a5035c 100644
--- a/toolsrc/src/vcpkg-test/arguments.cpp
+++ b/toolsrc/src/vcpkg-test/arguments.cpp
@@ -27,10 +27,10 @@ TEST_CASE ("VcpkgCmdArguments from lowercase argument sequence", "[arguments]")
REQUIRE(*v.scripts_root_dir == "C:\\scripts");
REQUIRE(v.debug);
REQUIRE(*v.debug.get());
- REQUIRE(v.sendmetrics);
- REQUIRE(*v.sendmetrics.get());
- REQUIRE(v.printmetrics);
- REQUIRE(*v.printmetrics.get());
+ REQUIRE(v.send_metrics);
+ REQUIRE(*v.send_metrics.get());
+ REQUIRE(v.print_metrics);
+ REQUIRE(*v.print_metrics.get());
REQUIRE(v.overlay_ports->size() == 2);
REQUIRE(v.overlay_ports->at(0) == "C:\\ports1");
@@ -59,10 +59,10 @@ TEST_CASE ("VcpkgCmdArguments from uppercase argument sequence", "[arguments]")
REQUIRE(*v.scripts_root_dir == "C:\\scripts");
REQUIRE(v.debug);
REQUIRE(*v.debug.get());
- REQUIRE(v.sendmetrics);
- REQUIRE(*v.sendmetrics.get());
- REQUIRE(v.printmetrics);
- REQUIRE(*v.printmetrics.get());
+ REQUIRE(v.send_metrics);
+ REQUIRE(*v.send_metrics.get());
+ REQUIRE(v.print_metrics);
+ REQUIRE(*v.print_metrics.get());
REQUIRE(v.overlay_ports->size() == 2);
REQUIRE(v.overlay_ports->at(0) == "C:\\ports1");
diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp
index 95cd39778..d4b51e96b 100644
--- a/toolsrc/src/vcpkg.cpp
+++ b/toolsrc/src/vcpkg.cpp
@@ -38,18 +38,16 @@ static constexpr int SURVEY_INITIAL_OFFSET_IN_HOURS = SURVEY_INTERVAL_IN_HOURS -
static void invalid_command(const std::string& cmd)
{
System::print2(System::Color::error, "invalid command: ", cmd, '\n');
- Help::print_usage();
+ print_usage();
Checks::exit_fail(VCPKG_LINE_INFO);
}
-static void inner(const VcpkgCmdArguments& args)
+static void inner(vcpkg::Files::Filesystem& fs, const VcpkgCmdArguments& args)
{
- auto& fs = Files::get_real_filesystem();
-
Metrics::g_metrics.lock()->track_property("command", args.command);
if (args.command.empty())
{
- Help::print_usage();
+ print_usage();
Checks::exit_fail(VCPKG_LINE_INFO);
}
@@ -63,86 +61,18 @@ static void inner(const VcpkgCmdArguments& args)
return &*it;
}
else
+ {
return static_cast<decltype(&*it)>(nullptr);
+ }
};
if (const auto command_function = find_command(Commands::get_available_commands_type_c()))
{
- return command_function->function(args);
- }
-
- fs::path vcpkg_root_dir;
- if (args.vcpkg_root_dir)
- {
- vcpkg_root_dir = fs.absolute(VCPKG_LINE_INFO, fs::u8path(*args.vcpkg_root_dir));
- }
- else
- {
- const auto vcpkg_root_dir_env = System::get_environment_variable("VCPKG_ROOT");
- if (const auto v = vcpkg_root_dir_env.get())
- {
- vcpkg_root_dir = fs.absolute(VCPKG_LINE_INFO, *v);
- }
- else
- {
- const fs::path current_path = fs.current_path(VCPKG_LINE_INFO);
- vcpkg_root_dir = fs.find_file_recursively_up(current_path, ".vcpkg-root");
-
- if (vcpkg_root_dir.empty())
- {
- vcpkg_root_dir = fs.find_file_recursively_up(
- fs.absolute(VCPKG_LINE_INFO, System::get_exe_path_of_current_process()), ".vcpkg-root");
- }
- }
- }
-
- Checks::check_exit(VCPKG_LINE_INFO, !vcpkg_root_dir.empty(), "Error: Could not detect vcpkg-root.");
-
- Debug::print("Using vcpkg-root: ", vcpkg_root_dir.u8string(), '\n');
-
- Optional<fs::path> install_root_dir;
- if (args.install_root_dir)
- {
- install_root_dir = Files::get_real_filesystem().canonical(VCPKG_LINE_INFO, fs::u8path(*args.install_root_dir));
- Debug::print("Using install-root: ", install_root_dir.value_or_exit(VCPKG_LINE_INFO).u8string(), '\n');
- }
-
- Optional<fs::path> vcpkg_scripts_root_dir;
- if (args.scripts_root_dir)
- {
- vcpkg_scripts_root_dir =
- Files::get_real_filesystem().canonical(VCPKG_LINE_INFO, fs::u8path(*args.scripts_root_dir));
- Debug::print("Using scripts-root: ", vcpkg_scripts_root_dir.value_or_exit(VCPKG_LINE_INFO).u8string(), '\n');
+ return command_function->function(args, fs);
}
- auto default_vs_path = System::get_environment_variable("VCPKG_VISUAL_STUDIO_PATH").value_or("");
-
- auto original_cwd = Files::get_real_filesystem().current_path(VCPKG_LINE_INFO);
-
- const Expected<VcpkgPaths> expected_paths = VcpkgPaths::create(vcpkg_root_dir,
- install_root_dir,
- vcpkg_scripts_root_dir,
- default_vs_path,
- args.overlay_triplets.get(),
- original_cwd);
- Checks::check_exit(VCPKG_LINE_INFO,
- !expected_paths.error(),
- "Error: Invalid vcpkg root directory %s: %s",
- vcpkg_root_dir.string(),
- expected_paths.error().message());
- const VcpkgPaths& paths = expected_paths.value_or_exit(VCPKG_LINE_INFO);
-
-#if defined(_WIN32)
- const int exit_code = _wchdir(paths.root.c_str());
-#else
- const int exit_code = chdir(paths.root.c_str());
-#endif
- Checks::check_exit(
- VCPKG_LINE_INFO,
- exit_code == 0,
- "Changing the working directory to the vcpkg root directory failed. Did you incorrectly define the VCPKG_ROOT "
- "environment variable, or did you mistakenly create a file named .vcpkg-root somewhere?");
-
+ const VcpkgPaths paths(fs, args);
+ fs.current_path(paths.root, VCPKG_LINE_INFO);
if (args.command == "install" || args.command == "remove" || args.command == "export" || args.command == "update")
{
Commands::Version::warn_if_vcpkg_version_mismatch(paths);
@@ -213,10 +143,8 @@ static void inner(const VcpkgCmdArguments& args)
return invalid_command(args.command);
}
-static void load_config()
+static void load_config(vcpkg::Files::Filesystem& fs)
{
- auto& fs = Files::get_real_filesystem();
-
auto config = UserConfig::try_read_data(fs);
bool write_config = false;
@@ -280,6 +208,7 @@ int main(const int argc, const char* const* const argv)
{
if (argc == 0) std::abort();
+ auto& fs = Files::get_real_filesystem();
*GlobalState::timer.lock() = Chrono::ElapsedTimer::create_started();
#if defined(_WIN32)
@@ -301,7 +230,7 @@ int main(const int argc, const char* const* const argv)
auto metrics = Metrics::g_metrics.lock();
metrics->track_metric("elapsed_us", elapsed_us_inner);
Debug::g_debugging = false;
- metrics->flush();
+ metrics->flush(Files::get_real_filesystem());
#if defined(_WIN32)
if (GlobalState::g_init_console_initialized)
@@ -325,7 +254,7 @@ int main(const int argc, const char* const* const argv)
System::register_console_ctrl_handler();
- load_config();
+ load_config(fs);
const auto vcpkg_feature_flags_env = System::get_environment_variable("VCPKG_FEATURE_FLAGS");
if (const auto v = vcpkg_feature_flags_env.get())
@@ -333,27 +262,21 @@ int main(const int argc, const char* const* const argv)
auto flags = Strings::split(*v, ',');
if (std::find(flags.begin(), flags.end(), "binarycaching") != flags.end()) GlobalState::g_binary_caching = true;
}
- const auto vcpkg_disable_metrics_env = System::get_environment_variable("VCPKG_DISABLE_METRICS");
- if (vcpkg_disable_metrics_env.has_value())
- {
- Metrics::g_metrics.lock()->set_disabled(true);
- }
-
- const VcpkgCmdArguments args = VcpkgCmdArguments::create_from_command_line(argc, argv);
-
- if (const auto p = args.binarycaching.get()) GlobalState::g_binary_caching = *p;
- if (const auto p = args.printmetrics.get()) Metrics::g_metrics.lock()->set_print_metrics(*p);
- if (const auto p = args.sendmetrics.get()) Metrics::g_metrics.lock()->set_send_metrics(*p);
+ VcpkgCmdArguments args = VcpkgCmdArguments::create_from_command_line(fs, argc, argv);
+ args.imbue_from_environment();
+ if (const auto p = args.binary_caching.get()) GlobalState::g_binary_caching = *p;
+ if (const auto p = args.print_metrics.get()) Metrics::g_metrics.lock()->set_print_metrics(*p);
+ if (const auto p = args.send_metrics.get()) Metrics::g_metrics.lock()->set_send_metrics(*p);
if (const auto p = args.disable_metrics.get()) Metrics::g_metrics.lock()->set_disabled(*p);
if (const auto p = args.debug.get()) Debug::g_debugging = *p;
- if (args.sendmetrics.has_value() && !Metrics::g_metrics.lock()->metrics_enabled())
+ if (args.send_metrics.has_value() && !Metrics::g_metrics.lock()->metrics_enabled())
{
System::print2(System::Color::warning,
"Warning: passed either --sendmetrics or --no-sendmetrics, but metrics are disabled.\n");
}
- if (args.printmetrics.has_value() && !Metrics::g_metrics.lock()->metrics_enabled())
+ if (args.print_metrics.has_value() && !Metrics::g_metrics.lock()->metrics_enabled())
{
System::print2(System::Color::warning,
"Warning: passed either --printmetrics or --no-printmetrics, but metrics are disabled.\n");
@@ -361,14 +284,14 @@ int main(const int argc, const char* const* const argv)
if (Debug::g_debugging)
{
- inner(args);
+ inner(fs, args);
Checks::exit_fail(VCPKG_LINE_INFO);
}
std::string exc_msg;
try
{
- inner(args);
+ inner(fs, args);
Checks::exit_fail(VCPKG_LINE_INFO);
}
catch (std::exception& e)
diff --git a/toolsrc/src/vcpkg/base/files.cpp b/toolsrc/src/vcpkg/base/files.cpp
index 0ef2fa992..74ad046ae 100644
--- a/toolsrc/src/vcpkg/base/files.cpp
+++ b/toolsrc/src/vcpkg/base/files.cpp
@@ -79,7 +79,7 @@ namespace vcpkg::Files
return fs::file_status(ft, permissions);
-#else // ^^^ defined(_WIN32) // !defined(_WIN32) vvv
+#else // ^^^ defined(_WIN32) // !defined(_WIN32) vvv
auto result = follow_symlinks ? fs::stdfs::status(p, ec) : fs::stdfs::symlink_status(p, ec);
// libstdc++ doesn't correctly not-set ec on nonexistent paths
if (ec.value() == ENOENT || ec.value() == ENOTDIR)
@@ -88,7 +88,7 @@ namespace vcpkg::Files
return fs::file_status(file_type::not_found, perms::unknown);
}
return fs::file_status(result.type(), result.permissions());
-#endif// ^^^ !defined(_WIN32)
+#endif // ^^^ !defined(_WIN32)
}
fs::file_status status(const fs::path& p, std::error_code& ec) noexcept
@@ -326,6 +326,12 @@ namespace vcpkg::Files
if (ec) Checks::exit_with_message(li, "Error getting current path: %s", ec.message());
return result;
}
+ void Filesystem::current_path(const fs::path& path, LineInfo li)
+ {
+ std::error_code ec;
+ this->current_path(path, ec);
+ if (ec) Checks::exit_with_message(li, "Error setting current path: %s", ec.message());
+ }
struct RealFilesystem final : Filesystem
{
@@ -501,7 +507,7 @@ namespace vcpkg::Files
auto written_bytes = sendfile(o_fd, i_fd, &bytes, info.st_size);
#elif defined(__APPLE__)
auto written_bytes = fcopyfile(i_fd, o_fd, 0, COPYFILE_ALL);
-#else // ^^^ defined(__APPLE__) // !(defined(__APPLE__) || defined(__linux__)) vvv
+#else // ^^^ defined(__APPLE__) // !(defined(__APPLE__) || defined(__linux__)) vvv
ssize_t written_bytes = 0;
{
constexpr std::size_t buffer_length = 4096;
@@ -598,7 +604,7 @@ namespace vcpkg::Files
{
ec.assign(GetLastError(), std::system_category());
}
-#else // ^^^ defined(_WIN32) // !defined(_WIN32) vvv
+#else // ^^^ defined(_WIN32) // !defined(_WIN32) vvv
if (rmdir(current_path.c_str()))
{
ec.assign(errno, std::system_category());
@@ -627,7 +633,7 @@ namespace vcpkg::Files
ec.assign(GetLastError(), std::system_category());
}
}
-#else // ^^^ defined(_WIN32) // !defined(_WIN32) vvv
+#else // ^^^ defined(_WIN32) // !defined(_WIN32) vvv
else
{
if (unlink(current_path.c_str()))
@@ -777,7 +783,7 @@ namespace vcpkg::Files
FILE* f = nullptr;
#if defined(_WIN32)
auto err = _wfopen_s(&f, file_path.native().c_str(), L"wb");
-#else // ^^^ defined(_WIN32) // !defined(_WIN32) vvv
+#else // ^^^ defined(_WIN32) // !defined(_WIN32) vvv
f = fopen(file_path.native().c_str(), "wb");
int err = f != nullptr ? 0 : 1;
#endif // ^^^ !defined(_WIN32)
@@ -807,7 +813,7 @@ namespace vcpkg::Files
#if defined(_WIN32)
// absolute was called system_complete in experimental filesystem
return fs::stdfs::system_complete(path, ec);
-#else // ^^^ defined(_WIN32) / !defined(_WIN32) vvv
+#else // ^^^ defined(_WIN32) / !defined(_WIN32) vvv
if (path.is_absolute())
{
return path;
@@ -828,13 +834,17 @@ namespace vcpkg::Files
}
virtual fs::path current_path(std::error_code& ec) const override { return fs::stdfs::current_path(ec); }
+ virtual void current_path(const fs::path& path, std::error_code& ec) override
+ {
+ fs::stdfs::current_path(path, ec);
+ }
virtual std::vector<fs::path> find_from_PATH(const std::string& name) const override
{
#if defined(_WIN32)
static constexpr StringLiteral EXTS[] = {".cmd", ".exe", ".bat"};
auto paths = Strings::split(System::get_environment_variable("PATH").value_or_exit(VCPKG_LINE_INFO), ';');
-#else // ^^^ defined(_WIN32) // !defined(_WIN32) vvv
+#else // ^^^ defined(_WIN32) // !defined(_WIN32) vvv
static constexpr StringLiteral EXTS[] = {""};
auto paths = Strings::split(System::get_environment_variable("PATH").value_or_exit(VCPKG_LINE_INFO), ':');
#endif // ^^^ !defined(_WIN32)
diff --git a/toolsrc/src/vcpkg/base/system.cpp b/toolsrc/src/vcpkg/base/system.cpp
index 60787727e..728d9d578 100644
--- a/toolsrc/src/vcpkg/base/system.cpp
+++ b/toolsrc/src/vcpkg/base/system.cpp
@@ -200,10 +200,10 @@ namespace vcpkg
Optional<CPUArchitecture> System::guess_visual_studio_prompt_target_architecture()
{
// Check for the "vsdevcmd" infrastructure used by Visual Studio 2017 and later
- const auto VSCMD_ARG_TGT_ARCH = System::get_environment_variable("VSCMD_ARG_TGT_ARCH");
- if (VSCMD_ARG_TGT_ARCH)
+ const auto vscmd_arg_tgt_arch_env = System::get_environment_variable("VSCMD_ARG_TGT_ARCH");
+ if (vscmd_arg_tgt_arch_env)
{
- return to_cpu_architecture(VSCMD_ARG_TGT_ARCH.value_or_exit(VCPKG_LINE_INFO));
+ return to_cpu_architecture(vscmd_arg_tgt_arch_env.value_or_exit(VCPKG_LINE_INFO));
}
// Check for the "vcvarsall" infrastructure used by Visual Studio 2015
diff --git a/toolsrc/src/vcpkg/base/system.process.cpp b/toolsrc/src/vcpkg/base/system.process.cpp
index 3f72396d9..f90bd8e1c 100644
--- a/toolsrc/src/vcpkg/base/system.process.cpp
+++ b/toolsrc/src/vcpkg/base/system.process.cpp
@@ -192,14 +192,14 @@ namespace vcpkg
Environment System::get_modified_clean_environment(const std::unordered_map<std::string, std::string>& extra_env,
const std::string& prepend_to_path)
{
- static const std::string SYSTEM_ROOT = get_environment_variable("SystemRoot").value_or_exit(VCPKG_LINE_INFO);
- static const std::string SYSTEM_32 = SYSTEM_ROOT + R"(\system32)";
+ static const std::string system_root_env = get_environment_variable("SystemRoot").value_or_exit(VCPKG_LINE_INFO);
+ static const std::string system32_env = system_root_env + R"(\system32)";
std::string new_path = Strings::format(R"(Path=%s%s;%s;%s\Wbem;%s\WindowsPowerShell\v1.0\)",
prepend_to_path,
- SYSTEM_32,
- SYSTEM_ROOT,
- SYSTEM_32,
- SYSTEM_32);
+ system32_env,
+ system_root_env,
+ system32_env,
+ system32_env);
std::vector<std::wstring> env_wstrings = {
L"ALLUSERSPROFILE",
diff --git a/toolsrc/src/vcpkg/binarycaching.cpp b/toolsrc/src/vcpkg/binarycaching.cpp
index 2ad061e2c..408477307 100644
--- a/toolsrc/src/vcpkg/binarycaching.cpp
+++ b/toolsrc/src/vcpkg/binarycaching.cpp
@@ -106,8 +106,8 @@ namespace
for (auto&& archives_root_dir : m_read_dirs)
{
const std::string archive_name = abi_tag + ".zip";
- const fs::path archive_subpath = fs::u8path(abi_tag.substr(0, 2)) / archive_name;
- const fs::path archive_tombstone_path = archives_root_dir / "fail" / archive_subpath;
+ const fs::path archive_subpath = fs::u8path(abi_tag.substr(0, 2)) / fs::u8path(archive_name);
+ const fs::path archive_tombstone_path = archives_root_dir / fs::u8path("fail") / archive_subpath;
if (fs.exists(archive_tombstone_path))
{
if (action.build_options.fail_on_tombstone == Build::FailOnTombstone::YES)
@@ -174,14 +174,15 @@ namespace
{
const fs::path& archives_root_dir = m_directory;
const std::string archive_name = abi_tag + ".zip";
- const fs::path archive_subpath = fs::u8path(abi_tag.substr(0, 2)) / archive_name;
- const fs::path archive_tombstone_path = archives_root_dir / "fail" / archive_subpath;
+ const fs::path archive_subpath = fs::u8path(abi_tag.substr(0, 2)) / fs::u8path(archive_name);
+ const fs::path archive_tombstone_path = archives_root_dir / fs::u8path("fail") / archive_subpath;
if (!fs.exists(archive_tombstone_path))
{
// Build failed, store all failure logs in the tombstone.
- const auto tmp_log_path = paths.buildtrees / spec.name() / "tmp_failure_logs";
- const auto tmp_log_path_destination = tmp_log_path / spec.name();
- const auto tmp_failure_zip = paths.buildtrees / spec.name() / "failure_logs.zip";
+ const auto spec_name_path = fs::u8path(spec.name());
+ const auto tmp_log_path = paths.buildtrees / spec_name_path / fs::u8path("tmp_failure_logs");
+ const auto tmp_log_path_destination = tmp_log_path / spec_name_path;
+ const auto tmp_failure_zip = paths.buildtrees / spec_name_path / fs::u8path("failure_logs.zip");
fs.create_directories(tmp_log_path_destination, ignore_errors);
for (auto& log_file : fs::stdfs::directory_iterator(paths.buildtrees / spec.name()))
@@ -195,8 +196,7 @@ namespace
}
}
- compress_directory(paths, tmp_log_path, paths.buildtrees / spec.name() / "failure_logs.zip");
-
+ compress_directory(paths, tmp_log_path, tmp_failure_zip);
fs.create_directories(archive_tombstone_path.parent_path(), ignore_errors);
fs.rename_or_copy(tmp_failure_zip, archive_tombstone_path, ".tmp", ec);
@@ -226,8 +226,8 @@ namespace
for (auto&& archives_root_dir : m_read_dirs)
{
const std::string archive_name = abi_tag + ".zip";
- const fs::path archive_subpath = fs::u8path(abi_tag.substr(0, 2)) / archive_name;
- const fs::path archive_tombstone_path = archives_root_dir / "fail" / archive_subpath;
+ const fs::path archive_subpath = fs::u8path(abi_tag.substr(0, 2)) / fs::u8path(archive_name);
+ const fs::path archive_tombstone_path = archives_root_dir / fs::u8path("fail") / archive_subpath;
if (purge_tombstones)
{
diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp
index 675c75ea5..e73bfce40 100644
--- a/toolsrc/src/vcpkg/build.cpp
+++ b/toolsrc/src/vcpkg/build.cpp
@@ -124,7 +124,7 @@ namespace vcpkg::Build::Command
}
const CommandStructure COMMAND_STRUCTURE = {
- Help::create_example_string("build zlib:x64-windows"),
+ create_example_string("build zlib:x64-windows"),
1,
1,
{{}, {}},
@@ -330,7 +330,7 @@ namespace vcpkg::Build
{
start += "\n" + Strings::serialize(feature);
}
- const fs::path binary_control_file = paths.packages / bcf.core_paragraph.dir() / "CONTROL";
+ const fs::path binary_control_file = paths.packages / bcf.core_paragraph.dir() / fs::u8path("CONTROL");
paths.get_filesystem().write_contents(binary_control_file, start, VCPKG_LINE_INFO);
}
@@ -375,7 +375,10 @@ namespace vcpkg::Build
{"CMD", "BUILD"},
{"PORT", scf.core_paragraph->name},
{"CURRENT_PORT_DIR", scfl.source_location},
- {"VCPKG_ROOT_PATH", paths.root},
+ {"VCPKG_ROOT_DIR", paths.root},
+ {"PACKAGES_DIR", paths.packages},
+ {"BUILDTREES_DIR", paths.buildtrees},
+ {"_VCPKG_INSTALLED_DIR", paths.installed},
{"TARGET_TRIPLET", triplet.canonical_name()},
{"TARGET_TRIPLET_FILE", paths.get_triplet_file_path(triplet).u8string()},
{"VCPKG_PLATFORM_TOOLSET", toolset.version.c_str()},
@@ -403,8 +406,9 @@ namespace vcpkg::Build
std::vector<std::string> port_configs;
for (const PackageSpec& dependency : action.package_dependencies)
{
- const fs::path port_config_path = paths.installed / dependency.triplet().canonical_name() / "share" /
- dependency.name() / "vcpkg-port-config.cmake";
+ const fs::path port_config_path = paths.installed / fs::u8path(dependency.triplet().canonical_name()) /
+ fs::u8path("share") / fs::u8path(dependency.name()) /
+ fs::u8path("vcpkg-port-config.cmake");
if (fs.is_regular_file(port_config_path))
{
@@ -449,22 +453,26 @@ namespace vcpkg::Build
else if (pre_build_info.cmake_system_name == "Linux")
{
hash += "-";
- hash += Hash::get_file_hash(VCPKG_LINE_INFO, fs, paths.scripts / "toolchains" / "linux.cmake", algo);
+ hash += Hash::get_file_hash(
+ VCPKG_LINE_INFO, fs, paths.scripts / fs::u8path("toolchains/linux.cmake"), algo);
}
else if (pre_build_info.cmake_system_name == "Darwin")
{
hash += "-";
- hash += Hash::get_file_hash(VCPKG_LINE_INFO, fs, paths.scripts / "toolchains" / "osx.cmake", algo);
+ hash += Hash::get_file_hash(
+ VCPKG_LINE_INFO, fs, paths.scripts / fs::u8path("toolchains/osx.cmake"), algo);
}
else if (pre_build_info.cmake_system_name == "FreeBSD")
{
hash += "-";
- hash += Hash::get_file_hash(VCPKG_LINE_INFO, fs, paths.scripts / "toolchains" / "freebsd.cmake", algo);
+ hash += Hash::get_file_hash(
+ VCPKG_LINE_INFO, fs, paths.scripts / fs::u8path("toolchains/freebsd.cmake"), algo);
}
else if (pre_build_info.cmake_system_name == "Android")
{
hash += "-";
- hash += Hash::get_file_hash(VCPKG_LINE_INFO, fs, paths.scripts / "toolchains" / "android.cmake", algo);
+ hash += Hash::get_file_hash(
+ VCPKG_LINE_INFO, fs, paths.scripts / fs::u8path("toolchains/android.cmake"), algo);
}
s_hash_cache.emplace(triplet_file_path, hash);
@@ -1063,31 +1071,30 @@ namespace vcpkg::Build
public_abi_override = variable_value.empty() ? nullopt : Optional<std::string>{variable_value};
break;
case VcpkgTripletVar::LOAD_VCVARS_ENV:
- if (variable_value.empty())
- {
- load_vcvars_env = true;
- if(external_toolchain_file)
- load_vcvars_env = false;
- }
- else if (Strings::case_insensitive_ascii_equals(variable_value, "1") ||
- Strings::case_insensitive_ascii_equals(variable_value, "on") ||
- Strings::case_insensitive_ascii_equals(variable_value, "true"))
- load_vcvars_env = true;
- else if (Strings::case_insensitive_ascii_equals(variable_value, "0") ||
- Strings::case_insensitive_ascii_equals(variable_value, "off") ||
- Strings::case_insensitive_ascii_equals(variable_value, "false"))
- load_vcvars_env = false;
- else
- Checks::exit_with_message(
- VCPKG_LINE_INFO, "Unknown boolean setting for VCPKG_LOAD_VCVARS_ENV: %s", variable_value);
- break;
+ if (variable_value.empty())
+ {
+ load_vcvars_env = true;
+ if (external_toolchain_file) load_vcvars_env = false;
+ }
+ else if (Strings::case_insensitive_ascii_equals(variable_value, "1") ||
+ Strings::case_insensitive_ascii_equals(variable_value, "on") ||
+ Strings::case_insensitive_ascii_equals(variable_value, "true"))
+ load_vcvars_env = true;
+ else if (Strings::case_insensitive_ascii_equals(variable_value, "0") ||
+ Strings::case_insensitive_ascii_equals(variable_value, "off") ||
+ Strings::case_insensitive_ascii_equals(variable_value, "false"))
+ load_vcvars_env = false;
+ else
+ Checks::exit_with_message(
+ VCPKG_LINE_INFO, "Unknown boolean setting for VCPKG_LOAD_VCVARS_ENV: %s", variable_value);
+ break;
}
}
triplet_abi_tag = get_triplet_abi(paths, *this, triplet);
}
- ExtendedBuildResult::ExtendedBuildResult(BuildResult code) : code(code) {}
+ ExtendedBuildResult::ExtendedBuildResult(BuildResult code) : code(code) { }
ExtendedBuildResult::ExtendedBuildResult(BuildResult code, std::unique_ptr<BinaryControlFile>&& bcf)
: code(code), binary_control_file(std::move(bcf))
{
diff --git a/toolsrc/src/vcpkg/commands.buildexternal.cpp b/toolsrc/src/vcpkg/commands.buildexternal.cpp
index c9ac0158a..77650bd5c 100644
--- a/toolsrc/src/vcpkg/commands.buildexternal.cpp
+++ b/toolsrc/src/vcpkg/commands.buildexternal.cpp
@@ -10,7 +10,7 @@
namespace vcpkg::Commands::BuildExternal
{
const CommandStructure COMMAND_STRUCTURE = {
- Help::create_example_string(R"(build_external zlib2 C:\path\to\dir\with\controlfile\)"),
+ create_example_string(R"(build_external zlib2 C:\path\to\dir\with\controlfile\)"),
2,
2,
{},
diff --git a/toolsrc/src/vcpkg/commands.cache.cpp b/toolsrc/src/vcpkg/commands.cache.cpp
index 5fb9d15f4..9dadedb41 100644
--- a/toolsrc/src/vcpkg/commands.cache.cpp
+++ b/toolsrc/src/vcpkg/commands.cache.cpp
@@ -14,7 +14,7 @@ namespace vcpkg::Commands::Cache
std::vector<BinaryParagraph> output;
for (auto&& path : paths.get_filesystem().get_files_non_recursive(paths.packages))
{
- const auto pghs = Paragraphs::get_single_paragraph(paths.get_filesystem(), path / "CONTROL");
+ const auto pghs = Paragraphs::get_single_paragraph(paths.get_filesystem(), path / fs::u8path("CONTROL"));
if (const auto p = pghs.get())
{
const BinaryParagraph binary_paragraph = BinaryParagraph(*p);
@@ -28,7 +28,7 @@ namespace vcpkg::Commands::Cache
const CommandStructure COMMAND_STRUCTURE = {
Strings::format(
"The argument should be a substring to search for, or no argument to display all cached libraries.\n%s",
- Help::create_example_string("cache png")),
+ create_example_string("cache png")),
0,
1,
{},
diff --git a/toolsrc/src/vcpkg/commands.ci.cpp b/toolsrc/src/vcpkg/commands.ci.cpp
index 336d30cf2..35e67c881 100644
--- a/toolsrc/src/vcpkg/commands.ci.cpp
+++ b/toolsrc/src/vcpkg/commands.ci.cpp
@@ -50,7 +50,7 @@ namespace vcpkg::Commands::CI
}};
const CommandStructure COMMAND_STRUCTURE = {
- Help::create_example_string("ci x64-windows"),
+ create_example_string("ci x64-windows"),
1,
SIZE_MAX,
{CI_SWITCHES, CI_SETTINGS},
diff --git a/toolsrc/src/vcpkg/commands.contact.cpp b/toolsrc/src/vcpkg/commands.contact.cpp
index afbdc1fa7..a1b72459c 100644
--- a/toolsrc/src/vcpkg/commands.contact.cpp
+++ b/toolsrc/src/vcpkg/commands.contact.cpp
@@ -22,14 +22,14 @@ namespace vcpkg::Commands::Contact
}};
const CommandStructure COMMAND_STRUCTURE = {
- Help::create_example_string("contact"),
+ create_example_string("contact"),
0,
0,
{SWITCHES, {}},
nullptr,
};
- void perform_and_exit(const VcpkgCmdArguments& args)
+ void perform_and_exit(const VcpkgCmdArguments& args, Files::Filesystem& fs)
{
const ParsedArguments parsed_args = args.parse_arguments(COMMAND_STRUCTURE);
@@ -38,7 +38,6 @@ namespace vcpkg::Commands::Contact
auto maybe_now = Chrono::CTime::get_current_date_time();
if (const auto p_now = maybe_now.get())
{
- auto& fs = Files::get_real_filesystem();
auto config = UserConfig::try_read_data(fs);
config.last_completed_survey = p_now->to_string();
config.try_write_data(fs);
diff --git a/toolsrc/src/vcpkg/commands.cpp b/toolsrc/src/vcpkg/commands.cpp
index 246f7dcdf..f09f5e4f8 100644
--- a/toolsrc/src/vcpkg/commands.cpp
+++ b/toolsrc/src/vcpkg/commands.cpp
@@ -68,7 +68,7 @@ namespace vcpkg::Commands
namespace vcpkg::Commands::Fetch
{
const CommandStructure COMMAND_STRUCTURE = {
- Strings::format("The argument should be tool name\n%s", Help::create_example_string("fetch cmake")),
+ Strings::format("The argument should be tool name\n%s", create_example_string("fetch cmake")),
1,
1,
{},
@@ -90,7 +90,7 @@ namespace vcpkg::Commands::Hash
{
const CommandStructure COMMAND_STRUCTURE = {
Strings::format("The argument should be a file path\n%s",
- Help::create_example_string("hash boost_1_62_0.tar.bz2")),
+ create_example_string("hash boost_1_62_0.tar.bz2")),
1,
2,
{},
diff --git a/toolsrc/src/vcpkg/commands.create.cpp b/toolsrc/src/vcpkg/commands.create.cpp
index e04599dfe..9296eed0e 100644
--- a/toolsrc/src/vcpkg/commands.create.cpp
+++ b/toolsrc/src/vcpkg/commands.create.cpp
@@ -9,7 +9,7 @@
namespace vcpkg::Commands::Create
{
const CommandStructure COMMAND_STRUCTURE = {
- Help::create_example_string(R"###(create zlib2 http://zlib.net/zlib1211.zip "zlib1211-2.zip")###"),
+ create_example_string(R"###(create zlib2 http://zlib.net/zlib1211.zip "zlib1211-2.zip")###"),
2,
3,
{},
@@ -24,7 +24,7 @@ namespace vcpkg::Commands::Create
const fs::path& cmake_exe = paths.get_tool_exe(Tools::CMAKE);
- std::vector<System::CMakeVariable> cmake_args{{"CMD", "CREATE"}, {"PORT", port_name}, {"URL", url}, {"VCPKG_ROOT_PATH", paths.root}};
+ std::vector<System::CMakeVariable> cmake_args{{"CMD", "CREATE"}, {"PORT", port_name}, {"URL", url}, {"VCPKG_ROOT_DIR", paths.root}};
if (args.command_arguments.size() >= 3)
{
diff --git a/toolsrc/src/vcpkg/commands.dependinfo.cpp b/toolsrc/src/vcpkg/commands.dependinfo.cpp
index f153626fa..32f467d41 100644
--- a/toolsrc/src/vcpkg/commands.dependinfo.cpp
+++ b/toolsrc/src/vcpkg/commands.dependinfo.cpp
@@ -227,7 +227,7 @@ namespace vcpkg::Commands::DependInfo
}
const CommandStructure COMMAND_STRUCTURE = {
- Help::create_example_string("depend-info sqlite3"),
+ create_example_string("depend-info sqlite3"),
1,
1,
{DEPEND_SWITCHES, DEPEND_SETTINGS},
diff --git a/toolsrc/src/vcpkg/commands.edit.cpp b/toolsrc/src/vcpkg/commands.edit.cpp
index 59e5cc6cf..e3c74d360 100644
--- a/toolsrc/src/vcpkg/commands.edit.cpp
+++ b/toolsrc/src/vcpkg/commands.edit.cpp
@@ -95,7 +95,7 @@ namespace vcpkg::Commands::Edit
{OPTION_ALL, "Open editor into the port as well as the port-specific buildtree subfolder"}}};
const CommandStructure COMMAND_STRUCTURE = {
- Help::create_example_string("edit zlib"),
+ create_example_string("edit zlib"),
1,
10,
{EDIT_SWITCHES, {}},
diff --git a/toolsrc/src/vcpkg/commands.env.cpp b/toolsrc/src/vcpkg/commands.env.cpp
index ca398068f..b361d6ff1 100644
--- a/toolsrc/src/vcpkg/commands.env.cpp
+++ b/toolsrc/src/vcpkg/commands.env.cpp
@@ -25,7 +25,7 @@ namespace vcpkg::Commands::Env
}};
const CommandStructure COMMAND_STRUCTURE = {
- Help::create_example_string("env <optional command> --triplet x64-windows"),
+ create_example_string("env <optional command> --triplet x64-windows"),
0,
1,
{SWITCHES, {}},
diff --git a/toolsrc/src/vcpkg/commands.import.cpp b/toolsrc/src/vcpkg/commands.import.cpp
index 521892e88..9d8e4b4b1 100644
--- a/toolsrc/src/vcpkg/commands.import.cpp
+++ b/toolsrc/src/vcpkg/commands.import.cpp
@@ -93,7 +93,7 @@ namespace vcpkg::Commands::Import
}
const CommandStructure COMMAND_STRUCTURE = {
- Help::create_example_string(R"(import C:\path\to\CONTROLfile C:\path\to\includedir C:\path\to\projectdir)"),
+ create_example_string(R"(import C:\path\to\CONTROLfile C:\path\to\includedir C:\path\to\projectdir)"),
3,
3,
{},
diff --git a/toolsrc/src/vcpkg/commands.integrate.cpp b/toolsrc/src/vcpkg/commands.integrate.cpp
index e2ae967aa..ad5583a5a 100644
--- a/toolsrc/src/vcpkg/commands.integrate.cpp
+++ b/toolsrc/src/vcpkg/commands.integrate.cpp
@@ -156,7 +156,7 @@ namespace vcpkg::Commands::Integrate
{
static const fs::path LOCAL_APP_DATA =
fs::u8path(System::get_environment_variable("LOCALAPPDATA").value_or_exit(VCPKG_LINE_INFO));
- return LOCAL_APP_DATA / "vcpkg" / "vcpkg.user.targets";
+ return LOCAL_APP_DATA / fs::u8path("vcpkg/vcpkg.user.targets");
}
#endif
@@ -446,19 +446,27 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console
}
#endif
+ void append_helpstring(HelpTableFormatter& table)
+ {
#if defined(_WIN32)
- const char* const INTEGRATE_COMMAND_HELPSTRING =
- " vcpkg integrate install Make installed packages available user-wide. Requires admin privileges on "
- "first use\n"
- " vcpkg integrate remove Remove user-wide integration\n"
- " vcpkg integrate project Generate a referencing nuget package for individual VS project use\n"
- " vcpkg integrate powershell Enable PowerShell tab-completion\n";
-#else
- const char* const INTEGRATE_COMMAND_HELPSTRING =
- " vcpkg integrate install Make installed packages available user-wide.\n"
- " vcpkg integrate remove Remove user-wide integration\n"
- " vcpkg integrate bash Enable bash tab-completion\n";
-#endif
+ table.format("vcpkg integrate install",
+ "Make installed packages available user-wide. Requires admin privileges on first use");
+ table.format("vcpkg integrate remove", "Remove user-wide integration");
+ table.format("vcpkg integrate project", "Generate a referencing nuget package for individual VS project use");
+ table.format("vcpkg integrate powershell", "Enable PowerShell tab-completion");
+#else // ^^^ defined(_WIN32) // !defined(_WIN32) vvv
+ table.format("vcpkg integrate install", "Make installed packages available user-wide");
+ table.format("vcpkg integrate remove", "Remove user-wide integration");
+ table.format("vcpkg integrate bash", "Enable bash tab-completion");
+#endif // ^^^ !defined(_WIN32)
+ }
+
+ std::string get_helpstring()
+ {
+ HelpTableFormatter table;
+ append_helpstring(table);
+ return std::move(table.m_str);
+ }
namespace Subcommand
{
@@ -483,9 +491,7 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console
}
const CommandStructure COMMAND_STRUCTURE = {
- Strings::format("Commands:\n"
- "%s",
- INTEGRATE_COMMAND_HELPSTRING),
+ "Commands:\n" + get_helpstring(),
1,
1,
{},
diff --git a/toolsrc/src/vcpkg/commands.list.cpp b/toolsrc/src/vcpkg/commands.list.cpp
index 71738427c..c837dc395 100644
--- a/toolsrc/src/vcpkg/commands.list.cpp
+++ b/toolsrc/src/vcpkg/commands.list.cpp
@@ -32,7 +32,7 @@ namespace vcpkg::Commands::List
const CommandStructure COMMAND_STRUCTURE = {
Strings::format(
"The argument should be a substring to search for, or no argument to display all installed libraries.\n%s",
- Help::create_example_string("list png")),
+ create_example_string("list png")),
0,
1,
{LIST_SWITCHES, {}},
diff --git a/toolsrc/src/vcpkg/commands.owns.cpp b/toolsrc/src/vcpkg/commands.owns.cpp
index 58ed69e8b..98d571df5 100644
--- a/toolsrc/src/vcpkg/commands.owns.cpp
+++ b/toolsrc/src/vcpkg/commands.owns.cpp
@@ -25,7 +25,7 @@ namespace vcpkg::Commands::Owns
}
const CommandStructure COMMAND_STRUCTURE = {
Strings::format("The argument should be a pattern to search for. %s",
- Help::create_example_string("owns zlib.dll")),
+ create_example_string("owns zlib.dll")),
1,
1,
{},
diff --git a/toolsrc/src/vcpkg/commands.porthistory.cpp b/toolsrc/src/vcpkg/commands.porthistory.cpp
index e60e7dc63..086c9d358 100644
--- a/toolsrc/src/vcpkg/commands.porthistory.cpp
+++ b/toolsrc/src/vcpkg/commands.porthistory.cpp
@@ -68,7 +68,7 @@ namespace vcpkg::Commands::PortHistory
}
const CommandStructure COMMAND_STRUCTURE = {
- Help::create_example_string("history <port>"),
+ create_example_string("history <port>"),
1,
1,
{},
diff --git a/toolsrc/src/vcpkg/commands.portsdiff.cpp b/toolsrc/src/vcpkg/commands.portsdiff.cpp
index 7a9a49da4..2ed05cb60 100644
--- a/toolsrc/src/vcpkg/commands.portsdiff.cpp
+++ b/toolsrc/src/vcpkg/commands.portsdiff.cpp
@@ -121,7 +121,7 @@ namespace vcpkg::Commands::PortsDiff
const CommandStructure COMMAND_STRUCTURE = {
Strings::format("The argument should be a branch/tag/hash to checkout.\n%s",
- Help::create_example_string("portsdiff mybranchname")),
+ create_example_string("portsdiff mybranchname")),
1,
2,
{},
diff --git a/toolsrc/src/vcpkg/commands.search.cpp b/toolsrc/src/vcpkg/commands.search.cpp
index 372c394fa..ebaa3ce43 100644
--- a/toolsrc/src/vcpkg/commands.search.cpp
+++ b/toolsrc/src/vcpkg/commands.search.cpp
@@ -54,7 +54,7 @@ namespace vcpkg::Commands::Search
const CommandStructure COMMAND_STRUCTURE = {
Strings::format(
"The argument should be a substring to search for, or no argument to display all libraries.\n%s",
- Help::create_example_string("search png")),
+ create_example_string("search png")),
0,
1,
{SEARCH_SWITCHES, {}},
diff --git a/toolsrc/src/vcpkg/commands.setinstalled.cpp b/toolsrc/src/vcpkg/commands.setinstalled.cpp
index 2ef1b5bd2..f484903b3 100644
--- a/toolsrc/src/vcpkg/commands.setinstalled.cpp
+++ b/toolsrc/src/vcpkg/commands.setinstalled.cpp
@@ -14,7 +14,7 @@
namespace vcpkg::Commands::SetInstalled
{
const CommandStructure COMMAND_STRUCTURE = {
- Help::create_example_string(R"(x-set-installed <package>...)"),
+ create_example_string(R"(x-set-installed <package>...)"),
1,
SIZE_MAX,
{},
diff --git a/toolsrc/src/vcpkg/commands.upgrade.cpp b/toolsrc/src/vcpkg/commands.upgrade.cpp
index 112a5b6d6..130b2a59b 100644
--- a/toolsrc/src/vcpkg/commands.upgrade.cpp
+++ b/toolsrc/src/vcpkg/commands.upgrade.cpp
@@ -28,7 +28,7 @@ namespace vcpkg::Commands::Upgrade
}};
const CommandStructure COMMAND_STRUCTURE = {
- Help::create_example_string("upgrade --no-dry-run"),
+ create_example_string("upgrade --no-dry-run"),
0,
SIZE_MAX,
{INSTALL_SWITCHES, {}},
diff --git a/toolsrc/src/vcpkg/commands.version.cpp b/toolsrc/src/vcpkg/commands.version.cpp
index 8ef29b116..403c319b1 100644
--- a/toolsrc/src/vcpkg/commands.version.cpp
+++ b/toolsrc/src/vcpkg/commands.version.cpp
@@ -74,14 +74,14 @@ namespace vcpkg::Commands::Version
}
}
const CommandStructure COMMAND_STRUCTURE = {
- Help::create_example_string("version"),
+ create_example_string("version"),
0,
0,
{},
nullptr,
};
- void perform_and_exit(const VcpkgCmdArguments& args)
+ void perform_and_exit(const VcpkgCmdArguments& args, Files::Filesystem&)
{
Util::unused(args.parse_arguments(COMMAND_STRUCTURE));
diff --git a/toolsrc/src/vcpkg/commands.xvsinstances.cpp b/toolsrc/src/vcpkg/commands.xvsinstances.cpp
index a110bbb18..d66de0dbd 100644
--- a/toolsrc/src/vcpkg/commands.xvsinstances.cpp
+++ b/toolsrc/src/vcpkg/commands.xvsinstances.cpp
@@ -8,7 +8,7 @@
namespace vcpkg::Commands::X_VSInstances
{
const CommandStructure COMMAND_STRUCTURE = {
- Help::create_example_string("x-vsinstances"),
+ create_example_string("x-vsinstances"),
0,
0,
{{}, {}},
diff --git a/toolsrc/src/vcpkg/export.cpp b/toolsrc/src/vcpkg/export.cpp
index 530a93204..af74879b7 100644
--- a/toolsrc/src/vcpkg/export.cpp
+++ b/toolsrc/src/vcpkg/export.cpp
@@ -341,7 +341,7 @@ namespace vcpkg::Export
}};
const CommandStructure COMMAND_STRUCTURE = {
- Help::create_example_string("export zlib zlib:x64-windows boost --nuget"),
+ create_example_string("export zlib zlib:x64-windows boost --nuget"),
0,
SIZE_MAX,
{EXPORT_SWITCHES, EXPORT_SETTINGS},
diff --git a/toolsrc/src/vcpkg/export.prefab.cpp b/toolsrc/src/vcpkg/export.prefab.cpp
index 3200159d5..9899f5d3c 100644
--- a/toolsrc/src/vcpkg/export.prefab.cpp
+++ b/toolsrc/src/vcpkg/export.prefab.cpp
@@ -329,10 +329,7 @@ namespace vcpkg::Export::Prefab
NdkVersion version = to_version(version_opt.value_or_exit(VCPKG_LINE_INFO)).value_or_exit(VCPKG_LINE_INFO);
- const fs::path vcpkg_root_path = paths.root;
- const fs::path raw_exported_dir_path = vcpkg_root_path / "prefab";
-
- utils.remove_all(raw_exported_dir_path, VCPKG_LINE_INFO);
+ utils.remove_all(paths.prefab, VCPKG_LINE_INFO);
/*
prefab
@@ -399,7 +396,7 @@ namespace vcpkg::Export::Prefab
continue;
}
- const fs::path per_package_dir_path = raw_exported_dir_path / name;
+ const fs::path per_package_dir_path = paths.prefab / fs::u8path(name);
const auto& binary_paragraph = action.core_paragraph().value_or_exit(VCPKG_LINE_INFO);
const std::string norm_version = binary_paragraph.version;
@@ -435,8 +432,7 @@ namespace vcpkg::Export::Prefab
utils.create_directories(meta_dir, error_code);
- const fs::path share_root =
- vcpkg_root_path / "packages" / Strings::format("%s_%s", name, action.spec.triplet());
+ const fs::path share_root = paths.packages / fs::u8path(Strings::format("%s_%s", name, action.spec.triplet()));
utils.copy_file(share_root / "share" / name / "copyright",
meta_dir / "LICENSE",
@@ -509,9 +505,9 @@ namespace vcpkg::Export::Prefab
for (const auto& triplet : triplets)
{
- const fs::path listfile = vcpkg_root_path / "installed" / "vcpkg" / "info" /
- (Strings::format("%s_%s_%s", name, norm_version, triplet) + ".list");
- const fs::path installed_dir = vcpkg_root_path / "packages" / Strings::format("%s_%s", name, triplet);
+ const fs::path listfile =
+ paths.vcpkg_dir_info / fs::u8path(Strings::format("%s_%s_%s", name, norm_version, triplet) + ".list");
+ const fs::path installed_dir = paths.packages / fs::u8path(Strings::format("%s_%s", name, triplet));
Checks::check_exit(VCPKG_LINE_INFO,
utils.exists(listfile),
"Error: Packages not installed %s:%s %s",
@@ -519,7 +515,7 @@ namespace vcpkg::Export::Prefab
triplet,
listfile.generic_u8string());
- fs::path libs = installed_dir / "lib";
+ fs::path libs = installed_dir / fs::u8path("lib");
std::vector<fs::path> modules;
@@ -540,13 +536,13 @@ namespace vcpkg::Export::Prefab
if (modules.empty())
{
fs::path module_dir = modules_directory / name;
- fs::path module_libs_dir = module_dir / "libs";
+ fs::path module_libs_dir = module_dir / fs::u8path("libs");
utils.create_directories(module_libs_dir, error_code);
- fs::path installed_headers_dir = installed_dir / "include";
- fs::path exported_headers_dir = module_dir / "include";
+ fs::path installed_headers_dir = installed_dir / fs::u8path("include");
+ fs::path exported_headers_dir = module_dir / fs::u8path("include");
ModuleMetadata meta;
- fs::path module_meta_path = module_dir / "module.json";
+ fs::path module_meta_path = module_dir / fs::u8path("module.json");
utils.write_contents(module_meta_path, meta.to_json(), VCPKG_LINE_INFO);
utils.copy(installed_headers_dir, exported_headers_dir, fs::copy_options::recursive);
@@ -689,7 +685,7 @@ namespace vcpkg::Export::Prefab
System::print2(System::Color::success,
Strings::format("Successfuly exported %s. Checkout %s \n",
name,
- raw_exported_dir_path.generic_u8string()));
+ paths.prefab.generic_u8string()));
}
}
}
diff --git a/toolsrc/src/vcpkg/help.cpp b/toolsrc/src/vcpkg/help.cpp
index f4a8a0ab8..f18bbffea 100644
--- a/toolsrc/src/vcpkg/help.cpp
+++ b/toolsrc/src/vcpkg/help.cpp
@@ -9,56 +9,11 @@
namespace vcpkg::Help
{
- void HelpTableFormatter::format(StringView col1, StringView col2)
- {
- // 1 space, 32 col1, 1 space, 85 col2 = 119
- m_str.append(1, ' ');
- Strings::append(m_str, col1);
- if (col1.size() > 32)
- {
- newline_indent();
- }
- else
- {
- m_str.append(33 - col1.size(), ' ');
- }
- const char* line_start = col2.begin();
- const char* const e = col2.end();
- const char* best_break = std::find_if(line_start, e, [](char ch) { return ch == ' ' || ch == '\n'; });
-
- while (best_break != e)
- {
- const char* next_break = std::find_if(best_break + 1, e, [](char ch) { return ch == ' ' || ch == '\n'; });
- if (next_break - line_start > 85 || *best_break == '\n')
- {
- m_str.append(line_start, best_break);
- line_start = best_break + 1;
- best_break = next_break;
- if (line_start != e)
- {
- newline_indent();
- }
- }
- else
- {
- best_break = next_break;
- }
- }
- m_str.append(line_start, best_break);
- m_str.push_back('\n');
- }
- void HelpTableFormatter::newline_indent()
- {
- m_str.push_back('\n');
- indent();
- }
- void HelpTableFormatter::indent() { m_str.append(34, ' '); }
-
struct Topic
{
using topic_function = void (*)(const VcpkgPaths& paths);
- constexpr Topic(CStringView n, topic_function fn) : name(n), print(fn) {}
+ constexpr Topic(CStringView n, topic_function fn) : name(n), print(fn) { }
CStringView name;
topic_function print;
@@ -67,18 +22,18 @@ namespace vcpkg::Help
template<const CommandStructure& S>
static void command_topic_fn(const VcpkgPaths&)
{
- display_usage(S);
+ print_usage(S);
}
static void integrate_topic_fn(const VcpkgPaths&)
{
- System::print2("Commands:\n", Commands::Integrate::INTEGRATE_COMMAND_HELPSTRING);
+ System::print2("Commands:\n", Commands::Integrate::get_helpstring());
}
static void help_topics(const VcpkgPaths&);
const CommandStructure COMMAND_STRUCTURE = {
- Help::create_example_string("help"),
+ create_example_string("help"),
0,
1,
{},
@@ -145,67 +100,6 @@ namespace vcpkg::Help
}
}
- void print_usage()
- {
-// Write environment variable names as %VARIABLE% on Windows and $VARIABLE in *nix
-#ifdef _WIN32
-#define ENVVAR(VARNAME) "%" #VARNAME "%"
-#else
-#define ENVVAR(VARNAME) "$" #VARNAME
-#endif
-
- System::print2(
- "Commands:\n"
- " vcpkg search [pat] Search for packages available to be built\n"
- " vcpkg install <pkg>... Install a package\n"
- " vcpkg remove <pkg>... Uninstall a package\n"
- " vcpkg remove --outdated Uninstall all out-of-date packages\n"
- " vcpkg list List installed packages\n"
- " vcpkg update Display list of packages for updating\n"
- " vcpkg upgrade Rebuild all outdated packages\n"
- " vcpkg x-history <pkg> (Experimental) Shows the history of CONTROL versions of a package\n"
- " vcpkg hash <file> [alg] Hash a file by specific algorithm, default SHA512\n"
- " vcpkg help topics Display the list of help topics\n"
- " vcpkg help <topic> Display help for a specific topic\n"
- "\n",
- Commands::Integrate::INTEGRATE_COMMAND_HELPSTRING, // Integration help
- "\n"
- " vcpkg export <pkg>... [opt]... Exports a package\n"
- // clang-format off
- " vcpkg edit <pkg> Open up a port for editing (uses " ENVVAR(EDITOR) ", default 'code')\n"
- " vcpkg import <pkg> Import a pre-built library\n"
- " vcpkg create <pkg> <url> [archivename]\n"
- " Create a new package\n"
- " vcpkg owns <pat> Search for files in installed packages\n"
- " vcpkg depend-info <pkg>... Display a list of dependencies for packages\n"
- " vcpkg env Creates a clean shell environment for development or compiling.\n"
- " vcpkg version Display version information\n"
- " vcpkg contact Display contact information to send feedback\n"
- "\n"
- "Options:\n"
- " --triplet <t> Specify the target architecture triplet. See 'vcpkg help triplet'\n"
- " (default: " ENVVAR(VCPKG_DEFAULT_TRIPLET) ")\n"
- " --overlay-ports=<path> Specify directories to be used when searching for ports\n"
- " --overlay-triplets=<path> Specify directories containing triplets files\n"
- " --vcpkg-root <path> Specify the vcpkg root directory\n"
- " (default: " ENVVAR(VCPKG_ROOT) ")\n"
- " --x-scripts-root=<path> (Experimental) Specify the scripts root directory\n"
- "\n"
- " @response_file Specify a response file to provide additional parameters\n"
- "\n"
- "For more help (including examples) see the accompanying README.md and docs folder.\n");
- // clang-format on
-#undef ENVVAR
- }
-
- std::string create_example_string(const std::string& command_and_arguments)
- {
- std::string cs = Strings::format("Example:\n"
- " vcpkg %s\n",
- command_and_arguments);
- return cs;
- }
-
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
{
Util::unused(args.parse_arguments(COMMAND_STRUCTURE));
diff --git a/toolsrc/src/vcpkg/install.cpp b/toolsrc/src/vcpkg/install.cpp
index 951e40278..4e5e082fc 100644
--- a/toolsrc/src/vcpkg/install.cpp
+++ b/toolsrc/src/vcpkg/install.cpp
@@ -514,7 +514,7 @@ namespace vcpkg::Install
}
const CommandStructure COMMAND_STRUCTURE = {
- Help::create_example_string("install zlib zlib:x64-windows curl boost"),
+ create_example_string("install zlib zlib:x64-windows curl boost"),
1,
SIZE_MAX,
{INSTALL_SWITCHES, INSTALL_SETTINGS},
diff --git a/toolsrc/src/vcpkg/metrics.cpp b/toolsrc/src/vcpkg/metrics.cpp
index 00c6d2f8f..d1acbed99 100644
--- a/toolsrc/src/vcpkg/metrics.cpp
+++ b/toolsrc/src/vcpkg/metrics.cpp
@@ -452,7 +452,7 @@ namespace vcpkg::Metrics
#endif
}
- void Metrics::flush()
+ void Metrics::flush(Files::Filesystem& fs)
{
if (!metrics_enabled())
{
@@ -472,8 +472,6 @@ namespace vcpkg::Metrics
temp_folder_path / Strings::format("vcpkgmetricsuploader-%s.exe", Commands::Version::base_version());
#endif
- auto& fs = Files::get_real_filesystem();
-
#if defined(_WIN32)
const fs::path exe_path = [&fs]() -> fs::path {
diff --git a/toolsrc/src/vcpkg/portfileprovider.cpp b/toolsrc/src/vcpkg/portfileprovider.cpp
index afb213784..6500f70a6 100644
--- a/toolsrc/src/vcpkg/portfileprovider.cpp
+++ b/toolsrc/src/vcpkg/portfileprovider.cpp
@@ -28,7 +28,7 @@ namespace vcpkg::PortFileProvider
const std::vector<std::string>* ports_dirs_paths)
: filesystem(paths.get_filesystem())
{
- auto& fs = Files::get_real_filesystem();
+ auto& fs = paths.get_filesystem();
if (ports_dirs_paths)
{
for (auto&& overlay_path : *ports_dirs_paths)
diff --git a/toolsrc/src/vcpkg/remove.cpp b/toolsrc/src/vcpkg/remove.cpp
index 5d033cd31..9b4dc86e0 100644
--- a/toolsrc/src/vcpkg/remove.cpp
+++ b/toolsrc/src/vcpkg/remove.cpp
@@ -206,7 +206,7 @@ namespace vcpkg::Remove
}
const CommandStructure COMMAND_STRUCTURE = {
- Help::create_example_string("remove zlib zlib:x64-windows curl boost"),
+ create_example_string("remove zlib zlib:x64-windows curl boost"),
0,
SIZE_MAX,
{SWITCHES, {}},
diff --git a/toolsrc/src/vcpkg/update.cpp b/toolsrc/src/vcpkg/update.cpp
index 8cb2ac557..556f9125c 100644
--- a/toolsrc/src/vcpkg/update.cpp
+++ b/toolsrc/src/vcpkg/update.cpp
@@ -43,7 +43,7 @@ namespace vcpkg::Update
}
const CommandStructure COMMAND_STRUCTURE = {
- Help::create_example_string("update"),
+ create_example_string("update"),
0,
0,
{},
diff --git a/toolsrc/src/vcpkg/vcpkgcmdarguments.cpp b/toolsrc/src/vcpkg/vcpkgcmdarguments.cpp
index c2a9e7095..f5967b89a 100644
--- a/toolsrc/src/vcpkg/vcpkgcmdarguments.cpp
+++ b/toolsrc/src/vcpkg/vcpkgcmdarguments.cpp
@@ -3,7 +3,6 @@
#include <vcpkg/base/system.print.h>
#include <vcpkg/commands.h>
#include <vcpkg/globalstate.h>
-#include <vcpkg/help.h>
#include <vcpkg/metrics.h>
#include <vcpkg/vcpkgcmdarguments.h>
@@ -18,7 +17,7 @@ namespace vcpkg
{
System::print2(System::Color::error, "Error: expected value after ", option_name, '\n');
Metrics::g_metrics.lock()->track_property("error", "error option name");
- Help::print_usage();
+ print_usage();
Checks::exit_fail(VCPKG_LINE_INFO);
}
@@ -26,7 +25,7 @@ namespace vcpkg
{
System::print2(System::Color::error, "Error: ", option_name, " specified multiple times\n");
Metrics::g_metrics.lock()->track_property("error", "error option specified multiple times");
- Help::print_usage();
+ print_usage();
Checks::exit_fail(VCPKG_LINE_INFO);
}
@@ -41,7 +40,7 @@ namespace vcpkg
{
System::printf(System::Color::error, "Error: %s specified multiple times\n", option_name);
Metrics::g_metrics.lock()->track_property("error", "error option specified multiple times");
- Help::print_usage();
+ print_usage();
Checks::exit_fail(VCPKG_LINE_INFO);
}
@@ -54,7 +53,7 @@ namespace vcpkg
{
System::print2(System::Color::error, "Error: conflicting values specified for --", option_name, '\n');
Metrics::g_metrics.lock()->track_property("error", "error conflicting switches");
- Help::print_usage();
+ print_usage();
Checks::exit_fail(VCPKG_LINE_INFO);
}
option_field = new_setting;
@@ -68,7 +67,7 @@ namespace vcpkg
{
System::print2(System::Color::error, "Error: expected value after ", option_name, '\n');
Metrics::g_metrics.lock()->track_property("error", "error option name");
- Help::print_usage();
+ print_usage();
Checks::exit_fail(VCPKG_LINE_INFO);
}
@@ -87,14 +86,15 @@ namespace vcpkg
{
System::print2(System::Color::error, "Error: expected value after ", option_name, '\n');
Metrics::g_metrics.lock()->track_property("error", "error option name");
- Help::print_usage();
+ print_usage();
Checks::exit_fail(VCPKG_LINE_INFO);
}
option_field.emplace_back(std::move(new_value));
}
- VcpkgCmdArguments VcpkgCmdArguments::create_from_command_line(const int argc,
+ VcpkgCmdArguments VcpkgCmdArguments::create_from_command_line(const Files::Filesystem& fs,
+ const int argc,
const CommandLineCharType* const* const argv)
{
std::vector<std::string> v;
@@ -110,7 +110,6 @@ namespace vcpkg
if (arg.size() > 0 && arg[0] == '@')
{
arg.erase(arg.begin());
- const auto& fs = Files::get_real_filesystem();
auto lines = fs.read_lines(fs::u8path(arg));
if (!lines.has_value())
{
@@ -161,10 +160,17 @@ namespace vcpkg
parse_value(arg_begin, arg_end, "--vcpkg-root", args.vcpkg_root_dir);
continue;
}
- if (Strings::starts_with(arg, "--x-scripts-root="))
+ if (Strings::starts_with(arg, "--x-buildtrees-root="))
+ {
+ parse_cojoined_value(arg.substr(sizeof("--x-buildtrees-root=") - 1),
+ "--x-buildtrees-root",
+ args.buildtrees_root_dir);
+ continue;
+ }
+ if (Strings::starts_with(arg, "--downloads-root="))
{
parse_cojoined_value(
- arg.substr(sizeof("--x-scripts-root=") - 1), "--x-scripts-root", args.scripts_root_dir);
+ arg.substr(sizeof("--downloads-root=") - 1), "--downloads-root", args.downloads_root_dir);
continue;
}
if (Strings::starts_with(arg, "--x-install-root="))
@@ -173,6 +179,18 @@ namespace vcpkg
arg.substr(sizeof("--x-install-root=") - 1), "--x-install-root=", args.install_root_dir);
continue;
}
+ if (Strings::starts_with(arg, "--x-packages-root="))
+ {
+ parse_cojoined_value(
+ arg.substr(sizeof("--x-packages-root=") - 1), "--x-packages-root=", args.packages_root_dir);
+ continue;
+ }
+ if (Strings::starts_with(arg, "--x-scripts-root="))
+ {
+ parse_cojoined_value(
+ arg.substr(sizeof("--x-scripts-root=") - 1), "--x-scripts-root", args.scripts_root_dir);
+ continue;
+ }
if (arg == "--triplet")
{
++arg_begin;
@@ -204,52 +222,52 @@ namespace vcpkg
}
if (arg == "--sendmetrics")
{
- parse_switch(true, "sendmetrics", args.sendmetrics);
+ parse_switch(true, "sendmetrics", args.send_metrics);
continue;
}
if (arg == "--printmetrics")
{
- parse_switch(true, "printmetrics", args.printmetrics);
+ parse_switch(true, "printmetrics", args.print_metrics);
continue;
}
if (arg == "--disable-metrics")
{
- parse_switch(true, "printmetrics", args.disable_metrics);
+ parse_switch(true, "disable-metrics", args.disable_metrics);
continue;
}
if (arg == "--no-sendmetrics")
{
- parse_switch(false, "sendmetrics", args.sendmetrics);
+ parse_switch(false, "no-sendmetrics", args.send_metrics);
continue;
}
if (arg == "--no-printmetrics")
{
- parse_switch(false, "printmetrics", args.printmetrics);
+ parse_switch(false, "no-printmetrics", args.print_metrics);
continue;
}
if (arg == "--no-disable-metrics")
{
- parse_switch(false, "printmetrics", args.disable_metrics);
+ parse_switch(false, "no-disable-metrics", args.disable_metrics);
continue;
}
if (arg == "--featurepackages")
{
- parse_switch(true, "featurepackages", args.featurepackages);
+ parse_switch(true, "featurepackages", args.feature_packages);
continue;
}
if (arg == "--no-featurepackages")
{
- parse_switch(false, "featurepackages", args.featurepackages);
+ parse_switch(false, "featurepackages", args.feature_packages);
continue;
}
if (arg == "--binarycaching")
{
- parse_switch(true, "binarycaching", args.binarycaching);
+ parse_switch(true, "binarycaching", args.binary_caching);
continue;
}
if (arg == "--no-binarycaching")
{
- parse_switch(false, "binarycaching", args.binarycaching);
+ parse_switch(false, "no-binarycaching", args.binary_caching);
continue;
}
@@ -432,22 +450,60 @@ namespace vcpkg
if (failed)
{
- display_usage(command_structure);
+ print_usage(command_structure);
Checks::exit_fail(VCPKG_LINE_INFO);
}
return output;
}
- void display_usage(const CommandStructure& command_structure)
+ void print_usage()
{
+ HelpTableFormatter table;
+ table.header("Commands");
+ table.format("vcpkg search [pat]", "Search for packages available to be built");
+ table.format("vcpkg install <pkg>...", "Install a package");
+ table.format("vcpkg remove <pkg>...", "Uninstall a package");
+ table.format("vcpkg remove --outdated", "Uninstall all out-of-date packages");
+ table.format("vcpkg list", "List installed packages");
+ table.format("vcpkg update", "Display list of packages for updating");
+ table.format("vcpkg upgrade", "Rebuild all outdated packages");
+ table.format("vcpkg x-history <pkg>", "(Experimental) Shows the history of CONTROL versions of a package");
+ table.format("vcpkg hash <file> [alg]", "Hash a file by specific algorithm, default SHA512");
+ table.format("vcpkg help topics", "Display the list of help topics");
+ table.format("vcpkg help <topic>", "Display help for a specific topic");
+ table.blank();
+ Commands::Integrate::append_helpstring(table);
+ table.blank();
+ table.format("vcpkg export <pkg>... [opt]...", "Exports a package");
+ table.format("vcpkg edit <pkg>",
+ "Open up a port for editing (uses " + format_environment_variable("EDITOR") + ", default 'code')");
+ table.format("vcpkg import <pkg>", "Import a pre-built library");
+ table.format("vcpkg create <pkg> <url> [archivename]", "Create a new package");
+ table.format("vcpkg owns <pat>", "Search for files in installed packages");
+ table.format("vcpkg depend-info <pkg>...", "Display a list of dependencies for packages");
+ table.format("vcpkg env", "Creates a clean shell environment for development or compiling");
+ table.format("vcpkg version", "Display version information");
+ table.format("vcpkg contact", "Display contact information to send feedback");
+ table.blank();
+ table.header("Options");
+ VcpkgCmdArguments::append_common_options(table);
+ table.blank();
+ table.format("@response_file", "Specify a response file to provide additional parameters");
+ table.blank();
+ table.example("For more help (including examples) see the accompanying README.md and docs folder.");
+ System::print2(table.m_str);
+ }
+
+ void print_usage(const CommandStructure& command_structure)
+ {
+ HelpTableFormatter table;
if (!command_structure.example_text.empty())
{
- System::print2(command_structure.example_text, "\n");
+ table.example(command_structure.example_text);
}
- System::print2("Options:\n");
- Help::HelpTableFormatter table;
+ table.header("Options");
for (auto&& option : command_structure.options.switches)
{
table.format(option.name, option.short_help_text);
@@ -460,13 +516,155 @@ namespace vcpkg
{
table.format((option.name + "=..."), option.short_help_text);
}
- table.format("--triplet <t>", "Set the default triplet for unqualified packages");
+
+ VcpkgCmdArguments::append_common_options(table);
+ System::print2(table.m_str);
+ }
+
+ void VcpkgCmdArguments::append_common_options(HelpTableFormatter& table)
+ {
+ table.format("--triplet <t>", "Specify the target architecture triplet. See 'vcpkg help triplet'");
+ table.format("", "(default: " + format_environment_variable("VCPKG_DEFAULT_TRIPLET") + ')');
table.format("--overlay-ports=<path>", "Specify directories to be used when searching for ports");
table.format("--overlay-triplets=<path>", "Specify directories containing triplets files");
- table.format("--vcpkg-root <path>",
- "Specify the vcpkg directory to use instead of current directory or tool directory");
- table.format("--x-scripts-root=<path>",
- "(Experimental) Specify the scripts directory to use instead of default vcpkg scripts directory");
- System::print2(table.m_str);
+ table.format("--downloads-root=<path>", "Specify the downloads root directory");
+ table.format("", "(default: " + format_environment_variable("VCPKG_DOWNLOADS") + ')');
+ table.format("--vcpkg-root <path>", "Specify the vcpkg root directory");
+ table.format("", "(default: " + format_environment_variable("VCPKG_ROOT") + ')');
+ table.format("--x-buildtrees-root=<path>", "(Experimental) Specify the buildtrees root directory");
+ table.format("--x-install-root=<path>", "(Experimental) Specify the install root directory");
+ table.format("--x-packages-root=<path>", "(Experimental) Specify the packages root directory");
+ table.format("--x-scripts-root=<path>", "(Experimental) Specify the scripts root directory");
}
+
+ void VcpkgCmdArguments::imbue_from_environment()
+ {
+ if (!disable_metrics)
+ {
+ const auto vcpkg_disable_metrics_env = System::get_environment_variable("VCPKG_DISABLE_METRICS");
+ if (vcpkg_disable_metrics_env)
+ {
+ disable_metrics = true;
+ }
+ }
+
+ if (!triplet)
+ {
+ const auto vcpkg_default_triplet_env = System::get_environment_variable("VCPKG_DEFAULT_TRIPLET");
+ if (const auto unpacked = vcpkg_default_triplet_env.get())
+ {
+ triplet = std::make_unique<std::string>(*unpacked);
+ }
+ }
+
+ if (!vcpkg_root_dir)
+ {
+ const auto vcpkg_root_env = System::get_environment_variable("VCPKG_ROOT");
+ if (const auto unpacked = vcpkg_root_env.get())
+ {
+ vcpkg_root_dir = std::make_unique<std::string>(*unpacked);
+ }
+ }
+
+ if (!downloads_root_dir)
+ {
+ const auto vcpkg_downloads_env = vcpkg::System::get_environment_variable("VCPKG_DOWNLOADS");
+ if (const auto unpacked = vcpkg_downloads_env.get())
+ {
+ downloads_root_dir = std::make_unique<std::string>(*unpacked);
+ }
+ }
+
+ {
+ const auto vcpkg_visual_studio_path_env = System::get_environment_variable("VCPKG_VISUAL_STUDIO_PATH");
+ if (const auto unpacked = vcpkg_visual_studio_path_env.get())
+ {
+ default_visual_studio_path = std::make_unique<std::string>(*unpacked);
+ }
+ }
+ }
+
+ std::string format_environment_variable(StringLiteral lit)
+ {
+ std::string result;
+#if defined(_WIN32)
+ result.reserve(lit.size() + 2);
+ result.push_back('%');
+ result.append(lit.data(), lit.size());
+ result.push_back('%');
+#else
+ result.reserve(lit.size() + 1);
+ result.push_back('$');
+ result.append(lit.data(), lit.size());
+#endif
+ return result;
+ }
+
+ std::string create_example_string(const std::string& command_and_arguments)
+ {
+ std::string cs = Strings::format("Example:\n"
+ " vcpkg %s\n",
+ command_and_arguments);
+ return cs;
+ }
+
+ static void help_table_newline_indent(std::string& target)
+ {
+ target.push_back('\n');
+ target.append(34, ' ');
+ }
+
+ void HelpTableFormatter::format(StringView col1, StringView col2)
+ {
+ // 2 space, 31 col1, 1 space, 65 col2 = 99
+ m_str.append(2, ' ');
+ Strings::append(m_str, col1);
+ if (col1.size() > 31)
+ {
+ help_table_newline_indent(m_str);
+ }
+ else
+ {
+ m_str.append(32 - col1.size(), ' ');
+ }
+ const char* line_start = col2.begin();
+ const char* const e = col2.end();
+ const char* best_break = std::find_if(line_start, e, [](char ch) { return ch == ' ' || ch == '\n'; });
+
+ while (best_break != e)
+ {
+ const char* next_break = std::find_if(best_break + 1, e, [](char ch) { return ch == ' ' || ch == '\n'; });
+ if (next_break - line_start > 65 || *best_break == '\n')
+ {
+ m_str.append(line_start, best_break);
+ line_start = best_break + 1;
+ best_break = next_break;
+ if (line_start != e)
+ {
+ help_table_newline_indent(m_str);
+ }
+ }
+ else
+ {
+ best_break = next_break;
+ }
+ }
+ m_str.append(line_start, best_break);
+ m_str.push_back('\n');
+ }
+
+ void HelpTableFormatter::header(StringView name)
+ {
+ m_str.append(name.data(), name.size());
+ m_str.push_back(':');
+ m_str.push_back('\n');
+ }
+
+ void HelpTableFormatter::example(StringView example_text)
+ {
+ m_str.append(example_text.data(), example_text.size());
+ m_str.push_back('\n');
+ }
+
+ void HelpTableFormatter::blank() { m_str.push_back('\n'); }
}
diff --git a/toolsrc/src/vcpkg/vcpkgpaths.cpp b/toolsrc/src/vcpkg/vcpkgpaths.cpp
index 8590b1549..2d933350b 100644
--- a/toolsrc/src/vcpkg/vcpkgpaths.cpp
+++ b/toolsrc/src/vcpkg/vcpkgpaths.cpp
@@ -4,6 +4,8 @@
#include <vcpkg/base/files.h>
#include <vcpkg/base/system.h>
#include <vcpkg/base/util.h>
+#include <vcpkg/base/system.debug.h>
+#include <vcpkg/base/system.process.h>
#include <vcpkg/build.h>
#include <vcpkg/commands.h>
#include <vcpkg/metrics.h>
@@ -11,120 +13,128 @@
#include <vcpkg/vcpkgpaths.h>
#include <vcpkg/visualstudio.h>
-namespace vcpkg
+namespace
{
- Expected<VcpkgPaths> VcpkgPaths::create(const fs::path& vcpkg_root_dir,
- const Optional<fs::path>& install_root_dir,
- const Optional<fs::path>& vcpkg_scripts_root_dir,
- const std::string& default_vs_path,
- const std::vector<std::string>* triplets_dirs,
- fs::path original_cwd)
+ using namespace vcpkg;
+ fs::path process_input_directory_impl(
+ Files::Filesystem& filesystem, const fs::path& root, std::string* option, StringLiteral name, LineInfo li)
{
- auto& fs = Files::get_real_filesystem();
- std::error_code ec;
- const fs::path canonical_vcpkg_root_dir = fs.canonical(vcpkg_root_dir, ec);
- if (ec)
+ if (option)
{
- return ec;
+ // input directories must exist, so we use canonical
+ return filesystem.canonical(li, fs::u8path(*option));
}
-
- VcpkgPaths paths;
- paths.root = canonical_vcpkg_root_dir;
- paths.default_vs_path = default_vs_path;
- paths.original_cwd = original_cwd;
-
- if (paths.root.empty())
+ else
{
- Metrics::g_metrics.lock()->track_property("error", "Invalid vcpkg root directory");
- Checks::exit_with_message(VCPKG_LINE_INFO, "Invalid vcpkg root directory: %s", paths.root.string());
+ return root / fs::u8path(name.begin(), name.end());
}
+ }
- paths.packages = paths.root / "packages";
- paths.buildtrees = paths.root / "buildtrees";
+ fs::path process_input_directory(
+ Files::Filesystem& filesystem, const fs::path& root, std::string* option, StringLiteral name, LineInfo li)
+ {
+ auto result = process_input_directory_impl(filesystem, root, option, name, li);
+ Debug::print("Using ", name, "-root: ", result.u8string(), '\n');
+ return result;
+ }
- const auto overriddenDownloadsPath = System::get_environment_variable("VCPKG_DOWNLOADS");
- if (auto odp = overriddenDownloadsPath.get())
+ fs::path process_output_directory_impl(
+ Files::Filesystem& filesystem, const fs::path& root, std::string* option, StringLiteral name, LineInfo li)
+ {
+ if (option)
{
- auto asPath = fs::u8path(*odp);
- if (!fs::is_directory(fs.status(VCPKG_LINE_INFO, asPath)))
- {
- Metrics::g_metrics.lock()->track_property("error", "Invalid VCPKG_DOWNLOADS override directory.");
- Checks::exit_with_message(
- VCPKG_LINE_INFO,
- "Invalid downloads override directory: %s; "
- "create that directory or unset VCPKG_DOWNLOADS to use the default downloads location.",
- asPath.u8string());
- }
-
- paths.downloads = fs.canonical(std::move(asPath), ec);
- if (ec)
- {
- return ec;
- }
+ // output directories might not exist, so we use merely absolute
+ return filesystem.absolute(li, fs::u8path(*option));
}
else
{
- paths.downloads = paths.root / "downloads";
+ return root / fs::u8path(name.begin(), name.end());
}
+ }
- paths.ports = paths.root / "ports";
- if (auto d = install_root_dir.get())
+ fs::path process_output_directory(
+ Files::Filesystem& filesystem, const fs::path& root, std::string* option, StringLiteral name, LineInfo li)
+ {
+ auto result = process_output_directory_impl(filesystem, root, option, name, li);
+ Debug::print("Using ", name, "-root: ", result.u8string(), '\n');
+ return result;
+ }
+
+} // unnamed namespace
+
+namespace vcpkg
+{
+ VcpkgPaths::VcpkgPaths(Files::Filesystem& filesystem, const VcpkgCmdArguments& args) : fsPtr(&filesystem)
+ {
+ original_cwd = filesystem.current_path(VCPKG_LINE_INFO);
+ if (args.vcpkg_root_dir)
{
- paths.installed = fs.absolute(VCPKG_LINE_INFO, *d);
+ root = filesystem.canonical(VCPKG_LINE_INFO, fs::u8path(*args.vcpkg_root_dir));
}
else
{
- paths.installed = paths.root / "installed";
- }
- paths.triplets = paths.root / "triplets";
- paths.community_triplets = paths.triplets / "community";
-
- if (auto scripts_dir = vcpkg_scripts_root_dir.get())
- {
- if (scripts_dir->empty() || !fs::is_directory(fs.status(VCPKG_LINE_INFO, *scripts_dir)))
+ root = filesystem.find_file_recursively_up(original_cwd, ".vcpkg-root");
+ if (root.empty())
{
- Metrics::g_metrics.lock()->track_property("error", "Invalid scripts override directory.");
- Checks::exit_with_message(
- VCPKG_LINE_INFO,
- "Invalid scripts override directory: %s; "
- "create that directory or unset --x-scripts-root to use the default scripts location.",
- scripts_dir->u8string());
+ root = filesystem.find_file_recursively_up(
+ filesystem.canonical(VCPKG_LINE_INFO, System::get_exe_path_of_current_process()), ".vcpkg-root");
}
+ }
- paths.scripts = *scripts_dir;
+ #if defined(_WIN32)
+ // fixup Windows drive letter to uppercase
+ const auto& nativeRoot = root.native();
+ if (nativeRoot.size() > 2 && (nativeRoot[0] >= L'a' && nativeRoot[0] <= L'z') && nativeRoot[1] == L':')
+ {
+ auto uppercaseFirstLetter = nativeRoot;
+ uppercaseFirstLetter[0] = nativeRoot[0] - L'a' + L'A';
+ root = uppercaseFirstLetter;
}
- else
+ #endif // defined(_WIN32)
+
+ Checks::check_exit(VCPKG_LINE_INFO, !root.empty(), "Error: Could not detect vcpkg-root.");
+ Debug::print("Using vcpkg-root: ", root.u8string(), '\n');
+
+ buildtrees =
+ process_output_directory(filesystem, root, args.buildtrees_root_dir.get(), "buildtrees", VCPKG_LINE_INFO);
+ downloads =
+ process_output_directory(filesystem, root, args.downloads_root_dir.get(), "downloads", VCPKG_LINE_INFO);
+ packages =
+ process_output_directory(filesystem, root, args.packages_root_dir.get(), "packages", VCPKG_LINE_INFO);
+ ports = filesystem.canonical(VCPKG_LINE_INFO, root / fs::u8path("ports"));
+ installed =
+ process_output_directory(filesystem, root, args.install_root_dir.get(), "installed", VCPKG_LINE_INFO);
+ scripts = process_input_directory(filesystem, root, args.scripts_root_dir.get(), "scripts", VCPKG_LINE_INFO);
+ prefab = root / fs::u8path("prefab");
+
+ if (args.default_visual_studio_path)
{
- paths.scripts = paths.root / "scripts";
+ default_vs_path = filesystem.canonical(VCPKG_LINE_INFO, fs::u8path(*args.default_visual_studio_path));
}
- paths.tools = paths.downloads / "tools";
- paths.buildsystems = paths.scripts / "buildsystems";
- paths.buildsystems_msbuild_targets = paths.buildsystems / "msbuild" / "vcpkg.targets";
+ triplets = filesystem.canonical(VCPKG_LINE_INFO, root / fs::u8path("triplets"));
+ community_triplets = filesystem.canonical(VCPKG_LINE_INFO, triplets / fs::u8path("community"));
+
+ tools = downloads / fs::u8path("tools");
+ buildsystems = scripts / fs::u8path("buildsystems");
+ buildsystems_msbuild_targets = buildsystems / fs::u8path("msbuild") / fs::u8path("vcpkg.targets");
- paths.vcpkg_dir = paths.installed / "vcpkg";
- paths.vcpkg_dir_status_file = paths.vcpkg_dir / "status";
- paths.vcpkg_dir_info = paths.vcpkg_dir / "info";
- paths.vcpkg_dir_updates = paths.vcpkg_dir / "updates";
+ vcpkg_dir = installed / fs::u8path("vcpkg");
+ vcpkg_dir_status_file = vcpkg_dir / fs::u8path("status");
+ vcpkg_dir_info = vcpkg_dir / fs::u8path("info");
+ vcpkg_dir_updates = vcpkg_dir / fs::u8path("updates");
- paths.ports_cmake = paths.scripts / "ports.cmake";
+ ports_cmake = filesystem.canonical(VCPKG_LINE_INFO, scripts / fs::u8path("ports.cmake"));
- if (triplets_dirs)
+ triplets_dirs.emplace_back(triplets);
+ triplets_dirs.emplace_back(community_triplets);
+ if (args.overlay_triplets)
{
- for (auto&& triplets_dir : *triplets_dirs)
+ for (auto&& overlay_triplets_dir : *args.overlay_triplets)
{
- auto path = fs::u8path(triplets_dir);
- Checks::check_exit(VCPKG_LINE_INFO,
- paths.get_filesystem().exists(path),
- "Error: Path does not exist '%s'",
- triplets_dir);
- paths.triplets_dirs.emplace_back(fs.canonical(VCPKG_LINE_INFO, path));
+ triplets_dirs.emplace_back(filesystem.canonical(VCPKG_LINE_INFO, fs::u8path(overlay_triplets_dir)));
}
}
- paths.triplets_dirs.emplace_back(fs.canonical(VCPKG_LINE_INFO, paths.triplets));
- paths.triplets_dirs.emplace_back(fs.canonical(VCPKG_LINE_INFO, paths.community_triplets));
-
- return paths;
}
fs::path VcpkgPaths::package_dir(const PackageSpec& spec) const { return this->packages / spec.dir(); }
@@ -272,5 +282,5 @@ namespace vcpkg
#endif
}
- Files::Filesystem& VcpkgPaths::get_filesystem() const { return Files::get_real_filesystem(); }
+ Files::Filesystem& VcpkgPaths::get_filesystem() const { return *fsPtr; }
}