Merge "Proceess post parse passes once for each type and expression"
diff --git a/Coordinator.cpp b/Coordinator.cpp
index 87ca1a3..2211804 100644
--- a/Coordinator.cpp
+++ b/Coordinator.cpp
@@ -92,7 +92,7 @@
// fall through.
}
- std::string path = getAbsolutePackagePath(fqName);
+ std::string path = makeAbsolute(getPackagePath(fqName));
path.append(fqName.name());
path.append(".hal");
@@ -213,14 +213,12 @@
return ret;
}
-std::string Coordinator::getAbsolutePackagePath(const FQName& fqName) const {
- const std::string packagePath = getPackagePath(fqName);
-
- if (StringHelper::StartsWith(packagePath, "/") || mRootPath.empty()) {
- return packagePath;
+std::string Coordinator::makeAbsolute(const std::string& path) const {
+ if (StringHelper::StartsWith(path, "/") || mRootPath.empty()) {
+ return path;
}
- return StringHelper::RTrim(mRootPath, "/") + "/" + packagePath;
+ return StringHelper::RTrim(mRootPath, "/") + "/" + path;
}
std::string Coordinator::getPackageRoot(const FQName &fqName) const {
@@ -287,7 +285,7 @@
std::vector<std::string> *fileNames) const {
fileNames->clear();
- const std::string packagePath = getAbsolutePackagePath(package);
+ const std::string packagePath = makeAbsolute(getPackagePath(package));
DIR *dir = opendir(packagePath.c_str());
@@ -438,7 +436,8 @@
FQName prevPackage = currentPackage;
while (prevPackage.getPackageMinorVersion() > 0) {
prevPackage = prevPackage.downRev();
- if (existdir(getAbsolutePackagePath(prevPackage).c_str())) {
+ const std::string prevPackagePath = makeAbsolute(getPackagePath(prevPackage));
+ if (existdir(prevPackagePath.c_str())) {
hasPrevPackage = true;
break;
}
@@ -550,7 +549,7 @@
continue;
}
- std::string hashPath = getPackageRootPath(currentFQName) + "/current.txt";
+ std::string hashPath = makeAbsolute(getPackageRootPath(currentFQName)) + "/current.txt";
std::string error;
std::vector<std::string> frozen = Hash::lookupHash(hashPath, currentFQName.string(), &error);
diff --git a/Coordinator.h b/Coordinator.h
index 6f589cf..ed1a81f 100644
--- a/Coordinator.h
+++ b/Coordinator.h
@@ -125,13 +125,9 @@
std::vector<std::string>::const_iterator findPackageRoot(
const FQName &fqName) const;
- // Returns abs package path by prepending the root path if a package
- // path is non-absolute.
- // If root is '/android/master' and getPackagePath returns 'h/i/nfc/V1_0'
- // this will return '/android/master/h/i/nfc/V1_0'.
- // If root is '/android/master' and getPackagePath returns '/abs/path/to/nfc/V1_0'
- // this will return '/abs/path/to/nfc/V1_0'
- std::string getAbsolutePackagePath(const FQName& fqName) const;
+ // Returns the given path if it is absolute, otherwise it returns
+ // the path relative to mRootPath
+ std::string makeAbsolute(const std::string& string) const;
// Rules of enforceRestrictionsOnPackage are listed below.
status_t enforceMinorVersionUprevs(const FQName &fqName) const;
diff --git a/main.cpp b/main.cpp
index 647ea3a..a936cab 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1430,8 +1430,7 @@
}
if (outputFormat->mOutputMode == OutputHandler::NEEDS_DIR) {
- const size_t len = outputPath.size();
- if (outputPath[len - 1] != '/') {
+ if (outputPath.back() != '/') {
outputPath += "/";
}
}
@@ -1442,6 +1441,9 @@
if (outputPath.empty()) {
outputPath = rootPath;
}
+ if (outputPath.back() != '/') {
+ outputPath += "/";
+ }
break;
}