summaryrefslogtreecommitdiff
path: root/tools/aapt2/util/Util.cpp
diff options
context:
space:
mode:
authorRyan Mitchell <rtmitchell@google.com>2019-03-18 08:57:47 -0700
committerRyan Mitchell <rtmitchell@google.com>2019-04-17 10:59:38 -0700
commit34039b26f554500450dd566d5710b9b17f155d6f (patch)
treeb9f075ca850bd50852cddc5df5e09e1cde0be0ed /tools/aapt2/util/Util.cpp
parent488693532998d5e08f68b58b235b7d6dcd3df1fb (diff)
Add build number to aapt2 version
This changes adds the build id to the version printed by "aapt2 version". This change also adds a field to the ResourceTable proto that specifies the fingerprints of tools used to build the table. Bug: 123663089 Test: manual Change-Id: Ifaf33c1e506b68e9f1d921fdbeddf36485e65790
Diffstat (limited to 'tools/aapt2/util/Util.cpp')
-rw-r--r--tools/aapt2/util/Util.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/tools/aapt2/util/Util.cpp b/tools/aapt2/util/Util.cpp
index 59b7fff0f9e3..37ce65e4fe5b 100644
--- a/tools/aapt2/util/Util.cpp
+++ b/tools/aapt2/util/Util.cpp
@@ -21,13 +21,15 @@
#include <string>
#include <vector>
+#include "android-base/stringprintf.h"
#include "androidfw/StringPiece.h"
-#include "utils/Unicode.h"
+#include "build/version.h"
#include "text/Unicode.h"
#include "text/Utf8Iterator.h"
#include "util/BigBuffer.h"
#include "util/Maybe.h"
+#include "utils/Unicode.h"
using ::aapt::text::Utf8Iterator;
using ::android::StringPiece;
@@ -200,6 +202,24 @@ Maybe<std::string> GetFullyQualifiedClassName(const StringPiece& package,
return result;
}
+const char* GetToolName() {
+ static const char* const sToolName = "Android Asset Packaging Tool (aapt)";
+ return sToolName;
+}
+
+std::string GetToolFingerprint() {
+ // DO NOT UPDATE, this is more of a marketing version.
+ static const char* const sMajorVersion = "2";
+
+ // Update minor version whenever a feature or flag is added.
+ static const char* const sMinorVersion = "19";
+
+ // The build id of aapt2 binary.
+ static const std::string sBuildId = android::build::GetBuildNumber();
+
+ return android::base::StringPrintf("%s.%s-%s", sMajorVersion, sMinorVersion, sBuildId.c_str());
+}
+
static size_t ConsumeDigits(const char* start, const char* end) {
const char* c = start;
for (; c != end && *c >= '0' && *c <= '9'; c++) {