Merge "Add build number to aapt2 version" into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
743266643a
@@ -57,6 +57,7 @@ cc_defaults {
|
||||
"libbase",
|
||||
"libprotobuf-cpp-lite",
|
||||
"libz",
|
||||
"libbuildversion",
|
||||
],
|
||||
stl: "libc++_static",
|
||||
group_static_libs: true,
|
||||
|
||||
@@ -46,12 +46,6 @@ using ::android::base::StringPrintf;
|
||||
|
||||
namespace aapt {
|
||||
|
||||
// DO NOT UPDATE, this is more of a marketing version.
|
||||
static const char* sMajorVersion = "2";
|
||||
|
||||
// Update minor version whenever a feature or flag is added.
|
||||
static const char* sMinorVersion = "19";
|
||||
|
||||
/** Prints the version information of AAPT2. */
|
||||
class VersionCommand : public Command {
|
||||
public:
|
||||
@@ -60,8 +54,7 @@ class VersionCommand : public Command {
|
||||
}
|
||||
|
||||
int Action(const std::vector<std::string>& /* args */) override {
|
||||
std::cerr << StringPrintf("Android Asset Packaging Tool (aapt) %s:%s", sMajorVersion,
|
||||
sMinorVersion)
|
||||
std::cerr << StringPrintf("%s %s", util::GetToolName(), util::GetToolFingerprint().c_str())
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,12 @@ message Source {
|
||||
SourcePosition position = 2;
|
||||
}
|
||||
|
||||
// The name and version fingerprint of a build tool.
|
||||
message ToolFingerprint {
|
||||
string tool = 1;
|
||||
string version = 2;
|
||||
}
|
||||
|
||||
// Top level message representing a resource table.
|
||||
message ResourceTable {
|
||||
// The string pool containing source paths referenced throughout the resource table. This does
|
||||
@@ -52,6 +58,9 @@ message ResourceTable {
|
||||
|
||||
// The <overlayable> declarations within the resource table.
|
||||
repeated Overlayable overlayable = 3;
|
||||
|
||||
// The version fingerprints of the tools that built the resource table.
|
||||
repeated ToolFingerprint tool_fingerprint = 4;
|
||||
}
|
||||
|
||||
// A package ID in the range [0x00, 0xff].
|
||||
|
||||
@@ -327,6 +327,9 @@ static void SerializeOverlayableItemToPb(const OverlayableItem& overlayable_item
|
||||
void SerializeTableToPb(const ResourceTable& table, pb::ResourceTable* out_table,
|
||||
IDiagnostics* diag) {
|
||||
StringPool source_pool;
|
||||
pb::ToolFingerprint* pb_fingerprint = out_table->add_tool_fingerprint();
|
||||
pb_fingerprint->set_tool(util::GetToolName());
|
||||
pb_fingerprint->set_version(util::GetToolFingerprint());
|
||||
|
||||
std::vector<Overlayable*> overlayables;
|
||||
for (const std::unique_ptr<ResourceTablePackage>& package : table.packages) {
|
||||
|
||||
@@ -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++) {
|
||||
|
||||
@@ -98,6 +98,12 @@ bool IsAndroidSplitName(const android::StringPiece& str);
|
||||
Maybe<std::string> GetFullyQualifiedClassName(const android::StringPiece& package,
|
||||
const android::StringPiece& class_name);
|
||||
|
||||
// Retrieves the formatted name of aapt2.
|
||||
const char* GetToolName();
|
||||
|
||||
// Retrieves the build fingerprint of aapt2.
|
||||
std::string GetToolFingerprint();
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<std::is_arithmetic<T>::value, int>::type compare(const T& a, const T& b) {
|
||||
if (a < b) {
|
||||
|
||||
Reference in New Issue
Block a user