aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/Paragraphs.cpp
diff options
context:
space:
mode:
authoratkawa7 <atkawa7@yahoo.com>2017-06-14 08:29:12 -0700
committeratkawa7 <atkawa7@yahoo.com>2017-06-14 08:29:12 -0700
commitce5ad1ffe1ed0c6351a09b01bc92a2ad258b8f19 (patch)
treeb64edb2fe7d020661b3fe30213eef2a967a60fd3 /toolsrc/src/Paragraphs.cpp
parent0a7fee0e8b0a637c83b9dd55bcb7a85c85779aba (diff)
parentc5ac9898999b712b7bac2fbc497825882d5e9011 (diff)
downloadvcpkg-ce5ad1ffe1ed0c6351a09b01bc92a2ad258b8f19.tar.gz
vcpkg-ce5ad1ffe1ed0c6351a09b01bc92a2ad258b8f19.zip
Merge https://github.com/Microsoft/vcpkg
Diffstat (limited to 'toolsrc/src/Paragraphs.cpp')
-rw-r--r--toolsrc/src/Paragraphs.cpp40
1 files changed, 28 insertions, 12 deletions
diff --git a/toolsrc/src/Paragraphs.cpp b/toolsrc/src/Paragraphs.cpp
index 70d3db2b3..31e8f1da3 100644
--- a/toolsrc/src/Paragraphs.cpp
+++ b/toolsrc/src/Paragraphs.cpp
@@ -168,7 +168,7 @@ namespace vcpkg::Paragraphs
return parse_single_paragraph(*spgh);
}
- return contents.error_code();
+ return contents.error();
}
Expected<std::vector<std::unordered_map<std::string, std::string>>> get_paragraphs(const Files::Filesystem& fs,
@@ -180,7 +180,7 @@ namespace vcpkg::Paragraphs
return parse_paragraphs(*spgh);
}
- return contents.error_code();
+ return contents.error();
}
Expected<std::unordered_map<std::string, std::string>> parse_single_paragraph(const std::string& str)
@@ -201,15 +201,17 @@ namespace vcpkg::Paragraphs
return Parser(str.c_str(), str.c_str() + str.size()).get_paragraphs();
}
- Expected<SourceParagraph> try_load_port(const Files::Filesystem& fs, const fs::path& path)
+ ExpectedT<SourceParagraph, ParseControlErrorInfo> try_load_port(const Files::Filesystem& fs, const fs::path& path)
{
+ ParseControlErrorInfo error_info;
Expected<std::unordered_map<std::string, std::string>> pghs = get_single_paragraph(fs, path / "CONTROL");
if (auto p = pghs.get())
{
- return SourceParagraph(*p);
+ return SourceParagraph::parse_control_file(*p);
}
-
- return pghs.error_code();
+ error_info.name = path.filename().generic_u8string();
+ error_info.error = pghs.error();
+ return error_info;
}
Expected<BinaryParagraph> try_load_cached_package(const VcpkgPaths& paths, const PackageSpec& spec)
@@ -222,22 +224,36 @@ namespace vcpkg::Paragraphs
return BinaryParagraph(*p);
}
- return pghs.error_code();
+ return pghs.error();
}
- std::vector<SourceParagraph> load_all_ports(const Files::Filesystem& fs, const fs::path& ports_dir)
+ LoadResults try_load_all_ports(const Files::Filesystem& fs, const fs::path& ports_dir)
{
- std::vector<SourceParagraph> output;
+ LoadResults ret;
for (auto&& path : fs.get_files_non_recursive(ports_dir))
{
- Expected<SourceParagraph> source_paragraph = try_load_port(fs, path);
+ ExpectedT<SourceParagraph, ParseControlErrorInfo> source_paragraph = try_load_port(fs, path);
if (auto srcpgh = source_paragraph.get())
{
- output.emplace_back(std::move(*srcpgh));
+ ret.paragraphs.emplace_back(std::move(*srcpgh));
+ }
+ else
+ {
+ ret.errors.emplace_back(source_paragraph.error());
}
}
+ return ret;
+ }
- return output;
+ std::vector<SourceParagraph> load_all_ports(const Files::Filesystem& fs, const fs::path& ports_dir)
+ {
+ auto results = try_load_all_ports(fs, ports_dir);
+ if (!results.errors.empty())
+ {
+ print_error_message(results.errors);
+ Checks::exit_fail(VCPKG_LINE_INFO);
+ }
+ return std::move(results.paragraphs);
}
std::map<std::string, VersionT> extract_port_names_and_versions(