Merge "assemble_vintf conflict of hal names for multiple manifest fragments"
diff --git a/assemble_vintf.cpp b/assemble_vintf.cpp
index 974c7fc..8874f69 100644
--- a/assemble_vintf.cpp
+++ b/assemble_vintf.cpp
@@ -318,7 +318,15 @@
<< std::endl;
return FAIL_AND_EXIT;
}
- schema.addAll(std::move(additionalSchema));
+ std::string error;
+ if (!schema.addAll(std::move(additionalSchema), &error)) {
+ std::cerr << "File \"" << mInFilePaths[std::distance(mInFiles.begin(), it)]
+ << "\" cannot be added: conflict on HAL \"" << error
+ << "\" with an existing HAL. See <hal> with the same name "
+ << "in previously parsed files or previously declared in this file."
+ << std::endl;
+ return FAIL_AND_EXIT;
+ }
}
return assemble(&schema) ? SUCCESS : FAIL_AND_EXIT;
}
diff --git a/include/vintf/HalGroup.h b/include/vintf/HalGroup.h
index 9962c29..8ef6f38 100644
--- a/include/vintf/HalGroup.h
+++ b/include/vintf/HalGroup.h
@@ -31,9 +31,12 @@
public:
virtual ~HalGroup() {}
// Move all hals from another HalGroup to this.
- bool addAll(HalGroup&& other) {
+ bool addAll(HalGroup&& other, std::string* error = nullptr) {
for (auto& pair : other.mHals) {
if (!add(std::move(pair.second))) {
+ if (error) {
+ *error = pair.first;
+ }
return false;
}
}