Merge "Do not enforce minor version uprev on imports."
diff --git a/AST.cpp b/AST.cpp
index fb5d333..4793021 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -117,7 +117,8 @@
}
for (const auto &subFQName : packageInterfaces) {
- AST *ast = mCoordinator->parse(subFQName, &mImportedASTs);
+ // Do not enforce restrictions on imports.
+ AST *ast = mCoordinator->parse(subFQName, &mImportedASTs, false /* enforce */);
if (ast == nullptr) {
return false;
}
@@ -135,7 +136,8 @@
// assume it is an interface, and try to import it.
const FQName interfaceName = fqName.getTopLevelType();
- importAST = mCoordinator->parse(interfaceName, &mImportedASTs);
+ // Do not enforce restrictions on imports.
+ importAST = mCoordinator->parse(interfaceName, &mImportedASTs, false /* enforce */);
if (importAST != nullptr) {
// cases like android.hardware.foo@1.0::IFoo.Internal
@@ -163,7 +165,9 @@
// probably a type in types.hal, like android.hardware.foo@1.0::Abc.Internal
FQName typesFQName = fqName.getTypesForPackage();
- importAST = mCoordinator->parse(typesFQName, &mImportedASTs);
+
+ // Do not enforce restrictions on imports.
+ importAST = mCoordinator->parse(typesFQName, &mImportedASTs, false /* enforce */);
if (importAST != nullptr) {
// Attempt to find Abc.Internal in types.
@@ -522,7 +526,7 @@
void AST::getAllImportedNames(std::set<FQName> *allImportNames) const {
for (const auto& name : mImportedNames) {
allImportNames->insert(name);
- AST *ast = mCoordinator->parse(name);
+ AST *ast = mCoordinator->parse(name, nullptr /* imported */, false /* enforce */);
ast->getAllImportedNames(allImportNames);
}
}
diff --git a/Coordinator.cpp b/Coordinator.cpp
index d50b639..72c8557 100644
--- a/Coordinator.cpp
+++ b/Coordinator.cpp
@@ -53,7 +53,7 @@
// empty
}
-AST *Coordinator::parse(const FQName &fqName, std::set<AST *> *parsedASTs) {
+AST *Coordinator::parse(const FQName &fqName, std::set<AST *> *parsedASTs, bool enforce) {
CHECK(fqName.isFullyQualified());
auto it = mCache.find(fqName);
@@ -75,7 +75,8 @@
if (fqName.name() != "types") {
// Any interface file implicitly imports its package's types.hal.
FQName typesName = fqName.getTypesForPackage();
- typesAST = parse(typesName, parsedASTs);
+ // Do not enforce on imports.
+ typesAST = parse(typesName, parsedASTs, false /* enforce */);
// fall through.
}
@@ -163,13 +164,15 @@
// parse fqName.
mCache[fqName] = ast;
- // For each .hal file that hidl-gen parses, the whole package will be checked.
- err = enforceRestrictionsOnPackage(fqName);
- if (err != OK) {
- mCache[fqName] = nullptr;
- delete ast;
- ast = nullptr;
- return nullptr;
+ if (enforce) {
+ // For each .hal file that hidl-gen parses, the whole package will be checked.
+ err = enforceRestrictionsOnPackage(fqName);
+ if (err != OK) {
+ mCache[fqName] = nullptr;
+ delete ast;
+ ast = nullptr;
+ return nullptr;
+ }
}
return ast;
diff --git a/Coordinator.h b/Coordinator.h
index 0aefb40..ddf5dfa 100644
--- a/Coordinator.h
+++ b/Coordinator.h
@@ -44,7 +44,9 @@
// file if it exists.
// If "parsedASTs" is non-NULL, successfully parsed ASTs are inserted
// into the set.
- AST *parse(const FQName &fqName, std::set<AST *> *parsedASTs = nullptr);
+ // If !enforce, enforceRestrictionsOnPackage won't be run.
+ AST *parse(const FQName &fqName, std::set<AST *> *parsedASTs = nullptr,
+ bool enforce = true);
// Given package-root paths of ["hardware/interfaces",
// "vendor/<something>/interfaces"], package roots of