aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/about/faq.md24
-rw-r--r--ports/fadbad/CONTROL3
-rw-r--r--ports/fadbad/portfile.cmake18
-rw-r--r--ports/gumbo/CMakeLists.txt32
-rw-r--r--ports/gumbo/CONTROL3
-rw-r--r--ports/gumbo/portfile.cmake24
-rw-r--r--ports/libmicrohttpd/CMakeLists.txt78
-rw-r--r--ports/libmicrohttpd/CONTROL3
-rw-r--r--ports/libmicrohttpd/portfile.cmake23
-rw-r--r--ports/libstemmer/CMakeLists.txt22
-rw-r--r--ports/libstemmer/CONTROL3
-rw-r--r--ports/libstemmer/LICENSE19
-rw-r--r--ports/libstemmer/portfile.cmake24
-rw-r--r--ports/libunibreak/CMakeLists.txt35
-rw-r--r--ports/libunibreak/CONTROL3
-rw-r--r--ports/libunibreak/portfile.cmake24
-rw-r--r--ports/picosha2/CONTROL3
-rw-r--r--ports/picosha2/portfile.cmake11
-rw-r--r--ports/protobuf/0001-fix-missing-export.patch13
-rw-r--r--ports/protobuf/001-add-compiler-flag.patch25
-rw-r--r--ports/protobuf/portfile.cmake11
-rw-r--r--ports/shaderc/CMakeLists.txt60
-rw-r--r--ports/shaderc/CONTROL2
-rw-r--r--ports/tinythread/CMakeLists.txt25
-rw-r--r--ports/tinythread/CONTROL3
-rw-r--r--ports/tinythread/portfile.cmake21
-rw-r--r--scripts/buildsystems/msbuild/vcpkg.targets12
-rw-r--r--toolsrc/include/SourceParagraph.h3
-rw-r--r--toolsrc/include/coff_file_reader.h2
-rw-r--r--toolsrc/include/triplet.h4
-rw-r--r--toolsrc/include/vcpkg_Checks.h22
-rw-r--r--toolsrc/include/vcpkg_Files.h2
-rw-r--r--toolsrc/include/vcpkg_Parse.h2
-rw-r--r--toolsrc/include/vcpkg_System.h4
-rw-r--r--toolsrc/src/MachineType.cpp2
-rw-r--r--toolsrc/src/PostBuildLint.cpp22
-rw-r--r--toolsrc/src/SourceParagraph.cpp25
-rw-r--r--toolsrc/src/StatusParagraph.cpp4
-rw-r--r--toolsrc/src/StatusParagraphs.cpp2
-rw-r--r--toolsrc/src/VcpkgPaths.cpp126
-rw-r--r--toolsrc/src/coff_file_reader.cpp2
-rw-r--r--toolsrc/src/commands_build.cpp8
-rw-r--r--toolsrc/src/commands_build_external.cpp7
-rw-r--r--toolsrc/src/commands_cache.cpp4
-rw-r--r--toolsrc/src/commands_ci.cpp6
-rw-r--r--toolsrc/src/commands_contact.cpp4
-rw-r--r--toolsrc/src/commands_create.cpp7
-rw-r--r--toolsrc/src/commands_depends.cpp4
-rw-r--r--toolsrc/src/commands_edit.cpp101
-rw-r--r--toolsrc/src/commands_export.cpp36
-rw-r--r--toolsrc/src/commands_import.cpp18
-rw-r--r--toolsrc/src/commands_install.cpp8
-rw-r--r--toolsrc/src/commands_integrate.cpp82
-rw-r--r--toolsrc/src/commands_list.cpp8
-rw-r--r--toolsrc/src/commands_owns.cpp4
-rw-r--r--toolsrc/src/commands_portsdiff.cpp11
-rw-r--r--toolsrc/src/commands_remove.cpp10
-rw-r--r--toolsrc/src/commands_search.cpp4
-rw-r--r--toolsrc/src/triplet.cpp6
-rw-r--r--toolsrc/src/vcpkg_Checks.cpp23
-rw-r--r--toolsrc/src/vcpkg_Chrono.cpp18
-rw-r--r--toolsrc/src/vcpkg_Files.cpp13
-rw-r--r--toolsrc/src/vcpkg_Input.cpp4
-rw-r--r--toolsrc/src/vcpkg_Parse.cpp4
-rw-r--r--toolsrc/src/vcpkg_System.cpp34
65 files changed, 769 insertions, 401 deletions
diff --git a/docs/about/faq.md b/docs/about/faq.md
index 85a0c14db..8234216e0 100644
--- a/docs/about/faq.md
+++ b/docs/about/faq.md
@@ -46,6 +46,30 @@ Yes. In the current preview, there is not yet a standardized global way to chang
By saving the changes to the portfile (and checking them in), you'll get the same results even if you're rebuilding from scratch in the future and forgot what exact settings you used.
+## Can I get Vcpkg integration for custom configurations?
+
+Yes. While Vcpkg will only produce the standard "Release" and "Debug" configurations when building a library, you can get integration support for your projects' custom configurations, in addition to your project's standard configurations.
+
+The MSBuild $(VcpkgConfiguration) macro, if not set in your project, will identify either the "Release" or the "Debug" configuration. You only need to override this macro in your project file (.vcxproj) to declare the compatibility between your configuration, and the target standard configuration.
+
+For example, you can add support for your "MyRelease" configuration by adding in your project file:
+```
+<PropertyGroup>
+ <VcpkgConfiguration Condition="'$(Configuration)' == 'MyRelease'">Release</VcpkgConfiguration>
+</PropertyGroup>
+```
+Of course, this will only produce viable binaries if your custom configuration is compatible with the target configuration (e.g. they should both link with the same runtime library).
+
+## I can't use user-wide integration. Can I use a per-project integration?
+
+Yes. A NuGet package suitable for per-project use can be generated via either the `vcpkg integrate project` command (lightweight linking) or the `vcpkg export --nuget` command (shrinkwrapped).
+
+A lower level mechanism to achieve the same as the `vcpkg integrate project` NuGet package is via the `<vcpkg_root>\scripts\buildsystems\msbuild\vcpkg.targets` file. All you need is to import it in your .vcxproj file, replacing `<vcpkg_root>` with the path where you installed vcpkg:
+
+```
+<Import Project="<vcpkg_root>\scripts\buildsystems\msbuild\vcpkg.targets" />
+```
+
## How is CMake used internally by Vcpkg?
Vcpkg uses CMake internally as a build scripting language. This is because CMake is already an extremely common build system for cross-platform open source libraries and is becoming very popular for C++ projects in general. It is easy to acquire on Windows, does not require system-wide installation, and legible for unfamiliar users.
diff --git a/ports/fadbad/CONTROL b/ports/fadbad/CONTROL
new file mode 100644
index 000000000..ebf987962
--- /dev/null
+++ b/ports/fadbad/CONTROL
@@ -0,0 +1,3 @@
+Source: fadbad
+Version: 2.1.0
+Description: FADBAD++ Templates for Automatic Differentiation
diff --git a/ports/fadbad/portfile.cmake b/ports/fadbad/portfile.cmake
new file mode 100644
index 000000000..af9721962
--- /dev/null
+++ b/ports/fadbad/portfile.cmake
@@ -0,0 +1,18 @@
+include(vcpkg_common_functions)
+set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/FADBAD++)
+vcpkg_download_distfile(ARCHIVE
+ URLS "http://www.fadbad.com/download/FADBAD++-2.1.tar.gz"
+ FILENAME "FADBAD++-2.1.tar.gz"
+ SHA512 7a82c51c03acb0806d673853f391379ea974e304c831ee15ef05a90c30661736ff572481b5b8254b2646c63968043ee90a06cba88261b87fc34d01f92403360a
+)
+vcpkg_extract_source_archive(${ARCHIVE})
+
+file(INSTALL
+ ${SOURCE_PATH}/tadiff.h
+ ${SOURCE_PATH}/fadbad.h
+ ${SOURCE_PATH}/fadiff.h
+ ${SOURCE_PATH}/badiff.h
+ DESTINATION ${CURRENT_PACKAGES_DIR}/include
+)
+
+file(INSTALL ${SOURCE_PATH}/COPYRIGHT DESTINATION ${CURRENT_PACKAGES_DIR}/share/fadbad RENAME copyright)
diff --git a/ports/gumbo/CMakeLists.txt b/ports/gumbo/CMakeLists.txt
new file mode 100644
index 000000000..fe239cb8a
--- /dev/null
+++ b/ports/gumbo/CMakeLists.txt
@@ -0,0 +1,32 @@
+cmake_minimum_required(VERSION 3.8.0)
+
+project(gumbo)
+
+set(gumbo_srcs
+ src/attribute.c
+ src/char_ref.c
+ src/error.c
+ src/parser.c
+ src/string_buffer.c
+ src/string_piece.c
+ src/tag.c
+ src/tokenizer.c
+ src/utf8.c
+ src/util.c
+ src/vector.c
+)
+
+
+include_directories(visualc/include src)
+
+add_library(gumbo ${gumbo_srcs})
+
+install(
+ TARGETS gumbo
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+)
+if(NOT DISABLE_INSTALL_HEADERS)
+ install(FILES src/gumbo.h src/tag_enum.h DESTINATION include)
+endif()
diff --git a/ports/gumbo/CONTROL b/ports/gumbo/CONTROL
new file mode 100644
index 000000000..b8e2e15d2
--- /dev/null
+++ b/ports/gumbo/CONTROL
@@ -0,0 +1,3 @@
+Source: gumbo
+Version: 0.10.1
+Description: An HTML5 parsing library in pure C99
diff --git a/ports/gumbo/portfile.cmake b/ports/gumbo/portfile.cmake
new file mode 100644
index 000000000..a4b0ded72
--- /dev/null
+++ b/ports/gumbo/portfile.cmake
@@ -0,0 +1,24 @@
+include(vcpkg_common_functions)
+if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
+ message(WARNING "Dynamic not supported building static")
+ set(VCPKG_LIBRARY_LINKAGE static)
+endif()
+vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO google/gumbo-parser
+ REF v0.10.1
+ SHA512 bb1fb55cd07076ab6a9f38dc14db50397dbdca9a04ace4895dfba8b8cbc09038a96e26070c09c75fa929ada2e815affe233c1e2ecd8afe2aba6201647cf277d1
+ HEAD_REF master
+)
+
+file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
+
+vcpkg_configure_cmake(
+ SOURCE_PATH ${SOURCE_PATH}
+ PREFER_NINJA
+ OPTIONS_DEBUG -DDISABLE_INSTALL_HEADERS=ON
+)
+
+vcpkg_install_cmake()
+
+file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/gumbo RENAME copyright)
diff --git a/ports/libmicrohttpd/CMakeLists.txt b/ports/libmicrohttpd/CMakeLists.txt
new file mode 100644
index 000000000..d76c09122
--- /dev/null
+++ b/ports/libmicrohttpd/CMakeLists.txt
@@ -0,0 +1,78 @@
+cmake_minimum_required(VERSION 3.8)
+project(libmicrohttpd C)
+
+if(MSVC)
+ add_compile_options(/W3 /wd4005 /wd4996 /wd4018 -D_CRT_SECURE_NO_WARNINGS)
+endif()
+
+set(MIN_SRC contrib/libmicrohttpd)
+
+
+set(SRC
+ src/microhttpd/base64.c
+ src/microhttpd/basicauth.c
+ src/microhttpd/connection.c
+ src/microhttpd/daemon.c
+ src/microhttpd/digestauth.c
+ src/microhttpd/internal.c
+ src/microhttpd/md5.c
+ src/microhttpd/memorypool.c
+ src/microhttpd/mhd_mono_clock.c
+ src/microhttpd/postprocessor.c
+ src/microhttpd/reason_phrase.c
+ src/microhttpd/response.c
+ src/microhttpd/tsearch.c
+ src/microhttpd/sysfdsetsize.c
+ src/microhttpd/mhd_str.c
+ src/microhttpd/mhd_threads.c
+ src/microhttpd/mhd_sockets.c
+ src/microhttpd/mhd_itc.c
+ src/microhttpd/mhd_compat.c
+)
+set(HEADERS
+ src/microhttpd/base64.h
+ src/microhttpd/connection.h
+ src/microhttpd/internal.h
+ src/microhttpd/md5.h
+ src/microhttpd/memorypool.h
+ src/microhttpd/mhd_byteorder.h
+ src/microhttpd/mhd_limits.h
+ src/microhttpd/mhd_mono_clock.h
+ src/microhttpd/response.h
+ src/microhttpd/tsearch.h
+ src/microhttpd/sysfdsetsize.h
+ src/microhttpd/mhd_str.h
+ src/microhttpd/mhd_threads.h
+ src/microhttpd/mhd_locks.h
+ src/microhttpd/mhd_sockets.h
+ src/microhttpd/mhd_itc.h
+ src/microhttpd/mhd_itc_types.h
+ src/microhttpd/mhd_compat.h
+)
+
+if(BUILD_SHARED_LIBS)
+ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
+endif()
+
+include_directories(${HEADERS} src/include w32/common)
+
+add_library(libmicrohttpd ${SRC})
+
+if(BUILD_SHARED_LIBS)
+ target_compile_definitions(libmicrohttpd PRIVATE -DMHD_W32DLL)
+else()
+ target_compile_definitions(libmicrohttpd PRIVATE -DMHD_W32LIB)
+endif()
+
+ target_link_libraries(libmicrohttpd ws2_32)
+
+install(
+ TARGETS libmicrohttpd
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+)
+
+if(NOT DISABLE_INSTALL_HEADERS)
+ install(FILES src/include/microhttpd.h DESTINATION include)
+endif()
diff --git a/ports/libmicrohttpd/CONTROL b/ports/libmicrohttpd/CONTROL
new file mode 100644
index 000000000..a5b6730cf
--- /dev/null
+++ b/ports/libmicrohttpd/CONTROL
@@ -0,0 +1,3 @@
+Source: libmicrohttpd
+Version: 0.9.55
+Description: GNU libmicrohttpd is a small C library that is supposed to make it easy to run an HTTP server as part of another application
diff --git a/ports/libmicrohttpd/portfile.cmake b/ports/libmicrohttpd/portfile.cmake
new file mode 100644
index 000000000..8b11e3e9c
--- /dev/null
+++ b/ports/libmicrohttpd/portfile.cmake
@@ -0,0 +1,23 @@
+include(vcpkg_common_functions)
+set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/libmicrohttpd-0.9.55)
+vcpkg_download_distfile(ARCHIVE
+ URLS "ftp://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-0.9.55.tar.gz"
+ FILENAME "libmicrohttpd-0.9.55.tar.gz"
+ SHA512 b410e7253d7c98c40b5e8b8dcd1f93bcbb05c88717190e8dae73073d36465e8e5cfa53c6c5098de60051a5ec64dc423fd94f4b06537d8146b744aa99f5a0b173
+)
+vcpkg_extract_source_archive(${ARCHIVE})
+
+file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
+
+
+vcpkg_configure_cmake(
+ SOURCE_PATH ${SOURCE_PATH}
+ PREFER_NINJA
+ OPTIONS_DEBUG -DDISABLE_INSTALL_HEADERS=ON
+)
+
+vcpkg_install_cmake()
+
+vcpkg_copy_pdbs()
+
+file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/libmicrohttpd RENAME copyright)
diff --git a/ports/libstemmer/CMakeLists.txt b/ports/libstemmer/CMakeLists.txt
new file mode 100644
index 000000000..787bb26ec
--- /dev/null
+++ b/ports/libstemmer/CMakeLists.txt
@@ -0,0 +1,22 @@
+cmake_minimum_required(VERSION 3.8.0)
+
+project(libstemmer)
+
+file(GLOB SNOWBALL_SOURCES
+ src_c/*.c
+ runtime/api.c
+ runtime/utilities.c
+ libstemmer/libstemmer.c
+)
+
+add_library(stemmer ${SNOWBALL_SOURCES})
+
+install(
+ TARGETS stemmer
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+)
+if(NOT DISABLE_INSTALL_HEADERS)
+ install(FILES include/libstemmer.h DESTINATION include)
+endif()
diff --git a/ports/libstemmer/CONTROL b/ports/libstemmer/CONTROL
new file mode 100644
index 000000000..f0a4db41c
--- /dev/null
+++ b/ports/libstemmer/CONTROL
@@ -0,0 +1,3 @@
+Source: libstemmer
+Version: 2017-9-02
+Description: Snowball is a small string processing language designed for creating stemming algorithms for use in Information Retrieval
diff --git a/ports/libstemmer/LICENSE b/ports/libstemmer/LICENSE
new file mode 100644
index 000000000..0c9e7c008
--- /dev/null
+++ b/ports/libstemmer/LICENSE
@@ -0,0 +1,19 @@
+Snowball - License
+Except where explicitly noted, all the software given out on this Snowball site is covered by the 3-clause BSD License:
+
+Copyright (c) 2001, Dr Martin Porter,
+Copyright (c) 2002, Richard Boulton.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+Essentially, all this means is that you can do what you like with the code, except claim another Copyright for it, or claim that it is issued under a different license. The software is also issued without warranties, which means that if anyone suffers through its use, they cannot come back and sue you. You also have to alert anyone to whom you give the Snowball software to the fact that it is covered by the BSD license.
+
+We have not bothered to insert the licensing arrangement into the text of the Snowball software.
diff --git a/ports/libstemmer/portfile.cmake b/ports/libstemmer/portfile.cmake
new file mode 100644
index 000000000..9a76c3a94
--- /dev/null
+++ b/ports/libstemmer/portfile.cmake
@@ -0,0 +1,24 @@
+include(vcpkg_common_functions)
+if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
+ message(WARNING "Dynamic not supported building static")
+ set(VCPKG_LIBRARY_LINKAGE static)
+endif()
+set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/libstemmer_c)
+vcpkg_download_distfile(ARCHIVE
+ URLS "http://snowball.tartarus.org/dist/libstemmer_c.tgz"
+ FILENAME "libstemmer_c.tgz"
+ SHA512 9ab5b8bfd5b4071dbbd63d769e09fae3971b49ee441ad970aa95d90b3297f5ffc9deed1613d99974d1485bf3b69292663591957f52bbeddcadbf9d9a4af432f2
+)
+vcpkg_extract_source_archive(${ARCHIVE})
+
+file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
+
+vcpkg_configure_cmake(
+ SOURCE_PATH ${SOURCE_PATH}
+ PREFER_NINJA
+ OPTIONS_DEBUG -DDISABLE_INSTALL_HEADERS=ON
+)
+
+vcpkg_install_cmake()
+
+file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/libstemmer RENAME copyright)
diff --git a/ports/libunibreak/CMakeLists.txt b/ports/libunibreak/CMakeLists.txt
new file mode 100644
index 000000000..9ee5437d3
--- /dev/null
+++ b/ports/libunibreak/CMakeLists.txt
@@ -0,0 +1,35 @@
+cmake_minimum_required(VERSION 3.8.0)
+
+project(libunibreak)
+
+set(libunibreak_srcs
+ src/linebreakdata.c
+ src/linebreakdef.c
+ src/wordbreak.c
+ src/graphemebreak.c
+ src/unibreakbase.c
+ src/unibreakdef.c
+)
+
+
+include_directories(src)
+
+add_library(libunibreak ${libunibreak_srcs})
+
+install(
+ TARGETS libunibreak
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+)
+
+if(NOT DISABLE_INSTALL_HEADERS)
+ install(
+ FILES
+ src/linebreak.h
+ src/linebreakdef.h
+ src/wordbreak.h
+ src/wordbreakdef.h
+ DESTINATION include
+ )
+endif()
diff --git a/ports/libunibreak/CONTROL b/ports/libunibreak/CONTROL
new file mode 100644
index 000000000..b8a96abd4
--- /dev/null
+++ b/ports/libunibreak/CONTROL
@@ -0,0 +1,3 @@
+Source: libunibreak
+Version: 4.0
+Description: an implementation of the line breaking and word breaking algorithms as described in [Unicode Standard Annex 14] 1 and [Unicode Standard Annex 29] 2. Check the project's [home page] 3 for up-to-date information.
diff --git a/ports/libunibreak/portfile.cmake b/ports/libunibreak/portfile.cmake
new file mode 100644
index 000000000..6ec8bdd74
--- /dev/null
+++ b/ports/libunibreak/portfile.cmake
@@ -0,0 +1,24 @@
+include(vcpkg_common_functions)
+if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
+ message(WARNING "Dynamic not supported building static")
+ set(VCPKG_LIBRARY_LINKAGE static)
+endif()
+vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO adah1972/libunibreak
+ REF libunibreak_4_0
+ SHA512 f11295133a1c65f365a5287f7377f69ac7998f19b06d44818fb55c8a5ba3edabc36de8d1b7c0d38db9d982f0e443d0a751f6d51841865094122df4cd74c9af3b
+ HEAD_REF master
+)
+
+file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
+
+vcpkg_configure_cmake(
+ SOURCE_PATH ${SOURCE_PATH}
+ PREFER_NINJA
+ OPTIONS_DEBUG -DDISABLE_INSTALL_HEADERS=ON
+)
+
+vcpkg_install_cmake()
+
+file(INSTALL ${SOURCE_PATH}/LICENCE DESTINATION ${CURRENT_PACKAGES_DIR}/share/libunibreak RENAME copyright)
diff --git a/ports/picosha2/CONTROL b/ports/picosha2/CONTROL
new file mode 100644
index 000000000..3aa5919a4
--- /dev/null
+++ b/ports/picosha2/CONTROL
@@ -0,0 +1,3 @@
+Source: picosha2
+Version: 2017-09-01-c5ff159b6
+Description: PicoSHA2 - a C++ SHA256 hash generator
diff --git a/ports/picosha2/portfile.cmake b/ports/picosha2/portfile.cmake
new file mode 100644
index 000000000..2ce820928
--- /dev/null
+++ b/ports/picosha2/portfile.cmake
@@ -0,0 +1,11 @@
+include(vcpkg_common_functions)
+vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO okdshin/PicoSHA2
+ REF c5ff159b60a7755f5601a18cf9c25388ad25e0ef
+ SHA512 8fa4045d73a921bbb9bf6de96e80272e1d54a52ddb8f7d05643785a3b582e8f7a069ccf901352af26db7788863717c0553f086f69578835d6a0512f0be04bae3
+ HEAD_REF master
+)
+
+file(INSTALL ${SOURCE_PATH}/picosha2.h DESTINATION ${CURRENT_PACKAGES_DIR}/include)
+file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/picosha2 RENAME copyright)
diff --git a/ports/protobuf/0001-fix-missing-export.patch b/ports/protobuf/0001-fix-missing-export.patch
deleted file mode 100644
index c7d5ff6c8..000000000
--- a/ports/protobuf/0001-fix-missing-export.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/src/google/protobuf/generated_message_util.h b/src/google/protobuf/generated_message_util.h
-index 4417446..a7154b4 100644
---- a/src/google/protobuf/generated_message_util.h
-+++ b/src/google/protobuf/generated_message_util.h
-@@ -164,7 +164,7 @@ class ExplicitlyConstructed {
-
- // Default empty string object. Don't use this directly. Instead, call
- // GetEmptyString() to get the reference.
--extern ExplicitlyConstructed< ::std::string> fixed_address_empty_string;
-+LIBPROTOBUF_EXPORT extern ExplicitlyConstructed< ::std::string> fixed_address_empty_string;
- LIBPROTOBUF_EXPORT extern ProtobufOnceType empty_string_once_init_;
- LIBPROTOBUF_EXPORT void InitEmptyString();
-
diff --git a/ports/protobuf/001-add-compiler-flag.patch b/ports/protobuf/001-add-compiler-flag.patch
index aec510f44..dd1285cea 100644
--- a/ports/protobuf/001-add-compiler-flag.patch
+++ b/ports/protobuf/001-add-compiler-flag.patch
@@ -1,14 +1,13 @@
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
-index 7618ba21..bd92b09d 100644
+index 7618ba2..d282a60 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
-@@ -165,8 +165,11 @@ endif (protobuf_UNICODE)
+@@ -165,8 +165,10 @@ endif (protobuf_UNICODE)
include(libprotobuf-lite.cmake)
include(libprotobuf.cmake)
-include(libprotoc.cmake)
-include(protoc.cmake)
-+
+if(protobuf_BUILD_COMPILER)
+ include(libprotoc.cmake)
+ include(protoc.cmake)
@@ -16,18 +15,26 @@ index 7618ba21..bd92b09d 100644
if (protobuf_BUILD_TESTS)
include(tests.cmake)
+
diff --git a/cmake/install.cmake b/cmake/install.cmake
-index 28dc90dc..52c1f721 100644
+index 441bf55..4158820 100644
--- a/cmake/install.cmake
+++ b/cmake/install.cmake
-@@ -1,9 +1,12 @@
+@@ -1,14 +1,17 @@
include(GNUInstallDirs)
+-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/protobuf.pc.cmake
+set(LIBRARIES_TO_SET_DEST libprotobuf-lite libprotobuf)
+if(protobuf_BUILD_COMPILER)
+ list(APPEND LIBRARIES_TO_SET_DEST libprotoc)
+endif()
+
++configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libprotobuf.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/protobuf.pc @ONLY)
+-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/protobuf-lite.pc.cmake
++configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libprotobuf-lite.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/protobuf-lite.pc @ONLY)
+
foreach(_library
- libprotobuf-lite
- libprotobuf
@@ -36,7 +43,7 @@ index 28dc90dc..52c1f721 100644
set_property(TARGET ${_library}
PROPERTY INTERFACE_INCLUDE_DIRECTORIES
$<BUILD_INTERFACE:${protobuf_source_dir}/src>
-@@ -14,8 +17,10 @@ foreach(_library
+@@ -19,8 +22,10 @@ foreach(_library
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${_library})
endforeach()
@@ -47,9 +54,9 @@ index 28dc90dc..52c1f721 100644
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc)
+endif()
- file(STRINGS extract_includes.bat.in _extract_strings
- REGEX "^copy")
-@@ -94,7 +99,12 @@ configure_file(protobuf-options.cmake
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/protobuf.pc ${CMAKE_CURRENT_BINARY_DIR}/protobuf-lite.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
+
+@@ -101,7 +106,12 @@ configure_file(protobuf-options.cmake
${CMAKE_INSTALL_CMAKEDIR}/protobuf-options.cmake @ONLY)
# Allows the build directory to be used as a find directory.
diff --git a/ports/protobuf/portfile.cmake b/ports/protobuf/portfile.cmake
index fa81e0542..83f9e1e1d 100644
--- a/ports/protobuf/portfile.cmake
+++ b/ports/protobuf/portfile.cmake
@@ -1,16 +1,16 @@
include(vcpkg_common_functions)
-set(PROTOBUF_VERSION 3.3.0)
+set(PROTOBUF_VERSION 3.4.0)
vcpkg_download_distfile(ARCHIVE_FILE
URLS "https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/protobuf-cpp-${PROTOBUF_VERSION}.tar.gz"
FILENAME "protobuf-cpp-${PROTOBUF_VERSION}.tar.gz"
- SHA512 ef01300bdda4a1a33a6056aea1d55e9d66ab1ca644aa2d9d5633cfc0bccfe4c24fdfa1015889b2c1c568e89ad053c701de1aca45196a6439130b7bb8f461595f
+ SHA512 ce9bd9bc818c4a8e8b08c83e8a4eba6fca008a64a5ad9d322b19683b1de2b5fa622ed99093323f3c9d0820ef23430f7ee07f6930f7f877d334e5d36df9b0be0e
)
vcpkg_download_distfile(TOOL_ARCHIVE_FILE
URLS "https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-win32.zip"
FILENAME "protoc-${PROTOBUF_VERSION}-win32.zip"
- SHA512 9b4902b3187fb978a8153aaf050314a3ca9ca161b0712a3672ccdfabb7f5a57035e71c2dfde9a0b99f9417e159dcbdedaf9a2b1917d712dc3d9d554bba0d4ee8
+ SHA512 b874c3f47b39ac78f5675e05220318683004a365c248bf47ba50d8c66c8ed7763432451bab30524e131e1185a2bdaa6e6071b389eb61ad58b1b95974cf39d41b
)
set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/protobuf-${PROTOBUF_VERSION})
@@ -18,13 +18,10 @@ set(TOOL_PATH ${CURRENT_BUILDTREES_DIR}/src/protobuf-${PROTOBUF_VERSION}-win32)
vcpkg_extract_source_archive(${ARCHIVE_FILE})
-# Patch to fix the missing export of fixed_address_empty_string,
-# see https://github.com/google/protobuf/pull/3216
# Add a flag that can be set to disable the protobuf compiler
vcpkg_apply_patches(
SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/protobuf-${PROTOBUF_VERSION}
- PATCHES "${CMAKE_CURRENT_LIST_DIR}/0001-fix-missing-export.patch"
- "${CMAKE_CURRENT_LIST_DIR}/001-add-compiler-flag.patch"
+ PATCHES "${CMAKE_CURRENT_LIST_DIR}/001-add-compiler-flag.patch"
)
diff --git a/ports/shaderc/CMakeLists.txt b/ports/shaderc/CMakeLists.txt
index 3dc7be973..f4e0830c6 100644
--- a/ports/shaderc/CMakeLists.txt
+++ b/ports/shaderc/CMakeLists.txt
@@ -1,29 +1,31 @@
-option(SUFFIX_D "Add d Suffix to lib" ${SUFFIX_D})
-if(NOT ${SUFFIX_D})
- find_library(GLSLANG glslang)
- find_library(OSDEPENDENT OSDependent)
- find_library(OGLCOMPILER OGLCompiler)
- find_library(HLSLLIB HLSL)
- find_library(SPIRVLIB SPIRV)
-ELSE()
- find_library(GLSLANG glslangd)
- find_library(OSDEPENDENT OSDependentd)
- find_library(OGLCOMPILER OGLCompilerd)
- find_library(HLSLLIB HLSLd)
- find_library(SPIRVLIB SPIRVd)
-ENDIF()
-
-add_library(glslang STATIC IMPORTED GLOBAL)
-set_property(TARGET glslang PROPERTY IMPORTED_LOCATION "${GLSLANG}")
-
-add_library(OSDependent STATIC IMPORTED GLOBAL)
-set_property(TARGET OSDependent PROPERTY IMPORTED_LOCATION "${OSDEPENDENT}")
-
-add_library(OGLCompiler STATIC IMPORTED GLOBAL)
-set_property(TARGET OGLCompiler PROPERTY IMPORTED_LOCATION "${OGLCOMPILER}")
-
-add_library(HLSL STATIC IMPORTED GLOBAL)
-set_property(TARGET HLSL PROPERTY IMPORTED_LOCATION "${HLSLLIB}")
-
-add_library(SPIRV STATIC IMPORTED GLOBAL)
-set_property(TARGET SPIRV PROPERTY IMPORTED_LOCATION "${SPIRVLIB}")
+option(SUFFIX_D "Add d Suffix to lib" ${SUFFIX_D})
+if(NOT ${SUFFIX_D})
+ find_library(GLSLANG glslang)
+ find_library(OSDEPENDENT OSDependent)
+ find_library(OGLCOMPILER OGLCompiler)
+ find_library(HLSLLIB HLSL)
+ find_library(SPIRVLIB SPIRV)
+ELSE()
+ find_library(GLSLANG glslangd)
+ find_library(OSDEPENDENT OSDependentd)
+ find_library(OGLCOMPILER OGLCompilerd)
+ find_library(HLSLLIB HLSLd)
+ find_library(SPIRVLIB SPIRVd)
+ENDIF()
+
+add_library(glslang STATIC IMPORTED GLOBAL)
+set_property(TARGET glslang PROPERTY IMPORTED_LOCATION "${GLSLANG}")
+set(glslang_SOURCE_DIR "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include" CACHE STRING "glslang source dir")
+set_property(TARGET glslang APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include")
+
+add_library(OSDependent STATIC IMPORTED GLOBAL)
+set_property(TARGET OSDependent PROPERTY IMPORTED_LOCATION "${OSDEPENDENT}")
+
+add_library(OGLCompiler STATIC IMPORTED GLOBAL)
+set_property(TARGET OGLCompiler PROPERTY IMPORTED_LOCATION "${OGLCOMPILER}")
+
+add_library(HLSL STATIC IMPORTED GLOBAL)
+set_property(TARGET HLSL PROPERTY IMPORTED_LOCATION "${HLSLLIB}")
+
+add_library(SPIRV STATIC IMPORTED GLOBAL)
+set_property(TARGET SPIRV PROPERTY IMPORTED_LOCATION "${SPIRVLIB}")
diff --git a/ports/shaderc/CONTROL b/ports/shaderc/CONTROL
index 6cab280a6..d9fe76beb 100644
--- a/ports/shaderc/CONTROL
+++ b/ports/shaderc/CONTROL
@@ -1,4 +1,4 @@
Source: shaderc
-Version: 2df47b51d83ad83cbc2e7f8ff2b56776293e8958
+Version: 2df47b51d83ad83cbc2e7f8ff2b56776293e8958-1
Description: A collection of tools, libraries and tests for shader compilation.
Build-Depends: glslang, spirv-tools
diff --git a/ports/tinythread/CMakeLists.txt b/ports/tinythread/CMakeLists.txt
new file mode 100644
index 000000000..ec8b3634c
--- /dev/null
+++ b/ports/tinythread/CMakeLists.txt
@@ -0,0 +1,25 @@
+cmake_minimum_required(VERSION 3.8.0)
+
+project(tinythread)
+
+if(MSVC)
+ add_compile_options(/W3 /wd4005 /wd4996 /wd4018 -D_CRT_SECURE_NO_WARNINGS)
+endif()
+
+if(BUILD_SHARED_LIBS)
+ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
+endif()
+
+include_directories(source)
+
+add_library(tinythread source/tinythread.cpp)
+
+install(
+ TARGETS tinythread
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+)
+if(NOT DISABLE_INSTALL_HEADERS)
+ install(FILES source/tinythread.h source/fast_mutex.h DESTINATION include)
+endif()
diff --git a/ports/tinythread/CONTROL b/ports/tinythread/CONTROL
new file mode 100644
index 000000000..3c45f153e
--- /dev/null
+++ b/ports/tinythread/CONTROL
@@ -0,0 +1,3 @@
+Source: tinythread
+Version: 1.1
+Description: Implements a fairly compatible subset of the C++11 thread management classes
diff --git a/ports/tinythread/portfile.cmake b/ports/tinythread/portfile.cmake
new file mode 100644
index 000000000..23903e30e
--- /dev/null
+++ b/ports/tinythread/portfile.cmake
@@ -0,0 +1,21 @@
+include(vcpkg_common_functions)
+set(SOURCE_PATH "${CURRENT_BUILDTREES_DIR}/src/TinyThread++-1.1")
+vcpkg_download_distfile(ARCHIVE
+ URLS "http://tinythreadpp.bitsnbites.eu/files/TinyThread%2B%2B-1.1-src.tar.bz2"
+ FILENAME "TinyThread++-1.1.tar.bz2"
+ SHA512 407f54fcf3f68dd7fec25e9e0749a1803dffa5d52d606905155714d29f519b5eae64ff654b11768fecc32c0123a78c48be37c47993e0caf157a63349a2f869c6
+)
+vcpkg_extract_source_archive(${ARCHIVE})
+
+file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
+
+
+vcpkg_configure_cmake(
+ SOURCE_PATH ${SOURCE_PATH}
+ PREFER_NINJA
+ OPTIONS_DEBUG -DDISABLE_INSTALL_HEADERS=ON
+)
+
+vcpkg_install_cmake()
+
+file(INSTALL "${SOURCE_PATH}/README.txt" DESTINATION ${CURRENT_PACKAGES_DIR}/share/tinythread RENAME copyright)
diff --git a/scripts/buildsystems/msbuild/vcpkg.targets b/scripts/buildsystems/msbuild/vcpkg.targets
index 5c24d755a..1cb338237 100644
--- a/scripts/buildsystems/msbuild/vcpkg.targets
+++ b/scripts/buildsystems/msbuild/vcpkg.targets
@@ -41,10 +41,10 @@
<ItemDefinitionGroup Condition="'$(VcpkgEnabled)' == 'true'">
<Link>
- <AdditionalDependencies Condition="'$(VcpkgConfiguration)' == 'Debug' and '$(VcpkgAutoLink)' != 'false'">%(AdditionalDependencies);$(VcpkgRoot)debug\lib\*.lib</AdditionalDependencies>
- <AdditionalDependencies Condition="'$(VcpkgConfiguration)' == 'Release' and '$(VcpkgAutoLink)' != 'false'">%(AdditionalDependencies);$(VcpkgRoot)lib\*.lib</AdditionalDependencies>
- <AdditionalLibraryDirectories Condition="'$(VcpkgConfiguration)' == 'Release'">%(AdditionalLibraryDirectories);$(VcpkgRoot)lib;$(VcpkgRoot)lib\manual-link</AdditionalLibraryDirectories>
- <AdditionalLibraryDirectories Condition="'$(VcpkgConfiguration)' == 'Debug'">%(AdditionalLibraryDirectories);$(VcpkgRoot)debug\lib;$(VcpkgRoot)debug\lib\manual-link</AdditionalLibraryDirectories>
+ <AdditionalDependencies Condition="$(VcpkgConfiguration.StartsWith('Debug')) and '$(VcpkgAutoLink)' != 'false'">%(AdditionalDependencies);$(VcpkgRoot)debug\lib\*.lib</AdditionalDependencies>
+ <AdditionalDependencies Condition="$(VcpkgConfiguration.StartsWith('Release')) and '$(VcpkgAutoLink)' != 'false'">%(AdditionalDependencies);$(VcpkgRoot)lib\*.lib</AdditionalDependencies>
+ <AdditionalLibraryDirectories Condition="$(VcpkgConfiguration.StartsWith('Release'))">%(AdditionalLibraryDirectories);$(VcpkgRoot)lib;$(VcpkgRoot)lib\manual-link</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories Condition="$(VcpkgConfiguration.StartsWith('Debug'))">%(AdditionalLibraryDirectories);$(VcpkgRoot)debug\lib;$(VcpkgRoot)debug\lib\manual-link</AdditionalLibraryDirectories>
</Link>
<ClCompile>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(VcpkgRoot)include</AdditionalIncludeDirectories>
@@ -63,11 +63,11 @@
<WriteLinesToFile
File="$(TLogLocation)$(ProjectName).write.1u.tlog"
Lines="^$(TargetPath);$([System.IO.Path]::Combine($(ProjectDir),$(IntDir)))vcpkg.applocal.log" Encoding="Unicode"/>
- <Exec Condition="'$(VcpkgConfiguration)' == 'Debug'"
+ <Exec Condition="$(VcpkgConfiguration.StartsWith('Debug'))"
Command="powershell.exe -ExecutionPolicy Bypass -noprofile -File %22$(MSBuildThisFileDirectory)applocal.ps1%22 %22$(TargetPath)%22 %22$(VcpkgRoot)debug\bin%22 %22$(TLogLocation)$(ProjectName).write.1u.tlog%22 %22$(IntDir)vcpkg.applocal.log%22"
StandardOutputImportance="Normal">
</Exec>
- <Exec Condition="'$(VcpkgConfiguration)' == 'Release'"
+ <Exec Condition="$(VcpkgConfiguration.StartsWith('Release'))"
Command="powershell.exe -ExecutionPolicy Bypass -noprofile -File %22$(MSBuildThisFileDirectory)applocal.ps1%22 %22$(TargetPath)%22 %22$(VcpkgRoot)bin%22 %22$(TLogLocation)$(ProjectName).write.1u.tlog%22 %22$(IntDir)vcpkg.applocal.log%22"
StandardOutputImportance="Normal">
</Exec>
diff --git a/toolsrc/include/SourceParagraph.h b/toolsrc/include/SourceParagraph.h
index 8563d83b0..1357b3769 100644
--- a/toolsrc/include/SourceParagraph.h
+++ b/toolsrc/include/SourceParagraph.h
@@ -7,7 +7,6 @@
#include "vcpkg_expected.h"
#include <string>
-#include <unordered_map>
#include <vector>
namespace vcpkg
@@ -27,7 +26,7 @@ namespace vcpkg
// zlib[uwp] becomes Dependency{"zlib", "uwp"}
std::vector<Dependency> expand_qualified_dependencies(const std::vector<std::string>& depends);
- const std::string to_string(const Dependency& dep);
+ std::string to_string(const Dependency& dep);
struct FeatureParagraph
{
diff --git a/toolsrc/include/coff_file_reader.h b/toolsrc/include/coff_file_reader.h
index 09f6447c2..7287211a1 100644
--- a/toolsrc/include/coff_file_reader.h
+++ b/toolsrc/include/coff_file_reader.h
@@ -3,7 +3,7 @@
#include "filesystem_fs.h"
#include <vector>
-namespace vcpkg::COFFFileReader
+namespace vcpkg::CoffFileReader
{
struct DllInfo
{
diff --git a/toolsrc/include/triplet.h b/toolsrc/include/triplet.h
index be3bcf5b3..46a52f8e6 100644
--- a/toolsrc/include/triplet.h
+++ b/toolsrc/include/triplet.h
@@ -9,7 +9,7 @@ namespace vcpkg
struct Triplet
{
public:
- constexpr Triplet() : m_instance(&default_instance) {}
+ constexpr Triplet() : m_instance(&DEFAULT_INSTANCE) {}
static Triplet from_canonical_name(const std::string& triplet_as_string);
@@ -26,7 +26,7 @@ namespace vcpkg
bool operator==(const Triplet& other) const;
private:
- static const TripletInstance default_instance;
+ static const TripletInstance DEFAULT_INSTANCE;
constexpr Triplet(const TripletInstance* ptr) : m_instance(ptr) {}
diff --git a/toolsrc/include/vcpkg_Checks.h b/toolsrc/include/vcpkg_Checks.h
index 01cb7209b..ce486ac19 100644
--- a/toolsrc/include/vcpkg_Checks.h
+++ b/toolsrc/include/vcpkg_Checks.h
@@ -20,33 +20,35 @@ namespace vcpkg::Checks
[[noreturn]] inline void exit_success(const LineInfo& line_info) { exit_with_code(line_info, EXIT_SUCCESS); }
// Display an error message to the user and exit the tool.
- [[noreturn]] void exit_with_message(const LineInfo& line_info, const CStringView errorMessage);
+ [[noreturn]] void exit_with_message(const LineInfo& line_info, const CStringView error_message);
template<class Arg1, class... Args>
// Display an error message to the user and exit the tool.
[[noreturn]] void exit_with_message(const LineInfo& line_info,
- const char* errorMessageTemplate,
- const Arg1 errorMessageArg1,
- const Args&... errorMessageArgs)
+ const char* error_message_template,
+ const Arg1 error_message_arg1,
+ const Args&... error_message_args)
{
- exit_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArg1, errorMessageArgs...));
+ exit_with_message(line_info,
+ Strings::format(error_message_template, error_message_arg1, error_message_args...));
}
void check_exit(const LineInfo& line_info, bool expression);
- void check_exit(const LineInfo& line_info, bool expression, const CStringView errorMessage);
+ void check_exit(const LineInfo& line_info, bool expression, const CStringView error_message);
template<class Conditional, class Arg1, class... Args>
void check_exit(const LineInfo& line_info,
Conditional&& expression,
- const char* errorMessageTemplate,
- const Arg1 errorMessageArg1,
- const Args&... errorMessageArgs)
+ const char* error_message_template,
+ const Arg1 error_message_arg1,
+ const Args&... error_message_args)
{
if (!expression)
{
// Only create the string if the expression is false
- exit_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArg1, errorMessageArgs...));
+ exit_with_message(line_info,
+ Strings::format(error_message_template, error_message_arg1, error_message_args...));
}
}
}
diff --git a/toolsrc/include/vcpkg_Files.h b/toolsrc/include/vcpkg_Files.h
index ad29ffa14..855e8ea45 100644
--- a/toolsrc/include/vcpkg_Files.h
+++ b/toolsrc/include/vcpkg_Files.h
@@ -38,4 +38,6 @@ namespace vcpkg::Files
bool has_invalid_chars_for_filesystem(const std::string& s);
void print_paths(const std::vector<fs::path>& paths);
+
+ std::vector<fs::path> find_from_PATH(const std::wstring& name);
}
diff --git a/toolsrc/include/vcpkg_Parse.h b/toolsrc/include/vcpkg_Parse.h
index e663448b9..2dda033b3 100644
--- a/toolsrc/include/vcpkg_Parse.h
+++ b/toolsrc/include/vcpkg_Parse.h
@@ -26,7 +26,7 @@ namespace vcpkg::Parse
ParagraphParser(RawParagraph&& fields) : fields(std::move(fields)) {}
void required_field(const std::string& fieldname, std::string& out);
- std::string optional_field(const std::string& fieldname);
+ std::string optional_field(const std::string& fieldname) const;
std::unique_ptr<ParseControlErrorInfo> error_info(const std::string& name) const;
private:
diff --git a/toolsrc/include/vcpkg_System.h b/toolsrc/include/vcpkg_System.h
index 9dd9ea8bd..65f80ae6d 100644
--- a/toolsrc/include/vcpkg_System.h
+++ b/toolsrc/include/vcpkg_System.h
@@ -80,9 +80,9 @@ namespace vcpkg::System
std::vector<CPUArchitecture> get_supported_host_architectures();
- const fs::path& get_ProgramFiles_32_bit();
+ const fs::path& get_program_files_32_bit();
- const fs::path& get_ProgramFiles_platform_bitness();
+ const fs::path& get_program_files_platform_bitness();
}
namespace vcpkg::Debug
diff --git a/toolsrc/src/MachineType.cpp b/toolsrc/src/MachineType.cpp
index 2f44ce21a..af6378c88 100644
--- a/toolsrc/src/MachineType.cpp
+++ b/toolsrc/src/MachineType.cpp
@@ -7,7 +7,7 @@ namespace vcpkg
{
MachineType to_machine_type(const uint16_t value)
{
- MachineType t = static_cast<MachineType>(value);
+ const MachineType t = static_cast<MachineType>(value);
switch (t)
{
case MachineType::UNKNOWN:
diff --git a/toolsrc/src/PostBuildLint.cpp b/toolsrc/src/PostBuildLint.cpp
index 473c81cfa..1fd48d3ec 100644
--- a/toolsrc/src/PostBuildLint.cpp
+++ b/toolsrc/src/PostBuildLint.cpp
@@ -40,7 +40,7 @@ namespace vcpkg::PostBuildLint
const std::vector<OutdatedDynamicCrt>& get_outdated_dynamic_crts()
{
- static const std::vector<OutdatedDynamicCrt> v_no_msvcrt = {
+ static const std::vector<OutdatedDynamicCrt> V_NO_MSVCRT = {
{"msvcp100.dll", R"(msvcp100\.dll)"},
{"msvcp100d.dll", R"(msvcp100d\.dll)"},
{"msvcp110.dll", R"(msvcp110\.dll)"},
@@ -59,7 +59,7 @@ namespace vcpkg::PostBuildLint
{"msvcrt20.dll", R"(msvcrt20\.dll)"},
{"msvcrt40.dll", R"(msvcrt40\.dll)"}};
- return v_no_msvcrt;
+ return V_NO_MSVCRT;
}
static LintStatus check_for_files_in_include_directory(const Files::Filesystem& fs,
@@ -389,7 +389,7 @@ namespace vcpkg::PostBuildLint
file.extension() == ".dll",
"The file extension was not .dll: %s",
file.generic_string());
- COFFFileReader::DllInfo info = COFFFileReader::read_dll(file);
+ const CoffFileReader::DllInfo info = CoffFileReader::read_dll(file);
const std::string actual_architecture = get_actual_architecture(info.machine_type);
if (expected_architecture != actual_architecture)
@@ -418,7 +418,7 @@ namespace vcpkg::PostBuildLint
file.extension() == ".lib",
"The file extension was not .lib: %s",
file.generic_string());
- COFFFileReader::LibInfo info = COFFFileReader::read_lib(file);
+ CoffFileReader::LibInfo info = CoffFileReader::read_lib(file);
// This is zero for folly's debug library
// TODO: Why?
@@ -580,7 +580,7 @@ namespace vcpkg::PostBuildLint
return LintStatus::SUCCESS;
}
- struct BuildType_and_file
+ struct BuildTypeAndFile
{
fs::path file;
BuildType build_type;
@@ -594,7 +594,7 @@ namespace vcpkg::PostBuildLint
bad_build_types.erase(std::remove(bad_build_types.begin(), bad_build_types.end(), expected_build_type),
bad_build_types.end());
- std::vector<BuildType_and_file> libs_with_invalid_crt;
+ std::vector<BuildTypeAndFile> libs_with_invalid_crt;
for (const fs::path& lib : libs)
{
@@ -622,7 +622,7 @@ namespace vcpkg::PostBuildLint
"Expected %s crt linkage, but the following libs had invalid crt linkage:",
expected_build_type.to_string());
System::println();
- for (const BuildType_and_file btf : libs_with_invalid_crt)
+ for (const BuildTypeAndFile btf : libs_with_invalid_crt)
{
System::println(" %s: %s", btf.file.generic_string(), btf.build_type.to_string());
}
@@ -636,12 +636,12 @@ namespace vcpkg::PostBuildLint
return LintStatus::SUCCESS;
}
- struct OutdatedDynamicCrt_and_file
+ struct OutdatedDynamicCrtAndFile
{
fs::path file;
OutdatedDynamicCrt outdated_crt;
- OutdatedDynamicCrt_and_file() = delete;
+ OutdatedDynamicCrtAndFile() = delete;
};
static LintStatus check_outdated_crt_linkage_of_dlls(const std::vector<fs::path>& dlls,
@@ -650,7 +650,7 @@ namespace vcpkg::PostBuildLint
{
if (build_info.policies.is_enabled(BuildPolicy::ALLOW_OBSOLETE_MSVCRT)) return LintStatus::SUCCESS;
- std::vector<OutdatedDynamicCrt_and_file> dlls_with_outdated_crt;
+ std::vector<OutdatedDynamicCrtAndFile> dlls_with_outdated_crt;
for (const fs::path& dll : dlls)
{
@@ -676,7 +676,7 @@ namespace vcpkg::PostBuildLint
{
System::println(System::Color::warning, "Detected outdated dynamic CRT in the following files:");
System::println();
- for (const OutdatedDynamicCrt_and_file btf : dlls_with_outdated_crt)
+ for (const OutdatedDynamicCrtAndFile btf : dlls_with_outdated_crt)
{
System::println(" %s: %s", btf.file.generic_string(), btf.outdated_crt.name);
}
diff --git a/toolsrc/src/SourceParagraph.cpp b/toolsrc/src/SourceParagraph.cpp
index 50d6ecf07..171689ce7 100644
--- a/toolsrc/src/SourceParagraph.cpp
+++ b/toolsrc/src/SourceParagraph.cpp
@@ -137,7 +137,7 @@ namespace vcpkg
auto control_file = std::make_unique<SourceControlFile>();
auto maybe_source = parse_source_paragraph(std::move(control_paragraphs.front()));
- if (auto source = maybe_source.get())
+ if (const auto source = maybe_source.get())
control_file->core_paragraph = std::move(*source);
else
return std::move(maybe_source).error();
@@ -147,7 +147,7 @@ namespace vcpkg
for (auto&& feature_pgh : control_paragraphs)
{
auto maybe_feature = parse_feature_paragraph(std::move(feature_pgh));
- if (auto feature = maybe_feature.get())
+ if (const auto feature = maybe_feature.get())
control_file->feature_paragraphs.emplace_back(std::move(*feature));
else
return std::move(maybe_feature).error();
@@ -170,17 +170,10 @@ namespace vcpkg
std::string Dependency::name() const
{
- std::string str = this->depend.name;
- if (this->depend.features.empty()) return str;
+ if (this->depend.features.empty()) return this->depend.name;
- str += "[";
- for (auto&& s : this->depend.features)
- {
- str += s + ",";
- }
- str.pop_back();
- str += "]";
- return str;
+ const std::string features = Strings::join(",", this->depend.features);
+ return Strings::format("%s[%s]", this->depend.name, features);
}
std::vector<Dependency> vcpkg::expand_qualified_dependencies(const std::vector<std::string>& depends)
@@ -220,11 +213,7 @@ namespace vcpkg
return FeatureSpec::from_strings_and_triplet(filter_dependencies(deps, t), t);
}
- const std::string to_string(const Dependency& dep)
- {
- std::string name = dep.name();
- return name;
- }
+ std::string to_string(const Dependency& dep) { return dep.name(); }
ExpectedT<Supports, std::vector<std::string>> Supports::parse(const std::vector<std::string>& strs)
{
@@ -263,7 +252,7 @@ namespace vcpkg
bool Supports::is_supported(Architecture arch, Platform plat, Linkage crt, ToolsetVersion tools)
{
- auto is_in_or_empty = [](auto v, auto&& c) -> bool { return c.empty() || c.end() != Util::find(c, v); };
+ const auto is_in_or_empty = [](auto v, auto&& c) -> bool { return c.empty() || c.end() != Util::find(c, v); };
if (!is_in_or_empty(arch, architectures)) return false;
if (!is_in_or_empty(plat, platforms)) return false;
if (!is_in_or_empty(crt, crt_linkages)) return false;
diff --git a/toolsrc/src/StatusParagraph.cpp b/toolsrc/src/StatusParagraph.cpp
index 5b5c3978f..f8ae293c2 100644
--- a/toolsrc/src/StatusParagraph.cpp
+++ b/toolsrc/src/StatusParagraph.cpp
@@ -33,8 +33,8 @@ namespace vcpkg
this->package = BinaryParagraph(std::move(fields));
auto b = status_field.begin();
- auto mark = b;
- auto e = status_field.end();
+ const auto mark = b;
+ const auto e = status_field.end();
// Todo: improve error handling
while (b != e && *b != ' ')
diff --git a/toolsrc/src/StatusParagraphs.cpp b/toolsrc/src/StatusParagraphs.cpp
index 02ee61f75..aaba95eb9 100644
--- a/toolsrc/src/StatusParagraphs.cpp
+++ b/toolsrc/src/StatusParagraphs.cpp
@@ -67,7 +67,7 @@ namespace vcpkg
{
Checks::check_exit(VCPKG_LINE_INFO, pgh != nullptr, "Inserted null paragraph");
const PackageSpec& spec = pgh->package.spec;
- auto ptr = find(spec.name(), spec.triplet(), pgh->package.feature);
+ const auto ptr = find(spec.name(), spec.triplet(), pgh->package.feature);
if (ptr == end())
{
paragraphs.push_back(std::move(pgh));
diff --git a/toolsrc/src/VcpkgPaths.cpp b/toolsrc/src/VcpkgPaths.cpp
index ef9209b78..906a5e67f 100644
--- a/toolsrc/src/VcpkgPaths.cpp
+++ b/toolsrc/src/VcpkgPaths.cpp
@@ -10,37 +10,27 @@
namespace vcpkg
{
- static std::string WORKAROUND_ISSUE_1712(const std::string& line)
- {
- auto colon_pos = line.find(':');
- if (colon_pos != std::string::npos && colon_pos > 0)
- {
- return line.substr(colon_pos - 1);
- }
- return line;
- }
-
static bool exists_and_has_equal_or_greater_version(const std::wstring& version_cmd,
const std::array<int, 3>& expected_version)
{
- static const std::regex re(R"###((\d+)\.(\d+)\.(\d+))###");
+ static const std::regex RE(R"###((\d+)\.(\d+)\.(\d+))###");
- auto rc = System::cmd_execute_and_capture_output(Strings::wformat(LR"(%s)", version_cmd));
+ const auto rc = System::cmd_execute_and_capture_output(Strings::wformat(LR"(%s)", version_cmd));
if (rc.exit_code != 0)
{
return false;
}
std::match_results<std::string::const_iterator> match;
- auto found = std::regex_search(rc.output, match, re);
+ const auto found = std::regex_search(rc.output, match, RE);
if (!found)
{
return false;
}
- int d1 = atoi(match[1].str().c_str());
- int d2 = atoi(match[2].str().c_str());
- int d3 = atoi(match[3].str().c_str());
+ const int d1 = atoi(match[1].str().c_str());
+ const int d2 = atoi(match[2].str().c_str());
+ const int d3 = atoi(match[3].str().c_str());
if (d1 > expected_version[0] || (d1 == expected_version[0] && d2 > expected_version[1]) ||
(d1 == expected_version[0] && d2 == expected_version[1] && d3 >= expected_version[2]))
{
@@ -68,26 +58,15 @@ namespace vcpkg
return nullopt;
}
- static std::vector<fs::path> find_from_PATH(const std::wstring& name)
- {
- const std::wstring cmd = Strings::wformat(L"where.exe %s", name);
- auto out = System::cmd_execute_and_capture_output(cmd);
- if (out.exit_code != 0)
- {
- return {};
- }
-
- return Util::fmap(Strings::split(out.output, "\n"), [](auto&& s) { return fs::path(s); });
- }
-
static fs::path fetch_dependency(const fs::path& scripts_folder,
const std::wstring& tool_name,
const fs::path& expected_downloaded_path,
const std::array<int, 3>& version)
{
const fs::path script = scripts_folder / "fetchDependency.ps1";
- auto install_cmd = System::create_powershell_script_cmd(script, Strings::wformat(L"-Dependency %s", tool_name));
- System::ExitCodeAndOutput rc = System::cmd_execute_and_capture_output(install_cmd);
+ const auto install_cmd =
+ System::create_powershell_script_cmd(script, Strings::wformat(L"-Dependency %s", tool_name));
+ const System::ExitCodeAndOutput rc = System::cmd_execute_and_capture_output(install_cmd);
if (rc.exit_code)
{
const std::string version_as_string = Strings::format("%d.%d.%d", version[0], version[1], version[2]);
@@ -105,9 +84,9 @@ namespace vcpkg
Checks::exit_with_code(VCPKG_LINE_INFO, rc.exit_code);
}
- const fs::path actual_downloaded_path = WORKAROUND_ISSUE_1712(Strings::trimmed(rc.output));
+ const fs::path actual_downloaded_path = Strings::trimmed(rc.output);
std::error_code ec;
- auto eq = fs::stdfs::equivalent(expected_downloaded_path, actual_downloaded_path, ec);
+ const auto eq = fs::stdfs::equivalent(expected_downloaded_path, actual_downloaded_path, ec);
Checks::check_exit(VCPKG_LINE_INFO,
eq && !ec,
"Expected dependency downloaded path to be %s, but was %s",
@@ -118,71 +97,71 @@ namespace vcpkg
static fs::path get_cmake_path(const fs::path& downloads_folder, const fs::path& scripts_folder)
{
- static constexpr std::array<int, 3> expected_version = {3, 9, 1};
- static const std::wstring version_check_arguments = L"--version";
+ static constexpr std::array<int, 3> EXPECTED_VERSION = {3, 9, 1};
+ static const std::wstring VERSION_CHECK_ARGUMENTS = L"--version";
const fs::path downloaded_copy = downloads_folder / "cmake-3.9.1-win32-x86" / "bin" / "cmake.exe";
- const std::vector<fs::path> from_path = find_from_PATH(L"cmake");
+ const std::vector<fs::path> from_path = Files::find_from_PATH(L"cmake");
std::vector<fs::path> candidate_paths;
candidate_paths.push_back(downloaded_copy);
candidate_paths.insert(candidate_paths.end(), from_path.cbegin(), from_path.cend());
- candidate_paths.push_back(System::get_ProgramFiles_platform_bitness() / "CMake" / "bin" / "cmake.exe");
- candidate_paths.push_back(System::get_ProgramFiles_32_bit() / "CMake" / "bin");
+ candidate_paths.push_back(System::get_program_files_platform_bitness() / "CMake" / "bin" / "cmake.exe");
+ candidate_paths.push_back(System::get_program_files_32_bit() / "CMake" / "bin");
const Optional<fs::path> path =
- find_if_has_equal_or_greater_version(candidate_paths, version_check_arguments, expected_version);
- if (auto p = path.get())
+ find_if_has_equal_or_greater_version(candidate_paths, VERSION_CHECK_ARGUMENTS, EXPECTED_VERSION);
+ if (const auto p = path.get())
{
return *p;
}
- return fetch_dependency(scripts_folder, L"cmake", downloaded_copy, expected_version);
+ return fetch_dependency(scripts_folder, L"cmake", downloaded_copy, EXPECTED_VERSION);
}
fs::path get_nuget_path(const fs::path& downloads_folder, const fs::path& scripts_folder)
{
- static constexpr std::array<int, 3> expected_version = {4, 1, 0};
- static const std::wstring version_check_arguments = Strings::WEMPTY;
+ static constexpr std::array<int, 3> EXPECTED_VERSION = {4, 1, 0};
+ static const std::wstring VERSION_CHECK_ARGUMENTS = Strings::WEMPTY;
const fs::path downloaded_copy = downloads_folder / "nuget-4.1.0" / "nuget.exe";
- const std::vector<fs::path> from_path = find_from_PATH(L"nuget");
+ const std::vector<fs::path> from_path = Files::find_from_PATH(L"nuget");
std::vector<fs::path> candidate_paths;
candidate_paths.push_back(downloaded_copy);
candidate_paths.insert(candidate_paths.end(), from_path.cbegin(), from_path.cend());
- auto path = find_if_has_equal_or_greater_version(candidate_paths, version_check_arguments, expected_version);
- if (auto p = path.get())
+ auto path = find_if_has_equal_or_greater_version(candidate_paths, VERSION_CHECK_ARGUMENTS, EXPECTED_VERSION);
+ if (const auto p = path.get())
{
return *p;
}
- return fetch_dependency(scripts_folder, L"nuget", downloaded_copy, expected_version);
+ return fetch_dependency(scripts_folder, L"nuget", downloaded_copy, EXPECTED_VERSION);
}
fs::path get_git_path(const fs::path& downloads_folder, const fs::path& scripts_folder)
{
- static constexpr std::array<int, 3> expected_version = {2, 14, 1};
- static const std::wstring version_check_arguments = L"--version";
+ static constexpr std::array<int, 3> EXPECTED_VERSION = {2, 14, 1};
+ static const std::wstring VERSION_CHECK_ARGUMENTS = L"--version";
const fs::path downloaded_copy = downloads_folder / "MinGit-2.14.1-32-bit" / "cmd" / "git.exe";
- const std::vector<fs::path> from_path = find_from_PATH(L"git");
+ const std::vector<fs::path> from_path = Files::find_from_PATH(L"git");
std::vector<fs::path> candidate_paths;
candidate_paths.push_back(downloaded_copy);
candidate_paths.insert(candidate_paths.end(), from_path.cbegin(), from_path.cend());
- candidate_paths.push_back(System::get_ProgramFiles_platform_bitness() / "git" / "cmd" / "git.exe");
- candidate_paths.push_back(System::get_ProgramFiles_32_bit() / "git" / "cmd" / "git.exe");
+ candidate_paths.push_back(System::get_program_files_platform_bitness() / "git" / "cmd" / "git.exe");
+ candidate_paths.push_back(System::get_program_files_32_bit() / "git" / "cmd" / "git.exe");
const Optional<fs::path> path =
- find_if_has_equal_or_greater_version(candidate_paths, version_check_arguments, expected_version);
- if (auto p = path.get())
+ find_if_has_equal_or_greater_version(candidate_paths, VERSION_CHECK_ARGUMENTS, EXPECTED_VERSION);
+ if (const auto p = path.get())
{
return *p;
}
- return fetch_dependency(scripts_folder, L"git", downloaded_copy, expected_version);
+ return fetch_dependency(scripts_folder, L"git", downloaded_copy, EXPECTED_VERSION);
}
Expected<VcpkgPaths> VcpkgPaths::create(const fs::path& vcpkg_root_dir)
@@ -243,7 +222,7 @@ namespace vcpkg
{
for (auto&& path : get_filesystem().get_files_non_recursive(this->triplets))
{
- std::string triplet_file_name = path.stem().generic_u8string();
+ const std::string triplet_file_name = path.stem().generic_u8string();
if (t.canonical_name() == triplet_file_name) // TODO: fuzzy compare
{
// t.value = triplet_file_name; // NOTE: uncomment when implementing fuzzy compare
@@ -268,19 +247,19 @@ namespace vcpkg
return this->nuget_exe.get_lazy([this]() { return get_nuget_path(this->downloads, this->scripts); });
}
- static std::vector<std::string> get_VS2017_installation_instances(const VcpkgPaths& paths)
+ static std::vector<std::string> get_vs2017_installation_instances(const VcpkgPaths& paths)
{
const fs::path script = paths.scripts / "findVisualStudioInstallationInstances.ps1";
const std::wstring cmd = System::create_powershell_script_cmd(script);
- System::ExitCodeAndOutput ec_data = System::cmd_execute_and_capture_output(cmd);
+ const System::ExitCodeAndOutput ec_data = System::cmd_execute_and_capture_output(cmd);
Checks::check_exit(VCPKG_LINE_INFO, ec_data.exit_code == 0, "Could not run script to detect VS 2017 instances");
- return Util::fmap(Strings::split(ec_data.output, "\n"), WORKAROUND_ISSUE_1712);
+ return Strings::split(ec_data.output, "\n");
}
- static Optional<fs::path> get_VS2015_installation_instance()
+ static Optional<fs::path> get_vs2015_installation_instance()
{
const Optional<std::wstring> vs2015_cmntools_optional = System::get_environment_variable(L"VS140COMNTOOLS");
- if (auto v = vs2015_cmntools_optional.get())
+ if (const auto v = vs2015_cmntools_optional.get())
{
const fs::path vs2015_cmntools = fs::path(*v).parent_path(); // The call to parent_path() is needed because
// the env variable has a trailing backslash
@@ -296,15 +275,15 @@ namespace vcpkg
const auto& fs = paths.get_filesystem();
- const std::vector<std::string> vs2017_installation_instances = get_VS2017_installation_instances(paths);
+ const std::vector<std::string> vs2017_installation_instances = get_vs2017_installation_instances(paths);
// Note: this will contain a mix of vcvarsall.bat locations and dumpbin.exe locations.
std::vector<fs::path> paths_examined;
std::vector<Toolset> found_toolsets;
// VS2015
- const Optional<fs::path> vs_2015_installation_instance = get_VS2015_installation_instance();
- if (auto v = vs_2015_installation_instance.get())
+ const Optional<fs::path> vs_2015_installation_instance = get_vs2015_installation_instance();
+ if (const auto v = vs_2015_installation_instance.get())
{
const fs::path vs2015_vcvarsall_bat = *v / "VC" / "vcvarsall.bat";
@@ -339,9 +318,9 @@ namespace vcpkg
// VS2017
Optional<Toolset> vs2017_toolset;
- for (const fs::path& instance : vs2017_installation_instances)
+ for (const std::string& instance : vs2017_installation_instances)
{
- const fs::path vc_dir = instance / "VC";
+ const fs::path vc_dir = fs::path{instance} / "VC";
// Skip any instances that do not have vcvarsall.
const fs::path vcvarsall_dir = vc_dir / "Auxiliary" / "Build";
@@ -384,7 +363,7 @@ namespace vcpkg
break;
}
}
- if (auto value = vs2017_toolset.get())
+ if (const auto value = vs2017_toolset.get())
{
found_toolsets.push_back(*value);
break;
@@ -414,15 +393,12 @@ namespace vcpkg
{
return vs_toolsets.back();
}
- else
- {
- const auto toolset = Util::find_if(vs_toolsets, [&](const Toolset& toolset) {
- return toolset_version == Strings::to_utf8(toolset.version);
- });
- Checks::check_exit(
- VCPKG_LINE_INFO, toolset != vs_toolsets.end(), "Could not find toolset '%s'", toolset_version);
- return *toolset;
- }
+
+ const auto toolset = Util::find_if(
+ vs_toolsets, [&](const Toolset& t) { return toolset_version == Strings::to_utf8(t.version); });
+ Checks::check_exit(
+ VCPKG_LINE_INFO, toolset != vs_toolsets.end(), "Could not find toolset '%s'", toolset_version);
+ return *toolset;
}
Files::Filesystem& VcpkgPaths::get_filesystem() const { return Files::get_real_filesystem(); }
diff --git a/toolsrc/src/coff_file_reader.cpp b/toolsrc/src/coff_file_reader.cpp
index 10c1437c6..bb3a6cefd 100644
--- a/toolsrc/src/coff_file_reader.cpp
+++ b/toolsrc/src/coff_file_reader.cpp
@@ -5,7 +5,7 @@
using namespace std;
-namespace vcpkg::COFFFileReader
+namespace vcpkg::CoffFileReader
{
template<class T>
static T reinterpret_bytes(const char* data)
diff --git a/toolsrc/src/commands_build.cpp b/toolsrc/src/commands_build.cpp
index 26a783a4b..a69958058 100644
--- a/toolsrc/src/commands_build.cpp
+++ b/toolsrc/src/commands_build.cpp
@@ -89,11 +89,11 @@ namespace vcpkg::Commands::BuildCommand
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet)
{
- static const std::string example = Commands::Help::create_example_string("build zlib:x64-windows");
- args.check_exact_arg_count(
- 1, example); // Build only takes a single package and all dependencies must already be installed
+ static const std::string EXAMPLE = Commands::Help::create_example_string("build zlib:x64-windows");
+ // Build only takes a single package and all dependencies must already be installed
+ args.check_exact_arg_count(1, EXAMPLE);
const std::string command_argument = args.command_arguments.at(0);
- const FullPackageSpec spec = Input::check_and_get_full_package_spec(command_argument, default_triplet, example);
+ const FullPackageSpec spec = Input::check_and_get_full_package_spec(command_argument, default_triplet, EXAMPLE);
Input::check_triplet(spec.package_spec.triplet(), paths);
const std::unordered_set<std::string> options =
args.check_and_get_optional_command_arguments({OPTION_CHECKS_ONLY});
diff --git a/toolsrc/src/commands_build_external.cpp b/toolsrc/src/commands_build_external.cpp
index ff70e9cf2..7e85f2250 100644
--- a/toolsrc/src/commands_build_external.cpp
+++ b/toolsrc/src/commands_build_external.cpp
@@ -2,17 +2,16 @@
#include "vcpkg_Commands.h"
#include "vcpkg_Input.h"
-#include "vcpkg_System.h"
namespace vcpkg::Commands::BuildExternal
{
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet)
{
- static const std::string example =
+ static const std::string EXAMPLE =
Commands::Help::create_example_string(R"(build_external zlib2 C:\path\to\dir\with\controlfile\)");
- args.check_exact_arg_count(2, example);
+ args.check_exact_arg_count(2, EXAMPLE);
const FullPackageSpec spec =
- Input::check_and_get_full_package_spec(args.command_arguments.at(0), default_triplet, example);
+ Input::check_and_get_full_package_spec(args.command_arguments.at(0), default_triplet, EXAMPLE);
Input::check_triplet(spec.package_spec.triplet(), paths);
const std::unordered_set<std::string> options = args.check_and_get_optional_command_arguments({});
diff --git a/toolsrc/src/commands_cache.cpp b/toolsrc/src/commands_cache.cpp
index fa0c62ee4..5b65b197f 100644
--- a/toolsrc/src/commands_cache.cpp
+++ b/toolsrc/src/commands_cache.cpp
@@ -27,10 +27,10 @@ namespace vcpkg::Commands::Cache
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
{
- static const std::string example = Strings::format(
+ static const std::string EXAMPLE = Strings::format(
"The argument should be a substring to search for, or no argument to display all cached libraries.\n%s",
Commands::Help::create_example_string("cache png"));
- args.check_max_arg_count(1, example);
+ args.check_max_arg_count(1, EXAMPLE);
args.check_and_get_optional_command_arguments({});
const std::vector<BinaryParagraph> binary_paragraphs = read_all_binary_paragraphs(paths);
diff --git a/toolsrc/src/commands_ci.cpp b/toolsrc/src/commands_ci.cpp
index f781adf69..ca5e8a9a9 100644
--- a/toolsrc/src/commands_ci.cpp
+++ b/toolsrc/src/commands_ci.cpp
@@ -13,9 +13,9 @@
namespace vcpkg::Commands::CI
{
+ using Build::BuildResult;
using Dependencies::InstallPlanAction;
using Dependencies::InstallPlanType;
- using Build::BuildResult;
static std::vector<PackageSpec> load_all_package_specs(Files::Filesystem& fs,
const fs::path& ports_directory,
@@ -30,8 +30,8 @@ namespace vcpkg::Commands::CI
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet)
{
- static const std::string example = Commands::Help::create_example_string("ci x64-windows");
- args.check_max_arg_count(1, example);
+ static const std::string EXAMPLE = Commands::Help::create_example_string("ci x64-windows");
+ args.check_max_arg_count(1, EXAMPLE);
const Triplet triplet = args.command_arguments.size() == 1
? Triplet::from_canonical_name(args.command_arguments.at(0))
: default_triplet;
diff --git a/toolsrc/src/commands_contact.cpp b/toolsrc/src/commands_contact.cpp
index 7f4161802..8374350ee 100644
--- a/toolsrc/src/commands_contact.cpp
+++ b/toolsrc/src/commands_contact.cpp
@@ -7,8 +7,8 @@ namespace vcpkg::Commands::Contact
{
const std::string& email()
{
- static const std::string s_email = R"(vcpkg@microsoft.com)";
- return s_email;
+ static const std::string S_EMAIL = R"(vcpkg@microsoft.com)";
+ return S_EMAIL;
}
void perform_and_exit(const VcpkgCmdArguments& args)
diff --git a/toolsrc/src/commands_create.cpp b/toolsrc/src/commands_create.cpp
index 7f85b776a..6898f7399 100644
--- a/toolsrc/src/commands_create.cpp
+++ b/toolsrc/src/commands_create.cpp
@@ -2,7 +2,6 @@
#include "vcpkg_Commands.h"
#include "vcpkg_Files.h"
-#include "vcpkg_Input.h"
#include "vcpkg_System.h"
#include "vcpkglib.h"
@@ -10,10 +9,10 @@ namespace vcpkg::Commands::Create
{
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
{
- static const std::string example = Commands::Help::create_example_string(
+ static const std::string EXAMPLE = Commands::Help::create_example_string(
R"###(create zlib2 http://zlib.net/zlib1211.zip "zlib1211-2.zip")###");
- args.check_max_arg_count(3, example);
- args.check_min_arg_count(2, example);
+ args.check_max_arg_count(3, EXAMPLE);
+ args.check_min_arg_count(2, EXAMPLE);
args.check_and_get_optional_command_arguments({});
const std::string port_name = args.command_arguments.at(0);
const std::string url = args.command_arguments.at(1);
diff --git a/toolsrc/src/commands_depends.cpp b/toolsrc/src/commands_depends.cpp
index ffad91226..17cd9c881 100644
--- a/toolsrc/src/commands_depends.cpp
+++ b/toolsrc/src/commands_depends.cpp
@@ -10,8 +10,8 @@ namespace vcpkg::Commands::DependInfo
{
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
{
- static const std::string example = Commands::Help::create_example_string(R"###(depend-info [pat])###");
- args.check_max_arg_count(1, example);
+ static const std::string EXAMPLE = Commands::Help::create_example_string(R"###(depend-info [pat])###");
+ args.check_max_arg_count(1, EXAMPLE);
args.check_and_get_optional_command_arguments({});
std::vector<std::unique_ptr<SourceControlFile>> source_control_files =
diff --git a/toolsrc/src/commands_edit.cpp b/toolsrc/src/commands_edit.cpp
index e72931e63..dc28de737 100644
--- a/toolsrc/src/commands_edit.cpp
+++ b/toolsrc/src/commands_edit.cpp
@@ -6,6 +6,30 @@
namespace vcpkg::Commands::Edit
{
+ static std::vector<fs::path> find_from_registry()
+ {
+ static const std::array<const wchar_t*, 4> REGKEYS = {
+ LR"(SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{C26E74D1-022E-4238-8B9D-1E7564A36CC9}_is1)",
+ LR"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C26E74D1-022E-4238-8B9D-1E7564A36CC9}_is1)",
+ LR"(SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{F8A2A208-72B3-4D61-95FC-8A65D340689B}_is1)",
+ LR"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{F8A2A208-72B3-4D61-95FC-8A65D340689B}_is1)",
+ };
+
+ std::vector<fs::path> output;
+ for (auto&& keypath : REGKEYS)
+ {
+ const Optional<std::wstring> code_installpath =
+ System::get_registry_string(HKEY_LOCAL_MACHINE, keypath, L"InstallLocation");
+ if (const auto c = code_installpath.get())
+ {
+ const fs::path install_path = fs::path(*c);
+ output.push_back(install_path / "Code.exe");
+ output.push_back(install_path / "Code - Insiders.exe");
+ }
+ }
+ return output;
+ }
+
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
{
static const std::string OPTION_BUILDTREES = "--buildtrees";
@@ -21,72 +45,27 @@ namespace vcpkg::Commands::Edit
const fs::path portpath = paths.ports / port_name;
Checks::check_exit(VCPKG_LINE_INFO, fs.is_directory(portpath), R"(Could not find port named "%s")", port_name);
- // Find the user's selected editor
- std::wstring env_editor;
+ std::vector<fs::path> candidate_paths;
+ const std::vector<fs::path> from_path = Files::find_from_PATH(L"EDITOR");
+ candidate_paths.insert(candidate_paths.end(), from_path.cbegin(), from_path.cend());
+ candidate_paths.push_back(System::get_program_files_platform_bitness() / "Microsoft VS Code" / "Code.exe");
+ candidate_paths.push_back(System::get_program_files_32_bit() / "Microsoft VS Code" / "Code.exe");
- if (env_editor.empty())
- {
- const Optional<std::wstring> env_editor_optional = System::get_environment_variable(L"EDITOR");
- if (const auto e = env_editor_optional.get())
- {
- env_editor = *e;
- }
- }
-
- if (env_editor.empty())
- {
- const fs::path code_exe_path = System::get_ProgramFiles_platform_bitness() / "Microsoft VS Code/Code.exe";
- if (fs.exists(code_exe_path))
- {
- env_editor = code_exe_path;
- }
- }
-
- if (env_editor.empty())
- {
- const fs::path code_exe_path = System::get_ProgramFiles_32_bit() / "Microsoft VS Code/Code.exe";
- if (fs.exists(code_exe_path))
- {
- env_editor = code_exe_path;
- }
- }
-
- if (env_editor.empty())
- {
- static const std::array<const wchar_t*, 4> REGKEYS = {
- LR"(SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{C26E74D1-022E-4238-8B9D-1E7564A36CC9}_is1)",
- LR"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C26E74D1-022E-4238-8B9D-1E7564A36CC9}_is1)",
- LR"(SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{F8A2A208-72B3-4D61-95FC-8A65D340689B}_is1)",
- LR"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{F8A2A208-72B3-4D61-95FC-8A65D340689B}_is1)",
- };
- for (auto&& keypath : REGKEYS)
- {
- const Optional<std::wstring> code_installpath =
- System::get_registry_string(HKEY_LOCAL_MACHINE, keypath, L"InstallLocation");
- if (const auto c = code_installpath.get())
- {
- auto p = fs::path(*c) / "Code.exe";
- if (fs.exists(p))
- {
- env_editor = p.native();
- break;
- }
- auto p_insiders = fs::path(*c) / "Code - Insiders.exe";
- if (fs.exists(p_insiders))
- {
- env_editor = p_insiders.native();
- break;
- }
- }
- }
- }
+ const std::vector<fs::path> from_registry = find_from_registry();
+ candidate_paths.insert(candidate_paths.end(), from_registry.cbegin(), from_registry.cend());
- if (env_editor.empty())
+ auto it = Util::find_if(candidate_paths, [&](const fs::path& p) { return fs.exists(p); });
+ if (it == candidate_paths.cend())
{
- Checks::exit_with_message(
- VCPKG_LINE_INFO, "Visual Studio Code was not found and the environment variable EDITOR is not set");
+ System::println(System::Color::error,
+ "Error: Visual Studio Code was not found and the environment variable EDITOR is not set.");
+ System::println("The following paths were examined:");
+ Files::print_paths(candidate_paths);
+ System::println("You can also set the environmental variable EDITOR to your editor of choice.");
+ Checks::exit_fail(VCPKG_LINE_INFO);
}
+ const fs::path env_editor = *it;
if (options.find(OPTION_BUILDTREES) != options.cend())
{
const auto buildtrees_current_dir = paths.buildtrees / port_name;
diff --git a/toolsrc/src/commands_export.cpp b/toolsrc/src/commands_export.cpp
index dbfb09aab..b416a6f3c 100644
--- a/toolsrc/src/commands_export.cpp
+++ b/toolsrc/src/commands_export.cpp
@@ -21,7 +21,7 @@ namespace vcpkg::Commands::Export
const std::string& nuget_id,
const std::string& nupkg_version)
{
- static constexpr auto content_template = R"(
+ static constexpr auto CONTENT_TEMPLATE = R"(
<package>
<metadata>
<id>@NUGET_ID@</id>
@@ -40,7 +40,7 @@ namespace vcpkg::Commands::Export
</package>
)";
- std::string nuspec_file_content = std::regex_replace(content_template, std::regex("@NUGET_ID@"), nuget_id);
+ std::string nuspec_file_content = std::regex_replace(CONTENT_TEMPLATE, std::regex("@NUGET_ID@"), nuget_id);
nuspec_file_content = std::regex_replace(nuspec_file_content, std::regex("@VERSION@"), nupkg_version);
nuspec_file_content =
std::regex_replace(nuspec_file_content, std::regex("@RAW_EXPORTED_DIR@"), raw_exported_dir);
@@ -62,10 +62,10 @@ namespace vcpkg::Commands::Export
static void print_plan(const std::map<ExportPlanType, std::vector<const ExportPlanAction*>>& group_by_plan_type)
{
- static constexpr std::array<ExportPlanType, 2> order = {ExportPlanType::ALREADY_BUILT,
+ static constexpr std::array<ExportPlanType, 2> ORDER = {ExportPlanType::ALREADY_BUILT,
ExportPlanType::PORT_AVAILABLE_BUT_NOT_BUILT};
- for (const ExportPlanType plan_type : order)
+ for (const ExportPlanType plan_type : ORDER)
{
const auto it = group_by_plan_type.find(plan_type);
if (it == group_by_plan_type.cend())
@@ -151,7 +151,7 @@ namespace vcpkg::Commands::Export
enum class BackingEnum
{
ZIP = 1,
- _7ZIP,
+ SEVEN_ZIP,
};
constexpr ArchiveFormat() = delete;
@@ -174,7 +174,7 @@ namespace vcpkg::Commands::Export
namespace ArchiveFormatC
{
constexpr const ArchiveFormat ZIP(ArchiveFormat::BackingEnum::ZIP, L"zip", L"zip");
- constexpr const ArchiveFormat _7ZIP(ArchiveFormat::BackingEnum::_7ZIP, L"7z", L"7zip");
+ constexpr const ArchiveFormat SEVEN_ZIP(ArchiveFormat::BackingEnum::SEVEN_ZIP, L"7z", L"7zip");
}
static fs::path do_archive_export(const VcpkgPaths& paths,
@@ -216,17 +216,17 @@ namespace vcpkg::Commands::Export
static const std::string OPTION_RAW = "--raw";
static const std::string OPTION_NUGET = "--nuget";
static const std::string OPTION_ZIP = "--zip";
- static const std::string OPTION_7ZIP = "--7zip";
+ static const std::string OPTION_SEVEN_ZIP = "--7zip";
static const std::string OPTION_NUGET_ID = "--nuget-id";
static const std::string OPTION_NUGET_VERSION = "--nuget-version";
// input sanitization
- static const std::string example =
+ static const std::string EXAMPLE =
Commands::Help::create_example_string("export zlib zlib:x64-windows boost --nuget");
- args.check_min_arg_count(1, example);
+ args.check_min_arg_count(1, EXAMPLE);
const std::vector<PackageSpec> specs = Util::fmap(args.command_arguments, [&](auto&& arg) {
- return Input::check_and_get_package_spec(arg, default_triplet, example);
+ return Input::check_and_get_package_spec(arg, default_triplet, EXAMPLE);
});
for (auto&& spec : specs)
Input::check_triplet(spec.triplet(), paths);
@@ -237,22 +237,22 @@ namespace vcpkg::Commands::Export
OPTION_RAW,
OPTION_NUGET,
OPTION_ZIP,
- OPTION_7ZIP,
+ OPTION_SEVEN_ZIP,
},
{
OPTION_NUGET_ID,
OPTION_NUGET_VERSION,
});
- const bool dryRun = options.switches.find(OPTION_DRY_RUN) != options.switches.cend();
+ const bool dry_run = options.switches.find(OPTION_DRY_RUN) != options.switches.cend();
const bool raw = options.switches.find(OPTION_RAW) != options.switches.cend();
const bool nuget = options.switches.find(OPTION_NUGET) != options.switches.cend();
const bool zip = options.switches.find(OPTION_ZIP) != options.switches.cend();
- const bool _7zip = options.switches.find(OPTION_7ZIP) != options.switches.cend();
+ const bool seven_zip = options.switches.find(OPTION_SEVEN_ZIP) != options.switches.cend();
- if (!raw && !nuget && !zip && !_7zip && !dryRun)
+ if (!raw && !nuget && !zip && !seven_zip && !dry_run)
{
System::println(System::Color::error, "Must provide at least one export type: --raw --nuget --zip --7zip");
- System::print(example);
+ System::print(EXAMPLE);
Checks::exit_fail(VCPKG_LINE_INFO);
}
@@ -300,7 +300,7 @@ namespace vcpkg::Commands::Export
Checks::exit_fail(VCPKG_LINE_INFO);
}
- if (dryRun)
+ if (dry_run)
{
Checks::exit_success(VCPKG_LINE_INFO);
}
@@ -407,11 +407,11 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console
print_next_step_info("[...]");
}
- if (_7zip)
+ if (seven_zip)
{
System::println("Creating 7zip archive... ");
const fs::path output_path =
- do_archive_export(paths, raw_exported_dir_path, export_to_path, ArchiveFormatC::_7ZIP);
+ do_archive_export(paths, raw_exported_dir_path, export_to_path, ArchiveFormatC::SEVEN_ZIP);
System::println(System::Color::success, "Creating 7zip archive... done");
System::println(System::Color::success, "7zip archive exported at: %s", output_path.generic_string());
print_next_step_info("[...]");
diff --git a/toolsrc/src/commands_import.cpp b/toolsrc/src/commands_import.cpp
index 5db1885b2..412a03d7f 100644
--- a/toolsrc/src/commands_import.cpp
+++ b/toolsrc/src/commands_import.cpp
@@ -28,7 +28,7 @@ namespace vcpkg::Commands::Import
for (auto&& file : files)
{
if (fs.is_directory(file)) continue;
- auto ext = file.extension();
+ const auto ext = file.extension();
if (ext == ".dll")
binaries.dlls.push_back(std::move(file));
else if (ext == ".lib")
@@ -46,7 +46,7 @@ namespace vcpkg::Commands::Import
for (auto const& src_path : files)
{
- fs::path dest_path = destination_folder / src_path.filename();
+ const fs::path dest_path = destination_folder / src_path.filename();
fs.copy(src_path, dest_path, fs::copy_options::overwrite_existing);
}
}
@@ -59,10 +59,10 @@ namespace vcpkg::Commands::Import
check_is_directory(VCPKG_LINE_INFO, fs, include_directory);
check_is_directory(VCPKG_LINE_INFO, fs, project_directory);
check_is_directory(VCPKG_LINE_INFO, fs, destination_path);
- Binaries debug_binaries = find_binaries_in_dir(fs, project_directory / "Debug");
- Binaries release_binaries = find_binaries_in_dir(fs, project_directory / "Release");
+ const Binaries debug_binaries = find_binaries_in_dir(fs, project_directory / "Debug");
+ const Binaries release_binaries = find_binaries_in_dir(fs, project_directory / "Release");
- fs::path destination_include_directory = destination_path / "include";
+ const fs::path destination_include_directory = destination_path / "include";
fs.copy(include_directory,
destination_include_directory,
fs::copy_options::recursive | fs::copy_options::overwrite_existing);
@@ -82,20 +82,20 @@ namespace vcpkg::Commands::Import
const BinaryParagraph& control_file_data)
{
auto& fs = paths.get_filesystem();
- fs::path library_destination_path = paths.package_dir(control_file_data.spec);
+ const fs::path library_destination_path = paths.package_dir(control_file_data.spec);
std::error_code ec;
fs.create_directory(library_destination_path, ec);
place_library_files_in(paths.get_filesystem(), include_directory, project_directory, library_destination_path);
- fs::path control_file_path = library_destination_path / "CONTROL";
+ const fs::path control_file_path = library_destination_path / "CONTROL";
fs.write_contents(control_file_path, Strings::serialize(control_file_data));
}
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
{
- static const std::string example = Commands::Help::create_example_string(
+ static const std::string EXAMPLE = Commands::Help::create_example_string(
R"(import C:\path\to\CONTROLfile C:\path\to\includedir C:\path\to\projectdir)");
- args.check_exact_arg_count(3, example);
+ args.check_exact_arg_count(3, EXAMPLE);
args.check_and_get_optional_command_arguments({});
const fs::path control_file_path(args.command_arguments[0]);
diff --git a/toolsrc/src/commands_install.cpp b/toolsrc/src/commands_install.cpp
index 8b1eec5eb..d7c14f39c 100644
--- a/toolsrc/src/commands_install.cpp
+++ b/toolsrc/src/commands_install.cpp
@@ -450,12 +450,12 @@ namespace vcpkg::Commands::Install
static const std::string OPTION_RECURSE = "--recurse";
// input sanitization
- static const std::string example =
+ static const std::string EXAMPLE =
Commands::Help::create_example_string("install zlib zlib:x64-windows curl boost");
- args.check_min_arg_count(1, example);
+ args.check_min_arg_count(1, EXAMPLE);
const std::vector<FullPackageSpec> specs = Util::fmap(args.command_arguments, [&](auto&& arg) {
- return Input::check_and_get_full_package_spec(arg, default_triplet, example);
+ return Input::check_and_get_full_package_spec(arg, default_triplet, EXAMPLE);
});
for (auto&& spec : specs)
@@ -549,7 +549,7 @@ namespace vcpkg::Commands::Install
{
// User specified --purge and --no-purge
System::println(System::Color::error, "Error: cannot specify both --no-purge and --purge.");
- System::print(example);
+ System::print(EXAMPLE);
Checks::exit_fail(VCPKG_LINE_INFO);
}
const std::string display_name = remove_action->spec.to_string();
diff --git a/toolsrc/src/commands_integrate.cpp b/toolsrc/src/commands_integrate.cpp
index c5942f9fc..1bf26910c 100644
--- a/toolsrc/src/commands_integrate.cpp
+++ b/toolsrc/src/commands_integrate.cpp
@@ -8,11 +8,11 @@
namespace vcpkg::Commands::Integrate
{
- static const std::array<fs::path, 2> old_system_target_files = {
- System::get_ProgramFiles_32_bit() / "MSBuild/14.0/Microsoft.Common.Targets/ImportBefore/vcpkg.nuget.targets",
- System::get_ProgramFiles_32_bit() / "MSBuild/14.0/Microsoft.Common.Targets/ImportBefore/vcpkg.system.targets"};
- static const fs::path system_wide_targets_file =
- System::get_ProgramFiles_32_bit() / "MSBuild/Microsoft.Cpp/v4.0/V140/ImportBefore/Default/vcpkg.system.props";
+ static const std::array<fs::path, 2> OLD_SYSTEM_TARGET_FILES = {
+ System::get_program_files_32_bit() / "MSBuild/14.0/Microsoft.Common.Targets/ImportBefore/vcpkg.nuget.targets",
+ System::get_program_files_32_bit() / "MSBuild/14.0/Microsoft.Common.Targets/ImportBefore/vcpkg.system.targets"};
+ static const fs::path SYSTEM_WIDE_TARGETS_FILE =
+ System::get_program_files_32_bit() / "MSBuild/Microsoft.Cpp/v4.0/V140/ImportBefore/Default/vcpkg.system.props";
static std::string create_appdata_targets_shortcut(const std::string& target_path) noexcept
{
@@ -82,7 +82,7 @@ namespace vcpkg::Commands::Integrate
const std::string& nuget_id,
const std::string& nupkg_version)
{
- static constexpr auto content_template = R"(
+ static constexpr auto CONTENT_TEMPLATE = R"(
<package>
<metadata>
<id>@NUGET_ID@</id>
@@ -99,7 +99,7 @@ namespace vcpkg::Commands::Integrate
</package>
)";
- std::string content = std::regex_replace(content_template, std::regex("@NUGET_ID@"), nuget_id);
+ std::string content = std::regex_replace(CONTENT_TEMPLATE, std::regex("@NUGET_ID@"), nuget_id);
content = std::regex_replace(content, std::regex("@VCPKG_DIR@"), vcpkg_root_dir.string());
content = std::regex_replace(content, std::regex("@VERSION@"), nupkg_version);
return content;
@@ -113,36 +113,36 @@ namespace vcpkg::Commands::Integrate
static ElevationPromptChoice elevated_cmd_execute(const std::string& param)
{
- SHELLEXECUTEINFO shExInfo = {0};
- shExInfo.cbSize = sizeof(shExInfo);
- shExInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
- shExInfo.hwnd = nullptr;
- shExInfo.lpVerb = "runas";
- shExInfo.lpFile = "cmd"; // Application to start
-
- shExInfo.lpParameters = param.c_str(); // Additional parameters
- shExInfo.lpDirectory = nullptr;
- shExInfo.nShow = SW_HIDE;
- shExInfo.hInstApp = nullptr;
-
- if (!ShellExecuteExA(&shExInfo))
+ SHELLEXECUTEINFO sh_ex_info = {0};
+ sh_ex_info.cbSize = sizeof(sh_ex_info);
+ sh_ex_info.fMask = SEE_MASK_NOCLOSEPROCESS;
+ sh_ex_info.hwnd = nullptr;
+ sh_ex_info.lpVerb = "runas";
+ sh_ex_info.lpFile = "cmd"; // Application to start
+
+ sh_ex_info.lpParameters = param.c_str(); // Additional parameters
+ sh_ex_info.lpDirectory = nullptr;
+ sh_ex_info.nShow = SW_HIDE;
+ sh_ex_info.hInstApp = nullptr;
+
+ if (!ShellExecuteExA(&sh_ex_info))
{
return ElevationPromptChoice::NO;
}
- if (shExInfo.hProcess == nullptr)
+ if (sh_ex_info.hProcess == nullptr)
{
return ElevationPromptChoice::NO;
}
- WaitForSingleObject(shExInfo.hProcess, INFINITE);
- CloseHandle(shExInfo.hProcess);
+ WaitForSingleObject(sh_ex_info.hProcess, INFINITE);
+ CloseHandle(sh_ex_info.hProcess);
return ElevationPromptChoice::YES;
}
static fs::path get_appdata_targets_path()
{
- static const fs::path local_app_data =
+ static const fs::path LOCAL_APP_DATA =
fs::path(System::get_environment_variable(L"LOCALAPPDATA").value_or_exit(VCPKG_LINE_INFO));
- return local_app_data / "vcpkg" / "vcpkg.user.targets";
+ return LOCAL_APP_DATA / "vcpkg" / "vcpkg.user.targets";
}
static void integrate_install(const VcpkgPaths& paths)
@@ -150,13 +150,13 @@ namespace vcpkg::Commands::Integrate
auto& fs = paths.get_filesystem();
// TODO: This block of code should eventually be removed
- for (auto&& old_system_wide_targets_file : old_system_target_files)
+ for (auto&& old_system_wide_targets_file : OLD_SYSTEM_TARGET_FILES)
{
if (fs.exists(old_system_wide_targets_file))
{
const std::string param =
Strings::format(R"(/c DEL "%s" /Q > nul)", old_system_wide_targets_file.string());
- ElevationPromptChoice user_choice = elevated_cmd_execute(param);
+ const ElevationPromptChoice user_choice = elevated_cmd_execute(param);
switch (user_choice)
{
case ElevationPromptChoice::YES: break;
@@ -174,15 +174,15 @@ namespace vcpkg::Commands::Integrate
fs.create_directory(tmp_dir, ec);
bool should_install_system = true;
- const Expected<std::string> system_wide_file_contents = fs.read_contents(system_wide_targets_file);
- if (auto contents_data = system_wide_file_contents.get())
+ const Expected<std::string> system_wide_file_contents = fs.read_contents(SYSTEM_WIDE_TARGETS_FILE);
+ static const std::regex RE(R"###(<!-- version (\d+) -->)###");
+ if (const auto contents_data = system_wide_file_contents.get())
{
- std::regex re(R"###(<!-- version (\d+) -->)###");
std::match_results<std::string::const_iterator> match;
- auto found = std::regex_search(*contents_data, match, re);
+ const auto found = std::regex_search(*contents_data, match, RE);
if (found)
{
- int ver = atoi(match[1].str().c_str());
+ const int ver = atoi(match[1].str().c_str());
if (ver >= 1) should_install_system = false;
}
}
@@ -193,10 +193,10 @@ namespace vcpkg::Commands::Integrate
fs.write_contents(sys_src_path, create_system_targets_shortcut());
const std::string param = Strings::format(R"(/c mkdir "%s" & copy "%s" "%s" /Y > nul)",
- system_wide_targets_file.parent_path().string(),
+ SYSTEM_WIDE_TARGETS_FILE.parent_path().string(),
sys_src_path.string(),
- system_wide_targets_file.string());
- ElevationPromptChoice user_choice = elevated_cmd_execute(param);
+ SYSTEM_WIDE_TARGETS_FILE.string());
+ const ElevationPromptChoice user_choice = elevated_cmd_execute(param);
switch (user_choice)
{
case ElevationPromptChoice::YES: break;
@@ -207,9 +207,9 @@ namespace vcpkg::Commands::Integrate
}
Checks::check_exit(VCPKG_LINE_INFO,
- fs.exists(system_wide_targets_file),
+ fs.exists(SYSTEM_WIDE_TARGETS_FILE),
"Error: failed to copy targets file to %s",
- system_wide_targets_file.string());
+ SYSTEM_WIDE_TARGETS_FILE.string());
}
const fs::path appdata_src_path = tmp_dir / "vcpkg.user.targets";
@@ -217,7 +217,7 @@ namespace vcpkg::Commands::Integrate
create_appdata_targets_shortcut(paths.buildsystems_msbuild_targets.string()));
auto appdata_dst_path = get_appdata_targets_path();
- auto rc = fs.copy_file(appdata_src_path, appdata_dst_path, fs::copy_options::overwrite_existing, ec);
+ const auto rc = fs.copy_file(appdata_src_path, appdata_dst_path, fs::copy_options::overwrite_existing, ec);
if (!rc || ec)
{
@@ -245,7 +245,7 @@ namespace vcpkg::Commands::Integrate
const fs::path path = get_appdata_targets_path();
std::error_code ec;
- bool was_deleted = fs.remove(path, ec);
+ const bool was_deleted = fs.remove(path, ec);
Checks::check_exit(VCPKG_LINE_INFO, !ec, "Error: Unable to remove user-wide integration: %d", ec.message());
@@ -317,10 +317,10 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
{
- static const std::string example = Strings::format("Commands:\n"
+ static const std::string EXAMPLE = Strings::format("Commands:\n"
"%s",
INTEGRATE_COMMAND_HELPSTRING);
- args.check_exact_arg_count(1, example);
+ args.check_exact_arg_count(1, EXAMPLE);
args.check_and_get_optional_command_arguments({});
if (args.command_arguments[0] == "install")
diff --git a/toolsrc/src/commands_list.cpp b/toolsrc/src/commands_list.cpp
index 3cfa7e184..640885860 100644
--- a/toolsrc/src/commands_list.cpp
+++ b/toolsrc/src/commands_list.cpp
@@ -8,9 +8,9 @@ namespace vcpkg::Commands::List
{
static const std::string OPTION_FULLDESC = "--x-full-desc"; // TODO: This should find a better home, eventually
- static void do_print(const StatusParagraph& pgh, bool FullDesc)
+ static void do_print(const StatusParagraph& pgh, bool full_desc)
{
- if (FullDesc)
+ if (full_desc)
{
System::println("%-30s %-16s %s", pgh.package.displayname(), pgh.package.version, pgh.package.description);
}
@@ -25,10 +25,10 @@ namespace vcpkg::Commands::List
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
{
- static const std::string example = Strings::format(
+ static const std::string EXAMPLE = Strings::format(
"The argument should be a substring to search for, or no argument to display all installed libraries.\n%s",
Commands::Help::create_example_string("list png"));
- args.check_max_arg_count(1, example);
+ args.check_max_arg_count(1, EXAMPLE);
const std::unordered_set<std::string> options =
args.check_and_get_optional_command_arguments({OPTION_FULLDESC});
diff --git a/toolsrc/src/commands_owns.cpp b/toolsrc/src/commands_owns.cpp
index 757292e96..718a0277f 100644
--- a/toolsrc/src/commands_owns.cpp
+++ b/toolsrc/src/commands_owns.cpp
@@ -25,9 +25,9 @@ namespace vcpkg::Commands::Owns
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
{
- static const std::string example = Strings::format("The argument should be a pattern to search for. %s",
+ static const std::string EXAMPLE = Strings::format("The argument should be a pattern to search for. %s",
Commands::Help::create_example_string("owns zlib.dll"));
- args.check_exact_arg_count(1, example);
+ args.check_exact_arg_count(1, EXAMPLE);
args.check_and_get_optional_command_arguments({});
StatusParagraphs status_db = database_load_check(paths);
diff --git a/toolsrc/src/commands_portsdiff.cpp b/toolsrc/src/commands_portsdiff.cpp
index 83d62896f..32bc3de3c 100644
--- a/toolsrc/src/commands_portsdiff.cpp
+++ b/toolsrc/src/commands_portsdiff.cpp
@@ -2,7 +2,6 @@
#include "Paragraphs.h"
#include "SortedVector.h"
-#include "SourceParagraph.h"
#include "vcpkg_Commands.h"
#include "vcpkg_Maps.h"
#include "vcpkg_System.h"
@@ -117,11 +116,11 @@ namespace vcpkg::Commands::PortsDiff
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
{
- static const std::string example =
+ static const std::string EXAMPLE =
Strings::format("The argument should be a branch/tag/hash to checkout.\n%s",
Commands::Help::create_example_string("portsdiff mybranchname"));
- args.check_min_arg_count(1, example);
- args.check_max_arg_count(2, example);
+ args.check_min_arg_count(1, EXAMPLE);
+ args.check_max_arg_count(2, EXAMPLE);
args.check_and_get_optional_command_arguments({});
const fs::path& git_exe = paths.get_git_exe();
@@ -139,8 +138,8 @@ namespace vcpkg::Commands::PortsDiff
read_ports_from_commit(paths, git_commit_id_for_previous_snapshot);
// Already sorted, so set_difference can work on std::vector too
- std::vector<std::string> current_ports = Maps::extract_keys(current_names_and_versions);
- std::vector<std::string> previous_ports = Maps::extract_keys(previous_names_and_versions);
+ const std::vector<std::string> current_ports = Maps::extract_keys(current_names_and_versions);
+ const std::vector<std::string> previous_ports = Maps::extract_keys(previous_names_and_versions);
const SetElementPresence<std::string> setp =
SetElementPresence<std::string>::create(current_ports, previous_ports);
diff --git a/toolsrc/src/commands_remove.cpp b/toolsrc/src/commands_remove.cpp
index cca541c85..2b5033166 100644
--- a/toolsrc/src/commands_remove.cpp
+++ b/toolsrc/src/commands_remove.cpp
@@ -136,7 +136,7 @@ namespace vcpkg::Commands::Remove
static const std::string OPTION_RECURSE = "--recurse";
static const std::string OPTION_DRY_RUN = "--dry-run";
static const std::string OPTION_OUTDATED = "--outdated";
- static const std::string example =
+ static const std::string EXAMPLE =
Commands::Help::create_example_string("remove zlib zlib:x64-windows curl boost");
const std::unordered_set<std::string> options = args.check_and_get_optional_command_arguments(
{OPTION_PURGE, OPTION_NO_PURGE, OPTION_RECURSE, OPTION_DRY_RUN, OPTION_OUTDATED});
@@ -145,7 +145,7 @@ namespace vcpkg::Commands::Remove
std::vector<PackageSpec> specs;
if (options.find(OPTION_OUTDATED) != options.cend())
{
- args.check_exact_arg_count(0, example);
+ args.check_exact_arg_count(0, EXAMPLE);
specs = Util::fmap(Update::find_outdated_packages(paths, status_db),
[](auto&& outdated) { return outdated.spec; });
@@ -157,9 +157,9 @@ namespace vcpkg::Commands::Remove
}
else
{
- args.check_min_arg_count(1, example);
+ args.check_min_arg_count(1, EXAMPLE);
specs = Util::fmap(args.command_arguments, [&](auto&& arg) {
- return Input::check_and_get_package_spec(arg, default_triplet, example);
+ return Input::check_and_get_package_spec(arg, default_triplet, EXAMPLE);
});
for (auto&& spec : specs)
@@ -171,7 +171,7 @@ namespace vcpkg::Commands::Remove
{
// User specified --purge and --no-purge
System::println(System::Color::error, "Error: cannot specify both --no-purge and --purge.");
- System::print(example);
+ System::print(EXAMPLE);
Checks::exit_fail(VCPKG_LINE_INFO);
}
const bool isRecursive = options.find(OPTION_RECURSE) != options.cend();
diff --git a/toolsrc/src/commands_search.cpp b/toolsrc/src/commands_search.cpp
index 529d52a8b..1ccec9fbe 100644
--- a/toolsrc/src/commands_search.cpp
+++ b/toolsrc/src/commands_search.cpp
@@ -80,10 +80,10 @@ namespace vcpkg::Commands::Search
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
{
- static const std::string example = Strings::format(
+ static const std::string EXAMPLE = Strings::format(
"The argument should be a substring to search for, or no argument to display all libraries.\n%s",
Commands::Help::create_example_string("search png"));
- args.check_max_arg_count(1, example);
+ args.check_max_arg_count(1, EXAMPLE);
const std::unordered_set<std::string> options =
args.check_and_get_optional_command_arguments({OPTION_GRAPH, OPTION_FULLDESC});
diff --git a/toolsrc/src/triplet.cpp b/toolsrc/src/triplet.cpp
index 451deb040..3b56da02a 100644
--- a/toolsrc/src/triplet.cpp
+++ b/toolsrc/src/triplet.cpp
@@ -15,7 +15,7 @@ namespace vcpkg
bool operator==(const TripletInstance& o) const { return o.value == value; }
};
- const TripletInstance Triplet::default_instance({});
+ const TripletInstance Triplet::DEFAULT_INSTANCE({});
}
template<>
@@ -41,10 +41,10 @@ namespace vcpkg
Triplet Triplet::from_canonical_name(const std::string& triplet_as_string)
{
std::string s(Strings::ascii_to_lowercase(triplet_as_string));
- auto it = std::find(s.cbegin(), s.cend(), '-');
+ const auto it = std::find(s.cbegin(), s.cend(), '-');
Checks::check_exit(VCPKG_LINE_INFO, it != s.cend(), "Invalid triplet: %s", triplet_as_string);
- auto p = g_triplet_instances.emplace(std::move(s));
+ const auto p = g_triplet_instances.emplace(std::move(s));
return &*p.first;
}
diff --git a/toolsrc/src/vcpkg_Checks.cpp b/toolsrc/src/vcpkg_Checks.cpp
index b6a88a011..e7c9046a4 100644
--- a/toolsrc/src/vcpkg_Checks.cpp
+++ b/toolsrc/src/vcpkg_Checks.cpp
@@ -10,7 +10,7 @@ namespace vcpkg::Checks
{
[[noreturn]] static void cleanup_and_exit(const int exit_code)
{
- auto elapsed_us = GlobalState::timer.lock()->microseconds();
+ const auto elapsed_us = GlobalState::timer.lock()->microseconds();
auto metrics = Metrics::g_metrics.lock();
metrics->track_metric("elapsed_us", elapsed_us);
@@ -20,20 +20,25 @@ namespace vcpkg::Checks
SetConsoleCP(GlobalState::g_init_console_cp);
SetConsoleOutputCP(GlobalState::g_init_console_output_cp);
- ::exit(exit_code);
+ fflush(nullptr);
+
+ ::TerminateProcess(::GetCurrentProcess(), exit_code);
}
- static BOOL CtrlHandler(DWORD fdwCtrlType)
+ static BOOL ctrl_handler(DWORD fdw_ctrl_type)
{
{
auto locked_metrics = Metrics::g_metrics.lock();
- locked_metrics->track_property("CtrlHandler", std::to_string(fdwCtrlType));
+ locked_metrics->track_property("CtrlHandler", std::to_string(fdw_ctrl_type));
locked_metrics->track_property("error", "CtrlHandler was fired.");
}
cleanup_and_exit(EXIT_FAILURE);
}
- void register_console_ctrl_handler() { SetConsoleCtrlHandler((PHANDLER_ROUTINE)CtrlHandler, TRUE); }
+ void register_console_ctrl_handler()
+ {
+ SetConsoleCtrlHandler(reinterpret_cast<PHANDLER_ROUTINE>(ctrl_handler), TRUE);
+ }
[[noreturn]] void unreachable(const LineInfo& line_info)
{
@@ -52,9 +57,9 @@ namespace vcpkg::Checks
cleanup_and_exit(exit_code);
}
- [[noreturn]] void exit_with_message(const LineInfo& line_info, const CStringView errorMessage)
+ [[noreturn]] void exit_with_message(const LineInfo& line_info, const CStringView error_message)
{
- System::println(System::Color::error, errorMessage);
+ System::println(System::Color::error, error_message);
exit_fail(line_info);
}
@@ -66,11 +71,11 @@ namespace vcpkg::Checks
}
}
- void check_exit(const LineInfo& line_info, bool expression, const CStringView errorMessage)
+ void check_exit(const LineInfo& line_info, bool expression, const CStringView error_message)
{
if (!expression)
{
- exit_with_message(line_info, errorMessage);
+ exit_with_message(line_info, error_message);
}
}
}
diff --git a/toolsrc/src/vcpkg_Chrono.cpp b/toolsrc/src/vcpkg_Chrono.cpp
index d70f4a054..d96f30987 100644
--- a/toolsrc/src/vcpkg_Chrono.cpp
+++ b/toolsrc/src/vcpkg_Chrono.cpp
@@ -7,43 +7,43 @@ namespace vcpkg
{
static std::string format_time_userfriendly(const std::chrono::nanoseconds& nanos)
{
+ using std::chrono::duration_cast;
using std::chrono::hours;
- using std::chrono::minutes;
- using std::chrono::seconds;
- using std::chrono::milliseconds;
using std::chrono::microseconds;
+ using std::chrono::milliseconds;
+ using std::chrono::minutes;
using std::chrono::nanoseconds;
- using std::chrono::duration_cast;
+ using std::chrono::seconds;
const double nanos_as_double = static_cast<double>(nanos.count());
if (duration_cast<hours>(nanos) > hours())
{
- auto t = nanos_as_double / duration_cast<nanoseconds>(hours(1)).count();
+ const auto t = nanos_as_double / duration_cast<nanoseconds>(hours(1)).count();
return Strings::format("%.4g h", t);
}
if (duration_cast<minutes>(nanos) > minutes())
{
- auto t = nanos_as_double / duration_cast<nanoseconds>(minutes(1)).count();
+ const auto t = nanos_as_double / duration_cast<nanoseconds>(minutes(1)).count();
return Strings::format("%.4g min", t);
}
if (duration_cast<seconds>(nanos) > seconds())
{
- auto t = nanos_as_double / duration_cast<nanoseconds>(seconds(1)).count();
+ const auto t = nanos_as_double / duration_cast<nanoseconds>(seconds(1)).count();
return Strings::format("%.4g s", t);
}
if (duration_cast<milliseconds>(nanos) > milliseconds())
{
- auto t = nanos_as_double / duration_cast<nanoseconds>(milliseconds(1)).count();
+ const auto t = nanos_as_double / duration_cast<nanoseconds>(milliseconds(1)).count();
return Strings::format("%.4g ms", t);
}
if (duration_cast<microseconds>(nanos) > microseconds())
{
- auto t = nanos_as_double / duration_cast<nanoseconds>(microseconds(1)).count();
+ const auto t = nanos_as_double / duration_cast<nanoseconds>(microseconds(1)).count();
return Strings::format("%.4g us", t);
}
diff --git a/toolsrc/src/vcpkg_Files.cpp b/toolsrc/src/vcpkg_Files.cpp
index 24edb779f..ad1fcebc6 100644
--- a/toolsrc/src/vcpkg_Files.cpp
+++ b/toolsrc/src/vcpkg_Files.cpp
@@ -2,6 +2,7 @@
#include "vcpkg_Files.h"
#include "vcpkg_System.h"
+#include "vcpkg_Util.h"
#include <thread>
namespace vcpkg::Files
@@ -193,4 +194,16 @@ namespace vcpkg::Files
}
System::println();
}
+
+ std::vector<fs::path> find_from_PATH(const std::wstring& name)
+ {
+ const std::wstring cmd = Strings::wformat(L"where.exe %s", name);
+ auto out = System::cmd_execute_and_capture_output(cmd);
+ if (out.exit_code != 0)
+ {
+ return {};
+ }
+
+ return Util::fmap(Strings::split(out.output, "\n"), [](auto&& s) { return fs::path(s); });
+ }
}
diff --git a/toolsrc/src/vcpkg_Input.cpp b/toolsrc/src/vcpkg_Input.cpp
index 153e6a942..f1cac9632 100644
--- a/toolsrc/src/vcpkg_Input.cpp
+++ b/toolsrc/src/vcpkg_Input.cpp
@@ -13,7 +13,7 @@ namespace vcpkg::Input
{
const std::string as_lowercase = Strings::ascii_to_lowercase(package_spec_as_string);
auto expected_spec = FullPackageSpec::from_string(as_lowercase, default_triplet);
- if (auto spec = expected_spec.get())
+ if (const auto spec = expected_spec.get())
{
return PackageSpec{spec->package_spec};
}
@@ -41,7 +41,7 @@ namespace vcpkg::Input
{
const std::string as_lowercase = Strings::ascii_to_lowercase(full_package_spec_as_string);
auto expected_spec = FullPackageSpec::from_string(as_lowercase, default_triplet);
- if (auto spec = expected_spec.get())
+ if (const auto spec = expected_spec.get())
{
return *spec;
}
diff --git a/toolsrc/src/vcpkg_Parse.cpp b/toolsrc/src/vcpkg_Parse.cpp
index b54f7360b..e671a1a05 100644
--- a/toolsrc/src/vcpkg_Parse.cpp
+++ b/toolsrc/src/vcpkg_Parse.cpp
@@ -23,12 +23,12 @@ namespace vcpkg::Parse
void ParagraphParser::required_field(const std::string& fieldname, std::string& out)
{
auto maybe_field = remove_field(&fields, fieldname);
- if (auto field = maybe_field.get())
+ if (const auto field = maybe_field.get())
out = std::move(*field);
else
missing_fields.push_back(fieldname);
}
- std::string ParagraphParser::optional_field(const std::string& fieldname)
+ std::string ParagraphParser::optional_field(const std::string& fieldname) const
{
return remove_field(&fields, fieldname).value_or(Strings::EMPTY);
}
diff --git a/toolsrc/src/vcpkg_System.cpp b/toolsrc/src/vcpkg_System.cpp
index f5106b25e..40e335117 100644
--- a/toolsrc/src/vcpkg_System.cpp
+++ b/toolsrc/src/vcpkg_System.cpp
@@ -176,6 +176,17 @@ namespace vcpkg::System
return exit_code;
}
+ // On Win7, output from powershell calls contain a byte order mark, so we strip it out if it is present
+ static void remove_byte_order_mark(std::wstring* s)
+ {
+ const wchar_t* a = s->c_str();
+ // This is the UTF-8 byte-order mark
+ if (a[0] == 0xEF && a[1] == 0xBB && a[2] == 0xBF)
+ {
+ s->erase(0, 3);
+ }
+ }
+
ExitCodeAndOutput cmd_execute_and_capture_output(const CWStringView cmd_line)
{
// Flush stdout before launching external process
@@ -202,6 +213,7 @@ namespace vcpkg::System
const auto ec = _pclose(pipe);
Debug::println("_pclose() returned %d", ec);
+ remove_byte_order_mark(&output);
return {ec, Strings::to_utf8(output)};
}
@@ -283,36 +295,36 @@ namespace vcpkg::System
return ret;
}
- static const fs::path& get_ProgramFiles()
+ static const fs::path& get_program_files()
{
- static const fs::path p = System::get_environment_variable(L"PROGRAMFILES").value_or_exit(VCPKG_LINE_INFO);
- return p;
+ static const fs::path PATH = System::get_environment_variable(L"PROGRAMFILES").value_or_exit(VCPKG_LINE_INFO);
+ return PATH;
}
- const fs::path& get_ProgramFiles_32_bit()
+ const fs::path& get_program_files_32_bit()
{
- static const fs::path p = []() -> fs::path {
+ static const fs::path PATH = []() -> fs::path {
auto value = System::get_environment_variable(L"ProgramFiles(x86)");
if (auto v = value.get())
{
return std::move(*v);
}
- return get_ProgramFiles();
+ return get_program_files();
}();
- return p;
+ return PATH;
}
- const fs::path& get_ProgramFiles_platform_bitness()
+ const fs::path& get_program_files_platform_bitness()
{
- static const fs::path p = []() -> fs::path {
+ static const fs::path PATH = []() -> fs::path {
auto value = System::get_environment_variable(L"ProgramW6432");
if (auto v = value.get())
{
return std::move(*v);
}
- return get_ProgramFiles();
+ return get_program_files();
}();
- return p;
+ return PATH;
}
}