summaryrefslogtreecommitdiffhomepage
path: root/MakefileReader.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2024-06-15 14:24:14 +0200
committerRoland Reichwein <mail@reichwein.it>2024-06-15 14:24:14 +0200
commitec955eb6726b31e26d17c34474619b60f3563194 (patch)
tree3ce74889185f0b2a3a9a13d67ccf9b3812479e83 /MakefileReader.cpp
parentd9e360bb95d4fced4974bb716f993c81626417cb (diff)
Automatically depend on YMakefile (rebuild if necessary), testsHEADmaster
Diffstat (limited to 'MakefileReader.cpp')
-rw-r--r--MakefileReader.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/MakefileReader.cpp b/MakefileReader.cpp
index ebcc0a8..2a5fa98 100644
--- a/MakefileReader.cpp
+++ b/MakefileReader.cpp
@@ -10,6 +10,7 @@ namespace fs = std::filesystem;
namespace {
// the elements with this name are considered paths, where relative prefixes will be added if necessary
std::vector<std::string> path_elements{"name", "source", "test"};
+ const std::string topelement{"ymake"};
// add path to respective elements in tree, recursively
void adjust_path(pt::ptree::value_type& element, const fs::path& path) {
@@ -30,8 +31,8 @@ namespace {
tree = makefile_tree; // including top level single "ymake" element
} else {
// copy all elements inside single "ymake"
- pt::ptree& target{tree.get_child("ymake")};
- const pt::ptree& source{makefile_tree.get_child("ymake")};
+ pt::ptree& target{tree.get_child(topelement)};
+ const pt::ptree& source{makefile_tree.get_child(topelement)};
for (const auto& i: source) {
auto it {target.push_back(i)};
auto &element{*it};
@@ -49,16 +50,25 @@ pt::ptree MakefileReader::read(const fs::path& path) const
{
pt::ptree ptree;
+ // YMakefile needs to exist, but it can be in a subdir, so we need to
+ // iterate first over directories
+ bool makefile_found{};
+
for (const fs::directory_entry& dir_entry: fs::recursive_directory_iterator(path)) {
pt::ptree makefile_tree;
fs::path path{dir_entry.path()};
if (dir_entry.is_regular_file() && path.filename() == YMakefile) {
+ makefile_found = true;
pt::read_xml(path, makefile_tree, pt::xml_parser::no_comments | pt::xml_parser::trim_whitespace);
join(ptree, makefile_tree, simplified_path(path.parent_path()));
}
}
+ if (!makefile_found) {
+ throw std::runtime_error("YMakefile not found");
+ }
+
return ptree;
}