mirror of
https://github.com/cemu-project/vcpkg.git
synced 2025-02-22 18:47:09 +01:00
[vcpkg] Major tool CMakeLists.txt updates
- Add the "VCPKG_DEVELOPMENT_WARNINGS" flag - setting "WERROR" will also set this flag - This flag is set by default - on GCC/clang, this will pass '-Wall -Wextra -Wpedantic -Werror' - on GCC, this will additionally pass '-Wmissing-declarations' - on clang, this will additionally pass '-Wmissing-prototypes' - on MSVC, this will pass '-W4 -WX' - On Visual Studio 2017 and later, pass '-permissive-' - Change the source for fallout of these changes - add `format` subcommand - formats all C++ source and header files using clang-format - move `include/vcpkg-test/catch.h` to `include/catch2/catch.hpp` - pass CONFIGURE_DEPENDS to file(GLOB)
This commit is contained in:
parent
5d1751dfda
commit
300e21d59e
@ -249,7 +249,7 @@ buildDir="$vcpkgRootDir/toolsrc/build.rel"
|
|||||||
rm -rf "$buildDir"
|
rm -rf "$buildDir"
|
||||||
mkdir -p "$buildDir"
|
mkdir -p "$buildDir"
|
||||||
|
|
||||||
(cd "$buildDir" && CXX=$CXX "$cmakeExe" .. -DCMAKE_BUILD_TYPE=Release -G "Ninja" "-DCMAKE_MAKE_PROGRAM=$ninjaExe" "-DBUILD_TESTING=OFF" "-DDEFINE_DISABLE_METRICS=$vcpkgDisableMetrics" "-DVCPKG_ALLOW_APPLE_CLANG=$vcpkgAllowAppleClang") || exit 1
|
(cd "$buildDir" && CXX=$CXX "$cmakeExe" .. -DCMAKE_BUILD_TYPE=Release -G "Ninja" "-DCMAKE_MAKE_PROGRAM=$ninjaExe" "-DBUILD_TESTING=OFF" "-DVCPKG_DEVELOPMENT_WARNINGS=Off" "-DDEFINE_DISABLE_METRICS=$vcpkgDisableMetrics" "-DVCPKG_ALLOW_APPLE_CLANG=$vcpkgAllowAppleClang") || exit 1
|
||||||
(cd "$buildDir" && "$cmakeExe" --build .) || exit 1
|
(cd "$buildDir" && "$cmakeExe" --build .) || exit 1
|
||||||
|
|
||||||
rm -rf "$vcpkgRootDir/vcpkg"
|
rm -rf "$vcpkgRootDir/vcpkg"
|
||||||
|
@ -2,10 +2,17 @@ cmake_minimum_required(VERSION 3.14)
|
|||||||
|
|
||||||
project(vcpkg C CXX)
|
project(vcpkg C CXX)
|
||||||
|
|
||||||
OPTION(BUILD_TESTING "Option for enabling testing" ON)
|
|
||||||
OPTION(VCPKG_BUILD_BENCHMARKING "Option for enabling benchmarking" OFF)
|
|
||||||
OPTION(DEFINE_DISABLE_METRICS "Option for disabling metrics" OFF)
|
OPTION(DEFINE_DISABLE_METRICS "Option for disabling metrics" OFF)
|
||||||
OPTION(VCPKG_ALLOW_APPLE_CLANG "Option for allowing apple clang" OFF)
|
OPTION(VCPKG_ALLOW_APPLE_CLANG "Option for allowing apple clang" OFF)
|
||||||
|
OPTION(VCPKG_DEVELOPMENT_WARNINGS "Option for turning on all warnings, and making them errors" ON)
|
||||||
|
OPTION(BUILD_TESTING "Option for enabling testing" ON)
|
||||||
|
OPTION(VCPKG_BUILD_BENCHMARKING "Option for enabling benchmarking" OFF)
|
||||||
|
|
||||||
|
# for backwards compatibility with existing code
|
||||||
|
if (WERROR)
|
||||||
|
set(VCPKG_DEVELOPMENT_WARNINGS On)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if (DEFINE_DISABLE_METRICS)
|
if (DEFINE_DISABLE_METRICS)
|
||||||
set(DISABLE_METRICS_VALUE "1")
|
set(DISABLE_METRICS_VALUE "1")
|
||||||
@ -27,33 +34,10 @@ If you would like to try anyway, pass --allowAppleClang to bootstrap.sh.")
|
|||||||
endif()
|
endif()
|
||||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang")
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang")
|
||||||
set(CLANG 1)
|
set(CLANG 1)
|
||||||
elseif(MSVC)
|
elseif(NOT MSVC)
|
||||||
add_compile_options(/FC)
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Unknown compiler: ${CMAKE_CXX_COMPILER_ID}")
|
message(FATAL_ERROR "Unknown compiler: ${CMAKE_CXX_COMPILER_ID}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(GCC OR (CLANG AND NOT MSVC))
|
|
||||||
if(WERROR)
|
|
||||||
add_compile_options(-Wall -Wno-unknown-pragmas -Werror)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (DEFINE_DISABLE_METRICS)
|
|
||||||
set(DISABLE_METRICS_VALUE "1")
|
|
||||||
else()
|
|
||||||
set(DISABLE_METRICS_VALUE "0")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
file(GLOB_RECURSE VCPKGLIB_SOURCES src/vcpkg/*.cpp)
|
|
||||||
|
|
||||||
add_library(vcpkglib OBJECT ${VCPKGLIB_SOURCES})
|
|
||||||
add_executable(vcpkg src/vcpkg.cpp $<TARGET_OBJECTS:vcpkglib>)
|
|
||||||
|
|
||||||
target_compile_features(vcpkg PRIVATE cxx_std_17)
|
|
||||||
target_compile_definitions(vcpkg PRIVATE -DDISABLE_METRICS=${DISABLE_METRICS_VALUE})
|
|
||||||
target_include_directories(vcpkg PRIVATE include)
|
|
||||||
|
|
||||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
@ -61,7 +45,7 @@ add_definitions(-DDISABLE_METRICS=${DISABLE_METRICS_VALUE})
|
|||||||
include_directories(include)
|
include_directories(include)
|
||||||
link_libraries(Threads::Threads)
|
link_libraries(Threads::Threads)
|
||||||
|
|
||||||
if(CLANG)
|
if(CLANG AND NOT MSVC)
|
||||||
include(CheckCXXSourceCompiles)
|
include(CheckCXXSourceCompiles)
|
||||||
check_cxx_source_compiles("#include <iostream>
|
check_cxx_source_compiles("#include <iostream>
|
||||||
int main() { return __GLIBCXX__; }" USES_LIBSTDCXX)
|
int main() { return __GLIBCXX__; }" USES_LIBSTDCXX)
|
||||||
@ -73,31 +57,70 @@ if(CLANG)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(GCC OR (CLANG AND USES_LIBSTDCXX))
|
if(GCC OR (CLANG AND USES_LIBSTDCXX))
|
||||||
target_link_libraries(vcpkg PRIVATE stdc++fs)
|
link_libraries(stdc++fs)
|
||||||
elseif(CLANG AND NOT MSVC)
|
elseif(CLANG AND NOT MSVC)
|
||||||
target_link_libraries(vcpkg PRIVATE c++fs)
|
link_libraries(c++fs)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(GCC OR CLANG)
|
if(MSVC)
|
||||||
|
# either MSVC, or clang-cl
|
||||||
|
add_compile_options(-FC)
|
||||||
|
|
||||||
|
if (MSVC_VERSION GREATER 1900)
|
||||||
|
# Visual Studio 2017 or later
|
||||||
|
add_compile_options(-std:c++17 -permissive-)
|
||||||
|
else()
|
||||||
|
# Visual Studio 2015
|
||||||
|
add_compile_options(-std:c++latest)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(VCPKG_DEVELOPMENT_WARNINGS)
|
||||||
|
string(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||||
|
add_compile_options(-W4 -WX)
|
||||||
|
|
||||||
|
if (CLANG)
|
||||||
|
add_compile_options(-Wmissing-prototypes -Wno-missing-field-initializers)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
elseif(GCC OR CLANG)
|
||||||
add_compile_options(-std=c++1z)
|
add_compile_options(-std=c++1z)
|
||||||
if(WERROR)
|
|
||||||
add_compile_options(-Wall -Wno-unknown-pragmas -Werror)
|
if(VCPKG_DEVELOPMENT_WARNINGS)
|
||||||
|
add_compile_options(-Wall -Wextra -Wpedantic -Wno-unknown-pragmas -Wno-missing-field-initializers -Werror)
|
||||||
|
|
||||||
|
# GCC and clang have different names for the same warning
|
||||||
|
if (GCC)
|
||||||
|
add_compile_options(-Wmissing-declarations)
|
||||||
|
elseif(CLANG)
|
||||||
|
add_compile_options(-Wmissing-prototypes)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
file(GLOB_RECURSE VCPKGLIB_SOURCES CONFIGURE_DEPENDS src/vcpkg/*.cpp)
|
||||||
|
|
||||||
|
add_library(vcpkglib OBJECT ${VCPKGLIB_SOURCES})
|
||||||
|
add_executable(vcpkg src/vcpkg.cpp $<TARGET_OBJECTS:vcpkglib>)
|
||||||
|
|
||||||
if (BUILD_TESTING)
|
if (BUILD_TESTING)
|
||||||
file(GLOB_RECURSE VCPKGTEST_SOURCES src/vcpkg-test/*.cpp)
|
file(GLOB_RECURSE VCPKGTEST_SOURCES CONFIGURE_DEPENDS src/vcpkg-test/*.cpp)
|
||||||
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
add_executable(vcpkg-test
|
add_executable(vcpkg-test
|
||||||
${VCPKGTEST_SOURCES}
|
${VCPKGTEST_SOURCES}
|
||||||
$<TARGET_OBJECTS:vcpkglib>)
|
$<TARGET_OBJECTS:vcpkglib>)
|
||||||
|
|
||||||
add_test(NAME default COMMAND vcpkg-test [${TEST_NAME}])
|
add_test(NAME default COMMAND vcpkg-test)
|
||||||
|
|
||||||
if (VCPKG_BUILD_BENCHMARKING)
|
if (VCPKG_BUILD_BENCHMARKING)
|
||||||
target_compile_options(vcpkg-test PRIVATE -DCATCH_CONFIG_ENABLE_BENCHMARKING)
|
target_compile_options(vcpkg-test PRIVATE -DCATCH_CONFIG_ENABLE_BENCHMARKING)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
find_program(CLANG_FORMAT clang-format)
|
||||||
|
if (CLANG_FORMAT)
|
||||||
|
file(GLOB_RECURSE VCPKG_FORMAT_SOURCES CONFIGURE_DEPENDS src/*.cpp include/pch.h include/vcpkg/*.h include/vcpkg-test/*.h)
|
||||||
|
add_custom_target(format COMMAND ${CLANG_FORMAT} -i -verbose ${VCPKG_FORMAT_SOURCES})
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <vcpkg-test/catch.h>
|
#include <catch2/catch.hpp>
|
||||||
#include <vcpkg/pragmas.h>
|
#include <vcpkg/pragmas.h>
|
||||||
|
|
||||||
#include <vcpkg/base/files.h>
|
#include <vcpkg/base/files.h>
|
||||||
|
@ -56,7 +56,7 @@ namespace vcpkg::Chrono
|
|||||||
static Optional<CTime> get_current_date_time();
|
static Optional<CTime> get_current_date_time();
|
||||||
static Optional<CTime> parse(CStringView str);
|
static Optional<CTime> parse(CStringView str);
|
||||||
|
|
||||||
constexpr CTime() noexcept : m_tm{0} {}
|
constexpr CTime() noexcept : m_tm{} {}
|
||||||
explicit constexpr CTime(tm t) noexcept : m_tm{t} {}
|
explicit constexpr CTime(tm t) noexcept : m_tm{t} {}
|
||||||
|
|
||||||
CTime add_hours(const int hours) const;
|
CTime add_hours(const int hours) const;
|
||||||
|
@ -46,7 +46,7 @@ namespace vcpkg::Graphs
|
|||||||
if (!r) return;
|
if (!r) return;
|
||||||
for (auto i = c.size(); i > 1; --i)
|
for (auto i = c.size(); i > 1; --i)
|
||||||
{
|
{
|
||||||
auto j = r->random(static_cast<int>(i));
|
std::size_t j = r->random(static_cast<int>(i));
|
||||||
if (j != i - 1)
|
if (j != i - 1)
|
||||||
{
|
{
|
||||||
std::swap(c[i - 1], c[j]);
|
std::swap(c[i - 1], c[j]);
|
||||||
|
@ -221,9 +221,8 @@ namespace vcpkg::Util
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class... Ts>
|
||||||
void unused(T&& param)
|
void unused(const Ts&...)
|
||||||
{
|
{
|
||||||
(void)param;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <vcpkg-test/catch.h>
|
#include <catch2/catch.hpp>
|
||||||
|
|
||||||
#include <vcpkg/vcpkgcmdarguments.h>
|
#include <vcpkg/vcpkgcmdarguments.h>
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#define CATCH_CONFIG_RUNNER
|
#define CATCH_CONFIG_RUNNER
|
||||||
#include <vcpkg-test/catch.h>
|
#include <catch2/catch.hpp>
|
||||||
|
|
||||||
#include <vcpkg/base/system.debug.h>
|
#include <vcpkg/base/system.debug.h>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <vcpkg-test/catch.h>
|
#include <catch2/catch.hpp>
|
||||||
|
|
||||||
#include <vcpkg/base/chrono.h>
|
#include <vcpkg/base/chrono.h>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <vcpkg-test/catch.h>
|
#include <catch2/catch.hpp>
|
||||||
|
|
||||||
#include <vcpkg/sourceparagraph.h>
|
#include <vcpkg/sourceparagraph.h>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <vcpkg-test/catch.h>
|
#include <catch2/catch.hpp>
|
||||||
#include <vcpkg-test/util.h>
|
#include <vcpkg-test/util.h>
|
||||||
|
|
||||||
#include <vcpkg/base/files.h>
|
#include <vcpkg/base/files.h>
|
||||||
@ -107,7 +107,7 @@ namespace
|
|||||||
CHECK_EC_ON_FILE(base, ec);
|
CHECK_EC_ON_FILE(base, ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < width; ++i)
|
for (std::uint64_t i = 0; i < width; ++i)
|
||||||
{
|
{
|
||||||
create_directory_tree(urbg,
|
create_directory_tree(urbg,
|
||||||
fs,
|
fs,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <vcpkg-test/catch.h>
|
#include <catch2/catch.hpp>
|
||||||
#include <vcpkg-test/util.h>
|
#include <vcpkg-test/util.h>
|
||||||
|
|
||||||
#include <vcpkg/base/strings.h>
|
#include <vcpkg/base/strings.h>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <vcpkg-test/catch.h>
|
#include <catch2/catch.hpp>
|
||||||
#include <vcpkg-test/util.h>
|
#include <vcpkg-test/util.h>
|
||||||
|
|
||||||
#include <vcpkg/dependencies.h>
|
#include <vcpkg/dependencies.h>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <vcpkg-test/catch.h>
|
#include <catch2/catch.hpp>
|
||||||
|
|
||||||
#include <vcpkg/base/util.h>
|
#include <vcpkg/base/util.h>
|
||||||
#include <vcpkg/packagespec.h>
|
#include <vcpkg/packagespec.h>
|
||||||
@ -131,4 +131,4 @@ TEST_CASE ("specifier parsing", "[specifier]")
|
|||||||
REQUIRE(str == L"abc -x86-windows");
|
REQUIRE(str == L"abc -x86-windows");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
};
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <vcpkg-test/catch.h>
|
#include <catch2/catch.hpp>
|
||||||
#include <vcpkg-test/util.h>
|
#include <vcpkg-test/util.h>
|
||||||
|
|
||||||
#include <vcpkg/base/util.h>
|
#include <vcpkg/base/util.h>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <vcpkg-test/catch.h>
|
#include <catch2/catch.hpp>
|
||||||
|
|
||||||
#include <vcpkg/base/strings.h>
|
#include <vcpkg/base/strings.h>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <vcpkg-test/catch.h>
|
#include <catch2/catch.hpp>
|
||||||
|
|
||||||
#include <vcpkg/sourceparagraph.h>
|
#include <vcpkg/sourceparagraph.h>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <vcpkg-test/catch.h>
|
#include <catch2/catch.hpp>
|
||||||
#include <vcpkg-test/util.h>
|
#include <vcpkg-test/util.h>
|
||||||
|
|
||||||
#include <vcpkg/base/sortedvector.h>
|
#include <vcpkg/base/sortedvector.h>
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
#include <vcpkg-test/catch.h>
|
#include <catch2/catch.hpp>
|
||||||
#include <vcpkg-test/util.h>
|
#include <vcpkg-test/util.h>
|
||||||
|
|
||||||
#include <vcpkg/base/checks.h>
|
#include <vcpkg/base/checks.h>
|
||||||
#include <vcpkg/base/files.h>
|
#include <vcpkg/base/files.h>
|
||||||
|
#include <vcpkg/base/util.h>
|
||||||
#include <vcpkg/statusparagraph.h>
|
#include <vcpkg/statusparagraph.h>
|
||||||
|
|
||||||
// used to get the implementation specific compiler flags (i.e., __cpp_lib_filesystem)
|
// used to get the implementation specific compiler flags (i.e., __cpp_lib_filesystem)
|
||||||
@ -153,7 +154,7 @@ namespace vcpkg::Test
|
|||||||
ec.assign(errno, std::system_category());
|
ec.assign(errno, std::system_category());
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static_cast<void>(ec);
|
Util::unused(target, file, ec);
|
||||||
vcpkg::Checks::exit_with_message(VCPKG_LINE_INFO, no_filesystem_message);
|
vcpkg::Checks::exit_with_message(VCPKG_LINE_INFO, no_filesystem_message);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -175,7 +176,7 @@ namespace vcpkg::Test
|
|||||||
#elif FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_UNIX
|
#elif FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_UNIX
|
||||||
::vcpkg::Test::create_symlink(target, file, ec);
|
::vcpkg::Test::create_symlink(target, file, ec);
|
||||||
#else
|
#else
|
||||||
static_cast<void>(ec);
|
Util::unused(target, file, ec);
|
||||||
vcpkg::Checks::exit_with_message(VCPKG_LINE_INFO, no_filesystem_message);
|
vcpkg::Checks::exit_with_message(VCPKG_LINE_INFO, no_filesystem_message);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ static constexpr int SURVEY_INTERVAL_IN_HOURS = 24 * 30 * 6;
|
|||||||
// Initial survey appears after 10 days. Therefore, subtract 24 hours/day * 10 days
|
// Initial survey appears after 10 days. Therefore, subtract 24 hours/day * 10 days
|
||||||
static constexpr int SURVEY_INITIAL_OFFSET_IN_HOURS = SURVEY_INTERVAL_IN_HOURS - 24 * 10;
|
static constexpr int SURVEY_INITIAL_OFFSET_IN_HOURS = SURVEY_INTERVAL_IN_HOURS - 24 * 10;
|
||||||
|
|
||||||
void invalid_command(const std::string& cmd)
|
static void invalid_command(const std::string& cmd)
|
||||||
{
|
{
|
||||||
System::print2(System::Color::error, "invalid command: ", cmd, '\n');
|
System::print2(System::Color::error, "invalid command: ", cmd, '\n');
|
||||||
Help::print_usage();
|
Help::print_usage();
|
||||||
@ -285,6 +285,8 @@ static std::string trim_path_from_command_line(const std::string& full_command_l
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
// note: this prevents a false positive for -Wmissing-prototypes on clang-cl
|
||||||
|
int wmain(int, const wchar_t* const*);
|
||||||
int wmain(const int argc, const wchar_t* const* const argv)
|
int wmain(const int argc, const wchar_t* const* const argv)
|
||||||
#else
|
#else
|
||||||
int main(const int argc, const char* const* const argv)
|
int main(const int argc, const char* const* const argv)
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
|
|
||||||
|
#include <vcpkg/base/hash.h>
|
||||||
|
|
||||||
#include <vcpkg/base/checks.h>
|
#include <vcpkg/base/checks.h>
|
||||||
#include <vcpkg/base/strings.h>
|
#include <vcpkg/base/strings.h>
|
||||||
#include <vcpkg/base/system.process.h>
|
#include <vcpkg/base/system.process.h>
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <vcpkg/base/system.debug.h>
|
#include <vcpkg/base/system.debug.h>
|
||||||
#include <vcpkg/base/system.h>
|
#include <vcpkg/base/system.h>
|
||||||
#include <vcpkg/base/system.process.h>
|
#include <vcpkg/base/system.process.h>
|
||||||
|
#include <vcpkg/base/util.h>
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
@ -381,6 +382,8 @@ namespace vcpkg
|
|||||||
"CreateProcessW() returned ", exit_code, " after ", static_cast<int>(timer.microseconds()), " us\n");
|
"CreateProcessW() returned ", exit_code, " after ", static_cast<int>(timer.microseconds()), " us\n");
|
||||||
return static_cast<int>(exit_code);
|
return static_cast<int>(exit_code);
|
||||||
#else
|
#else
|
||||||
|
// TODO: this should create a clean environment on Linux/macOS
|
||||||
|
Util::unused(extra_env, prepend_to_path);
|
||||||
Debug::print("system(", cmd_line, ")\n");
|
Debug::print("system(", cmd_line, ")\n");
|
||||||
fflush(nullptr);
|
fflush(nullptr);
|
||||||
int rc = system(cmd_line.c_str());
|
int rc = system(cmd_line.c_str());
|
||||||
@ -549,10 +552,7 @@ namespace vcpkg
|
|||||||
return Strings::to_utf8(ret);
|
return Strings::to_utf8(ret);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
Optional<std::string> System::get_registry_string(void* base_hkey, StringView sub_key, StringView valuename)
|
Optional<std::string> System::get_registry_string(void*, StringView, StringView) { return nullopt; }
|
||||||
{
|
|
||||||
return nullopt;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const Optional<fs::path>& get_program_files()
|
static const Optional<fs::path>& get_program_files()
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
|
|
||||||
#include <vcpkg/base/system.print.h>
|
#include <vcpkg/base/system.print.h>
|
||||||
|
#include <vcpkg/base/util.h>
|
||||||
|
|
||||||
namespace vcpkg::System
|
namespace vcpkg::System
|
||||||
{
|
{
|
||||||
@ -21,6 +22,9 @@ namespace vcpkg::System
|
|||||||
System::print2(message);
|
System::print2(message);
|
||||||
SetConsoleTextAttribute(console_handle, original_color);
|
SetConsoleTextAttribute(console_handle, original_color);
|
||||||
#else
|
#else
|
||||||
|
// TODO: add color handling code
|
||||||
|
// it should probably use VT-220 codes
|
||||||
|
Util::unused(c);
|
||||||
System::print2(message);
|
System::print2(message);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -184,7 +184,7 @@ namespace vcpkg::Build
|
|||||||
static const std::string LIBRARY_LINKAGE = "LibraryLinkage";
|
static const std::string LIBRARY_LINKAGE = "LibraryLinkage";
|
||||||
}
|
}
|
||||||
|
|
||||||
CStringView to_vcvarsall_target(const std::string& cmake_system_name)
|
static CStringView to_vcvarsall_target(const std::string& cmake_system_name)
|
||||||
{
|
{
|
||||||
if (cmake_system_name.empty()) return "";
|
if (cmake_system_name.empty()) return "";
|
||||||
if (cmake_system_name == "Windows") return "";
|
if (cmake_system_name == "Windows") return "";
|
||||||
@ -193,7 +193,7 @@ namespace vcpkg::Build
|
|||||||
Checks::exit_with_message(VCPKG_LINE_INFO, "Unsupported vcvarsall target %s", cmake_system_name);
|
Checks::exit_with_message(VCPKG_LINE_INFO, "Unsupported vcvarsall target %s", cmake_system_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
CStringView to_vcvarsall_toolchain(const std::string& target_architecture, const Toolset& toolset)
|
static CStringView to_vcvarsall_toolchain(const std::string& target_architecture, const Toolset& toolset)
|
||||||
{
|
{
|
||||||
auto maybe_target_arch = System::to_cpu_architecture(target_architecture);
|
auto maybe_target_arch = System::to_cpu_architecture(target_architecture);
|
||||||
Checks::check_exit(
|
Checks::check_exit(
|
||||||
@ -217,7 +217,7 @@ namespace vcpkg::Build
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_map<std::string, std::string> make_env_passthrough(const PreBuildInfo& pre_build_info)
|
static auto make_env_passthrough(const PreBuildInfo& pre_build_info) -> std::unordered_map<std::string, std::string>
|
||||||
{
|
{
|
||||||
std::unordered_map<std::string, std::string> env;
|
std::unordered_map<std::string, std::string> env;
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ namespace vcpkg::Commands::Autocomplete
|
|||||||
Checks::exit_success(line_info);
|
Checks::exit_success(line_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> combine_port_with_triplets(const std::string& port,
|
static std::vector<std::string> combine_port_with_triplets(const std::string& port,
|
||||||
const std::vector<std::string>& triplets)
|
const std::vector<std::string>& triplets)
|
||||||
{
|
{
|
||||||
return Util::fmap(triplets,
|
return Util::fmap(triplets,
|
||||||
[&](const std::string& triplet) { return Strings::format("%s:%s", port, triplet); });
|
[&](const std::string& triplet) { return Strings::format("%s:%s", port, triplet); });
|
||||||
|
@ -18,23 +18,213 @@ using vcpkg::Dependencies::PathsPortFileProvider;
|
|||||||
|
|
||||||
namespace vcpkg::Commands::DependInfo
|
namespace vcpkg::Commands::DependInfo
|
||||||
{
|
{
|
||||||
constexpr StringLiteral OPTION_DOT = "--dot";
|
namespace
|
||||||
constexpr StringLiteral OPTION_DGML = "--dgml";
|
{
|
||||||
constexpr StringLiteral OPTION_SHOW_DEPTH = "--show-depth";
|
constexpr StringLiteral OPTION_DOT = "--dot";
|
||||||
constexpr StringLiteral OPTION_MAX_RECURSE = "--max-recurse";
|
constexpr StringLiteral OPTION_DGML = "--dgml";
|
||||||
constexpr StringLiteral OPTION_SORT = "--sort";
|
constexpr StringLiteral OPTION_SHOW_DEPTH = "--show-depth";
|
||||||
|
constexpr StringLiteral OPTION_MAX_RECURSE = "--max-recurse";
|
||||||
|
constexpr StringLiteral OPTION_SORT = "--sort";
|
||||||
|
|
||||||
constexpr int NO_RECURSE_LIMIT_VALUE = -1;
|
constexpr int NO_RECURSE_LIMIT_VALUE = -1;
|
||||||
|
|
||||||
constexpr std::array<CommandSwitch, 3> DEPEND_SWITCHES = {{{OPTION_DOT, "Creates graph on basis of dot"},
|
constexpr std::array<CommandSwitch, 3> DEPEND_SWITCHES = {
|
||||||
{OPTION_DGML, "Creates graph on basis of dgml"},
|
{{OPTION_DOT, "Creates graph on basis of dot"},
|
||||||
{OPTION_SHOW_DEPTH, "Show recursion depth in output"}}};
|
{OPTION_DGML, "Creates graph on basis of dgml"},
|
||||||
|
{OPTION_SHOW_DEPTH, "Show recursion depth in output"}}};
|
||||||
|
|
||||||
constexpr std::array<CommandSetting, 2> DEPEND_SETTINGS = {
|
constexpr std::array<CommandSetting, 2> DEPEND_SETTINGS = {
|
||||||
{{OPTION_MAX_RECURSE, "Set max recursion depth, a value of -1 indicates no limit"},
|
{{OPTION_MAX_RECURSE, "Set max recursion depth, a value of -1 indicates no limit"},
|
||||||
{OPTION_SORT,
|
{OPTION_SORT,
|
||||||
"Set sort order for the list of dependencies, accepted values are: lexicographical, topological (default), "
|
"Set sort order for the list of dependencies, accepted values are: lexicographical, topological "
|
||||||
"reverse"}}};
|
"(default), "
|
||||||
|
"reverse"}}};
|
||||||
|
|
||||||
|
struct PackageDependInfo
|
||||||
|
{
|
||||||
|
std::string package;
|
||||||
|
int depth;
|
||||||
|
std::set<std::string> features;
|
||||||
|
std::vector<std::string> dependencies;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum SortMode
|
||||||
|
{
|
||||||
|
Lexicographical = 0,
|
||||||
|
Topological,
|
||||||
|
ReverseTopological,
|
||||||
|
Default = Topological
|
||||||
|
};
|
||||||
|
|
||||||
|
int get_max_depth(const ParsedArguments& options)
|
||||||
|
{
|
||||||
|
auto iter = options.settings.find(OPTION_MAX_RECURSE);
|
||||||
|
if (iter != options.settings.end())
|
||||||
|
{
|
||||||
|
std::string value = iter->second;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return std::stoi(value);
|
||||||
|
}
|
||||||
|
catch (std::exception&)
|
||||||
|
{
|
||||||
|
Checks::exit_with_message(VCPKG_LINE_INFO, "Value of --max-depth must be an integer");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// No --max-depth set, default to no limit.
|
||||||
|
return NO_RECURSE_LIMIT_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
SortMode get_sort_mode(const ParsedArguments& options)
|
||||||
|
{
|
||||||
|
constexpr StringLiteral OPTION_SORT_LEXICOGRAPHICAL = "lexicographical";
|
||||||
|
constexpr StringLiteral OPTION_SORT_TOPOLOGICAL = "topological";
|
||||||
|
constexpr StringLiteral OPTION_SORT_REVERSE = "reverse";
|
||||||
|
|
||||||
|
static const std::map<std::string, SortMode> sortModesMap{{OPTION_SORT_LEXICOGRAPHICAL, Lexicographical},
|
||||||
|
{OPTION_SORT_TOPOLOGICAL, Topological},
|
||||||
|
{OPTION_SORT_REVERSE, ReverseTopological}};
|
||||||
|
|
||||||
|
auto iter = options.settings.find(OPTION_SORT);
|
||||||
|
if (iter != options.settings.end())
|
||||||
|
{
|
||||||
|
const std::string value = Strings::ascii_to_lowercase(std::string{iter->second});
|
||||||
|
auto it = sortModesMap.find(value);
|
||||||
|
if (it != sortModesMap.end())
|
||||||
|
{
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
Checks::exit_with_message(VCPKG_LINE_INFO,
|
||||||
|
"Value of --sort must be one of `%s`, `%s`, or `%s`",
|
||||||
|
OPTION_SORT_LEXICOGRAPHICAL,
|
||||||
|
OPTION_SORT_TOPOLOGICAL,
|
||||||
|
OPTION_SORT_REVERSE);
|
||||||
|
}
|
||||||
|
return Default;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string create_dot_as_string(const std::vector<PackageDependInfo>& depend_info)
|
||||||
|
{
|
||||||
|
int empty_node_count = 0;
|
||||||
|
|
||||||
|
std::string s;
|
||||||
|
s.append("digraph G{ rankdir=LR; edge [minlen=3]; overlap=false;");
|
||||||
|
|
||||||
|
for (const auto& package : depend_info)
|
||||||
|
{
|
||||||
|
if (package.dependencies.empty())
|
||||||
|
{
|
||||||
|
empty_node_count++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string name = Strings::replace_all(std::string{package.package}, "-", "_");
|
||||||
|
s.append(Strings::format("%s;", name));
|
||||||
|
for (const auto& d : package.dependencies)
|
||||||
|
{
|
||||||
|
const std::string dependency_name = Strings::replace_all(std::string{d}, "-", "_");
|
||||||
|
s.append(Strings::format("%s -> %s;", name, dependency_name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
s.append(Strings::format("empty [label=\"%d singletons...\"]; }", empty_node_count));
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string create_dgml_as_string(const std::vector<PackageDependInfo>& depend_info)
|
||||||
|
{
|
||||||
|
std::string s;
|
||||||
|
s.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
||||||
|
s.append("<DirectedGraph xmlns=\"http://schemas.microsoft.com/vs/2009/dgml\">");
|
||||||
|
|
||||||
|
std::string nodes, links;
|
||||||
|
for (const auto& package : depend_info)
|
||||||
|
{
|
||||||
|
const std::string name = package.package;
|
||||||
|
nodes.append(Strings::format("<Node Id=\"%s\" />", name));
|
||||||
|
|
||||||
|
// Iterate over dependencies.
|
||||||
|
for (const auto& d : package.dependencies)
|
||||||
|
{
|
||||||
|
links.append(Strings::format("<Link Source=\"%s\" Target=\"%s\" />", name, d));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
s.append(Strings::format("<Nodes>%s</Nodes>", nodes));
|
||||||
|
|
||||||
|
s.append(Strings::format("<Links>%s</Links>", links));
|
||||||
|
|
||||||
|
s.append("</DirectedGraph>");
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string create_graph_as_string(const std::unordered_set<std::string>& switches,
|
||||||
|
const std::vector<PackageDependInfo>& depend_info)
|
||||||
|
{
|
||||||
|
if (Util::Sets::contains(switches, OPTION_DOT))
|
||||||
|
{
|
||||||
|
return create_dot_as_string(depend_info);
|
||||||
|
}
|
||||||
|
else if (Util::Sets::contains(switches, OPTION_DGML))
|
||||||
|
{
|
||||||
|
return create_dgml_as_string(depend_info);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
void assign_depth_to_dependencies(const std::string& package,
|
||||||
|
const int depth,
|
||||||
|
const int max_depth,
|
||||||
|
std::map<std::string, PackageDependInfo>& dependencies_map)
|
||||||
|
{
|
||||||
|
auto iter = dependencies_map.find(package);
|
||||||
|
Checks::check_exit(
|
||||||
|
VCPKG_LINE_INFO, iter != dependencies_map.end(), "Package not found in dependency graph");
|
||||||
|
|
||||||
|
PackageDependInfo& info = iter->second;
|
||||||
|
|
||||||
|
if (depth > info.depth)
|
||||||
|
{
|
||||||
|
info.depth = depth;
|
||||||
|
if (depth < max_depth || max_depth == NO_RECURSE_LIMIT_VALUE)
|
||||||
|
{
|
||||||
|
for (auto&& dependency : info.dependencies)
|
||||||
|
{
|
||||||
|
assign_depth_to_dependencies(dependency, depth + 1, max_depth, dependencies_map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<PackageDependInfo> extract_depend_info(const std::vector<const InstallPlanAction*>& install_actions,
|
||||||
|
const int max_depth)
|
||||||
|
{
|
||||||
|
std::map<std::string, PackageDependInfo> package_dependencies;
|
||||||
|
for (const InstallPlanAction* pia : install_actions)
|
||||||
|
{
|
||||||
|
const InstallPlanAction& install_action = *pia;
|
||||||
|
|
||||||
|
const std::vector<std::string> dependencies = Util::fmap(
|
||||||
|
install_action.computed_dependencies, [](const PackageSpec& spec) { return spec.name(); });
|
||||||
|
|
||||||
|
std::set<std::string> features{install_action.feature_list};
|
||||||
|
features.erase("core");
|
||||||
|
|
||||||
|
std::string port_name = install_action.spec.name();
|
||||||
|
|
||||||
|
PackageDependInfo info{port_name, -1, features, dependencies};
|
||||||
|
package_dependencies.emplace(port_name, std::move(info));
|
||||||
|
}
|
||||||
|
|
||||||
|
const InstallPlanAction& init = *install_actions.back();
|
||||||
|
assign_depth_to_dependencies(init.spec.name(), 0, max_depth, package_dependencies);
|
||||||
|
|
||||||
|
std::vector<PackageDependInfo> out =
|
||||||
|
Util::fmap(package_dependencies, [](auto&& kvpair) -> PackageDependInfo { return kvpair.second; });
|
||||||
|
Util::erase_remove_if(out, [](auto&& info) { return info.depth < 0; });
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const CommandStructure COMMAND_STRUCTURE = {
|
const CommandStructure COMMAND_STRUCTURE = {
|
||||||
Help::create_example_string("depend-info sqlite3"),
|
Help::create_example_string("depend-info sqlite3"),
|
||||||
@ -44,190 +234,6 @@ namespace vcpkg::Commands::DependInfo
|
|||||||
nullptr,
|
nullptr,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PackageDependInfo
|
|
||||||
{
|
|
||||||
std::string package;
|
|
||||||
int depth;
|
|
||||||
std::set<std::string> features;
|
|
||||||
std::vector<std::string> dependencies;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum SortMode
|
|
||||||
{
|
|
||||||
Lexicographical = 0,
|
|
||||||
Topological,
|
|
||||||
ReverseTopological,
|
|
||||||
Default = Topological
|
|
||||||
};
|
|
||||||
|
|
||||||
int get_max_depth(const ParsedArguments& options)
|
|
||||||
{
|
|
||||||
auto iter = options.settings.find(OPTION_MAX_RECURSE);
|
|
||||||
if (iter != options.settings.end())
|
|
||||||
{
|
|
||||||
std::string value = iter->second;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return std::stoi(value);
|
|
||||||
}
|
|
||||||
catch (std::exception&)
|
|
||||||
{
|
|
||||||
Checks::exit_with_message(VCPKG_LINE_INFO, "Value of --max-depth must be an integer");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// No --max-depth set, default to no limit.
|
|
||||||
return NO_RECURSE_LIMIT_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
SortMode get_sort_mode(const ParsedArguments& options)
|
|
||||||
{
|
|
||||||
constexpr StringLiteral OPTION_SORT_LEXICOGRAPHICAL = "lexicographical";
|
|
||||||
constexpr StringLiteral OPTION_SORT_TOPOLOGICAL = "topological";
|
|
||||||
constexpr StringLiteral OPTION_SORT_REVERSE = "reverse";
|
|
||||||
|
|
||||||
static const std::map<std::string, SortMode> sortModesMap{{OPTION_SORT_LEXICOGRAPHICAL, Lexicographical},
|
|
||||||
{OPTION_SORT_TOPOLOGICAL, Topological},
|
|
||||||
{OPTION_SORT_REVERSE, ReverseTopological}};
|
|
||||||
|
|
||||||
auto iter = options.settings.find(OPTION_SORT);
|
|
||||||
if (iter != options.settings.end())
|
|
||||||
{
|
|
||||||
const std::string value = Strings::ascii_to_lowercase(std::string{iter->second});
|
|
||||||
auto it = sortModesMap.find(value);
|
|
||||||
if (it != sortModesMap.end())
|
|
||||||
{
|
|
||||||
return it->second;
|
|
||||||
}
|
|
||||||
Checks::exit_with_message(VCPKG_LINE_INFO,
|
|
||||||
"Value of --sort must be one of `%s`, `%s`, or `%s`",
|
|
||||||
OPTION_SORT_LEXICOGRAPHICAL,
|
|
||||||
OPTION_SORT_TOPOLOGICAL,
|
|
||||||
OPTION_SORT_REVERSE);
|
|
||||||
}
|
|
||||||
return Default;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string create_dot_as_string(const std::vector<PackageDependInfo>& depend_info)
|
|
||||||
{
|
|
||||||
int empty_node_count = 0;
|
|
||||||
|
|
||||||
std::string s;
|
|
||||||
s.append("digraph G{ rankdir=LR; edge [minlen=3]; overlap=false;");
|
|
||||||
|
|
||||||
for (const auto& package : depend_info)
|
|
||||||
{
|
|
||||||
if (package.dependencies.empty())
|
|
||||||
{
|
|
||||||
empty_node_count++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string name = Strings::replace_all(std::string{ package.package }, "-", "_");
|
|
||||||
s.append(Strings::format("%s;", name));
|
|
||||||
for (const auto &d : package.dependencies)
|
|
||||||
{
|
|
||||||
const std::string dependency_name = Strings::replace_all(std::string{ d }, "-", "_");
|
|
||||||
s.append(Strings::format("%s -> %s;", name, dependency_name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
s.append(Strings::format("empty [label=\"%d singletons...\"]; }", empty_node_count));
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string create_dgml_as_string(const std::vector<PackageDependInfo>& depend_info)
|
|
||||||
{
|
|
||||||
std::string s;
|
|
||||||
s.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
|
||||||
s.append("<DirectedGraph xmlns=\"http://schemas.microsoft.com/vs/2009/dgml\">");
|
|
||||||
|
|
||||||
std::string nodes, links;
|
|
||||||
for (const auto& package : depend_info)
|
|
||||||
{
|
|
||||||
const std::string name = package.package;
|
|
||||||
nodes.append(Strings::format("<Node Id=\"%s\" />", name));
|
|
||||||
|
|
||||||
// Iterate over dependencies.
|
|
||||||
for (const auto& d : package.dependencies)
|
|
||||||
{
|
|
||||||
links.append(Strings::format("<Link Source=\"%s\" Target=\"%s\" />", name, d));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
s.append(Strings::format("<Nodes>%s</Nodes>", nodes));
|
|
||||||
|
|
||||||
s.append(Strings::format("<Links>%s</Links>", links));
|
|
||||||
|
|
||||||
s.append("</DirectedGraph>");
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string create_graph_as_string(const std::unordered_set<std::string>& switches,
|
|
||||||
const std::vector<PackageDependInfo>& depend_info)
|
|
||||||
{
|
|
||||||
if (Util::Sets::contains(switches, OPTION_DOT))
|
|
||||||
{
|
|
||||||
return create_dot_as_string(depend_info);
|
|
||||||
}
|
|
||||||
else if (Util::Sets::contains(switches, OPTION_DGML))
|
|
||||||
{
|
|
||||||
return create_dgml_as_string(depend_info);
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
void assign_depth_to_dependencies(const std::string& package,
|
|
||||||
const int depth,
|
|
||||||
const int max_depth,
|
|
||||||
std::map<std::string, PackageDependInfo>& dependencies_map)
|
|
||||||
{
|
|
||||||
auto iter = dependencies_map.find(package);
|
|
||||||
Checks::check_exit(VCPKG_LINE_INFO, iter != dependencies_map.end(), "Package not found in dependency graph");
|
|
||||||
|
|
||||||
PackageDependInfo& info = iter->second;
|
|
||||||
|
|
||||||
if (depth > info.depth)
|
|
||||||
{
|
|
||||||
info.depth = depth;
|
|
||||||
if (depth < max_depth || max_depth == NO_RECURSE_LIMIT_VALUE)
|
|
||||||
{
|
|
||||||
for (auto&& dependency : info.dependencies)
|
|
||||||
{
|
|
||||||
assign_depth_to_dependencies(dependency, depth + 1, max_depth, dependencies_map);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
std::vector<PackageDependInfo> extract_depend_info(const std::vector<const InstallPlanAction*>& install_actions,
|
|
||||||
const int max_depth)
|
|
||||||
{
|
|
||||||
std::map<std::string, PackageDependInfo> package_dependencies;
|
|
||||||
for (const InstallPlanAction* pia : install_actions)
|
|
||||||
{
|
|
||||||
const InstallPlanAction& install_action = *pia;
|
|
||||||
|
|
||||||
const std::vector<std::string> dependencies =
|
|
||||||
Util::fmap(install_action.computed_dependencies, [](const PackageSpec& spec) { return spec.name(); });
|
|
||||||
|
|
||||||
std::set<std::string> features{install_action.feature_list};
|
|
||||||
features.erase("core");
|
|
||||||
|
|
||||||
std::string port_name = install_action.spec.name();
|
|
||||||
|
|
||||||
PackageDependInfo info {port_name, -1, features, dependencies};
|
|
||||||
package_dependencies.emplace(port_name, std::move(info));
|
|
||||||
}
|
|
||||||
|
|
||||||
const InstallPlanAction& init = *install_actions.back();
|
|
||||||
assign_depth_to_dependencies(init.spec.name(), 0, max_depth, package_dependencies);
|
|
||||||
|
|
||||||
std::vector<PackageDependInfo> out =
|
|
||||||
Util::fmap(package_dependencies, [](auto&& kvpair) -> PackageDependInfo { return kvpair.second; });
|
|
||||||
Util::erase_remove_if(out, [](auto&& info) { return info.depth < 0; });
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet)
|
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet)
|
||||||
{
|
{
|
||||||
const ParsedArguments options = args.parse_arguments(COMMAND_STRUCTURE);
|
const ParsedArguments options = args.parse_arguments(COMMAND_STRUCTURE);
|
||||||
@ -276,7 +282,6 @@ namespace vcpkg::Commands::DependInfo
|
|||||||
Checks::exit_success(VCPKG_LINE_INFO);
|
Checks::exit_success(VCPKG_LINE_INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: Improve this code
|
// TODO: Improve this code
|
||||||
auto lex = [](const PackageDependInfo& lhs, const PackageDependInfo& rhs) -> bool {
|
auto lex = [](const PackageDependInfo& lhs, const PackageDependInfo& rhs) -> bool {
|
||||||
return lhs.package < rhs.package;
|
return lhs.package < rhs.package;
|
||||||
@ -284,7 +289,7 @@ namespace vcpkg::Commands::DependInfo
|
|||||||
auto topo = [](const PackageDependInfo& lhs, const PackageDependInfo& rhs) -> bool {
|
auto topo = [](const PackageDependInfo& lhs, const PackageDependInfo& rhs) -> bool {
|
||||||
return lhs.depth > rhs.depth;
|
return lhs.depth > rhs.depth;
|
||||||
};
|
};
|
||||||
auto reverse = [topo](const PackageDependInfo& lhs, const PackageDependInfo& rhs) -> bool {
|
auto reverse = [](const PackageDependInfo& lhs, const PackageDependInfo& rhs) -> bool {
|
||||||
return lhs.depth < rhs.depth;
|
return lhs.depth < rhs.depth;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
|
|
||||||
namespace vcpkg::Commands::Edit
|
namespace vcpkg::Commands::Edit
|
||||||
{
|
{
|
||||||
|
#if defined(_WIN32)
|
||||||
static std::vector<fs::path> find_from_registry()
|
static std::vector<fs::path> find_from_registry()
|
||||||
{
|
{
|
||||||
std::vector<fs::path> output;
|
std::vector<fs::path> output;
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
struct RegKey
|
struct RegKey
|
||||||
{
|
{
|
||||||
HKEY root;
|
HKEY root;
|
||||||
@ -42,9 +42,9 @@ namespace vcpkg::Commands::Edit
|
|||||||
output.push_back(install_path / "Code.exe");
|
output.push_back(install_path / "Code.exe");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static constexpr StringLiteral OPTION_BUILDTREES = "--buildtrees";
|
static constexpr StringLiteral OPTION_BUILDTREES = "--buildtrees";
|
||||||
|
|
||||||
|
@ -13,86 +13,94 @@ namespace vcpkg::Export::IFW
|
|||||||
using Dependencies::ExportPlanType;
|
using Dependencies::ExportPlanType;
|
||||||
using Install::InstallDir;
|
using Install::InstallDir;
|
||||||
|
|
||||||
static std::string create_release_date()
|
namespace
|
||||||
{
|
{
|
||||||
const tm date_time = Chrono::get_current_date_time_local();
|
std::string create_release_date()
|
||||||
|
{
|
||||||
|
const tm date_time = Chrono::get_current_date_time_local();
|
||||||
|
|
||||||
// Format is: YYYY-mm-dd
|
// Format is: YYYY-mm-dd
|
||||||
// 10 characters + 1 null terminating character will be written for a total of 11 chars
|
// 10 characters + 1 null terminating character will be written for a total of 11 chars
|
||||||
char mbstr[11];
|
char mbstr[11];
|
||||||
const size_t bytes_written = std::strftime(mbstr, sizeof(mbstr), "%Y-%m-%d", &date_time);
|
const size_t bytes_written = std::strftime(mbstr, sizeof(mbstr), "%Y-%m-%d", &date_time);
|
||||||
Checks::check_exit(VCPKG_LINE_INFO,
|
Checks::check_exit(VCPKG_LINE_INFO,
|
||||||
bytes_written == 10,
|
bytes_written == 10,
|
||||||
"Expected 10 bytes to be written, but %u were written",
|
"Expected 10 bytes to be written, but %u were written",
|
||||||
bytes_written);
|
bytes_written);
|
||||||
const std::string date_time_as_string(mbstr);
|
const std::string date_time_as_string(mbstr);
|
||||||
return date_time_as_string;
|
return date_time_as_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string safe_rich_from_plain_text(const std::string& text)
|
std::string safe_rich_from_plain_text(const std::string& text)
|
||||||
{
|
{
|
||||||
// match standalone ampersand, no HTML number or name
|
// match standalone ampersand, no HTML number or name
|
||||||
std::regex standalone_ampersand(R"###(&(?!(#[0-9]+|\w+);))###");
|
std::regex standalone_ampersand(R"###(&(?!(#[0-9]+|\w+);))###");
|
||||||
|
|
||||||
return std::regex_replace(text, standalone_ampersand, "&");
|
return std::regex_replace(text, standalone_ampersand, "&");
|
||||||
}
|
}
|
||||||
|
|
||||||
fs::path get_packages_dir_path(const std::string& export_id, const Options& ifw_options, const VcpkgPaths& paths)
|
fs::path get_packages_dir_path(const std::string& export_id,
|
||||||
{
|
const Options& ifw_options,
|
||||||
return ifw_options.maybe_packages_dir_path.has_value()
|
const VcpkgPaths& paths)
|
||||||
? fs::path(ifw_options.maybe_packages_dir_path.value_or_exit(VCPKG_LINE_INFO))
|
{
|
||||||
: paths.root / (export_id + "-ifw-packages");
|
return ifw_options.maybe_packages_dir_path.has_value()
|
||||||
}
|
? fs::path(ifw_options.maybe_packages_dir_path.value_or_exit(VCPKG_LINE_INFO))
|
||||||
|
: paths.root / (export_id + "-ifw-packages");
|
||||||
|
}
|
||||||
|
|
||||||
fs::path get_repository_dir_path(const std::string& export_id, const Options& ifw_options, const VcpkgPaths& paths)
|
fs::path get_repository_dir_path(const std::string& export_id,
|
||||||
{
|
const Options& ifw_options,
|
||||||
return ifw_options.maybe_repository_dir_path.has_value()
|
const VcpkgPaths& paths)
|
||||||
? fs::path(ifw_options.maybe_repository_dir_path.value_or_exit(VCPKG_LINE_INFO))
|
{
|
||||||
: paths.root / (export_id + "-ifw-repository");
|
return ifw_options.maybe_repository_dir_path.has_value()
|
||||||
}
|
? fs::path(ifw_options.maybe_repository_dir_path.value_or_exit(VCPKG_LINE_INFO))
|
||||||
|
: paths.root / (export_id + "-ifw-repository");
|
||||||
|
}
|
||||||
|
|
||||||
fs::path get_config_file_path(const std::string& export_id, const Options& ifw_options, const VcpkgPaths& paths)
|
fs::path get_config_file_path(const std::string& export_id, const Options& ifw_options, const VcpkgPaths& paths)
|
||||||
{
|
{
|
||||||
return ifw_options.maybe_config_file_path.has_value()
|
return ifw_options.maybe_config_file_path.has_value()
|
||||||
? fs::path(ifw_options.maybe_config_file_path.value_or_exit(VCPKG_LINE_INFO))
|
? fs::path(ifw_options.maybe_config_file_path.value_or_exit(VCPKG_LINE_INFO))
|
||||||
: paths.root / (export_id + "-ifw-configuration.xml");
|
: paths.root / (export_id + "-ifw-configuration.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
fs::path get_installer_file_path(const std::string& export_id, const Options& ifw_options, const VcpkgPaths& paths)
|
fs::path get_installer_file_path(const std::string& export_id,
|
||||||
{
|
const Options& ifw_options,
|
||||||
return ifw_options.maybe_installer_file_path.has_value()
|
const VcpkgPaths& paths)
|
||||||
? fs::path(ifw_options.maybe_installer_file_path.value_or_exit(VCPKG_LINE_INFO))
|
{
|
||||||
: paths.root / (export_id + "-ifw-installer.exe");
|
return ifw_options.maybe_installer_file_path.has_value()
|
||||||
}
|
? fs::path(ifw_options.maybe_installer_file_path.value_or_exit(VCPKG_LINE_INFO))
|
||||||
|
: paths.root / (export_id + "-ifw-installer.exe");
|
||||||
|
}
|
||||||
|
|
||||||
fs::path export_real_package(const fs::path& ifw_packages_dir_path,
|
fs::path export_real_package(const fs::path& ifw_packages_dir_path,
|
||||||
const ExportPlanAction& action,
|
const ExportPlanAction& action,
|
||||||
Files::Filesystem& fs)
|
Files::Filesystem& fs)
|
||||||
{
|
{
|
||||||
std::error_code ec;
|
std::error_code ec;
|
||||||
|
|
||||||
const BinaryParagraph& binary_paragraph = action.core_paragraph().value_or_exit(VCPKG_LINE_INFO);
|
const BinaryParagraph& binary_paragraph = action.core_paragraph().value_or_exit(VCPKG_LINE_INFO);
|
||||||
|
|
||||||
// Prepare meta dir
|
// Prepare meta dir
|
||||||
const fs::path package_xml_file_path =
|
const fs::path package_xml_file_path =
|
||||||
ifw_packages_dir_path /
|
ifw_packages_dir_path /
|
||||||
Strings::format("packages.%s.%s", action.spec.name(), action.spec.triplet().canonical_name()) / "meta" /
|
Strings::format("packages.%s.%s", action.spec.name(), action.spec.triplet().canonical_name()) / "meta" /
|
||||||
"package.xml";
|
"package.xml";
|
||||||
const fs::path package_xml_dir_path = package_xml_file_path.parent_path();
|
const fs::path package_xml_dir_path = package_xml_file_path.parent_path();
|
||||||
fs.create_directories(package_xml_dir_path, ec);
|
fs.create_directories(package_xml_dir_path, ec);
|
||||||
Checks::check_exit(VCPKG_LINE_INFO,
|
Checks::check_exit(VCPKG_LINE_INFO,
|
||||||
!ec,
|
!ec,
|
||||||
"Could not create directory for package file %s",
|
"Could not create directory for package file %s",
|
||||||
package_xml_file_path.generic_u8string());
|
package_xml_file_path.generic_u8string());
|
||||||
|
|
||||||
auto deps = Strings::join(
|
auto deps = Strings::join(
|
||||||
",", binary_paragraph.depends, [](const std::string& dep) { return "packages." + dep + ":"; });
|
",", binary_paragraph.depends, [](const std::string& dep) { return "packages." + dep + ":"; });
|
||||||
|
|
||||||
if (!deps.empty()) deps = "\n <Dependencies>" + deps + "</Dependencies>";
|
if (!deps.empty()) deps = "\n <Dependencies>" + deps + "</Dependencies>";
|
||||||
|
|
||||||
fs.write_contents(package_xml_file_path,
|
fs.write_contents(package_xml_file_path,
|
||||||
Strings::format(
|
Strings::format(
|
||||||
R"###(<?xml version="1.0"?>
|
R"###(<?xml version="1.0"?>
|
||||||
<Package>
|
<Package>
|
||||||
<DisplayName>%s</DisplayName>
|
<DisplayName>%s</DisplayName>
|
||||||
<Version>%s</Version>
|
<Version>%s</Version>
|
||||||
@ -101,64 +109,64 @@ namespace vcpkg::Export::IFW
|
|||||||
<Virtual>true</Virtual>
|
<Virtual>true</Virtual>
|
||||||
</Package>
|
</Package>
|
||||||
)###",
|
)###",
|
||||||
action.spec.to_string(),
|
action.spec.to_string(),
|
||||||
binary_paragraph.version,
|
binary_paragraph.version,
|
||||||
create_release_date(),
|
create_release_date(),
|
||||||
action.spec.name(),
|
action.spec.name(),
|
||||||
action.spec.triplet().canonical_name(),
|
action.spec.triplet().canonical_name(),
|
||||||
deps),
|
deps),
|
||||||
VCPKG_LINE_INFO);
|
VCPKG_LINE_INFO);
|
||||||
|
|
||||||
// Return dir path for export package data
|
// Return dir path for export package data
|
||||||
return ifw_packages_dir_path /
|
return ifw_packages_dir_path /
|
||||||
Strings::format("packages.%s.%s", action.spec.name(), action.spec.triplet().canonical_name()) / "data" /
|
Strings::format("packages.%s.%s", action.spec.name(), action.spec.triplet().canonical_name()) /
|
||||||
"installed";
|
"data" / "installed";
|
||||||
}
|
}
|
||||||
|
|
||||||
void export_unique_packages(const fs::path& raw_exported_dir_path,
|
void export_unique_packages(const fs::path& raw_exported_dir_path,
|
||||||
std::map<std::string, const ExportPlanAction*> unique_packages,
|
std::map<std::string, const ExportPlanAction*> unique_packages,
|
||||||
Files::Filesystem& fs)
|
Files::Filesystem& fs)
|
||||||
{
|
{
|
||||||
std::error_code ec;
|
std::error_code ec;
|
||||||
|
|
||||||
// packages
|
// packages
|
||||||
|
|
||||||
fs::path package_xml_file_path = raw_exported_dir_path / "packages" / "meta" / "package.xml";
|
fs::path package_xml_file_path = raw_exported_dir_path / "packages" / "meta" / "package.xml";
|
||||||
fs::path package_xml_dir_path = package_xml_file_path.parent_path();
|
fs::path package_xml_dir_path = package_xml_file_path.parent_path();
|
||||||
fs.create_directories(package_xml_dir_path, ec);
|
fs.create_directories(package_xml_dir_path, ec);
|
||||||
Checks::check_exit(VCPKG_LINE_INFO,
|
Checks::check_exit(VCPKG_LINE_INFO,
|
||||||
!ec,
|
!ec,
|
||||||
"Could not create directory for package file %s",
|
"Could not create directory for package file %s",
|
||||||
package_xml_file_path.generic_u8string());
|
package_xml_file_path.generic_u8string());
|
||||||
fs.write_contents(package_xml_file_path,
|
fs.write_contents(package_xml_file_path,
|
||||||
Strings::format(
|
Strings::format(
|
||||||
R"###(<?xml version="1.0"?>
|
R"###(<?xml version="1.0"?>
|
||||||
<Package>
|
<Package>
|
||||||
<DisplayName>Packages</DisplayName>
|
<DisplayName>Packages</DisplayName>
|
||||||
<Version>1.0.0</Version>
|
<Version>1.0.0</Version>
|
||||||
<ReleaseDate>%s</ReleaseDate>
|
<ReleaseDate>%s</ReleaseDate>
|
||||||
</Package>
|
</Package>
|
||||||
)###",
|
)###",
|
||||||
create_release_date()),
|
create_release_date()),
|
||||||
VCPKG_LINE_INFO);
|
VCPKG_LINE_INFO);
|
||||||
|
|
||||||
for (const auto& unique_package : unique_packages)
|
for (const auto& unique_package : unique_packages)
|
||||||
{
|
{
|
||||||
const ExportPlanAction& action = *(unique_package.second);
|
const ExportPlanAction& action = *(unique_package.second);
|
||||||
const BinaryParagraph& binary_paragraph = action.core_paragraph().value_or_exit(VCPKG_LINE_INFO);
|
const BinaryParagraph& binary_paragraph = action.core_paragraph().value_or_exit(VCPKG_LINE_INFO);
|
||||||
|
|
||||||
package_xml_file_path =
|
package_xml_file_path = raw_exported_dir_path / Strings::format("packages.%s", unique_package.first) /
|
||||||
raw_exported_dir_path / Strings::format("packages.%s", unique_package.first) / "meta" / "package.xml";
|
"meta" / "package.xml";
|
||||||
package_xml_dir_path = package_xml_file_path.parent_path();
|
package_xml_dir_path = package_xml_file_path.parent_path();
|
||||||
fs.create_directories(package_xml_dir_path, ec);
|
fs.create_directories(package_xml_dir_path, ec);
|
||||||
Checks::check_exit(VCPKG_LINE_INFO,
|
Checks::check_exit(VCPKG_LINE_INFO,
|
||||||
!ec,
|
!ec,
|
||||||
"Could not create directory for package file %s",
|
"Could not create directory for package file %s",
|
||||||
package_xml_file_path.generic_u8string());
|
package_xml_file_path.generic_u8string());
|
||||||
|
|
||||||
fs.write_contents(package_xml_file_path,
|
fs.write_contents(package_xml_file_path,
|
||||||
Strings::format(
|
Strings::format(
|
||||||
R"###(<?xml version="1.0"?>
|
R"###(<?xml version="1.0"?>
|
||||||
<Package>
|
<Package>
|
||||||
<DisplayName>%s</DisplayName>
|
<DisplayName>%s</DisplayName>
|
||||||
<Description>%s</Description>
|
<Description>%s</Description>
|
||||||
@ -166,46 +174,24 @@ namespace vcpkg::Export::IFW
|
|||||||
<ReleaseDate>%s</ReleaseDate>
|
<ReleaseDate>%s</ReleaseDate>
|
||||||
</Package>
|
</Package>
|
||||||
)###",
|
)###",
|
||||||
action.spec.name(),
|
action.spec.name(),
|
||||||
safe_rich_from_plain_text(binary_paragraph.description),
|
safe_rich_from_plain_text(binary_paragraph.description),
|
||||||
binary_paragraph.version,
|
binary_paragraph.version,
|
||||||
create_release_date()),
|
create_release_date()),
|
||||||
VCPKG_LINE_INFO);
|
VCPKG_LINE_INFO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void export_unique_triplets(const fs::path& raw_exported_dir_path,
|
void export_unique_triplets(const fs::path& raw_exported_dir_path,
|
||||||
std::set<std::string> unique_triplets,
|
std::set<std::string> unique_triplets,
|
||||||
Files::Filesystem& fs)
|
Files::Filesystem& fs)
|
||||||
{
|
|
||||||
std::error_code ec;
|
|
||||||
|
|
||||||
// triplets
|
|
||||||
|
|
||||||
fs::path package_xml_file_path = raw_exported_dir_path / "triplets" / "meta" / "package.xml";
|
|
||||||
fs::path package_xml_dir_path = package_xml_file_path.parent_path();
|
|
||||||
fs.create_directories(package_xml_dir_path, ec);
|
|
||||||
Checks::check_exit(VCPKG_LINE_INFO,
|
|
||||||
!ec,
|
|
||||||
"Could not create directory for package file %s",
|
|
||||||
package_xml_file_path.generic_u8string());
|
|
||||||
fs.write_contents(package_xml_file_path,
|
|
||||||
Strings::format(
|
|
||||||
R"###(<?xml version="1.0"?>
|
|
||||||
<Package>
|
|
||||||
<DisplayName>Triplets</DisplayName>
|
|
||||||
<Version>1.0.0</Version>
|
|
||||||
<ReleaseDate>%s</ReleaseDate>
|
|
||||||
</Package>
|
|
||||||
)###",
|
|
||||||
create_release_date()),
|
|
||||||
VCPKG_LINE_INFO);
|
|
||||||
|
|
||||||
for (const std::string& triplet : unique_triplets)
|
|
||||||
{
|
{
|
||||||
package_xml_file_path =
|
std::error_code ec;
|
||||||
raw_exported_dir_path / Strings::format("triplets.%s", triplet) / "meta" / "package.xml";
|
|
||||||
package_xml_dir_path = package_xml_file_path.parent_path();
|
// triplets
|
||||||
|
|
||||||
|
fs::path package_xml_file_path = raw_exported_dir_path / "triplets" / "meta" / "package.xml";
|
||||||
|
fs::path package_xml_dir_path = package_xml_file_path.parent_path();
|
||||||
fs.create_directories(package_xml_dir_path, ec);
|
fs.create_directories(package_xml_dir_path, ec);
|
||||||
Checks::check_exit(VCPKG_LINE_INFO,
|
Checks::check_exit(VCPKG_LINE_INFO,
|
||||||
!ec,
|
!ec,
|
||||||
@ -214,74 +200,96 @@ namespace vcpkg::Export::IFW
|
|||||||
fs.write_contents(package_xml_file_path,
|
fs.write_contents(package_xml_file_path,
|
||||||
Strings::format(
|
Strings::format(
|
||||||
R"###(<?xml version="1.0"?>
|
R"###(<?xml version="1.0"?>
|
||||||
|
<Package>
|
||||||
|
<DisplayName>Triplets</DisplayName>
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
<ReleaseDate>%s</ReleaseDate>
|
||||||
|
</Package>
|
||||||
|
)###",
|
||||||
|
create_release_date()),
|
||||||
|
VCPKG_LINE_INFO);
|
||||||
|
|
||||||
|
for (const std::string& triplet : unique_triplets)
|
||||||
|
{
|
||||||
|
package_xml_file_path =
|
||||||
|
raw_exported_dir_path / Strings::format("triplets.%s", triplet) / "meta" / "package.xml";
|
||||||
|
package_xml_dir_path = package_xml_file_path.parent_path();
|
||||||
|
fs.create_directories(package_xml_dir_path, ec);
|
||||||
|
Checks::check_exit(VCPKG_LINE_INFO,
|
||||||
|
!ec,
|
||||||
|
"Could not create directory for package file %s",
|
||||||
|
package_xml_file_path.generic_u8string());
|
||||||
|
fs.write_contents(package_xml_file_path,
|
||||||
|
Strings::format(
|
||||||
|
R"###(<?xml version="1.0"?>
|
||||||
<Package>
|
<Package>
|
||||||
<DisplayName>%s</DisplayName>
|
<DisplayName>%s</DisplayName>
|
||||||
<Version>1.0.0</Version>
|
<Version>1.0.0</Version>
|
||||||
<ReleaseDate>%s</ReleaseDate>
|
<ReleaseDate>%s</ReleaseDate>
|
||||||
</Package>
|
</Package>
|
||||||
)###",
|
)###",
|
||||||
triplet,
|
triplet,
|
||||||
create_release_date()),
|
create_release_date()),
|
||||||
VCPKG_LINE_INFO);
|
VCPKG_LINE_INFO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void export_integration(const fs::path& raw_exported_dir_path, Files::Filesystem& fs)
|
void export_integration(const fs::path& raw_exported_dir_path, Files::Filesystem& fs)
|
||||||
{
|
{
|
||||||
std::error_code ec;
|
std::error_code ec;
|
||||||
|
|
||||||
// integration
|
// integration
|
||||||
fs::path package_xml_file_path = raw_exported_dir_path / "integration" / "meta" / "package.xml";
|
fs::path package_xml_file_path = raw_exported_dir_path / "integration" / "meta" / "package.xml";
|
||||||
fs::path package_xml_dir_path = package_xml_file_path.parent_path();
|
fs::path package_xml_dir_path = package_xml_file_path.parent_path();
|
||||||
fs.create_directories(package_xml_dir_path, ec);
|
fs.create_directories(package_xml_dir_path, ec);
|
||||||
Checks::check_exit(VCPKG_LINE_INFO,
|
Checks::check_exit(VCPKG_LINE_INFO,
|
||||||
!ec,
|
!ec,
|
||||||
"Could not create directory for package file %s",
|
"Could not create directory for package file %s",
|
||||||
package_xml_file_path.generic_u8string());
|
package_xml_file_path.generic_u8string());
|
||||||
|
|
||||||
fs.write_contents(package_xml_file_path,
|
fs.write_contents(package_xml_file_path,
|
||||||
Strings::format(
|
Strings::format(
|
||||||
R"###(<?xml version="1.0"?>
|
R"###(<?xml version="1.0"?>
|
||||||
<Package>
|
<Package>
|
||||||
<DisplayName>Integration</DisplayName>
|
<DisplayName>Integration</DisplayName>
|
||||||
<Version>1.0.0</Version>
|
<Version>1.0.0</Version>
|
||||||
<ReleaseDate>%s</ReleaseDate>
|
<ReleaseDate>%s</ReleaseDate>
|
||||||
</Package>
|
</Package>
|
||||||
)###",
|
)###",
|
||||||
create_release_date()),
|
create_release_date()),
|
||||||
VCPKG_LINE_INFO);
|
VCPKG_LINE_INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
void export_config(const std::string& export_id, const Options& ifw_options, const VcpkgPaths& paths)
|
void export_config(const std::string& export_id, const Options& ifw_options, const VcpkgPaths& paths)
|
||||||
{
|
|
||||||
std::error_code ec;
|
|
||||||
Files::Filesystem& fs = paths.get_filesystem();
|
|
||||||
|
|
||||||
const fs::path config_xml_file_path = get_config_file_path(export_id, ifw_options, paths);
|
|
||||||
|
|
||||||
fs::path config_xml_dir_path = config_xml_file_path.parent_path();
|
|
||||||
fs.create_directories(config_xml_dir_path, ec);
|
|
||||||
Checks::check_exit(VCPKG_LINE_INFO,
|
|
||||||
!ec,
|
|
||||||
"Could not create directory for configuration file %s",
|
|
||||||
config_xml_file_path.generic_u8string());
|
|
||||||
|
|
||||||
std::string formatted_repo_url;
|
|
||||||
std::string ifw_repo_url = ifw_options.maybe_repository_url.value_or("");
|
|
||||||
if (!ifw_repo_url.empty())
|
|
||||||
{
|
{
|
||||||
formatted_repo_url = Strings::format(R"###(
|
std::error_code ec;
|
||||||
|
Files::Filesystem& fs = paths.get_filesystem();
|
||||||
|
|
||||||
|
const fs::path config_xml_file_path = get_config_file_path(export_id, ifw_options, paths);
|
||||||
|
|
||||||
|
fs::path config_xml_dir_path = config_xml_file_path.parent_path();
|
||||||
|
fs.create_directories(config_xml_dir_path, ec);
|
||||||
|
Checks::check_exit(VCPKG_LINE_INFO,
|
||||||
|
!ec,
|
||||||
|
"Could not create directory for configuration file %s",
|
||||||
|
config_xml_file_path.generic_u8string());
|
||||||
|
|
||||||
|
std::string formatted_repo_url;
|
||||||
|
std::string ifw_repo_url = ifw_options.maybe_repository_url.value_or("");
|
||||||
|
if (!ifw_repo_url.empty())
|
||||||
|
{
|
||||||
|
formatted_repo_url = Strings::format(R"###(
|
||||||
<RemoteRepositories>
|
<RemoteRepositories>
|
||||||
<Repository>
|
<Repository>
|
||||||
<Url>%s</Url>
|
<Url>%s</Url>
|
||||||
</Repository>
|
</Repository>
|
||||||
</RemoteRepositories>)###",
|
</RemoteRepositories>)###",
|
||||||
ifw_repo_url);
|
ifw_repo_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.write_contents(config_xml_file_path,
|
fs.write_contents(config_xml_file_path,
|
||||||
Strings::format(
|
Strings::format(
|
||||||
R"###(<?xml version="1.0"?>
|
R"###(<?xml version="1.0"?>
|
||||||
<Installer>
|
<Installer>
|
||||||
<Name>vcpkg</Name>
|
<Name>vcpkg</Name>
|
||||||
<Version>1.0.0</Version>
|
<Version>1.0.0</Version>
|
||||||
@ -289,38 +297,38 @@ namespace vcpkg::Export::IFW
|
|||||||
<TargetDir>@RootDir@/src/vcpkg</TargetDir>%s
|
<TargetDir>@RootDir@/src/vcpkg</TargetDir>%s
|
||||||
</Installer>
|
</Installer>
|
||||||
)###",
|
)###",
|
||||||
formatted_repo_url),
|
formatted_repo_url),
|
||||||
VCPKG_LINE_INFO);
|
VCPKG_LINE_INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
void export_maintenance_tool(const fs::path& ifw_packages_dir_path, const VcpkgPaths& paths)
|
void export_maintenance_tool(const fs::path& ifw_packages_dir_path, const VcpkgPaths& paths)
|
||||||
{
|
{
|
||||||
System::print2("Exporting maintenance tool...\n");
|
System::print2("Exporting maintenance tool...\n");
|
||||||
|
|
||||||
std::error_code ec;
|
std::error_code ec;
|
||||||
Files::Filesystem& fs = paths.get_filesystem();
|
Files::Filesystem& fs = paths.get_filesystem();
|
||||||
|
|
||||||
const fs::path& installerbase_exe = paths.get_tool_exe(Tools::IFW_INSTALLER_BASE);
|
const fs::path& installerbase_exe = paths.get_tool_exe(Tools::IFW_INSTALLER_BASE);
|
||||||
fs::path tempmaintenancetool = ifw_packages_dir_path / "maintenance" / "data" / "tempmaintenancetool.exe";
|
fs::path tempmaintenancetool = ifw_packages_dir_path / "maintenance" / "data" / "tempmaintenancetool.exe";
|
||||||
fs.create_directories(tempmaintenancetool.parent_path(), ec);
|
fs.create_directories(tempmaintenancetool.parent_path(), ec);
|
||||||
Checks::check_exit(VCPKG_LINE_INFO,
|
Checks::check_exit(VCPKG_LINE_INFO,
|
||||||
!ec,
|
!ec,
|
||||||
"Could not create directory for package file %s",
|
"Could not create directory for package file %s",
|
||||||
tempmaintenancetool.generic_u8string());
|
tempmaintenancetool.generic_u8string());
|
||||||
fs.copy_file(installerbase_exe, tempmaintenancetool, fs::copy_options::overwrite_existing, ec);
|
fs.copy_file(installerbase_exe, tempmaintenancetool, fs::copy_options::overwrite_existing, ec);
|
||||||
Checks::check_exit(
|
Checks::check_exit(
|
||||||
VCPKG_LINE_INFO, !ec, "Could not write package file %s", tempmaintenancetool.generic_u8string());
|
VCPKG_LINE_INFO, !ec, "Could not write package file %s", tempmaintenancetool.generic_u8string());
|
||||||
|
|
||||||
fs::path package_xml_file_path = ifw_packages_dir_path / "maintenance" / "meta" / "package.xml";
|
fs::path package_xml_file_path = ifw_packages_dir_path / "maintenance" / "meta" / "package.xml";
|
||||||
fs::path package_xml_dir_path = package_xml_file_path.parent_path();
|
fs::path package_xml_dir_path = package_xml_file_path.parent_path();
|
||||||
fs.create_directories(package_xml_dir_path, ec);
|
fs.create_directories(package_xml_dir_path, ec);
|
||||||
Checks::check_exit(VCPKG_LINE_INFO,
|
Checks::check_exit(VCPKG_LINE_INFO,
|
||||||
!ec,
|
!ec,
|
||||||
"Could not create directory for package file %s",
|
"Could not create directory for package file %s",
|
||||||
package_xml_file_path.generic_u8string());
|
package_xml_file_path.generic_u8string());
|
||||||
fs.write_contents(package_xml_file_path,
|
fs.write_contents(package_xml_file_path,
|
||||||
Strings::format(
|
Strings::format(
|
||||||
R"###(<?xml version="1.0"?>
|
R"###(<?xml version="1.0"?>
|
||||||
<Package>
|
<Package>
|
||||||
<DisplayName>Maintenance Tool</DisplayName>
|
<DisplayName>Maintenance Tool</DisplayName>
|
||||||
<Description>Maintenance Tool</Description>
|
<Description>Maintenance Tool</Description>
|
||||||
@ -332,82 +340,84 @@ namespace vcpkg::Export::IFW
|
|||||||
<ForcedInstallation>true</ForcedInstallation>
|
<ForcedInstallation>true</ForcedInstallation>
|
||||||
</Package>
|
</Package>
|
||||||
)###",
|
)###",
|
||||||
create_release_date()),
|
create_release_date()),
|
||||||
VCPKG_LINE_INFO);
|
VCPKG_LINE_INFO);
|
||||||
const fs::path script_source = paths.root / "scripts" / "ifw" / "maintenance.qs";
|
const fs::path script_source = paths.root / "scripts" / "ifw" / "maintenance.qs";
|
||||||
const fs::path script_destination = ifw_packages_dir_path / "maintenance" / "meta" / "maintenance.qs";
|
const fs::path script_destination = ifw_packages_dir_path / "maintenance" / "meta" / "maintenance.qs";
|
||||||
fs.copy_file(script_source, script_destination, fs::copy_options::overwrite_existing, ec);
|
fs.copy_file(script_source, script_destination, fs::copy_options::overwrite_existing, ec);
|
||||||
Checks::check_exit(
|
Checks::check_exit(
|
||||||
VCPKG_LINE_INFO, !ec, "Could not write package file %s", script_destination.generic_u8string());
|
VCPKG_LINE_INFO, !ec, "Could not write package file %s", script_destination.generic_u8string());
|
||||||
|
|
||||||
System::print2("Exporting maintenance tool... done\n");
|
System::print2("Exporting maintenance tool... done\n");
|
||||||
}
|
|
||||||
|
|
||||||
void do_repository(const std::string& export_id, const Options& ifw_options, const VcpkgPaths& paths)
|
|
||||||
{
|
|
||||||
const fs::path& repogen_exe = paths.get_tool_exe(Tools::IFW_REPOGEN);
|
|
||||||
const fs::path packages_dir = get_packages_dir_path(export_id, ifw_options, paths);
|
|
||||||
const fs::path repository_dir = get_repository_dir_path(export_id, ifw_options, paths);
|
|
||||||
|
|
||||||
System::print2("Generating repository ", repository_dir.generic_u8string(), "...\n");
|
|
||||||
|
|
||||||
std::error_code ec;
|
|
||||||
fs::path failure_point;
|
|
||||||
Files::Filesystem& fs = paths.get_filesystem();
|
|
||||||
|
|
||||||
fs.remove_all(repository_dir, ec, failure_point);
|
|
||||||
Checks::check_exit(VCPKG_LINE_INFO,
|
|
||||||
!ec,
|
|
||||||
"Could not remove outdated repository directory %s due to file %s",
|
|
||||||
repository_dir.generic_u8string(),
|
|
||||||
failure_point.string());
|
|
||||||
|
|
||||||
const auto cmd_line = Strings::format(R"("%s" --packages "%s" "%s" > nul)",
|
|
||||||
repogen_exe.u8string(),
|
|
||||||
packages_dir.u8string(),
|
|
||||||
repository_dir.u8string());
|
|
||||||
|
|
||||||
const int exit_code = System::cmd_execute_clean(cmd_line);
|
|
||||||
Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Error: IFW repository generating failed");
|
|
||||||
|
|
||||||
System::printf(
|
|
||||||
System::Color::success, "Generating repository %s... done.\n", repository_dir.generic_u8string());
|
|
||||||
}
|
|
||||||
|
|
||||||
void do_installer(const std::string& export_id, const Options& ifw_options, const VcpkgPaths& paths)
|
|
||||||
{
|
|
||||||
const fs::path& binarycreator_exe = paths.get_tool_exe(Tools::IFW_BINARYCREATOR);
|
|
||||||
const fs::path config_file = get_config_file_path(export_id, ifw_options, paths);
|
|
||||||
const fs::path packages_dir = get_packages_dir_path(export_id, ifw_options, paths);
|
|
||||||
const fs::path repository_dir = get_repository_dir_path(export_id, ifw_options, paths);
|
|
||||||
const fs::path installer_file = get_installer_file_path(export_id, ifw_options, paths);
|
|
||||||
|
|
||||||
System::printf("Generating installer %s...\n", installer_file.generic_u8string());
|
|
||||||
|
|
||||||
std::string cmd_line;
|
|
||||||
|
|
||||||
std::string ifw_repo_url = ifw_options.maybe_repository_url.value_or("");
|
|
||||||
if (!ifw_repo_url.empty())
|
|
||||||
{
|
|
||||||
cmd_line = Strings::format(R"("%s" --online-only --config "%s" --repository "%s" "%s" > nul)",
|
|
||||||
binarycreator_exe.u8string(),
|
|
||||||
config_file.u8string(),
|
|
||||||
repository_dir.u8string(),
|
|
||||||
installer_file.u8string());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cmd_line = Strings::format(R"("%s" --config "%s" --packages "%s" "%s" > nul)",
|
|
||||||
binarycreator_exe.u8string(),
|
|
||||||
config_file.u8string(),
|
|
||||||
packages_dir.u8string(),
|
|
||||||
installer_file.u8string());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const int exit_code = System::cmd_execute_clean(cmd_line);
|
void do_repository(const std::string& export_id, const Options& ifw_options, const VcpkgPaths& paths)
|
||||||
Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Error: IFW installer generating failed");
|
{
|
||||||
|
const fs::path& repogen_exe = paths.get_tool_exe(Tools::IFW_REPOGEN);
|
||||||
|
const fs::path packages_dir = get_packages_dir_path(export_id, ifw_options, paths);
|
||||||
|
const fs::path repository_dir = get_repository_dir_path(export_id, ifw_options, paths);
|
||||||
|
|
||||||
System::printf(System::Color::success, "Generating installer %s... done.\n", installer_file.generic_u8string());
|
System::print2("Generating repository ", repository_dir.generic_u8string(), "...\n");
|
||||||
|
|
||||||
|
std::error_code ec;
|
||||||
|
fs::path failure_point;
|
||||||
|
Files::Filesystem& fs = paths.get_filesystem();
|
||||||
|
|
||||||
|
fs.remove_all(repository_dir, ec, failure_point);
|
||||||
|
Checks::check_exit(VCPKG_LINE_INFO,
|
||||||
|
!ec,
|
||||||
|
"Could not remove outdated repository directory %s due to file %s",
|
||||||
|
repository_dir.generic_u8string(),
|
||||||
|
failure_point.string());
|
||||||
|
|
||||||
|
const auto cmd_line = Strings::format(R"("%s" --packages "%s" "%s" > nul)",
|
||||||
|
repogen_exe.u8string(),
|
||||||
|
packages_dir.u8string(),
|
||||||
|
repository_dir.u8string());
|
||||||
|
|
||||||
|
const int exit_code = System::cmd_execute_clean(cmd_line);
|
||||||
|
Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Error: IFW repository generating failed");
|
||||||
|
|
||||||
|
System::printf(
|
||||||
|
System::Color::success, "Generating repository %s... done.\n", repository_dir.generic_u8string());
|
||||||
|
}
|
||||||
|
|
||||||
|
void do_installer(const std::string& export_id, const Options& ifw_options, const VcpkgPaths& paths)
|
||||||
|
{
|
||||||
|
const fs::path& binarycreator_exe = paths.get_tool_exe(Tools::IFW_BINARYCREATOR);
|
||||||
|
const fs::path config_file = get_config_file_path(export_id, ifw_options, paths);
|
||||||
|
const fs::path packages_dir = get_packages_dir_path(export_id, ifw_options, paths);
|
||||||
|
const fs::path repository_dir = get_repository_dir_path(export_id, ifw_options, paths);
|
||||||
|
const fs::path installer_file = get_installer_file_path(export_id, ifw_options, paths);
|
||||||
|
|
||||||
|
System::printf("Generating installer %s...\n", installer_file.generic_u8string());
|
||||||
|
|
||||||
|
std::string cmd_line;
|
||||||
|
|
||||||
|
std::string ifw_repo_url = ifw_options.maybe_repository_url.value_or("");
|
||||||
|
if (!ifw_repo_url.empty())
|
||||||
|
{
|
||||||
|
cmd_line = Strings::format(R"("%s" --online-only --config "%s" --repository "%s" "%s" > nul)",
|
||||||
|
binarycreator_exe.u8string(),
|
||||||
|
config_file.u8string(),
|
||||||
|
repository_dir.u8string(),
|
||||||
|
installer_file.u8string());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmd_line = Strings::format(R"("%s" --config "%s" --packages "%s" "%s" > nul)",
|
||||||
|
binarycreator_exe.u8string(),
|
||||||
|
config_file.u8string(),
|
||||||
|
packages_dir.u8string(),
|
||||||
|
installer_file.u8string());
|
||||||
|
}
|
||||||
|
|
||||||
|
const int exit_code = System::cmd_execute_clean(cmd_line);
|
||||||
|
Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Error: IFW installer generating failed");
|
||||||
|
|
||||||
|
System::printf(
|
||||||
|
System::Color::success, "Generating installer %s... done.\n", installer_file.generic_u8string());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_export(const std::vector<ExportPlanAction>& export_plan,
|
void do_export(const std::vector<ExportPlanAction>& export_plan,
|
||||||
|
@ -28,6 +28,7 @@ namespace vcpkg::Commands::X_VSInstances
|
|||||||
|
|
||||||
Checks::exit_success(VCPKG_LINE_INFO);
|
Checks::exit_success(VCPKG_LINE_INFO);
|
||||||
#else
|
#else
|
||||||
|
Util::unused(args, paths);
|
||||||
Checks::exit_with_message(VCPKG_LINE_INFO, "This command is not supported on non-windows platforms.");
|
Checks::exit_with_message(VCPKG_LINE_INFO, "This command is not supported on non-windows platforms.");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -13,45 +13,48 @@
|
|||||||
|
|
||||||
namespace vcpkg::Dependencies
|
namespace vcpkg::Dependencies
|
||||||
{
|
{
|
||||||
struct ClusterInstalled
|
namespace
|
||||||
{
|
{
|
||||||
InstalledPackageView ipv;
|
struct ClusterInstalled
|
||||||
std::set<PackageSpec> remove_edges;
|
{
|
||||||
std::set<std::string> original_features;
|
InstalledPackageView ipv;
|
||||||
};
|
std::set<PackageSpec> remove_edges;
|
||||||
|
std::set<std::string> original_features;
|
||||||
|
};
|
||||||
|
|
||||||
struct ClusterSource
|
struct ClusterSource
|
||||||
{
|
{
|
||||||
const SourceControlFileLocation* scfl = nullptr;
|
const SourceControlFileLocation* scfl = nullptr;
|
||||||
std::unordered_map<std::string, std::vector<FeatureSpec>> build_edges;
|
std::unordered_map<std::string, std::vector<FeatureSpec>> build_edges;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Representation of a package and its features in a ClusterGraph.
|
/// Representation of a package and its features in a ClusterGraph.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
struct Cluster : Util::MoveOnlyBase
|
struct Cluster : Util::MoveOnlyBase
|
||||||
{
|
{
|
||||||
PackageSpec spec;
|
PackageSpec spec;
|
||||||
|
|
||||||
Optional<ClusterInstalled> installed;
|
Optional<ClusterInstalled> installed;
|
||||||
Optional<ClusterSource> source;
|
Optional<ClusterSource> source;
|
||||||
|
|
||||||
// Note: this map can contain "special" strings such as "" and "*"
|
// Note: this map can contain "special" strings such as "" and "*"
|
||||||
std::unordered_map<std::string, bool> plus;
|
std::unordered_map<std::string, bool> plus;
|
||||||
std::set<std::string> to_install_features;
|
std::set<std::string> to_install_features;
|
||||||
bool minus = false;
|
bool minus = false;
|
||||||
bool transient_uninstalled = true;
|
bool transient_uninstalled = true;
|
||||||
RequestType request_type = RequestType::AUTO_SELECTED;
|
RequestType request_type = RequestType::AUTO_SELECTED;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ClusterPtr
|
struct ClusterPtr
|
||||||
{
|
{
|
||||||
Cluster* ptr;
|
Cluster* ptr;
|
||||||
|
|
||||||
Cluster* operator->() const { return ptr; }
|
Cluster* operator->() const { return ptr; }
|
||||||
};
|
};
|
||||||
|
|
||||||
bool operator==(const ClusterPtr& l, const ClusterPtr& r) { return l.ptr == r.ptr; }
|
bool operator==(const ClusterPtr& l, const ClusterPtr& r) { return l.ptr == r.ptr; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace std
|
namespace std
|
||||||
@ -122,11 +125,11 @@ namespace vcpkg::Dependencies
|
|||||||
const PortFileProvider& m_provider;
|
const PortFileProvider& m_provider;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string to_output_string(RequestType request_type,
|
static std::string to_output_string(RequestType request_type,
|
||||||
const CStringView s,
|
const CStringView s,
|
||||||
const Build::BuildPackageOptions& options,
|
const Build::BuildPackageOptions& options,
|
||||||
const fs::path& install_port_path,
|
const fs::path& install_port_path,
|
||||||
const fs::path& default_port_path)
|
const fs::path& default_port_path)
|
||||||
{
|
{
|
||||||
if (!default_port_path.empty() &&
|
if (!default_port_path.empty() &&
|
||||||
!Strings::case_insensitive_ascii_starts_with(install_port_path.u8string(), default_port_path.u8string()))
|
!Strings::case_insensitive_ascii_starts_with(install_port_path.u8string(), default_port_path.u8string()))
|
||||||
@ -670,7 +673,7 @@ namespace vcpkg::Dependencies
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//The feature was not previously installed. Mark the cluster
|
// The feature was not previously installed. Mark the cluster
|
||||||
//(aka the entire port) to be removed before re-adding it.
|
//(aka the entire port) to be removed before re-adding it.
|
||||||
mark_minus(cluster, graph, graph_plan, prevent_default_features);
|
mark_minus(cluster, graph, graph_plan, prevent_default_features);
|
||||||
|
|
||||||
|
@ -360,6 +360,12 @@ namespace vcpkg::Export
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && _MSC_VER <= 1900
|
||||||
|
// there's a bug in VS 2015 that causes a bunch of "unreferenced local variable" warnings
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4189)
|
||||||
|
#endif
|
||||||
|
|
||||||
options_implies(OPTION_NUGET,
|
options_implies(OPTION_NUGET,
|
||||||
ret.nuget,
|
ret.nuget,
|
||||||
{
|
{
|
||||||
@ -376,6 +382,9 @@ namespace vcpkg::Export
|
|||||||
{OPTION_IFW_CONFIG_FILE_PATH, ret.ifw_options.maybe_config_file_path},
|
{OPTION_IFW_CONFIG_FILE_PATH, ret.ifw_options.maybe_config_file_path},
|
||||||
{OPTION_IFW_INSTALLER_FILE_PATH, ret.ifw_options.maybe_installer_file_path},
|
{OPTION_IFW_INSTALLER_FILE_PATH, ret.ifw_options.maybe_installer_file_path},
|
||||||
});
|
});
|
||||||
|
#if defined(_MSC_VER) && _MSC_VER <= 1900
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ namespace vcpkg::Install
|
|||||||
const std::vector<fs::path> package_file_paths = fs.get_files_recursive(package_dir);
|
const std::vector<fs::path> package_file_paths = fs.get_files_recursive(package_dir);
|
||||||
const size_t package_remove_char_count = package_dir.generic_string().size() + 1; // +1 for the slash
|
const size_t package_remove_char_count = package_dir.generic_string().size() + 1; // +1 for the slash
|
||||||
auto package_files = Util::fmap(package_file_paths, [package_remove_char_count](const fs::path& path) {
|
auto package_files = Util::fmap(package_file_paths, [package_remove_char_count](const fs::path& path) {
|
||||||
return std::move(std::string(path.generic_string(), package_remove_char_count));
|
return std::string(path.generic_string(), package_remove_char_count);
|
||||||
});
|
});
|
||||||
|
|
||||||
return SortedVector<std::string>(std::move(package_files));
|
return SortedVector<std::string>(std::move(package_files));
|
||||||
|
@ -54,9 +54,12 @@ namespace vcpkg
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ExpressionParser(const std::string& str, const std::string& evaluation_context)
|
ExpressionParser(const std::string& str, const std::string& evaluation_context)
|
||||||
: raw_text(str), evaluation_context(evaluation_context)
|
: raw_text(str)
|
||||||
|
, evaluation_context(evaluation_context)
|
||||||
|
, current_iter(raw_text.begin())
|
||||||
|
, current_char(get_current_char())
|
||||||
{
|
{
|
||||||
go_to_begin();
|
skip_whitespace();
|
||||||
|
|
||||||
final_result = logic_expression();
|
final_result = logic_expression();
|
||||||
|
|
||||||
@ -77,16 +80,17 @@ namespace vcpkg
|
|||||||
bool has_error() const { return err == nullptr; }
|
bool has_error() const { return err == nullptr; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool final_result;
|
|
||||||
|
|
||||||
std::string::const_iterator current_iter;
|
|
||||||
const std::string& raw_text;
|
const std::string& raw_text;
|
||||||
|
const std::string& evaluation_context;
|
||||||
|
std::string::const_iterator current_iter;
|
||||||
char current_char;
|
char current_char;
|
||||||
|
|
||||||
const std::string& evaluation_context;
|
bool final_result;
|
||||||
|
|
||||||
std::unique_ptr<ParseError> err;
|
std::unique_ptr<ParseError> err;
|
||||||
|
|
||||||
|
char get_current_char() const { return (current_iter != raw_text.end() ? *current_iter : '\0'); }
|
||||||
|
|
||||||
void add_error(std::string message, int column = -1)
|
void add_error(std::string message, int column = -1)
|
||||||
{
|
{
|
||||||
// avoid castcading errors by only saving the first
|
// avoid castcading errors by only saving the first
|
||||||
@ -105,16 +109,6 @@ namespace vcpkg
|
|||||||
|
|
||||||
int current_column() const { return static_cast<int>(current_iter - raw_text.begin()); }
|
int current_column() const { return static_cast<int>(current_iter - raw_text.begin()); }
|
||||||
|
|
||||||
void go_to_begin()
|
|
||||||
{
|
|
||||||
current_iter = raw_text.begin();
|
|
||||||
current_char = (current_iter != raw_text.end() ? *current_iter : current_char);
|
|
||||||
|
|
||||||
if (current_char == ' ' || current_char == '\t')
|
|
||||||
{
|
|
||||||
next_skip_whitespace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void skip_to_end()
|
void skip_to_end()
|
||||||
{
|
{
|
||||||
current_iter = raw_text.end();
|
current_iter = raw_text.end();
|
||||||
@ -126,7 +120,7 @@ namespace vcpkg
|
|||||||
if (current_char != '\0')
|
if (current_char != '\0')
|
||||||
{
|
{
|
||||||
current_iter++;
|
current_iter++;
|
||||||
current_char = (current_iter != raw_text.end() ? *current_iter : '\0');
|
current_char = get_current_char();
|
||||||
}
|
}
|
||||||
return current();
|
return current();
|
||||||
}
|
}
|
||||||
|
@ -307,7 +307,9 @@ namespace vcpkg::Metrics
|
|||||||
|
|
||||||
void Metrics::upload(const std::string& payload)
|
void Metrics::upload(const std::string& payload)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
|
Util::unused(payload);
|
||||||
|
#else
|
||||||
HINTERNET connect = nullptr, request = nullptr;
|
HINTERNET connect = nullptr, request = nullptr;
|
||||||
BOOL results = FALSE;
|
BOOL results = FALSE;
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ namespace vcpkg::Paragraphs
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Expected<RawParagraph> parse_single_paragraph(const std::string& str)
|
static Expected<RawParagraph> parse_single_paragraph(const std::string& str)
|
||||||
{
|
{
|
||||||
const std::vector<RawParagraph> p = Parser(str.c_str(), str.c_str() + str.size()).get_paragraphs();
|
const std::vector<RawParagraph> p = Parser(str.c_str(), str.c_str() + str.size()).get_paragraphs();
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ namespace vcpkg::PostBuildLint
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Span<const OutdatedDynamicCrt> get_outdated_dynamic_crts(const Optional<std::string>& toolset_version)
|
static Span<const OutdatedDynamicCrt> get_outdated_dynamic_crts(const Optional<std::string>& toolset_version)
|
||||||
{
|
{
|
||||||
static const std::vector<OutdatedDynamicCrt> V_NO_120 = {
|
static const std::vector<OutdatedDynamicCrt> V_NO_120 = {
|
||||||
{"msvcp100.dll", R"(msvcp100\.dll)"},
|
{"msvcp100.dll", R"(msvcp100\.dll)"},
|
||||||
@ -462,7 +462,7 @@ namespace vcpkg::PostBuildLint
|
|||||||
return LintStatus::ERROR_DETECTED;
|
return LintStatus::ERROR_DETECTED;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Util::unused(expected_architecture, files);
|
||||||
return LintStatus::SUCCESS;
|
return LintStatus::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,8 +7,9 @@ namespace vcpkg
|
|||||||
{
|
{
|
||||||
StatusParagraphs::StatusParagraphs() = default;
|
StatusParagraphs::StatusParagraphs() = default;
|
||||||
|
|
||||||
StatusParagraphs::StatusParagraphs(std::vector<std::unique_ptr<StatusParagraph>>&& ps)
|
StatusParagraphs::StatusParagraphs(std::vector<std::unique_ptr<StatusParagraph>>&& ps) : paragraphs(std::move(ps))
|
||||||
: paragraphs(std::move(ps)){};
|
{
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::unique_ptr<StatusParagraph>*> StatusParagraphs::find_all(const std::string& name,
|
std::vector<std::unique_ptr<StatusParagraph>*> StatusParagraphs::find_all(const std::string& name,
|
||||||
const Triplet& triplet)
|
const Triplet& triplet)
|
||||||
|
@ -274,6 +274,9 @@ namespace vcpkg
|
|||||||
const auto& program_files_32_bit = System::get_program_files_32_bit();
|
const auto& program_files_32_bit = System::get_program_files_32_bit();
|
||||||
if (const auto pf = program_files_32_bit.get())
|
if (const auto pf = program_files_32_bit.get())
|
||||||
out_candidate_paths.push_back(*pf / "CMake" / "bin" / "cmake.exe");
|
out_candidate_paths.push_back(*pf / "CMake" / "bin" / "cmake.exe");
|
||||||
|
#else
|
||||||
|
// TODO: figure out if this should do anything on non-Windows
|
||||||
|
Util::unused(out_candidate_paths);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
virtual Optional<std::string> get_version(const fs::path& path_to_exe) const override
|
virtual Optional<std::string> get_version(const fs::path& path_to_exe) const override
|
||||||
@ -362,6 +365,9 @@ Type 'NuGet help <command>' for help on a specific command.
|
|||||||
const auto& program_files_32_bit = System::get_program_files_32_bit();
|
const auto& program_files_32_bit = System::get_program_files_32_bit();
|
||||||
if (const auto pf = program_files_32_bit.get())
|
if (const auto pf = program_files_32_bit.get())
|
||||||
out_candidate_paths.push_back(*pf / "git" / "cmd" / "git.exe");
|
out_candidate_paths.push_back(*pf / "git" / "cmd" / "git.exe");
|
||||||
|
#else
|
||||||
|
// TODO: figure out if this should do anything on non-windows
|
||||||
|
Util::unused(out_candidate_paths);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,9 +155,9 @@ namespace vcpkg
|
|||||||
{
|
{
|
||||||
return m_triplets_cache.get_lazy(
|
return m_triplets_cache.get_lazy(
|
||||||
triplet, [&]() -> auto {
|
triplet, [&]() -> auto {
|
||||||
for (auto&& triplet_dir : triplets_dirs)
|
for (const auto& triplet_dir : triplets_dirs)
|
||||||
{
|
{
|
||||||
auto&& path = triplet_dir / (triplet.canonical_name() + ".cmake");
|
auto path = triplet_dir / (triplet.canonical_name() + ".cmake");
|
||||||
if (this->get_filesystem().exists(path))
|
if (this->get_filesystem().exists(path))
|
||||||
{
|
{
|
||||||
return path;
|
return path;
|
||||||
|
@ -11,7 +11,6 @@ namespace vcpkg
|
|||||||
const std::string& VersionT::to_string() const { return value; }
|
const std::string& VersionT::to_string() const { return value; }
|
||||||
bool operator==(const VersionT& left, const VersionT& right) { return left.to_string() == right.to_string(); }
|
bool operator==(const VersionT& left, const VersionT& right) { return left.to_string() == right.to_string(); }
|
||||||
bool operator!=(const VersionT& left, const VersionT& right) { return left.to_string() != right.to_string(); }
|
bool operator!=(const VersionT& left, const VersionT& right) { return left.to_string() != right.to_string(); }
|
||||||
std::string to_printf_arg(const VersionT& version) { return version.to_string(); }
|
|
||||||
|
|
||||||
VersionDiff::VersionDiff() noexcept : left(), right() {}
|
VersionDiff::VersionDiff() noexcept : left(), right() {}
|
||||||
VersionDiff::VersionDiff(const VersionT& left, const VersionT& right) : left(left), right(right) {}
|
VersionDiff::VersionDiff(const VersionT& left, const VersionT& right) : left(left), right(right) {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user