Dont include day/time or ldap for eng aapt2 builds
Previously, eng builds included a fingerprint that was a combination of
the developers ldap, the date, and the time. This meant that the build
system (including RBE) couldn't cache the ouput of aapt. This removes
the ldap, day, and time part of that so that caching will work.
Fixes: 200741997
Test: ran `aapt2 version` to verify the updated format
Change-Id: Id0d1ff99c8fbbf18261d3fc06f21b2969ed2e247
diff --git a/tools/aapt2/util/Util.cpp b/tools/aapt2/util/Util.cpp
index 44b4ec1..efbbf8e 100644
--- a/tools/aapt2/util/Util.cpp
+++ b/tools/aapt2/util/Util.cpp
@@ -22,9 +22,9 @@
#include <vector>
#include "android-base/stringprintf.h"
+#include "android-base/strings.h"
#include "androidfw/StringPiece.h"
#include "build/version.h"
-
#include "text/Unicode.h"
#include "text/Utf8Iterator.h"
#include "util/BigBuffer.h"
@@ -231,7 +231,14 @@
static const char* const sMinorVersion = "19";
// The build id of aapt2 binary.
- static const std::string sBuildId = android::build::GetBuildNumber();
+ static std::string sBuildId = android::build::GetBuildNumber();
+
+ if (android::base::StartsWith(sBuildId, "eng.")) {
+ time_t now = time(0);
+ tm* ltm = localtime(&now);
+
+ sBuildId = android::base::StringPrintf("eng.%d%d", 1900 + ltm->tm_year, 1 + ltm->tm_mon);
+ }
return android::base::StringPrintf("%s.%s-%s", sMajorVersion, sMinorVersion, sBuildId.c_str());
}