diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2017-03-13 17:38:04 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2017-03-13 17:56:21 -0700 |
| commit | 4114d87a0774fff7d8bc5e041bb56158bfdbcac8 (patch) | |
| tree | 5afcf15a4de03e9294e5fe3b301cdc902b01ddd6 | |
| parent | 98ea6780e7a4af7d237783a72a2a56a6188ae3da (diff) | |
| download | vcpkg-4114d87a0774fff7d8bc5e041bb56158bfdbcac8.tar.gz vcpkg-4114d87a0774fff7d8bc5e041bb56158bfdbcac8.zip | |
All Checks now take LineInfo as the first argument
33 files changed, 122 insertions, 112 deletions
diff --git a/toolsrc/include/expected.h b/toolsrc/include/expected.h index cbb513b22..377168645 100644 --- a/toolsrc/include/expected.h +++ b/toolsrc/include/expected.h @@ -40,15 +40,15 @@ namespace vcpkg return this->m_error_code; } - T&& get_or_throw() && + T&& get_or_throw(const LineInfo& line_info) && { - throw_if_error(); + throw_if_error(line_info); return std::move(this->m_t); } - const T& get_or_throw() const & + const T& get_or_throw(const LineInfo& line_info) const & { - throw_if_error(); + throw_if_error(line_info); return this->m_t; } @@ -71,9 +71,9 @@ namespace vcpkg } private: - void throw_if_error() const + void throw_if_error(const LineInfo& line_info) const { - Checks::check_throw(!this->m_error_code, this->m_error_code.message().c_str()); + Checks::check_throw(line_info, !this->m_error_code, this->m_error_code.message().c_str()); } std::error_code m_error_code; diff --git a/toolsrc/include/vcpkg_Checks.h b/toolsrc/include/vcpkg_Checks.h index 76c86cfab..47662637f 100644 --- a/toolsrc/include/vcpkg_Checks.h +++ b/toolsrc/include/vcpkg_Checks.h @@ -8,45 +8,45 @@ namespace vcpkg::Checks __declspec(noreturn) void unreachable(const LineInfo& line_info); // Part of the reason these exist is to not include extra headers in this one to avoid circular #includes. - _declspec(noreturn) void exit_with_message(const char* errorMessage); + _declspec(noreturn) void exit_with_message(const LineInfo& line_info, const char* errorMessage); template <class...Args> - _declspec(noreturn) void exit_with_message(const char* errorMessageTemplate, const Args&... errorMessageArgs) + _declspec(noreturn) void exit_with_message(const LineInfo& line_info, const char* errorMessageTemplate, const Args&... errorMessageArgs) { - exit_with_message(Strings::format(errorMessageTemplate, errorMessageArgs...).c_str()); + exit_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArgs...).c_str()); } - _declspec(noreturn) void throw_with_message(const char* errorMessage); + _declspec(noreturn) void throw_with_message(const LineInfo& line_info, const char* errorMessage); template <class...Args> - _declspec(noreturn) void throw_with_message(const char* errorMessageTemplate, const Args&... errorMessageArgs) + _declspec(noreturn) void throw_with_message(const LineInfo& line_info, const char* errorMessageTemplate, const Args&... errorMessageArgs) { - throw_with_message(Strings::format(errorMessageTemplate, errorMessageArgs...).c_str()); + throw_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArgs...).c_str()); } - void check_throw(bool expression, const char* errorMessage); + void check_throw(const LineInfo& line_info, bool expression, const char* errorMessage); template <class...Args> - void check_throw(bool expression, const char* errorMessageTemplate, const Args&... errorMessageArgs) + void check_throw(const LineInfo& line_info, bool expression, const char* errorMessageTemplate, const Args&... errorMessageArgs) { if (!expression) { // Only create the string if the expression is false - throw_with_message(Strings::format(errorMessageTemplate, errorMessageArgs...).c_str()); + throw_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArgs...).c_str()); } } - void check_exit(bool expression); + void check_exit(const LineInfo& line_info, bool expression); - void check_exit(bool expression, const char* errorMessage); + void check_exit(const LineInfo& line_info, bool expression, const char* errorMessage); template <class...Args> - void check_exit(bool expression, const char* errorMessageTemplate, const Args&... errorMessageArgs) + void check_exit(const LineInfo& line_info, bool expression, const char* errorMessageTemplate, const Args&... errorMessageArgs) { if (!expression) { // Only create the string if the expression is false - exit_with_message(Strings::format(errorMessageTemplate, errorMessageArgs...).c_str()); + exit_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArgs...).c_str()); } } } diff --git a/toolsrc/include/vcpkg_Files.h b/toolsrc/include/vcpkg_Files.h index 3f9570946..0b0373231 100644 --- a/toolsrc/include/vcpkg_Files.h +++ b/toolsrc/include/vcpkg_Files.h @@ -8,7 +8,7 @@ namespace vcpkg::Files { static const char* FILESYSTEM_INVALID_CHARACTERS = R"(\/:*?"<>|)"; - void check_is_directory(const fs::path& dirpath); + void check_is_directory(const LineInfo& line_info, const fs::path& dirpath); bool has_invalid_chars_for_filesystem(const std::string& s); diff --git a/toolsrc/src/BinaryParagraph.cpp b/toolsrc/src/BinaryParagraph.cpp index 8605cd276..be3931ba9 100644 --- a/toolsrc/src/BinaryParagraph.cpp +++ b/toolsrc/src/BinaryParagraph.cpp @@ -31,14 +31,14 @@ namespace vcpkg const std::string architecture = details::remove_required_field(&fields, BinaryParagraphRequiredField::ARCHITECTURE); const triplet target_triplet = triplet::from_canonical_name(architecture); - this->spec = package_spec::from_name_and_triplet(name, target_triplet).get_or_throw(); + this->spec = package_spec::from_name_and_triplet(name, target_triplet).get_or_throw(VCPKG_LINE_INFO); this->version = details::remove_required_field(&fields, BinaryParagraphRequiredField::VERSION); this->description = details::remove_optional_field(&fields, BinaryParagraphOptionalField::DESCRIPTION); this->maintainer = details::remove_optional_field(&fields, BinaryParagraphOptionalField::MAINTAINER); std::string multi_arch = details::remove_required_field(&fields, BinaryParagraphRequiredField::MULTI_ARCH); - Checks::check_exit(multi_arch == "same", "Multi-Arch must be 'same' but was %s", multi_arch); + Checks::check_exit(VCPKG_LINE_INFO, multi_arch == "same", "Multi-Arch must be 'same' but was %s", multi_arch); std::string deps = details::remove_optional_field(&fields, BinaryParagraphOptionalField::DEPENDS); this->depends = parse_depends(deps); @@ -46,7 +46,7 @@ namespace vcpkg BinaryParagraph::BinaryParagraph(const SourceParagraph& spgh, const triplet& target_triplet) { - this->spec = package_spec::from_name_and_triplet(spgh.name, target_triplet).get_or_throw(); + this->spec = package_spec::from_name_and_triplet(spgh.name, target_triplet).get_or_throw(VCPKG_LINE_INFO); this->version = spgh.version; this->description = spgh.description; this->maintainer = spgh.maintainer; diff --git a/toolsrc/src/MachineType.cpp b/toolsrc/src/MachineType.cpp index 81012234d..97d0a0280 100644 --- a/toolsrc/src/MachineType.cpp +++ b/toolsrc/src/MachineType.cpp @@ -36,7 +36,7 @@ namespace vcpkg case MachineType::WCEMIPSV2: return t; default: - Checks::exit_with_message("Unknown machine type code 0x%x", value); + Checks::exit_with_message(VCPKG_LINE_INFO, "Unknown machine type code 0x%x", value); } } } diff --git a/toolsrc/src/Paragraphs.cpp b/toolsrc/src/Paragraphs.cpp index cb90ed1ec..f1505698c 100644 --- a/toolsrc/src/Paragraphs.cpp +++ b/toolsrc/src/Paragraphs.cpp @@ -99,7 +99,7 @@ namespace vcpkg::Paragraphs auto begin_fieldname = cur; while (is_alphanum(ch) || ch == '-') next(ch); - Checks::check_exit(ch == ':', "Expected ':'"); + Checks::check_exit(VCPKG_LINE_INFO, ch == ':', "Expected ':'"); fieldname = std::string(begin_fieldname, cur); // skip ': ' @@ -117,7 +117,7 @@ namespace vcpkg::Paragraphs get_fieldname(ch, fieldname); auto it = fields.find(fieldname); - Checks::check_exit(it == fields.end(), "Duplicate field"); + Checks::check_exit(VCPKG_LINE_INFO, it == fields.end(), "Duplicate field"); get_fieldvalue(ch, fieldvalue); @@ -158,7 +158,7 @@ namespace vcpkg::Paragraphs return parse_paragraphs(*spgh); } - Checks::exit_with_message("Error while reading %s: %s", control_path.generic_string(), contents.error_code().message()); + Checks::exit_with_message(VCPKG_LINE_INFO, "Error while reading %s: %s", control_path.generic_string(), contents.error_code().message()); } std::vector<std::unordered_map<std::string, std::string>> parse_paragraphs(const std::string& str) @@ -171,7 +171,7 @@ namespace vcpkg::Paragraphs try { auto pghs = get_paragraphs(path / "CONTROL"); - Checks::check_exit(pghs.size() == 1, "Invalid control file at %s\\CONTROL", path.string()); + Checks::check_exit(VCPKG_LINE_INFO, pghs.size() == 1, "Invalid control file at %s\\CONTROL", path.string()); return SourceParagraph(pghs[0]); } catch (std::runtime_error const&) {} @@ -192,7 +192,7 @@ namespace vcpkg::Paragraphs pghs = parse_paragraphs(*control_contents); } catch (std::runtime_error) {} - Checks::check_exit(pghs.size() == 1, "Invalid control file at %s", path.string()); + Checks::check_exit(VCPKG_LINE_INFO, pghs.size() == 1, "Invalid control file at %s", path.string()); return BinaryParagraph(pghs[0]); } return control_contents_maybe.error_code(); diff --git a/toolsrc/src/PostBuildLint.cpp b/toolsrc/src/PostBuildLint.cpp index 3df237b2d..468236b54 100644 --- a/toolsrc/src/PostBuildLint.cpp +++ b/toolsrc/src/PostBuildLint.cpp @@ -227,7 +227,7 @@ namespace vcpkg::PostBuildLint { const std::wstring cmd_line = Strings::wformat(LR"("%s" /exports "%s")", dumpbin_exe.native(), dll.native()); System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(cmd_line); - Checks::check_exit(ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line)); + Checks::check_exit(VCPKG_LINE_INFO, ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line)); if (ec_data.output.find("ordinal hint RVA name") == std::string::npos) { @@ -258,7 +258,7 @@ namespace vcpkg::PostBuildLint { const std::wstring cmd_line = Strings::wformat(LR"("%s" /headers "%s")", dumpbin_exe.native(), dll.native()); System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(cmd_line); - Checks::check_exit(ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line)); + Checks::check_exit(VCPKG_LINE_INFO, ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line)); if (ec_data.output.find("App Container") == std::string::npos) { @@ -318,7 +318,7 @@ namespace vcpkg::PostBuildLint for (const fs::path& file : files) { - Checks::check_exit(file.extension() == ".dll", "The file extension was not .dll: %s", file.generic_string()); + Checks::check_exit(VCPKG_LINE_INFO, file.extension() == ".dll", "The file extension was not .dll: %s", file.generic_string()); COFFFileReader::dll_info info = COFFFileReader::read_dll(file); const std::string actual_architecture = get_actual_architecture(info.machine_type); @@ -343,9 +343,9 @@ namespace vcpkg::PostBuildLint for (const fs::path& file : files) { - Checks::check_exit(file.extension() == ".lib", "The file extension was not .lib: %s", file.generic_string()); + Checks::check_exit(VCPKG_LINE_INFO, file.extension() == ".lib", "The file extension was not .lib: %s", file.generic_string()); COFFFileReader::lib_info info = COFFFileReader::read_lib(file); - Checks::check_exit(info.machine_types.size() == 1, "Found more than 1 architecture in file %s", file.generic_string()); + Checks::check_exit(VCPKG_LINE_INFO, info.machine_types.size() == 1, "Found more than 1 architecture in file %s", file.generic_string()); const std::string actual_architecture = get_actual_architecture(info.machine_types.at(0)); if (expected_architecture != actual_architecture) @@ -496,7 +496,7 @@ namespace vcpkg::PostBuildLint { const std::wstring cmd_line = Strings::wformat(LR"("%s" /directives "%s")", dumpbin_exe.native(), lib.native()); System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(cmd_line); - Checks::check_exit(ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line)); + Checks::check_exit(VCPKG_LINE_INFO, ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line)); for (const BuildType::type& bad_build_type : bad_build_types) { @@ -543,7 +543,7 @@ namespace vcpkg::PostBuildLint { const std::wstring cmd_line = Strings::wformat(LR"("%s" /dependents "%s")", dumpbin_exe.native(), dll.native()); System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(cmd_line); - Checks::check_exit(ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line)); + Checks::check_exit(VCPKG_LINE_INFO, ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line)); for (const OutdatedDynamicCrt& outdated_crt : outdated_crts) { diff --git a/toolsrc/src/PostBuildLint_BuildInfo.cpp b/toolsrc/src/PostBuildLint_BuildInfo.cpp index 0d1d480b8..5b475322a 100644 --- a/toolsrc/src/PostBuildLint_BuildInfo.cpp +++ b/toolsrc/src/PostBuildLint_BuildInfo.cpp @@ -19,17 +19,17 @@ namespace vcpkg::PostBuildLint BuildInfo build_info; const std::string crt_linkage_as_string = details::remove_required_field(&pgh, BuildInfoRequiredField::CRT_LINKAGE); build_info.crt_linkage = LinkageType::value_of(crt_linkage_as_string); - Checks::check_exit(build_info.crt_linkage != LinkageType::NULLVALUE, "Invalid crt linkage type: [%s]", crt_linkage_as_string); + Checks::check_exit(VCPKG_LINE_INFO, build_info.crt_linkage != LinkageType::NULLVALUE, "Invalid crt linkage type: [%s]", crt_linkage_as_string); const std::string library_linkage_as_string = details::remove_required_field(&pgh, BuildInfoRequiredField::LIBRARY_LINKAGE); build_info.library_linkage = LinkageType::value_of(library_linkage_as_string); - Checks::check_exit(build_info.library_linkage != LinkageType::NULLVALUE, "Invalid library linkage type: [%s]", library_linkage_as_string); + Checks::check_exit(VCPKG_LINE_INFO, build_info.library_linkage != LinkageType::NULLVALUE, "Invalid library linkage type: [%s]", library_linkage_as_string); // The remaining entries are policies for (const std::unordered_map<std::string, std::string>::value_type& p : pgh) { const BuildPolicies::type policy = BuildPolicies::parse(p.first); - Checks::check_exit(policy != BuildPolicies::NULLVALUE, "Unknown policy found: %s", 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); build_info.policies.emplace(policy, status); } @@ -40,7 +40,7 @@ namespace vcpkg::PostBuildLint BuildInfo read_build_info(const fs::path& filepath) { const std::vector<std::unordered_map<std::string, std::string>> pghs = Paragraphs::get_paragraphs(filepath); - Checks::check_exit(pghs.size() == 1, "Invalid BUILD_INFO file for package"); + Checks::check_exit(VCPKG_LINE_INFO, pghs.size() == 1, "Invalid BUILD_INFO file for package"); return BuildInfo::create(pghs[0]); } diff --git a/toolsrc/src/StatusParagraphs.cpp b/toolsrc/src/StatusParagraphs.cpp index 9a440fbb8..cd932fd72 100644 --- a/toolsrc/src/StatusParagraphs.cpp +++ b/toolsrc/src/StatusParagraphs.cpp @@ -42,7 +42,7 @@ namespace vcpkg StatusParagraphs::iterator StatusParagraphs::insert(std::unique_ptr<StatusParagraph> pgh) { - Checks::check_exit(pgh != nullptr, "Inserted null paragraph"); + Checks::check_exit(VCPKG_LINE_INFO, pgh != nullptr, "Inserted null paragraph"); const package_spec& spec = pgh->package.spec; auto ptr = find(spec.name(), spec.target_triplet()); if (ptr == end()) diff --git a/toolsrc/src/coff_file_reader.cpp b/toolsrc/src/coff_file_reader.cpp index f48f912c1..922d8c420 100644 --- a/toolsrc/src/coff_file_reader.cpp +++ b/toolsrc/src/coff_file_reader.cpp @@ -30,9 +30,9 @@ namespace vcpkg::COFFFileReader return data; } - static void verify_equal_strings(const char* expected, const char* actual, int size, const char* label) + static void verify_equal_strings(const LineInfo& line_info, const char* expected, const char* actual, int size, const char* label) { - Checks::check_exit(memcmp(expected, actual, size) == 0, "Incorrect string (%s) found. Expected: (%s) but found (%s)", label, expected, actual); + Checks::check_exit(line_info, memcmp(expected, actual, size) == 0, "Incorrect string (%s) found. Expected: (%s) but found (%s)", label, expected, actual); } static void read_and_verify_PE_signature(fstream& fs) @@ -48,7 +48,7 @@ namespace vcpkg::COFFFileReader fs.seekg(offset_to_PE_signature); char signature[PE_SIGNATURE_SIZE]; fs.read(signature, PE_SIGNATURE_SIZE); - verify_equal_strings(PE_SIGNATURE, signature, PE_SIGNATURE_SIZE, "PE_SIGNATURE"); + verify_equal_strings(VCPKG_LINE_INFO, PE_SIGNATURE, signature, PE_SIGNATURE_SIZE, "PE_SIGNATURE"); fs.seekg(offset_to_PE_signature + PE_SIGNATURE_SIZE, ios_base::beg); } @@ -104,7 +104,7 @@ namespace vcpkg::COFFFileReader if (ret.data[0] != '\0') // Due to freeglut. github issue #223 { const std::string header_end = ret.data.substr(HEADER_END_OFFSET, HEADER_END_SIZE); - verify_equal_strings(HEADER_END, header_end.c_str(), HEADER_END_SIZE, "LIB HEADER_END"); + verify_equal_strings(VCPKG_LINE_INFO, HEADER_END, header_end.c_str(), HEADER_END_SIZE, "LIB HEADER_END"); } return ret; @@ -186,11 +186,11 @@ namespace vcpkg::COFFFileReader const std::string sig1_as_string = ret.data.substr(SIG1_OFFSET, SIG1_SIZE); const uint16_t sig1 = reinterpret_bytes<uint16_t>(sig1_as_string.c_str()); - Checks::check_exit(sig1 == SIG1, "Sig1 was incorrect. Expected %s but got %s", SIG1, sig1); + Checks::check_exit(VCPKG_LINE_INFO, sig1 == SIG1, "Sig1 was incorrect. Expected %s but got %s", SIG1, sig1); const std::string sig2_as_string = ret.data.substr(SIG2_OFFSET, SIG2_SIZE); const uint16_t sig2 = reinterpret_bytes<uint16_t>(sig2_as_string.c_str()); - Checks::check_exit(sig2 == SIG2, "Sig2 was incorrect. Expected %s but got %s", SIG2, sig2); + Checks::check_exit(VCPKG_LINE_INFO, sig2 == SIG2, "Sig2 was incorrect. Expected %s but got %s", SIG2, sig2); return ret; } @@ -218,13 +218,13 @@ namespace vcpkg::COFFFileReader char file_start[FILE_START_SIZE]; fs.read(file_start, FILE_START_SIZE); - verify_equal_strings(FILE_START, file_start, FILE_START_SIZE, "LIB FILE_START"); + verify_equal_strings(VCPKG_LINE_INFO, FILE_START, file_start, FILE_START_SIZE, "LIB FILE_START"); } dll_info read_dll(const fs::path& path) { std::fstream fs(path, std::ios::in | std::ios::binary | std::ios::ate); - Checks::check_exit(fs.is_open(), "Could not open file %s for reading", path.generic_string()); + Checks::check_exit(VCPKG_LINE_INFO, fs.is_open(), "Could not open file %s for reading", path.generic_string()); read_and_verify_PE_signature(fs); coff_file_header header = coff_file_header::read(fs); @@ -261,7 +261,7 @@ namespace vcpkg::COFFFileReader lib_info read_lib(const fs::path& path) { std::fstream fs(path, std::ios::in | std::ios::binary | std::ios::ate); - Checks::check_exit(fs.is_open(), "Could not open file %s for reading", path.generic_string()); + Checks::check_exit(VCPKG_LINE_INFO, fs.is_open(), "Could not open file %s for reading", path.generic_string()); read_and_verify_archive_file_signature(fs); @@ -270,12 +270,12 @@ namespace vcpkg::COFFFileReader // First Linker Member const archive_member_header first_linker_member_header = archive_member_header::read(fs); - Checks::check_exit(first_linker_member_header.name().substr(0, 2) == "/ ", "Could not find proper first linker member"); + Checks::check_exit(VCPKG_LINE_INFO, first_linker_member_header.name().substr(0, 2) == "/ ", "Could not find proper first linker member"); marker.advance_by(archive_member_header::HEADER_SIZE + first_linker_member_header.member_size()); marker.seek_to_marker(fs); const archive_member_header second_linker_member_header = archive_member_header::read(fs); - Checks::check_exit(second_linker_member_header.name().substr(0, 2) == "/ ", "Could not find proper second linker member"); + Checks::check_exit(VCPKG_LINE_INFO, second_linker_member_header.name().substr(0, 2) == "/ ", "Could not find proper second linker member"); // The first 4 bytes contains the number of archive members const uint32_t archive_member_count = read_value_from_stream<uint32_t>(fs); const offsets_array offsets = offsets_array::read(fs, archive_member_count); diff --git a/toolsrc/src/commands_build.cpp b/toolsrc/src/commands_build.cpp index ac2a9c53d..1a634c8db 100644 --- a/toolsrc/src/commands_build.cpp +++ b/toolsrc/src/commands_build.cpp @@ -28,7 +28,7 @@ namespace vcpkg::Commands::Build BuildResult build_package(const SourceParagraph& source_paragraph, const package_spec& spec, const vcpkg_paths& paths, const fs::path& port_dir, const StatusParagraphs& status_db) { - Checks::check_exit(spec.name() == source_paragraph.name, "inconsistent arguments to build_package()"); + Checks::check_exit(VCPKG_LINE_INFO, spec.name() == source_paragraph.name, "inconsistent arguments to build_package()"); const triplet& target_triplet = spec.target_triplet(); for (auto&& dep : source_paragraph.depends) @@ -134,7 +134,7 @@ namespace vcpkg::Commands::Build } const expected<SourceParagraph> maybe_spgh = Paragraphs::try_load_port(port_dir); - Checks::check_exit(!maybe_spgh.error_code(), "Could not find package named %s: %s", spec, maybe_spgh.error_code().message()); + Checks::check_exit(VCPKG_LINE_INFO, !maybe_spgh.error_code(), "Could not find package named %s: %s", spec, maybe_spgh.error_code().message()); const SourceParagraph& spgh = *maybe_spgh.get(); StatusParagraphs status_db = database_load_check(paths); @@ -149,7 +149,7 @@ namespace vcpkg::Commands::Build }), unmet_dependencies.end()); - Checks::check_exit(!unmet_dependencies.empty()); + Checks::check_exit(VCPKG_LINE_INFO, !unmet_dependencies.empty()); System::println(System::color::error, "The build command requires all dependencies to be already installed."); System::println("The following dependencies are missing:"); System::println(""); diff --git a/toolsrc/src/commands_ci.cpp b/toolsrc/src/commands_ci.cpp index f5df41ace..45ef2db28 100644 --- a/toolsrc/src/commands_ci.cpp +++ b/toolsrc/src/commands_ci.cpp @@ -20,7 +20,7 @@ namespace vcpkg::Commands::CI std::vector<package_spec> specs; for (const SourceParagraph& p : ports) { - specs.push_back(package_spec::from_name_and_triplet(p.name, target_triplet).get_or_throw()); + specs.push_back(package_spec::from_name_and_triplet(p.name, target_triplet).get_or_throw(VCPKG_LINE_INFO)); } return specs; @@ -37,7 +37,7 @@ namespace vcpkg::Commands::CI StatusParagraphs status_db = database_load_check(paths); const std::vector<package_spec_with_install_plan> install_plan = Dependencies::create_install_plan(paths, specs, status_db); - Checks::check_exit(!install_plan.empty(), "Install plan cannot be empty"); + Checks::check_exit(VCPKG_LINE_INFO, !install_plan.empty(), "Install plan cannot be empty"); std::vector<BuildResult> results; std::vector<std::chrono::milliseconds::rep> timing; @@ -70,7 +70,7 @@ namespace vcpkg::Commands::CI System::println(System::color::error, Build::create_error_message(result, action.spec)); continue; } - const BinaryParagraph bpgh = Paragraphs::try_load_cached_package(paths, action.spec).get_or_throw(); + const BinaryParagraph bpgh = Paragraphs::try_load_cached_package(paths, action.spec).get_or_throw(VCPKG_LINE_INFO); Install::install_package(paths, bpgh, &status_db); System::println(System::color::success, "Package %s is installed", action.spec); } diff --git a/toolsrc/src/commands_create.cpp b/toolsrc/src/commands_create.cpp index b74693ed5..2c3e02877 100644 --- a/toolsrc/src/commands_create.cpp +++ b/toolsrc/src/commands_create.cpp @@ -29,9 +29,9 @@ namespace vcpkg::Commands::Create if (args.command_arguments.size() >= 3) { const std::string& zip_file_name = args.command_arguments.at(2); - Checks::check_exit(!Files::has_invalid_chars_for_filesystem(zip_file_name), - R"(Filename cannot contain invalid chars %s, but was %s)", - Files::FILESYSTEM_INVALID_CHARACTERS, zip_file_name); + Checks::check_exit(VCPKG_LINE_INFO, !Files::has_invalid_chars_for_filesystem(zip_file_name), + R"(Filename cannot contain invalid chars %s, but was %s)", + Files::FILESYSTEM_INVALID_CHARACTERS, zip_file_name); cmake_args.push_back({ L"FILENAME", zip_file_name }); } diff --git a/toolsrc/src/commands_edit.cpp b/toolsrc/src/commands_edit.cpp index ce0557e09..bc1f6715d 100644 --- a/toolsrc/src/commands_edit.cpp +++ b/toolsrc/src/commands_edit.cpp @@ -14,7 +14,7 @@ namespace vcpkg::Commands::Edit const std::string port_name = args.command_arguments.at(0); const fs::path portpath = paths.ports / port_name; - Checks::check_exit(fs::is_directory(portpath), R"(Could not find port named "%s")", port_name); + Checks::check_exit(VCPKG_LINE_INFO, fs::is_directory(portpath), R"(Could not find port named "%s")", port_name); // Find the user's selected editor std::wstring env_EDITOR; @@ -62,7 +62,7 @@ namespace vcpkg::Commands::Edit if (env_EDITOR.empty()) { - Checks::exit_with_message("Visual Studio Code was not found and the environment variable EDITOR is not set"); + Checks::exit_with_message(VCPKG_LINE_INFO, "Visual Studio Code was not found and the environment variable EDITOR is not set"); } std::wstring cmdLine = Strings::wformat(LR"("%s" "%s" "%s" -n)", env_EDITOR, portpath.native(), (portpath / "portfile.cmake").native()); diff --git a/toolsrc/src/commands_hash.cpp b/toolsrc/src/commands_hash.cpp index 805da4153..2e55a4bb6 100644 --- a/toolsrc/src/commands_hash.cpp +++ b/toolsrc/src/commands_hash.cpp @@ -9,15 +9,15 @@ namespace vcpkg::Commands::Hash auto cmd_line = Strings::wformat(LR"(CertUtil.exe -hashfile "%s" %s)", path.c_str(), hashType.c_str()); auto ec_data = System::cmd_execute_and_capture_output(cmd_line); - Checks::check_exit(ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line)); + Checks::check_exit(VCPKG_LINE_INFO, ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line)); std::string const& output = ec_data.output; auto start = output.find_first_of("\r\n"); - Checks::check_exit(start != std::string::npos, "Unexpected output format from command: %s", Strings::utf16_to_utf8(cmd_line)); + Checks::check_exit(VCPKG_LINE_INFO, start != std::string::npos, "Unexpected output format from command: %s", Strings::utf16_to_utf8(cmd_line)); auto end = output.find_first_of("\r\n", start + 1); - Checks::check_exit(end != std::string::npos, "Unexpected output format from command: %s", Strings::utf16_to_utf8(cmd_line)); + Checks::check_exit(VCPKG_LINE_INFO, end != std::string::npos, "Unexpected output format from command: %s", Strings::utf16_to_utf8(cmd_line)); auto hash = output.substr(start, end - start); hash.erase(std::remove_if(hash.begin(), hash.end(), isspace), hash.end()); diff --git a/toolsrc/src/commands_import.cpp b/toolsrc/src/commands_import.cpp index 11924b4b2..a74b9e662 100644 --- a/toolsrc/src/commands_import.cpp +++ b/toolsrc/src/commands_import.cpp @@ -14,7 +14,7 @@ namespace vcpkg::Commands::Import static Binaries find_binaries_in_dir(const fs::path& path) { - Files::check_is_directory(path); + Files::check_is_directory(VCPKG_LINE_INFO, path); Binaries binaries; binaries.dlls = Files::recursive_find_files_with_extension_in_dir(path, ".dll"); @@ -35,9 +35,9 @@ namespace vcpkg::Commands::Import static void place_library_files_in(const fs::path& include_directory, const fs::path& project_directory, const fs::path& destination_path) { - Files::check_is_directory(include_directory); - Files::check_is_directory(project_directory); - Files::check_is_directory(destination_path); + Files::check_is_directory(VCPKG_LINE_INFO, include_directory); + Files::check_is_directory(VCPKG_LINE_INFO, project_directory); + Files::check_is_directory(VCPKG_LINE_INFO, destination_path); Binaries debug_binaries = find_binaries_in_dir(project_directory / "Debug"); Binaries release_binaries = find_binaries_in_dir(project_directory / "Release"); @@ -73,7 +73,7 @@ namespace vcpkg::Commands::Import const fs::path project_directory(args.command_arguments[2]); auto pghs = Paragraphs::get_paragraphs(control_file_path); - Checks::check_exit(pghs.size() == 1, "Invalid control file %s for package", control_file_path.generic_string()); + Checks::check_exit(VCPKG_LINE_INFO, pghs.size() == 1, "Invalid control file %s for package", control_file_path.generic_string()); StatusParagraph spgh; spgh.package = BinaryParagraph(pghs[0]); diff --git a/toolsrc/src/commands_install.cpp b/toolsrc/src/commands_install.cpp index 61e46b604..b7a8eafac 100644 --- a/toolsrc/src/commands_install.cpp +++ b/toolsrc/src/commands_install.cpp @@ -193,7 +193,7 @@ namespace vcpkg::Commands::Install StatusParagraphs status_db = database_load_check(paths); std::vector<package_spec_with_install_plan> install_plan = Dependencies::create_install_plan(paths, specs, status_db); - Checks::check_exit(!install_plan.empty(), "Install plan cannot be empty"); + Checks::check_exit(VCPKG_LINE_INFO, !install_plan.empty(), "Install plan cannot be empty"); std::string specs_string = install_plan[0].spec.toString(); for (size_t i = 1; i < install_plan.size(); ++i) @@ -223,7 +223,7 @@ namespace vcpkg::Commands::Install System::println(Build::create_user_troubleshooting_message(action.spec)); exit(EXIT_FAILURE); } - const BinaryParagraph bpgh = Paragraphs::try_load_cached_package(paths, action.spec).get_or_throw(); + const BinaryParagraph bpgh = Paragraphs::try_load_cached_package(paths, action.spec).get_or_throw(VCPKG_LINE_INFO); install_package(paths, bpgh, &status_db); System::println(System::color::success, "Package %s is installed", action.spec); } diff --git a/toolsrc/src/commands_integrate.cpp b/toolsrc/src/commands_integrate.cpp index ccc2a46b2..7011f8d1d 100644 --- a/toolsrc/src/commands_integrate.cpp +++ b/toolsrc/src/commands_integrate.cpp @@ -198,7 +198,7 @@ namespace vcpkg::Commands::Integrate Checks::unreachable(VCPKG_LINE_INFO); } - Checks::check_exit(fs::exists(system_wide_targets_file), "Error: failed to copy targets file to %s", system_wide_targets_file.string()); + Checks::check_exit(VCPKG_LINE_INFO, fs::exists(system_wide_targets_file), "Error: failed to copy targets file to %s", system_wide_targets_file.string()); } const fs::path appdata_src_path = tmp_dir / "vcpkg.user.targets"; @@ -272,7 +272,7 @@ namespace vcpkg::Commands::Integrate const int exit_code = System::cmd_execute_clean(cmd_line); const fs::path nuget_package = buildsystems_dir / Strings::format("%s.%s.nupkg", nuget_id, nupkg_version); - Checks::check_exit(exit_code == 0 && fs::exists(nuget_package), "Error: NuGet package creation failed"); + Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0 && fs::exists(nuget_package), "Error: NuGet package creation failed"); System::println(System::color::success, "Created nupkg: %s", nuget_package.string()); System::println(R"( diff --git a/toolsrc/src/commands_portsdiff.cpp b/toolsrc/src/commands_portsdiff.cpp index dea95f56c..b1a166ed1 100644 --- a/toolsrc/src/commands_portsdiff.cpp +++ b/toolsrc/src/commands_portsdiff.cpp @@ -59,7 +59,7 @@ namespace vcpkg::Commands::PortsDiff const std::wstring cmd = Strings::wformat(LR"("%s" cat-file -t %s)", git_exe.native(), git_commit_id); const System::exit_code_and_output output = System::cmd_execute_and_capture_output(cmd); - Checks::check_exit(output.output == VALID_COMMIT_OUTPUT, "Invalid commit id %s", Strings::utf16_to_utf8(git_commit_id)); + Checks::check_exit(VCPKG_LINE_INFO, output.output == VALID_COMMIT_OUTPUT, "Invalid commit id %s", Strings::utf16_to_utf8(git_commit_id)); } void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths) diff --git a/toolsrc/src/commands_remove.cpp b/toolsrc/src/commands_remove.cpp index 54ed201d0..7e4228496 100644 --- a/toolsrc/src/commands_remove.cpp +++ b/toolsrc/src/commands_remove.cpp @@ -175,7 +175,7 @@ namespace vcpkg::Commands::Remove auto status_db = database_load_check(paths); const std::vector<package_spec_with_remove_plan> remove_plan = Dependencies::create_remove_plan(specs, status_db); - Checks::check_exit(!remove_plan.empty(), "Remove plan cannot be empty"); + Checks::check_exit(VCPKG_LINE_INFO, !remove_plan.empty(), "Remove plan cannot be empty"); print_plan(remove_plan); diff --git a/toolsrc/src/opt_bool.cpp b/toolsrc/src/opt_bool.cpp index 324936fb4..b4642f273 100644 --- a/toolsrc/src/opt_bool.cpp +++ b/toolsrc/src/opt_bool.cpp @@ -24,6 +24,6 @@ namespace vcpkg::opt_bool return opt_bool_t::DISABLED; } - Checks::exit_with_message("Could not convert string [%s] to opt_bool", s); + Checks::exit_with_message(VCPKG_LINE_INFO, "Could not convert string [%s] to opt_bool", s); } } diff --git a/toolsrc/src/triplet.cpp b/toolsrc/src/triplet.cpp index d91e0e68f..173656f7b 100644 --- a/toolsrc/src/triplet.cpp +++ b/toolsrc/src/triplet.cpp @@ -40,7 +40,7 @@ namespace vcpkg { const std::string s(Strings::ascii_to_lowercase(triplet_as_string)); auto it = std::find(s.cbegin(), s.cend(), '-'); - Checks::check_exit(it != s.cend(), "Invalid triplet: %s", triplet_as_string); + Checks::check_exit(VCPKG_LINE_INFO, it != s.cend(), "Invalid triplet: %s", triplet_as_string); triplet t; t.m_canonical_name = s; diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp index 38a648b42..6c81d54f9 100644 --- a/toolsrc/src/vcpkg.cpp +++ b/toolsrc/src/vcpkg.cpp @@ -56,13 +56,13 @@ static void inner(const vcpkg_cmd_arguments& args) } } - Checks::check_exit(!vcpkg_root_dir.empty(), "Error: Could not detect vcpkg-root."); + Checks::check_exit(VCPKG_LINE_INFO, !vcpkg_root_dir.empty(), "Error: Could not detect vcpkg-root."); const expected<vcpkg_paths> expected_paths = vcpkg_paths::create(vcpkg_root_dir); - Checks::check_exit(!expected_paths.error_code(), "Error: Invalid vcpkg root directory %s: %s", vcpkg_root_dir.string(), expected_paths.error_code().message()); - const vcpkg_paths paths = expected_paths.get_or_throw(); + Checks::check_exit(VCPKG_LINE_INFO, !expected_paths.error_code(), "Error: Invalid vcpkg root directory %s: %s", vcpkg_root_dir.string(), expected_paths.error_code().message()); + const vcpkg_paths paths = expected_paths.get_or_throw(VCPKG_LINE_INFO); int exit_code = _wchdir(paths.root.c_str()); - Checks::check_exit(exit_code == 0, "Changing the working dir failed"); + Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Changing the working dir failed"); if (auto command_function = Commands::find(args.command, Commands::get_available_commands_type_b())) { @@ -111,7 +111,7 @@ static void loadConfig() try { - std::string config_contents = Files::read_contents(localappdata / "vcpkg" / "config").get_or_throw(); + std::string config_contents = Files::read_contents(localappdata / "vcpkg" / "config").get_or_throw(VCPKG_LINE_INFO); std::unordered_map<std::string, std::string> keys; auto pghs = Paragraphs::parse_paragraphs(config_contents); @@ -126,7 +126,7 @@ static void loadConfig() auto user_id = keys["User-Id"]; auto user_time = keys["User-Since"]; - Checks::check_throw(!user_id.empty() && !user_time.empty(), ""); // Use as goto to the catch statement + Checks::check_throw(VCPKG_LINE_INFO, !user_id.empty() && !user_time.empty(), ""); // Use as goto to the catch statement SetUserInformation(user_id, user_time); return; @@ -154,7 +154,7 @@ static void loadConfig() static std::string trim_path_from_command_line(const std::string& full_command_line) { - Checks::check_exit(full_command_line.size() > 0, "Internal failure - cannot have empty command line"); + Checks::check_exit(VCPKG_LINE_INFO, full_command_line.size() > 0, "Internal failure - cannot have empty command line"); if (full_command_line[0] == '"') { diff --git a/toolsrc/src/vcpkg_Checks.cpp b/toolsrc/src/vcpkg_Checks.cpp index 911f1d9f8..81e7d3825 100644 --- a/toolsrc/src/vcpkg_Checks.cpp +++ b/toolsrc/src/vcpkg_Checks.cpp @@ -5,6 +5,14 @@ namespace vcpkg::Checks { + static void print_line_info_if_debug(const LineInfo& line_info) + { + if (g_debugging) + { + System::println(System::color::error, line_info.toString()); + } + } + __declspec(noreturn) void unreachable(const LineInfo& line_info) { System::println(System::color::error, "Error: Unreachable code was reached"); @@ -16,38 +24,40 @@ namespace vcpkg::Checks #endif } - __declspec(noreturn) void exit_with_message(const char* errorMessage) + __declspec(noreturn) void exit_with_message(const LineInfo& line_info, const char* errorMessage) { System::println(System::color::error, errorMessage); + print_line_info_if_debug(line_info); exit(EXIT_FAILURE); } - __declspec(noreturn) void throw_with_message(const char* errorMessage) + __declspec(noreturn) void throw_with_message(const LineInfo& line_info, const char* errorMessage) { + print_line_info_if_debug(line_info); throw std::runtime_error(errorMessage); } - void check_throw(bool expression, const char* errorMessage) + void check_throw(const LineInfo& line_info, bool expression, const char* errorMessage) { if (!expression) { - throw_with_message(errorMessage); + throw_with_message(line_info, errorMessage); } } - void check_exit(bool expression) + void check_exit(const LineInfo& line_info, bool expression) { if (!expression) { - exit(EXIT_FAILURE); + exit_with_message(line_info, ""); } } - void check_exit(bool expression, const char* errorMessage) + void check_exit(const LineInfo& line_info, bool expression, const char* errorMessage) { if (!expression) { - exit_with_message(errorMessage); + exit_with_message(line_info, errorMessage); } } } diff --git a/toolsrc/src/vcpkg_Dependencies.cpp b/toolsrc/src/vcpkg_Dependencies.cpp index e8bf10617..b96cf282c 100644 --- a/toolsrc/src/vcpkg_Dependencies.cpp +++ b/toolsrc/src/vcpkg_Dependencies.cpp @@ -56,7 +56,7 @@ namespace vcpkg::Dependencies { for (const std::string& dep_as_string : dependencies_as_string) { - const package_spec current_dep = package_spec::from_name_and_triplet(dep_as_string, spec.target_triplet()).get_or_throw(); + const package_spec current_dep = package_spec::from_name_and_triplet(dep_as_string, spec.target_triplet()).get_or_throw(VCPKG_LINE_INFO); graph.add_edge(spec, current_dep); if (was_examined.find(current_dep) == was_examined.end()) { @@ -82,7 +82,7 @@ namespace vcpkg::Dependencies expected<SourceParagraph> maybe_spgh = Paragraphs::try_load_port(paths.port_dir(spec)); SourceParagraph* spgh = maybe_spgh.get(); - Checks::check_exit(spgh != nullptr, "Cannot find package %s", spec.name()); + Checks::check_exit(VCPKG_LINE_INFO, spgh != nullptr, "Cannot find package %s", spec.name()); process_dependencies(filter_dependencies(spgh->depends, spec.target_triplet())); was_examined.emplace(spec, install_plan_action{install_plan_type::BUILD_AND_INSTALL, nullptr, std::make_unique<SourceParagraph>(std::move(*spgh))}); } diff --git a/toolsrc/src/vcpkg_Enums.cpp b/toolsrc/src/vcpkg_Enums.cpp index c8925fc63..b5a487a37 100644 --- a/toolsrc/src/vcpkg_Enums.cpp +++ b/toolsrc/src/vcpkg_Enums.cpp @@ -11,6 +11,6 @@ namespace vcpkg::Enums __declspec(noreturn) void nullvalue_used(const LineInfo& line_info, const std::string& enum_name) { - Checks::exit_with_message("NULLVALUE of enum %s was used", enum_name); + Checks::exit_with_message(VCPKG_LINE_INFO, "NULLVALUE of enum %s was used", enum_name); } } diff --git a/toolsrc/src/vcpkg_Environment.cpp b/toolsrc/src/vcpkg_Environment.cpp index 8aaaba8a8..f0c157b6e 100644 --- a/toolsrc/src/vcpkg_Environment.cpp +++ b/toolsrc/src/vcpkg_Environment.cpp @@ -12,7 +12,7 @@ namespace vcpkg::Environment const fs::path script = paths.scripts / "findVisualStudioInstallationInstances.ps1"; const std::wstring cmd = System::create_powershell_script_cmd(script); System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(cmd); - Checks::check_exit(ec_data.exit_code == 0, "Could not run script to detect VS 2017 instances"); + Checks::check_exit(VCPKG_LINE_INFO, ec_data.exit_code == 0, "Could not run script to detect VS 2017 instances"); return Strings::split(ec_data.output, "\n"); } @@ -141,7 +141,7 @@ namespace vcpkg::Environment static fs::path find_ProgramFiles() { const optional<std::wstring> program_files = System::get_environmental_variable(L"PROGRAMFILES"); - Checks::check_exit(program_files.get() != nullptr, "Could not detect the PROGRAMFILES environmental variable"); + Checks::check_exit(VCPKG_LINE_INFO, program_files.get() != nullptr, "Could not detect the PROGRAMFILES environmental variable"); return *program_files; } diff --git a/toolsrc/src/vcpkg_Files.cpp b/toolsrc/src/vcpkg_Files.cpp index 57d4c665c..95b99691c 100644 --- a/toolsrc/src/vcpkg_Files.cpp +++ b/toolsrc/src/vcpkg_Files.cpp @@ -6,9 +6,9 @@ namespace vcpkg::Files { static const std::regex FILESYSTEM_INVALID_CHARACTERS_REGEX = std::regex(R"([\/:*?"<>|])"); - void check_is_directory(const fs::path& dirpath) + void check_is_directory(const LineInfo& line_info, const fs::path& dirpath) { - Checks::check_exit(fs::is_directory(dirpath), "The path %s is not a directory", dirpath.string()); + Checks::check_exit(VCPKG_LINE_INFO, fs::is_directory(dirpath), "The path %s is not a directory", dirpath.string()); } bool has_invalid_chars_for_filesystem(const std::string& s) diff --git a/toolsrc/src/vcpkg_System.cpp b/toolsrc/src/vcpkg_System.cpp index b872fe2fd..14a6f3a73 100644 --- a/toolsrc/src/vcpkg_System.cpp +++ b/toolsrc/src/vcpkg_System.cpp @@ -172,9 +172,9 @@ namespace vcpkg::System return nullptr; auto ret = std::make_unique<std::wstring>(sz, L'\0'); - Checks::check_exit(MAXDWORD >= ret->size()); + Checks::check_exit(VCPKG_LINE_INFO, MAXDWORD >= ret->size()); auto sz2 = GetEnvironmentVariableW(varname, ret->data(), static_cast<DWORD>(ret->size())); - Checks::check_exit(sz2 + 1 == sz); + Checks::check_exit(VCPKG_LINE_INFO, sz2 + 1 == sz); ret->pop_back(); return ret; } diff --git a/toolsrc/src/vcpkg_metrics_uploader.cpp b/toolsrc/src/vcpkg_metrics_uploader.cpp index 82dcd4b03..9f040286b 100644 --- a/toolsrc/src/vcpkg_metrics_uploader.cpp +++ b/toolsrc/src/vcpkg_metrics_uploader.cpp @@ -12,6 +12,6 @@ int WINAPI WinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ LPSTR, _In_ int) szArgList = CommandLineToArgvW(GetCommandLineW(), &argCount); - Checks::check_exit(argCount == 2, "Requires exactly one argument, the path to the payload file"); - Upload(Files::read_contents(szArgList[1]).get_or_throw()); + Checks::check_exit(VCPKG_LINE_INFO, argCount == 2, "Requires exactly one argument, the path to the payload file"); + Upload(Files::read_contents(szArgList[1]).get_or_throw(VCPKG_LINE_INFO)); } diff --git a/toolsrc/src/vcpkg_paths.cpp b/toolsrc/src/vcpkg_paths.cpp index 84c99c806..dcc010cd0 100644 --- a/toolsrc/src/vcpkg_paths.cpp +++ b/toolsrc/src/vcpkg_paths.cpp @@ -82,8 +82,8 @@ namespace vcpkg } const fs::path actual_downloaded_path = rc.output; - Checks::check_exit(expected_downloaded_path == actual_downloaded_path, "Expected dependency downloaded path to be %s, but was %s", - expected_downloaded_path.generic_string(), actual_downloaded_path.generic_string()); + Checks::check_exit(VCPKG_LINE_INFO, expected_downloaded_path == actual_downloaded_path, "Expected dependency downloaded path to be %s, but was %s", + expected_downloaded_path.generic_string(), actual_downloaded_path.generic_string()); return actual_downloaded_path; } diff --git a/toolsrc/src/vcpkglib.cpp b/toolsrc/src/vcpkglib.cpp index 62b6e78f1..932502d2d 100644 --- a/toolsrc/src/vcpkglib.cpp +++ b/toolsrc/src/vcpkglib.cpp @@ -22,7 +22,7 @@ namespace vcpkg fs::rename(vcpkg_dir_status_file_old, vcpkg_dir_status_file); } - auto text = Files::read_contents(vcpkg_dir_status_file).get_or_throw(); + auto text = Files::read_contents(vcpkg_dir_status_file).get_or_throw(VCPKG_LINE_INFO); auto pghs = Paragraphs::parse_paragraphs(text); std::vector<std::unique_ptr<StatusParagraph>> status_pghs; @@ -65,7 +65,7 @@ namespace vcpkg if (b->path().filename() == "incomplete") continue; - auto text = Files::read_contents(b->path()).get_or_throw(); + auto text = Files::read_contents(b->path()).get_or_throw(VCPKG_LINE_INFO); auto pghs = Paragraphs::parse_paragraphs(text); for (auto&& p : pghs) { @@ -185,7 +185,7 @@ namespace vcpkg } const fs::path listfile_path = paths.listfile_path(pgh->package); - std::vector<std::string> installed_files_of_current_pgh = Files::read_all_lines(listfile_path).get_or_throw(); + std::vector<std::string> installed_files_of_current_pgh = Files::read_all_lines(listfile_path).get_or_throw(VCPKG_LINE_INFO); Strings::trim_all_and_remove_whitespace_strings(&installed_files_of_current_pgh); upgrade_to_slash_terminated_sorted_format(&installed_files_of_current_pgh, listfile_path); diff --git a/toolsrc/src/vcpkglib_helpers.cpp b/toolsrc/src/vcpkglib_helpers.cpp index 6b96c25cb..1730be374 100644 --- a/toolsrc/src/vcpkglib_helpers.cpp +++ b/toolsrc/src/vcpkglib_helpers.cpp @@ -31,14 +31,14 @@ namespace vcpkg::details std::string required_field(const std::unordered_map<std::string, std::string>& fields, const std::string& fieldname) { auto it = fields.find(fieldname); - Checks::check_exit(it != fields.end(), "Required field not present: %s", fieldname); + Checks::check_exit(VCPKG_LINE_INFO, it != fields.end(), "Required field not present: %s", fieldname); return it->second; } std::string remove_required_field(std::unordered_map<std::string, std::string>* fields, const std::string& fieldname) { auto it = fields->find(fieldname); - Checks::check_exit(it != fields->end(), "Required field not present: %s", fieldname); + Checks::check_exit(VCPKG_LINE_INFO, it != fields->end(), "Required field not present: %s", fieldname); const std::string value = std::move(it->second); fields->erase(it); |
