From 326e35ffaf0ee1e3d07c977217f4e600088fd9d5 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Mon, 12 Apr 2021 07:50:42 -0700 Subject: Add tag to aapt2 AAPT2 Macros are compile-time resources definitions that are expanded when referenced during the link phase. A macro must be defined in the res/values.xml directory. A macro definition for a macro named "foo" looks like the following: contents When "@macro/foo" is used in the res/values directory or in a compiled XML file, the contents of the macro replace the macro reference and then the substituted contents are compiled and linked. If the macro contents reference xml namespaces from its original definition, the namespaces of the original macro definition will be used to determine which package is being referenced. Macros can be used anywhere resources can be referenced using the @package:type/entry syntax. Macros are not included in the final resource table or the R.java since they are not actual resources. Bug: 175616308 Test: aapt2_tests Change-Id: I48b29ab6564357b32b4b4e32bff7ef06036382bc --- tools/aapt2/java/JavaClassGenerator.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tools/aapt2/java/JavaClassGenerator.cpp') diff --git a/tools/aapt2/java/JavaClassGenerator.cpp b/tools/aapt2/java/JavaClassGenerator.cpp index e1e2e0135cf7..de6524dc7027 100644 --- a/tools/aapt2/java/JavaClassGenerator.cpp +++ b/tools/aapt2/java/JavaClassGenerator.cpp @@ -616,8 +616,9 @@ bool JavaClassGenerator::Generate(const StringPiece& package_name_to_generate, for (const auto& package : table_->packages) { for (const auto& type : package->types) { - if (type->type == ResourceType::kAttrPrivate) { - // We generate these as part of the kAttr type, so skip them here. + if (type->type == ResourceType::kAttrPrivate || type->type == ResourceType::kMacro) { + // We generate kAttrPrivate as part of the kAttr type, so skip them here. + // Macros are not actual resources, so skip them as well. continue; } -- cgit v1.2.3