AAPT2: Process <java-symbols> and private symbol package
Need to introduce the idea of multiple levels of visibility to support <java-symbol>.
Public, Private, Undefined.
Public means it is accessible from outside and requires an ID assigned.
Private means that we explicitly want this to be a symbol (show up in R.java), but not visible
to other packages. No ID required.
Undefined is any normal resource. When --private-symbols is specified in the link phase,
these resources will not show up in R.java.
Change-Id: Icba89221e08e685dee7683786aa7112baf28c856
diff --git a/tools/aapt2/ResourceTable.h b/tools/aapt2/ResourceTable.h
index 60fed2f..be90936 100644
--- a/tools/aapt2/ResourceTable.h
+++ b/tools/aapt2/ResourceTable.h
@@ -31,11 +31,17 @@
namespace aapt {
+enum class SymbolState {
+ kUndefined,
+ kPublic,
+ kPrivate
+};
+
/**
* The Public status of a resource.
*/
-struct Public {
- bool isPublic = false;
+struct Symbol {
+ SymbolState state = SymbolState::kUndefined;
Source source;
std::u16string comment;
};
@@ -71,7 +77,7 @@
* Whether this resource is public (and must maintain the same
* entry ID across builds).
*/
- Public publicStatus;
+ Symbol symbolStatus;
/**
* The resource's values for each configuration.
@@ -100,7 +106,7 @@
* Whether this type is public (and must maintain the same
* type ID across builds).
*/
- Public publicStatus;
+ Symbol symbolStatus;
/**
* List of resources for this type.
@@ -171,10 +177,15 @@
const Source& source, std::unique_ptr<Value> value,
IDiagnostics* diag);
- bool markPublic(const ResourceNameRef& name, const ResourceId resId, const Source& source,
- IDiagnostics* diag);
- bool markPublicAllowMangled(const ResourceNameRef& name, const ResourceId resId,
- const Source& source, IDiagnostics* diag);
+ bool addResourceAllowMangled(const ResourceNameRef& name, const ResourceId id,
+ const ConfigDescription& config,
+ const Source& source, std::unique_ptr<Value> value,
+ IDiagnostics* diag);
+
+ bool setSymbolState(const ResourceNameRef& name, const ResourceId resId, const Source& source,
+ SymbolState state, IDiagnostics* diag);
+ bool setSymbolStateAllowMangled(const ResourceNameRef& name, const ResourceId resId,
+ const Source& source, SymbolState state, IDiagnostics* diag);
struct SearchResult {
ResourceTablePackage* package;
ResourceTableType* type;
@@ -217,8 +228,9 @@
const ConfigDescription& config, const Source& source,
std::unique_ptr<Value> value, const char16_t* validChars,
IDiagnostics* diag);
- bool markPublicImpl(const ResourceNameRef& name, const ResourceId resId,
- const Source& source, const char16_t* validChars, IDiagnostics* diag);
+ bool setSymbolStateImpl(const ResourceNameRef& name, const ResourceId resId,
+ const Source& source, SymbolState state, const char16_t* validChars,
+ IDiagnostics* diag);
};
} // namespace aapt