diff options
Diffstat (limited to 'tools/aapt2/configuration/ConfigurationParser.h')
-rw-r--r-- | tools/aapt2/configuration/ConfigurationParser.h | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/tools/aapt2/configuration/ConfigurationParser.h b/tools/aapt2/configuration/ConfigurationParser.h index 28c355e39643..c5d3284c33f4 100644 --- a/tools/aapt2/configuration/ConfigurationParser.h +++ b/tools/aapt2/configuration/ConfigurationParser.h @@ -17,6 +17,7 @@ #ifndef AAPT2_CONFIGURATION_H #define AAPT2_CONFIGURATION_H +#include <set> #include <string> #include <unordered_map> #include <vector> @@ -33,10 +34,20 @@ namespace configuration { template<class T> using Group = std::unordered_map<std::string, std::vector<T>>; +/** A mapping of group label to a single configuration item. */ +template <class T> +using Entry = std::unordered_map<std::string, T>; + /** Output artifact configuration options. */ struct Artifact { /** Name to use for output of processing foo.apk -> foo.<name>.apk. */ - std::string name; + Maybe<std::string> name; + /** + * Value to add to the base Android manifest versionCode. If it is not present in the + * configuration file, it is set to the previous artifact + 1. If the first artifact does not have + * a value, artifacts are a 1 based index. + */ + int version; /** If present, uses the ABI group with this name. */ Maybe<std::string> abi_group; /** If present, uses the screen density group with this name. */ @@ -51,7 +62,20 @@ struct Artifact { Maybe<std::string> gl_texture_group; /** Convert an artifact name template into a name string based on configuration contents. */ - Maybe<std::string> ToArtifactName(const std::string& format, IDiagnostics* diag) const; + Maybe<std::string> ToArtifactName(const android::StringPiece& format, + const android::StringPiece& apk_name, IDiagnostics* diag) const; + + /** Convert an artifact name template into a name string based on configuration contents. */ + Maybe<std::string> Name(const android::StringPiece& apk_name, IDiagnostics* diag) const; + + bool operator<(const Artifact& rhs) const { + // TODO(safarmer): Order by play store multi-APK requirements. + return version < rhs.version; + } + + bool operator==(const Artifact& rhs) const { + return version == rhs.version; + } }; /** Enumeration of currently supported ABIs. */ @@ -95,11 +119,17 @@ struct AndroidManifest { }; struct AndroidSdk { - Maybe<std::string> min_sdk_version; - Maybe<std::string> target_sdk_version; - Maybe<std::string> max_sdk_version; + Maybe<int> min_sdk_version; + Maybe<int> target_sdk_version; + Maybe<int> max_sdk_version; Maybe<AndroidManifest> manifest; + static AndroidSdk ForMinSdk(int min_sdk) { + AndroidSdk sdk; + sdk.min_sdk_version = min_sdk; + return sdk; + } + inline friend bool operator==(const AndroidSdk& lhs, const AndroidSdk& rhs) { return lhs.min_sdk_version == rhs.min_sdk_version && lhs.target_sdk_version == rhs.target_sdk_version && @@ -129,10 +159,14 @@ struct PostProcessingConfiguration { Group<Abi> abi_groups; Group<ConfigDescription> screen_density_groups; - Group<Locale> locale_groups; - Group<AndroidSdk> android_sdk_groups; + Group<ConfigDescription> locale_groups; + Entry<AndroidSdk> android_sdk_groups; Group<DeviceFeature> device_feature_groups; Group<GlTexture> gl_texture_groups; + + /** Helper method that generates a list of artifact names and returns true on success. */ + bool AllArtifactNames(const android::StringPiece& apk_name, + std::vector<std::string>* artifact_names, IDiagnostics* diag) const; }; } // namespace configuration |