[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:
Nicole Mazzuca 2019-08-09 11:16:35 -07:00 committed by nicole mazzuca
parent 5d1751dfda
commit 300e21d59e
41 changed files with 687 additions and 626 deletions

View File

@ -249,7 +249,7 @@ buildDir="$vcpkgRootDir/toolsrc/build.rel"
rm -rf "$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
rm -rf "$vcpkgRootDir/vcpkg"

View File

@ -2,10 +2,17 @@ cmake_minimum_required(VERSION 3.14)
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(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)
set(DISABLE_METRICS_VALUE "1")
@ -27,33 +34,10 @@ If you would like to try anyway, pass --allowAppleClang to bootstrap.sh.")
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang")
set(CLANG 1)
elseif(MSVC)
add_compile_options(/FC)
else()
elseif(NOT MSVC)
message(FATAL_ERROR "Unknown compiler: ${CMAKE_CXX_COMPILER_ID}")
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)
find_package(Threads REQUIRED)
@ -61,7 +45,7 @@ add_definitions(-DDISABLE_METRICS=${DISABLE_METRICS_VALUE})
include_directories(include)
link_libraries(Threads::Threads)
if(CLANG)
if(CLANG AND NOT MSVC)
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("#include <iostream>
int main() { return __GLIBCXX__; }" USES_LIBSTDCXX)
@ -73,31 +57,70 @@ if(CLANG)
endif()
if(GCC OR (CLANG AND USES_LIBSTDCXX))
target_link_libraries(vcpkg PRIVATE stdc++fs)
link_libraries(stdc++fs)
elseif(CLANG AND NOT MSVC)
target_link_libraries(vcpkg PRIVATE c++fs)
link_libraries(c++fs)
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)
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()
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)
file(GLOB_RECURSE VCPKGTEST_SOURCES src/vcpkg-test/*.cpp)
file(GLOB_RECURSE VCPKGTEST_SOURCES CONFIGURE_DEPENDS src/vcpkg-test/*.cpp)
enable_testing()
add_executable(vcpkg-test
${VCPKGTEST_SOURCES}
$<TARGET_OBJECTS:vcpkglib>)
add_test(NAME default COMMAND vcpkg-test [${TEST_NAME}])
add_test(NAME default COMMAND vcpkg-test)
if (VCPKG_BUILD_BENCHMARKING)
target_compile_options(vcpkg-test PRIVATE -DCATCH_CONFIG_ENABLE_BENCHMARKING)
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()
if(MSVC)

View File

@ -1,4 +1,4 @@
#include <vcpkg-test/catch.h>
#include <catch2/catch.hpp>
#include <vcpkg/pragmas.h>
#include <vcpkg/base/files.h>

View File

@ -56,7 +56,7 @@ namespace vcpkg::Chrono
static Optional<CTime> get_current_date_time();
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} {}
CTime add_hours(const int hours) const;

View File

@ -46,7 +46,7 @@ namespace vcpkg::Graphs
if (!r) return;
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)
{
std::swap(c[i - 1], c[j]);

View File

@ -221,9 +221,8 @@ namespace vcpkg::Util
}
}
template<class T>
void unused(T&& param)
template<class... Ts>
void unused(const Ts&...)
{
(void)param;
}
}

View File

@ -1,4 +1,4 @@
#include <vcpkg-test/catch.h>
#include <catch2/catch.hpp>
#include <vcpkg/vcpkgcmdarguments.h>

View File

@ -1,5 +1,5 @@
#define CATCH_CONFIG_RUNNER
#include <vcpkg-test/catch.h>
#include <catch2/catch.hpp>
#include <vcpkg/base/system.debug.h>

View File

@ -1,4 +1,4 @@
#include <vcpkg-test/catch.h>
#include <catch2/catch.hpp>
#include <vcpkg/base/chrono.h>

View File

@ -1,4 +1,4 @@
#include <vcpkg-test/catch.h>
#include <catch2/catch.hpp>
#include <vcpkg/sourceparagraph.h>

View File

@ -1,4 +1,4 @@
#include <vcpkg-test/catch.h>
#include <catch2/catch.hpp>
#include <vcpkg-test/util.h>
#include <vcpkg/base/files.h>
@ -107,7 +107,7 @@ namespace
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,
fs,

View File

@ -1,4 +1,4 @@
#include <vcpkg-test/catch.h>
#include <catch2/catch.hpp>
#include <vcpkg-test/util.h>
#include <vcpkg/base/strings.h>

View File

@ -1,4 +1,4 @@
#include <vcpkg-test/catch.h>
#include <catch2/catch.hpp>
#include <vcpkg-test/util.h>
#include <vcpkg/dependencies.h>

View File

@ -1,4 +1,4 @@
#include <vcpkg-test/catch.h>
#include <catch2/catch.hpp>
#include <vcpkg/base/util.h>
#include <vcpkg/packagespec.h>
@ -131,4 +131,4 @@ TEST_CASE ("specifier parsing", "[specifier]")
REQUIRE(str == L"abc -x86-windows");
}
#endif
};
}

View File

@ -1,4 +1,4 @@
#include <vcpkg-test/catch.h>
#include <catch2/catch.hpp>
#include <vcpkg-test/util.h>
#include <vcpkg/base/util.h>

View File

@ -1,4 +1,4 @@
#include <vcpkg-test/catch.h>
#include <catch2/catch.hpp>
#include <vcpkg/base/strings.h>

View File

@ -1,4 +1,4 @@
#include <vcpkg-test/catch.h>
#include <catch2/catch.hpp>
#include <vcpkg/sourceparagraph.h>

View File

@ -1,4 +1,4 @@
#include <vcpkg-test/catch.h>
#include <catch2/catch.hpp>
#include <vcpkg-test/util.h>
#include <vcpkg/base/sortedvector.h>

View File

@ -1,8 +1,9 @@
#include <vcpkg-test/catch.h>
#include <catch2/catch.hpp>
#include <vcpkg-test/util.h>
#include <vcpkg/base/checks.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/util.h>
#include <vcpkg/statusparagraph.h>
// 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());
}
#else
static_cast<void>(ec);
Util::unused(target, file, ec);
vcpkg::Checks::exit_with_message(VCPKG_LINE_INFO, no_filesystem_message);
#endif
}
@ -175,7 +176,7 @@ namespace vcpkg::Test
#elif FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_UNIX
::vcpkg::Test::create_symlink(target, file, ec);
#else
static_cast<void>(ec);
Util::unused(target, file, ec);
vcpkg::Checks::exit_with_message(VCPKG_LINE_INFO, no_filesystem_message);
#endif
}

View File

@ -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
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');
Help::print_usage();
@ -285,6 +285,8 @@ static std::string trim_path_from_command_line(const std::string& full_command_l
#endif
#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)
#else
int main(const int argc, const char* const* const argv)

View File

@ -1,5 +1,7 @@
#include "pch.h"
#include <vcpkg/base/hash.h>
#include <vcpkg/base/checks.h>
#include <vcpkg/base/strings.h>
#include <vcpkg/base/system.process.h>

View File

@ -5,6 +5,7 @@
#include <vcpkg/base/system.debug.h>
#include <vcpkg/base/system.h>
#include <vcpkg/base/system.process.h>
#include <vcpkg/base/util.h>
#include <ctime>
@ -381,6 +382,8 @@ namespace vcpkg
"CreateProcessW() returned ", exit_code, " after ", static_cast<int>(timer.microseconds()), " us\n");
return static_cast<int>(exit_code);
#else
// TODO: this should create a clean environment on Linux/macOS
Util::unused(extra_env, prepend_to_path);
Debug::print("system(", cmd_line, ")\n");
fflush(nullptr);
int rc = system(cmd_line.c_str());
@ -549,10 +552,7 @@ namespace vcpkg
return Strings::to_utf8(ret);
}
#else
Optional<std::string> System::get_registry_string(void* base_hkey, StringView sub_key, StringView valuename)
{
return nullopt;
}
Optional<std::string> System::get_registry_string(void*, StringView, StringView) { return nullopt; }
#endif
static const Optional<fs::path>& get_program_files()

View File

@ -1,6 +1,7 @@
#include "pch.h"
#include <vcpkg/base/system.print.h>
#include <vcpkg/base/util.h>
namespace vcpkg::System
{
@ -21,6 +22,9 @@ namespace vcpkg::System
System::print2(message);
SetConsoleTextAttribute(console_handle, original_color);
#else
// TODO: add color handling code
// it should probably use VT-220 codes
Util::unused(c);
System::print2(message);
#endif
}

View File

@ -184,7 +184,7 @@ namespace vcpkg::Build
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 == "Windows") return "";
@ -193,7 +193,7 @@ namespace vcpkg::Build
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);
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;

View File

@ -19,7 +19,7 @@ namespace vcpkg::Commands::Autocomplete
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)
{
return Util::fmap(triplets,

View File

@ -17,6 +17,8 @@ using vcpkg::Dependencies::InstallPlanAction;
using vcpkg::Dependencies::PathsPortFileProvider;
namespace vcpkg::Commands::DependInfo
{
namespace
{
constexpr StringLiteral OPTION_DOT = "--dot";
constexpr StringLiteral OPTION_DGML = "--dgml";
@ -26,24 +28,18 @@ namespace vcpkg::Commands::DependInfo
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_DOT, "Creates graph on basis of dot"},
{OPTION_DGML, "Creates graph on basis of dgml"},
{OPTION_SHOW_DEPTH, "Show recursion depth in output"}}};
constexpr std::array<CommandSetting, 2> DEPEND_SETTINGS = {
{{OPTION_MAX_RECURSE, "Set max recursion depth, a value of -1 indicates no limit"},
{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 "
"(default), "
"reverse"}}};
const CommandStructure COMMAND_STRUCTURE = {
Help::create_example_string("depend-info sqlite3"),
0,
SIZE_MAX,
{DEPEND_SWITCHES, DEPEND_SETTINGS},
nullptr,
};
struct PackageDependInfo
{
std::string package;
@ -182,7 +178,8 @@ namespace vcpkg::Commands::DependInfo
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");
Checks::check_exit(
VCPKG_LINE_INFO, iter != dependencies_map.end(), "Package not found in dependency graph");
PackageDependInfo& info = iter->second;
@ -197,7 +194,7 @@ namespace vcpkg::Commands::DependInfo
}
}
}
};
}
std::vector<PackageDependInfo> extract_depend_info(const std::vector<const InstallPlanAction*>& install_actions,
const int max_depth)
@ -207,8 +204,8 @@ namespace vcpkg::Commands::DependInfo
{
const InstallPlanAction& install_action = *pia;
const std::vector<std::string> dependencies =
Util::fmap(install_action.computed_dependencies, [](const PackageSpec& spec) { return spec.name(); });
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");
@ -227,6 +224,15 @@ namespace vcpkg::Commands::DependInfo
Util::erase_remove_if(out, [](auto&& info) { return info.depth < 0; });
return out;
}
}
const CommandStructure COMMAND_STRUCTURE = {
Help::create_example_string("depend-info sqlite3"),
0,
SIZE_MAX,
{DEPEND_SWITCHES, DEPEND_SETTINGS},
nullptr,
};
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet)
{
@ -276,7 +282,6 @@ namespace vcpkg::Commands::DependInfo
Checks::exit_success(VCPKG_LINE_INFO);
}
// TODO: Improve this code
auto lex = [](const PackageDependInfo& lhs, const PackageDependInfo& rhs) -> bool {
return lhs.package < rhs.package;
@ -284,7 +289,7 @@ namespace vcpkg::Commands::DependInfo
auto topo = [](const PackageDependInfo& lhs, const PackageDependInfo& rhs) -> bool {
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;
};

View File

@ -9,11 +9,11 @@
namespace vcpkg::Commands::Edit
{
#if defined(_WIN32)
static std::vector<fs::path> find_from_registry()
{
std::vector<fs::path> output;
#if defined(_WIN32)
struct RegKey
{
HKEY root;
@ -42,9 +42,9 @@ namespace vcpkg::Commands::Edit
output.push_back(install_path / "Code.exe");
}
}
#endif
return output;
}
#endif
static constexpr StringLiteral OPTION_BUILDTREES = "--buildtrees";

View File

@ -13,7 +13,9 @@ namespace vcpkg::Export::IFW
using Dependencies::ExportPlanType;
using Install::InstallDir;
static std::string create_release_date()
namespace
{
std::string create_release_date()
{
const tm date_time = Chrono::get_current_date_time_local();
@ -37,14 +39,18 @@ namespace vcpkg::Export::IFW
return std::regex_replace(text, standalone_ampersand, "&amp;");
}
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,
const VcpkgPaths& paths)
{
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,
const VcpkgPaths& paths)
{
return ifw_options.maybe_repository_dir_path.has_value()
? fs::path(ifw_options.maybe_repository_dir_path.value_or_exit(VCPKG_LINE_INFO))
@ -58,7 +64,9 @@ namespace vcpkg::Export::IFW
: 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,
const VcpkgPaths& paths)
{
return ifw_options.maybe_installer_file_path.has_value()
? fs::path(ifw_options.maybe_installer_file_path.value_or_exit(VCPKG_LINE_INFO))
@ -111,8 +119,8 @@ namespace vcpkg::Export::IFW
// Return dir path for export package data
return ifw_packages_dir_path /
Strings::format("packages.%s.%s", action.spec.name(), action.spec.triplet().canonical_name()) / "data" /
"installed";
Strings::format("packages.%s.%s", action.spec.name(), action.spec.triplet().canonical_name()) /
"data" / "installed";
}
void export_unique_packages(const fs::path& raw_exported_dir_path,
@ -147,8 +155,8 @@ namespace vcpkg::Export::IFW
const ExportPlanAction& action = *(unique_package.second);
const BinaryParagraph& binary_paragraph = action.core_paragraph().value_or_exit(VCPKG_LINE_INFO);
package_xml_file_path =
raw_exported_dir_path / Strings::format("packages.%s", unique_package.first) / "meta" / "package.xml";
package_xml_file_path = raw_exported_dir_path / Strings::format("packages.%s", unique_package.first) /
"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,
@ -407,7 +415,9 @@ namespace vcpkg::Export::IFW
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());
System::printf(
System::Color::success, "Generating installer %s... done.\n", installer_file.generic_u8string());
}
}
void do_export(const std::vector<ExportPlanAction>& export_plan,

View File

@ -28,6 +28,7 @@ namespace vcpkg::Commands::X_VSInstances
Checks::exit_success(VCPKG_LINE_INFO);
#else
Util::unused(args, paths);
Checks::exit_with_message(VCPKG_LINE_INFO, "This command is not supported on non-windows platforms.");
#endif
}

View File

@ -12,6 +12,8 @@
#include <vcpkg/vcpkgpaths.h>
namespace vcpkg::Dependencies
{
namespace
{
struct ClusterInstalled
{
@ -53,6 +55,7 @@ namespace vcpkg::Dependencies
bool operator==(const ClusterPtr& l, const ClusterPtr& r) { return l.ptr == r.ptr; }
}
}
namespace std
{
@ -122,7 +125,7 @@ namespace vcpkg::Dependencies
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 Build::BuildPackageOptions& options,
const fs::path& install_port_path,

View File

@ -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,
ret.nuget,
{
@ -376,6 +382,9 @@ namespace vcpkg::Export
{OPTION_IFW_CONFIG_FILE_PATH, ret.ifw_options.maybe_config_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;
}

View File

@ -174,7 +174,7 @@ namespace vcpkg::Install
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
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));

View File

@ -54,9 +54,12 @@ namespace vcpkg
{
public:
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();
@ -77,16 +80,17 @@ namespace vcpkg
bool has_error() const { return err == nullptr; }
private:
bool final_result;
std::string::const_iterator current_iter;
const std::string& raw_text;
const std::string& evaluation_context;
std::string::const_iterator current_iter;
char current_char;
const std::string& evaluation_context;
bool final_result;
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)
{
// 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()); }
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()
{
current_iter = raw_text.end();
@ -126,7 +120,7 @@ namespace vcpkg
if (current_char != '\0')
{
current_iter++;
current_char = (current_iter != raw_text.end() ? *current_iter : '\0');
current_char = get_current_char();
}
return current();
}

View File

@ -307,7 +307,9 @@ namespace vcpkg::Metrics
void Metrics::upload(const std::string& payload)
{
#if defined(_WIN32)
#if !defined(_WIN32)
Util::unused(payload);
#else
HINTERNET connect = nullptr, request = nullptr;
BOOL results = FALSE;

View File

@ -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();

View File

@ -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 = {
{"msvcp100.dll", R"(msvcp100\.dll)"},
@ -462,7 +462,7 @@ namespace vcpkg::PostBuildLint
return LintStatus::ERROR_DETECTED;
}
#endif
Util::unused(expected_architecture, files);
return LintStatus::SUCCESS;
}

View File

@ -7,8 +7,9 @@ namespace vcpkg
{
StatusParagraphs::StatusParagraphs() = default;
StatusParagraphs::StatusParagraphs(std::vector<std::unique_ptr<StatusParagraph>>&& ps)
: paragraphs(std::move(ps)){};
StatusParagraphs::StatusParagraphs(std::vector<std::unique_ptr<StatusParagraph>>&& ps) : paragraphs(std::move(ps))
{
}
std::vector<std::unique_ptr<StatusParagraph>*> StatusParagraphs::find_all(const std::string& name,
const Triplet& triplet)

View File

@ -274,6 +274,9 @@ namespace vcpkg
const auto& program_files_32_bit = System::get_program_files_32_bit();
if (const auto pf = program_files_32_bit.get())
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
}
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();
if (const auto pf = program_files_32_bit.get())
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
}

View File

@ -155,9 +155,9 @@ namespace vcpkg
{
return m_triplets_cache.get_lazy(
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))
{
return path;

View File

@ -11,7 +11,6 @@ namespace vcpkg
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(); }
std::string to_printf_arg(const VersionT& version) { return version.to_string(); }
VersionDiff::VersionDiff() noexcept : left(), right() {}
VersionDiff::VersionDiff(const VersionT& left, const VersionT& right) : left(left), right(right) {}