Fix vts generation in hidl.
* Needs to generate the imported attributes (from types.hal in a
different package) within an interface.
Test: make hidl-gen
mma for hardware/interfaces
successfully build the driver/profiler for
android.hardware.graphics.allocator@2.0 locally.
Change-Id: I1c149d0fc76d9aaf662d8463a8bf485dc931e128
diff --git a/generateVts.cpp b/generateVts.cpp
index 5224d17..ed8e837 100644
--- a/generateVts.cpp
+++ b/generateVts.cpp
@@ -45,29 +45,33 @@
}
allImportSet->insert(ast);
std::string ifaceName;
- // We only care about types.hal.
- if (!ast->isInterface(&ifaceName)) {
- status_t status = ast->emitVtsTypeDeclarationsHelper(
- out, allImportSet);
+ // Skip the process of ast within the same package.
+ if (ast->package() != mPackage) {
+ status_t status = ast->emitVtsTypeDeclarationsHelper(out,
+ allImportSet);
if (status != OK) {
return status;
}
}
}
// Next, generate vts type declaration for the current AST.
- for (const auto &type : mRootScope->getSubTypes()) {
- // Skip for TypeDef as it is just an alias of a defined type.
- if (type->isTypeDef()) {
- continue;
+ std::string ifaceName;
+ // We only care about types.hal.
+ if (!AST::isInterface(&ifaceName)) {
+ for (const auto &type : mRootScope->getSubTypes()) {
+ // Skip for TypeDef as it is just an alias of a defined type.
+ if (type->isTypeDef()) {
+ continue;
+ }
+ out << "attribute: {\n";
+ out.indent();
+ status_t status = type->emitVtsTypeDeclarations(out);
+ if (status != OK) {
+ return status;
+ }
+ out.unindent();
+ out << "}\n\n";
}
- out << "attribute: {\n";
- out.indent();
- status_t status = type->emitVtsTypeDeclarations(out);
- if (status != OK) {
- return status;
- }
- out.unindent();
- out << "}\n\n";
}
return OK;
}
@@ -127,6 +131,10 @@
std::vector<const Interface *> chain = iface->typeChain();
// Generate all the attribute declarations first.
+ status_t status = emitVtsTypeDeclarations(out);
+ if (status != OK) {
+ return status;
+ }
for (auto it = chain.rbegin(); it != chain.rend(); ++it) {
const Interface *superInterface = *it;
status_t status = superInterface->emitVtsAttributeDeclaration(out);