mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-25 11:49:00 +08:00
opt_bool->OptBool
This commit is contained in:
parent
830a4d97d4
commit
1c1423014f
@ -3,24 +3,24 @@
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
namespace vcpkg::opt_bool
|
||||
namespace vcpkg::OptBool
|
||||
{
|
||||
enum class type
|
||||
enum class Type
|
||||
{
|
||||
UNSPECIFIED = 0,
|
||||
ENABLED,
|
||||
DISABLED
|
||||
};
|
||||
|
||||
type parse(const std::string& s);
|
||||
Type parse(const std::string& s);
|
||||
|
||||
template <class T>
|
||||
type from_map(const std::map<T, std::string>& map, const T& key)
|
||||
Type from_map(const std::map<T, std::string>& map, const T& key)
|
||||
{
|
||||
auto it = map.find(key);
|
||||
if (it == map.cend())
|
||||
{
|
||||
return type::UNSPECIFIED;
|
||||
return Type::UNSPECIFIED;
|
||||
}
|
||||
|
||||
return parse(*it);
|
||||
@ -29,5 +29,5 @@ namespace vcpkg::opt_bool
|
||||
|
||||
namespace vcpkg
|
||||
{
|
||||
using opt_bool_t = opt_bool::type;
|
||||
using OptBoolT = OptBool::Type;
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "filesystem_fs.h"
|
||||
#include "PostBuildLint_BuildPolicies.h"
|
||||
#include "opt_bool.h"
|
||||
#include "OptBool.h"
|
||||
#include "PostBuildLint_LinkageType.h"
|
||||
|
||||
namespace vcpkg::PostBuildLint
|
||||
@ -14,7 +14,7 @@ namespace vcpkg::PostBuildLint
|
||||
LinkageType::type crt_linkage;
|
||||
LinkageType::type library_linkage;
|
||||
|
||||
std::map<BuildPolicies::type, opt_bool_t> policies;
|
||||
std::map<BuildPolicies::type, OptBoolT> policies;
|
||||
};
|
||||
|
||||
BuildInfo read_build_info(const fs::path& filepath);
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <unordered_set>
|
||||
#include "opt_bool.h"
|
||||
#include "OptBool.h"
|
||||
|
||||
namespace vcpkg
|
||||
{
|
||||
@ -14,9 +14,9 @@ namespace vcpkg
|
||||
|
||||
std::unique_ptr<std::string> vcpkg_root_dir;
|
||||
std::unique_ptr<std::string> target_triplet;
|
||||
opt_bool_t debug = opt_bool_t::UNSPECIFIED;
|
||||
opt_bool_t sendmetrics = opt_bool_t::UNSPECIFIED;
|
||||
opt_bool_t printmetrics = opt_bool_t::UNSPECIFIED;
|
||||
OptBoolT debug = OptBoolT::UNSPECIFIED;
|
||||
OptBoolT sendmetrics = OptBoolT::UNSPECIFIED;
|
||||
OptBoolT printmetrics = OptBoolT::UNSPECIFIED;
|
||||
|
||||
std::string command;
|
||||
std::vector<std::string> command_arguments;
|
||||
|
@ -1,29 +1,29 @@
|
||||
#include "pch.h"
|
||||
#include "opt_bool.h"
|
||||
#include "OptBool.h"
|
||||
#include "vcpkg_Checks.h"
|
||||
|
||||
namespace vcpkg::opt_bool
|
||||
namespace vcpkg::OptBool
|
||||
{
|
||||
static const std::string UNSPECIFIED_NAME = "unspecified";
|
||||
static const std::string ENABLED_NAME = "enabled";
|
||||
static const std::string DISABLED_NAME = "disabled";
|
||||
type parse(const std::string& s)
|
||||
Type parse(const std::string& s)
|
||||
{
|
||||
if (s == UNSPECIFIED_NAME)
|
||||
{
|
||||
return opt_bool_t::UNSPECIFIED;
|
||||
return OptBoolT::UNSPECIFIED;
|
||||
}
|
||||
|
||||
if (s == ENABLED_NAME)
|
||||
{
|
||||
return opt_bool_t::ENABLED;
|
||||
return OptBoolT::ENABLED;
|
||||
}
|
||||
|
||||
if (s == DISABLED_NAME)
|
||||
{
|
||||
return opt_bool_t::DISABLED;
|
||||
return OptBoolT::DISABLED;
|
||||
}
|
||||
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO, "Could not convert string [%s] to opt_bool", s);
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO, "Could not convert string [%s] to OptBool", s);
|
||||
}
|
||||
}
|
@ -53,10 +53,10 @@ namespace vcpkg::PostBuildLint
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static bool contains_and_enabled(const std::map<T, opt_bool_t> map, const T& key)
|
||||
static bool contains_and_enabled(const std::map<T, OptBoolT> map, const T& key)
|
||||
{
|
||||
auto it = map.find(key);
|
||||
if (it != map.cend() && it->second == opt_bool_t::ENABLED)
|
||||
if (it != map.cend() && it->second == OptBoolT::ENABLED)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -64,7 +64,7 @@ namespace vcpkg::PostBuildLint
|
||||
return false;
|
||||
}
|
||||
|
||||
static lint_status check_for_files_in_include_directory(const std::map<BuildPolicies::type, opt_bool_t>& policies, const fs::path& package_dir)
|
||||
static lint_status check_for_files_in_include_directory(const std::map<BuildPolicies::type, OptBoolT>& policies, const fs::path& package_dir)
|
||||
{
|
||||
if (contains_and_enabled(policies, BuildPolicies::EMPTY_INCLUDE_FOLDER))
|
||||
{
|
||||
@ -423,10 +423,10 @@ namespace vcpkg::PostBuildLint
|
||||
return lint_status::ERROR_DETECTED;
|
||||
}
|
||||
|
||||
static lint_status check_lib_files_are_available_if_dlls_are_available(const std::map<BuildPolicies::type, opt_bool_t>& policies, const size_t lib_count, const size_t dll_count, const fs::path& lib_dir)
|
||||
static lint_status check_lib_files_are_available_if_dlls_are_available(const std::map<BuildPolicies::type, OptBoolT>& policies, const size_t lib_count, const size_t dll_count, const fs::path& lib_dir)
|
||||
{
|
||||
auto it = policies.find(BuildPolicies::DLLS_WITHOUT_LIBS);
|
||||
if (it != policies.cend() && it->second == opt_bool_t::ENABLED)
|
||||
if (it != policies.cend() && it->second == OptBoolT::ENABLED)
|
||||
{
|
||||
return lint_status::SUCCESS;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "pch.h"
|
||||
#include "PostBuildLint_BuildInfo.h"
|
||||
#include "vcpkg_Checks.h"
|
||||
#include "opt_bool.h"
|
||||
#include "OptBool.h"
|
||||
#include "vcpkglib_helpers.h"
|
||||
#include "Paragraphs.h"
|
||||
|
||||
@ -30,7 +30,7 @@ namespace vcpkg::PostBuildLint
|
||||
{
|
||||
const BuildPolicies::type policy = BuildPolicies::parse(p.first);
|
||||
Checks::check_exit(VCPKG_LINE_INFO, policy != BuildPolicies::NULLVALUE, "Unknown policy found: %s", p.first);
|
||||
const opt_bool_t status = opt_bool::parse(p.second);
|
||||
const OptBoolT status = OptBool::parse(p.second);
|
||||
build_info.policies.emplace(policy, status);
|
||||
}
|
||||
|
||||
|
@ -196,14 +196,14 @@ int wmain(const int argc, const wchar_t* const* const argv)
|
||||
|
||||
const vcpkg_cmd_arguments args = vcpkg_cmd_arguments::create_from_command_line(argc, argv);
|
||||
|
||||
if (args.printmetrics != opt_bool_t::UNSPECIFIED)
|
||||
Metrics::set_print_metrics(args.printmetrics == opt_bool_t::ENABLED);
|
||||
if (args.sendmetrics != opt_bool_t::UNSPECIFIED)
|
||||
Metrics::set_send_metrics(args.sendmetrics == opt_bool_t::ENABLED);
|
||||
if (args.printmetrics != OptBoolT::UNSPECIFIED)
|
||||
Metrics::set_print_metrics(args.printmetrics == OptBoolT::ENABLED);
|
||||
if (args.sendmetrics != OptBoolT::UNSPECIFIED)
|
||||
Metrics::set_send_metrics(args.sendmetrics == OptBoolT::ENABLED);
|
||||
|
||||
if (args.debug != opt_bool_t::UNSPECIFIED)
|
||||
if (args.debug != OptBoolT::UNSPECIFIED)
|
||||
{
|
||||
g_debugging = (args.debug == opt_bool_t::ENABLED);
|
||||
g_debugging = (args.debug == OptBoolT::ENABLED);
|
||||
}
|
||||
|
||||
if (g_debugging)
|
||||
|
@ -32,11 +32,11 @@ namespace vcpkg
|
||||
}
|
||||
|
||||
static void parse_switch(
|
||||
opt_bool_t new_setting,
|
||||
OptBoolT new_setting,
|
||||
const std::string& option_name,
|
||||
opt_bool_t& option_field)
|
||||
OptBoolT& option_field)
|
||||
{
|
||||
if (option_field != opt_bool_t::UNSPECIFIED && option_field != new_setting)
|
||||
if (option_field != OptBoolT::UNSPECIFIED && option_field != new_setting)
|
||||
{
|
||||
System::println(System::color::error, "Error: conflicting values specified for --%s", option_name);
|
||||
Metrics::track_property("error", "error conflicting switches");
|
||||
@ -93,27 +93,27 @@ namespace vcpkg
|
||||
}
|
||||
if (arg == "--debug")
|
||||
{
|
||||
parse_switch(opt_bool_t::ENABLED, "debug", args.debug);
|
||||
parse_switch(OptBoolT::ENABLED, "debug", args.debug);
|
||||
continue;
|
||||
}
|
||||
if (arg == "--sendmetrics")
|
||||
{
|
||||
parse_switch(opt_bool_t::ENABLED, "sendmetrics", args.sendmetrics);
|
||||
parse_switch(OptBoolT::ENABLED, "sendmetrics", args.sendmetrics);
|
||||
continue;
|
||||
}
|
||||
if (arg == "--printmetrics")
|
||||
{
|
||||
parse_switch(opt_bool_t::ENABLED, "printmetrics", args.printmetrics);
|
||||
parse_switch(OptBoolT::ENABLED, "printmetrics", args.printmetrics);
|
||||
continue;
|
||||
}
|
||||
if (arg == "--no-sendmetrics")
|
||||
{
|
||||
parse_switch(opt_bool_t::DISABLED, "sendmetrics", args.sendmetrics);
|
||||
parse_switch(OptBoolT::DISABLED, "sendmetrics", args.sendmetrics);
|
||||
continue;
|
||||
}
|
||||
if (arg == "--no-printmetrics")
|
||||
{
|
||||
parse_switch(opt_bool_t::DISABLED, "printmetrics", args.printmetrics);
|
||||
parse_switch(OptBoolT::DISABLED, "printmetrics", args.printmetrics);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@
|
||||
<ClInclude Include="..\include\SortedVector.h" />
|
||||
<ClInclude Include="..\include\MachineType.h" />
|
||||
<ClInclude Include="..\include\metrics.h" />
|
||||
<ClInclude Include="..\include\opt_bool.h" />
|
||||
<ClInclude Include="..\include\OptBool.h" />
|
||||
<ClInclude Include="..\include\package_spec.h" />
|
||||
<ClInclude Include="..\include\package_spec_parse_result.h" />
|
||||
<ClInclude Include="..\include\Paragraphs.h" />
|
||||
@ -212,7 +212,7 @@
|
||||
<ClCompile Include="..\src\commands_version.cpp" />
|
||||
<ClCompile Include="..\src\MachineType.cpp" />
|
||||
<ClCompile Include="..\src\metrics.cpp" />
|
||||
<ClCompile Include="..\src\opt_bool.cpp" />
|
||||
<ClCompile Include="..\src\OptBool.cpp" />
|
||||
<ClCompile Include="..\src\pch.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
|
@ -138,9 +138,6 @@
|
||||
<ClCompile Include="..\src\pch.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\opt_bool.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\PostBuildLint.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -180,6 +177,9 @@
|
||||
<ClCompile Include="..\src\commands_env.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\OptBool.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\include\package_spec.h">
|
||||
@ -239,9 +239,6 @@
|
||||
<ClInclude Include="..\include\vcpkglib.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\opt_bool.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\vcpkg_Checks.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
@ -314,5 +311,8 @@
|
||||
<ClInclude Include="..\include\CStringView.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\OptBool.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user