def _ParseArgs(args): """Parses command line options. Returns: An options object as from argparse.ArgumentParser.parse_args() """ parser, input_opts, output_opts = resource_utils.ResourceArgsParser() input_opts.add_argument( '--resource-dirs', default='[]', help='A list of input directories containing resources ' 'for this target.') input_opts.add_argument( '--shared-resources', action='store_true', help='Make resources shareable by generating an onResourcesLoaded() ' 'method in the R.java source file.') input_opts.add_argument('--custom-package', help='Optional Java package for main R.java.') input_opts.add_argument( '--android-manifest', help='Optional AndroidManifest.xml path. Only used to extract a package ' 'name for R.java if a --custom-package is not provided.') output_opts.add_argument( '--resource-zip-out', help='Path to a zip archive containing all resources from ' '--resource-dirs, merged into a single directory tree. This will ' 'also include auto-generated v14-compatible resources unless ' '--v14-skip is used.') output_opts.add_argument( '--srcjar-out', help='Path to .srcjar to contain the generated R.java.') output_opts.add_argument('--r-text-out', help='Path to store the generated R.txt file.') input_opts.add_argument('--v14-skip', action="store_true", help='Do not generate nor verify v14 resources.') input_opts.add_argument('--strip-drawables', action="store_true", help='Remove drawables from the resources.') options = parser.parse_args(args) resource_utils.HandleCommonOptions(options) options.resource_dirs = build_utils.ParseGnList(options.resource_dirs) return options
def _ParseArgs(args): """Parses command line options. Returns: An options object as from argparse.ArgumentParser.parse_args() """ parser, input_opts, output_opts = resource_utils.ResourceArgsParser() input_opts.add_argument('--aapt-path', required=True, help='Path to the Android aapt tool') input_opts.add_argument( '--res-sources-path', required=True, help='Path to a list of input resources for this target.') input_opts.add_argument( '--shared-resources', action='store_true', help='Make resources shareable by generating an onResourcesLoaded() ' 'method in the R.java source file.') input_opts.add_argument('--custom-package', help='Optional Java package for main R.java.') input_opts.add_argument( '--android-manifest', help='Optional AndroidManifest.xml path. Only used to extract a package ' 'name for R.java if a --custom-package is not provided.') output_opts.add_argument( '--resource-zip-out', help='Path to a zip archive containing all resources from ' '--resource-dirs, merged into a single directory tree.') output_opts.add_argument( '--srcjar-out', help='Path to .srcjar to contain the generated R.java.') output_opts.add_argument('--r-text-out', help='Path to store the generated R.txt file.') input_opts.add_argument('--strip-drawables', action="store_true", help='Remove drawables from the resources.') options = parser.parse_args(args) resource_utils.HandleCommonOptions(options) with open(options.res_sources_path) as f: options.sources = [line.strip() for line in f.readlines()] options.resource_dirs = resource_utils.ExtractResourceDirsFromFileList( options.sources) return options
def _ParseArgs(args): """Parses command line options. Returns: An options object as from argparse.ArgumentParser.parse_args() """ parser, input_opts, output_opts = resource_utils.ResourceArgsParser() input_opts.add_argument('--aapt2-path', required=True, help='Path to the Android aapt2 tool.') input_opts.add_argument('--android-manifest', required=True, help='AndroidManifest.xml path.') input_opts.add_argument('--android-manifest-expected', help='Expected contents for the final manifest.') input_opts.add_argument('--android-manifest-normalized', help='Normalized manifest.') input_opts.add_argument( '--android-manifest-expectations-failure-file', help='Write to this file if expected manifest contents do not match ' 'final manifest contents.') input_opts.add_argument( '--r-java-root-package-name', default='base', help='Short package name for this target\'s root R java file (ex. ' 'input of "base" would become gen.base_module). Defaults to "base".') group = input_opts.add_mutually_exclusive_group() group.add_argument( '--shared-resources', action='store_true', help='Make all resources in R.java non-final and allow the resource IDs ' 'to be reset to a different package index when the apk is loaded by ' 'another application at runtime.') group.add_argument( '--app-as-shared-lib', action='store_true', help='Same as --shared-resources, but also ensures all resource IDs are ' 'directly usable from the APK loaded as an application.') input_opts.add_argument( '--package-id', type=int, help='Decimal integer representing custom package ID for resources ' '(instead of 127==0x7f). Cannot be used with --shared-resources.') input_opts.add_argument( '--package-name', help='Package name that will be used to create R class.') input_opts.add_argument('--rename-manifest-package', help='Package name to force AAPT to use.') input_opts.add_argument( '--arsc-package-name', help='Package name to set in manifest of resources.arsc file. This is ' 'only used for apks under test.') input_opts.add_argument( '--shared-resources-whitelist', help='An R.txt file acting as a whitelist for resources that should be ' 'non-final and have their package ID changed at runtime in R.java. ' 'Implies and overrides --shared-resources.') input_opts.add_argument( '--shared-resources-whitelist-locales', default='[]', help= 'Optional GN-list of locales. If provided, all strings corresponding' ' to this locale list will be kept in the final output for the ' 'resources identified through --shared-resources-whitelist, even ' 'if --locale-whitelist is being used.') input_opts.add_argument( '--use-resource-ids-path', help='Use resource IDs generated by aapt --emit-ids.') input_opts.add_argument( '--extra-main-r-text-files', help= 'Additional R.txt files that will be added to the root R.java file, ' 'but not packaged in the generated resources.arsc. If these resources ' 'entries contain duplicate resources with the generated R.txt file, they ' 'must be identical.') input_opts.add_argument('--support-zh-hk', action='store_true', help='Use zh-rTW resources for zh-rHK.') input_opts.add_argument('--debuggable', action='store_true', help='Whether to add android:debuggable="true".') input_opts.add_argument('--version-code', help='Version code for apk.') input_opts.add_argument('--version-name', help='Version name for apk.') input_opts.add_argument('--min-sdk-version', required=True, help='android:minSdkVersion for APK.') input_opts.add_argument('--target-sdk-version', required=True, help="android:targetSdkVersion for APK.") input_opts.add_argument( '--max-sdk-version', help="android:maxSdkVersion expected in AndroidManifest.xml.") input_opts.add_argument('--manifest-package', help='Package name of the AndroidManifest.xml.') input_opts.add_argument( '--locale-whitelist', default='[]', help='GN list of languages to include. All other language configs will ' 'be stripped out. List may include a combination of Android locales ' 'or Chrome locales.') input_opts.add_argument('--resource-blacklist-regex', default='', help='Do not include matching drawables.') input_opts.add_argument( '--resource-blacklist-exceptions', default='[]', help= 'GN list of globs that say which blacklisted images to include even ' 'when --resource-blacklist-regex is set.') input_opts.add_argument('--png-to-webp', action='store_true', help='Convert png files to webp format.') input_opts.add_argument('--webp-binary', default='', help='Path to the cwebp binary.') input_opts.add_argument( '--no-xml-namespaces', action='store_true', help='Whether to strip xml namespaces from processed xml resources.') input_opts.add_argument( '--short-resource-paths', action='store_true', help='Whether to shorten resource paths inside the apk or module.') input_opts.add_argument( '--strip-resource-names', action='store_true', help= 'Whether to strip resource names from the resource table of the apk ' 'or module.') output_opts.add_argument('--arsc-path', help='Apk output for arsc format.') output_opts.add_argument('--proto-path', help='Apk output for proto format.') group = input_opts.add_mutually_exclusive_group() group.add_argument( '--optimized-arsc-path', help='Output for `aapt2 optimize` for arsc format (enables the step).') group.add_argument( '--optimized-proto-path', help='Output for `aapt2 optimize` for proto format (enables the step).' ) input_opts.add_argument('--resources-config-path', help='Path to aapt2 resources config file.') output_opts.add_argument( '--info-path', help='Path to output info file for the partial apk.') output_opts.add_argument( '--srcjar-out', required=True, help='Path to srcjar to contain generated R.java.') output_opts.add_argument('--r-text-out', help='Path to store the generated R.txt file.') output_opts.add_argument('--proguard-file', help='Path to proguard.txt generated file.') output_opts.add_argument( '--proguard-file-main-dex', help='Path to proguard.txt generated file for main dex.') output_opts.add_argument('--emit-ids-out', help='Path to file produced by aapt2 --emit-ids.') output_opts.add_argument( '--resources-path-map-out-path', help='Path to file produced by aapt2 that maps original resource paths ' 'to shortened resource paths inside the apk or module.') options = parser.parse_args(args) resource_utils.HandleCommonOptions(options) options.locale_whitelist = build_utils.ParseGnList( options.locale_whitelist) options.shared_resources_whitelist_locales = build_utils.ParseGnList( options.shared_resources_whitelist_locales) options.resource_blacklist_exceptions = build_utils.ParseGnList( options.resource_blacklist_exceptions) options.extra_main_r_text_files = build_utils.ParseGnList( options.extra_main_r_text_files) if options.optimized_proto_path and not options.proto_path: # We could write to a temp file, but it's simpler to require it. parser.error('--optimized-proto-path requires --proto-path') if not options.arsc_path and not options.proto_path: parser.error('One of --arsc-path or --proto-path is required.') if options.resources_path_map_out_path and not options.short_resource_paths: parser.error( '--resources-path-map-out-path requires --short-resource-paths') if options.package_id and options.shared_resources: parser.error( '--package-id and --shared-resources are mutually exclusive') return options
def _ParseArgs(args): """Parses command line options. Returns: An options object as from argparse.ArgumentParser.parse_args() """ parser, input_opts, output_opts = resource_utils.ResourceArgsParser() input_opts.add_argument('--aapt2-path', required=True, help='Path to the Android aapt2 tool.') input_opts.add_argument('--android-manifest', required=True, help='AndroidManifest.xml path.') input_opts.add_argument( '--r-java-root-package-name', default='base', help='Short package name for this target\'s root R java file (ex. ' 'input of "base" would become gen.base_module). Defaults to "base".') group = input_opts.add_mutually_exclusive_group() group.add_argument( '--shared-resources', action='store_true', help='Make all resources in R.java non-final and allow the resource IDs ' 'to be reset to a different package index when the apk is loaded by ' 'another application at runtime.') group.add_argument( '--app-as-shared-lib', action='store_true', help='Same as --shared-resources, but also ensures all resource IDs are ' 'directly usable from the APK loaded as an application.') input_opts.add_argument( '--package-id', type=int, help='Decimal integer representing custom package ID for resources ' '(instead of 127==0x7f). Cannot be used with --shared-resources.') input_opts.add_argument( '--package-name', help='Package name that will be used to create R class.') input_opts.add_argument('--rename-manifest-package', help='Package name to force AAPT to use.') input_opts.add_argument( '--arsc-package-name', help='Package name to set in manifest of resources.arsc file. This is ' 'only used for apks under test.') input_opts.add_argument( '--shared-resources-allowlist', help='An R.txt file acting as a allowlist for resources that should be ' 'non-final and have their package ID changed at runtime in R.java. ' 'Implies and overrides --shared-resources.') input_opts.add_argument( '--shared-resources-allowlist-locales', default='[]', help= 'Optional GN-list of locales. If provided, all strings corresponding' ' to this locale list will be kept in the final output for the ' 'resources identified through --shared-resources-allowlist, even ' 'if --locale-allowlist is being used.') input_opts.add_argument( '--use-resource-ids-path', help='Use resource IDs generated by aapt --emit-ids.') input_opts.add_argument( '--extra-main-r-text-files', help= 'Additional R.txt files that will be added to the root R.java file, ' 'but not packaged in the generated resources.arsc. If these resources ' 'entries contain duplicate resources with the generated R.txt file, they ' 'must be identical.') input_opts.add_argument('--debuggable', action='store_true', help='Whether to add android:debuggable="true".') input_opts.add_argument('--version-code', help='Version code for apk.') input_opts.add_argument('--version-name', help='Version name for apk.') input_opts.add_argument('--min-sdk-version', required=True, help='android:minSdkVersion for APK.') input_opts.add_argument('--target-sdk-version', required=True, help="android:targetSdkVersion for APK.") input_opts.add_argument( '--max-sdk-version', help="android:maxSdkVersion expected in AndroidManifest.xml.") input_opts.add_argument('--manifest-package', help='Package name of the AndroidManifest.xml.') input_opts.add_argument( '--locale-allowlist', default='[]', help='GN list of languages to include. All other language configs will ' 'be stripped out. List may include a combination of Android locales ' 'or Chrome locales.') input_opts.add_argument( '--resource-exclusion-regex', default='', help='File-based filter for resources (applied before compiling)') input_opts.add_argument( '--resource-exclusion-exceptions', default='[]', help='GN list of globs that say which files to include even ' 'when --resource-exclusion-regex is set.') input_opts.add_argument( '--dependencies-res-zip-overlays', help='GN list with subset of --dependencies-res-zips to use overlay ' 'semantics for.') input_opts.add_argument( '--values-filter-rules', help='GN list of source_glob:regex for filtering resources after they ' 'are compiled. Use this to filter out entries within values/ files.') input_opts.add_argument('--png-to-webp', action='store_true', help='Convert png files to webp format.') input_opts.add_argument('--webp-binary', default='', help='Path to the cwebp binary.') input_opts.add_argument('--webp-cache-dir', help='The directory to store webp image cache.') input_opts.add_argument( '--no-xml-namespaces', action='store_true', help='Whether to strip xml namespaces from processed xml resources.') output_opts.add_argument('--arsc-path', help='Apk output for arsc format.') output_opts.add_argument('--proto-path', help='Apk output for proto format.') group = input_opts.add_mutually_exclusive_group() output_opts.add_argument( '--info-path', help='Path to output info file for the partial apk.') output_opts.add_argument( '--srcjar-out', required=True, help='Path to srcjar to contain generated R.java.') output_opts.add_argument('--r-text-out', help='Path to store the generated R.txt file.') output_opts.add_argument('--proguard-file', help='Path to proguard.txt generated file.') output_opts.add_argument( '--proguard-file-main-dex', help='Path to proguard.txt generated file for main dex.') output_opts.add_argument('--emit-ids-out', help='Path to file produced by aapt2 --emit-ids.') input_opts.add_argument( '--is-bundle-module', action='store_true', help='Whether resources are being generated for a bundle module.') input_opts.add_argument( '--uses-split', help='Value to set uses-split to in the AndroidManifest.xml.') input_opts.add_argument( '--extra-verification-manifest', help='Path to AndroidManifest.xml which should be merged into base ' 'manifest when performing verification.') diff_utils.AddCommandLineFlags(parser) options = parser.parse_args(args) resource_utils.HandleCommonOptions(options) options.locale_allowlist = build_utils.ParseGnList( options.locale_allowlist) options.shared_resources_allowlist_locales = build_utils.ParseGnList( options.shared_resources_allowlist_locales) options.resource_exclusion_exceptions = build_utils.ParseGnList( options.resource_exclusion_exceptions) options.dependencies_res_zip_overlays = build_utils.ParseGnList( options.dependencies_res_zip_overlays) options.values_filter_rules = build_utils.ParseGnList( options.values_filter_rules) options.extra_main_r_text_files = build_utils.ParseGnList( options.extra_main_r_text_files) if not options.arsc_path and not options.proto_path: parser.error('One of --arsc-path or --proto-path is required.') if options.package_id and options.shared_resources: parser.error( '--package-id and --shared-resources are mutually exclusive') return options
def _ParseArgs(args): """Parses command line options. Returns: An options object as from argparse.ArgumentParser.parse_args() """ parser, input_opts, output_opts = resource_utils.ResourceArgsParser() input_opts.add_argument('--android-manifest', required=True, help='AndroidManifest.xml path') input_opts.add_argument( '--shared-resources', action='store_true', help='Make all resources in R.java non-final and allow the resource IDs ' 'to be reset to a different package index when the apk is loaded by ' 'another application at runtime.') input_opts.add_argument( '--app-as-shared-lib', action='store_true', help='Same as --shared-resources, but also ensures all resource IDs are ' 'directly usable from the APK loaded as an application.') input_opts.add_argument( '--shared-resources-whitelist', help='An R.txt file acting as a whitelist for resources that should be ' 'non-final and have their package ID changed at runtime in R.java. ' 'Implies and overrides --shared-resources.') input_opts.add_argument( '--shared-resources-whitelist-locales', default='[]', help= 'Optional GN-list of locales. If provided, all strings corresponding' ' to this locale list will be kept in the final output for the ' 'resources identified through --shared-resources-whitelist, even ' 'if --locale-whitelist is being used.') input_opts.add_argument( '--use-resource-ids-path', help='Use resource IDs generated by aapt --emit-ids') input_opts.add_argument( '--proto-format', action='store_true', help='Compile resources to protocol buffer format.') input_opts.add_argument('--support-zh-hk', action='store_true', help='Use zh-rTW resources for zh-rHK.') input_opts.add_argument('--debuggable', action='store_true', help='Whether to add android:debuggable="true"') input_opts.add_argument('--version-code', help='Version code for apk.') input_opts.add_argument('--version-name', help='Version name for apk.') input_opts.add_argument( '--no-compress', help='disables compression for the given comma-separated list of ' 'extensions') input_opts.add_argument( '--locale-whitelist', default='[]', help='GN list of languages to include. All other language configs will ' 'be stripped out. List may include a combination of Android locales ' 'or Chrome locales.') input_opts.add_argument('--resource-blacklist-regex', default='', help='Do not include matching drawables.') input_opts.add_argument( '--resource-blacklist-exceptions', default='[]', help= 'GN list of globs that say which blacklisted images to include even ' 'when --resource-blacklist-regex is set.') input_opts.add_argument('--png-to-webp', action='store_true', help='Convert png files to webp format.') input_opts.add_argument('--webp-binary', default='', help='Path to the cwebp binary.') input_opts.add_argument( '--no-xml-namespaces', action='store_true', help='Whether to strip xml namespaces from processed ' 'xml resources') input_opts.add_argument('--resources-config-path', help='Path to aapt2 resources config file.') input_opts.add_argument( '--optimize-resources', default=False, action='store_true', help='Whether to run the `aapt2 optimize` step on the resources.') input_opts.add_argument( '--unoptimized-resources-path', help='Path to output the intermediate apk before running ' '`aapt2 optimize`.') input_opts.add_argument( '--check-resources-pkg-id', type=_PackageIdArgument, help='Check the package ID of the generated resources table. ' 'Value must be integer in [0..127] range.') output_opts.add_argument('--apk-path', required=True, help='Path to output (partial) apk.') output_opts.add_argument( '--apk-info-path', required=True, help='Path to output info file for the partial apk.') output_opts.add_argument( '--srcjar-out', help='Path to srcjar to contain generated R.java.') output_opts.add_argument('--r-text-out', help='Path to store the generated R.txt file.') output_opts.add_argument('--proguard-file', help='Path to proguard.txt generated file') output_opts.add_argument( '--proguard-file-main-dex', help='Path to proguard.txt generated file for main dex') output_opts.add_argument( '--emit-ids-out', help= 'Path to file produced by aapt2 --emit-ids (for use with --stable-ids)' ) options = parser.parse_args(args) resource_utils.HandleCommonOptions(options) options.locale_whitelist = build_utils.ParseGnList( options.locale_whitelist) options.shared_resources_whitelist_locales = build_utils.ParseGnList( options.shared_resources_whitelist_locales) options.resource_blacklist_exceptions = build_utils.ParseGnList( options.resource_blacklist_exceptions) if options.check_resources_pkg_id is not None: if options.check_resources_pkg_id < 0: raise Exception( 'Package resource id should be integer in [0..127] range.') if options.shared_resources and options.app_as_shared_lib: raise Exception( 'Only one of --app-as-shared-lib or --shared-resources ' 'can be used.') if options.package_name_to_id_mapping: package_names_list = build_utils.ParseGnList( options.package_name_to_id_mapping) options.package_name_to_id_mapping = _ListToDictionary( package_names_list, '=') return options
def _ParseArgs(args): """Parses command line options. Returns: An options object as from argparse.ArgumentParser.parse_args() """ parser, input_opts, output_opts = resource_utils.ResourceArgsParser() input_opts.add_argument('--android-manifest', required=True, help='AndroidManifest.xml path') input_opts.add_argument( '--shared-resources', action='store_true', help='Make all resources in R.java non-final and allow the resource IDs ' 'to be reset to a different package index when the apk is loaded by ' 'another application at runtime.') input_opts.add_argument( '--app-as-shared-lib', action='store_true', help='Same as --shared-resources, but also ensures all resource IDs are ' 'directly usable from the APK loaded as an application.') input_opts.add_argument( '--shared-resources-whitelist', help='An R.txt file acting as a whitelist for resources that should be ' 'non-final and have their package ID changed at runtime in R.java. ' 'Implies and overrides --shared-resources.') input_opts.add_argument('--support-zh-hk', action='store_true', help='Use zh-rTW resources for zh-rHK.') input_opts.add_argument('--debuggable', action='store_true', help='Whether to add android:debuggable="true"') input_opts.add_argument('--version-code', help='Version code for apk.') input_opts.add_argument('--version-name', help='Version name for apk.') input_opts.add_argument( '--no-compress', help='disables compression for the given comma-separated list of ' 'extensions') input_opts.add_argument( '--locale-whitelist', default='[]', help='GN list of languages to include. All other language configs will ' 'be stripped out. List may include a combination of Android locales ' 'or Chrome locales.') input_opts.add_argument('--exclude-xxxhdpi', action='store_true', help='Do not include xxxhdpi drawables.') input_opts.add_argument( '--xxxhdpi-whitelist', default='[]', help='GN list of globs that say which xxxhdpi images to include even ' 'when --exclude-xxxhdpi is set.') input_opts.add_argument('--png-to-webp', action='store_true', help='Convert png files to webp format.') input_opts.add_argument('--webp-binary', default='', help='Path to the cwebp binary.') input_opts.add_argument( '--no-xml-namespaces', action='store_true', help='Whether to strip xml namespaces from processed ' 'xml resources') input_opts.add_argument( '--check-resources-pkg-id', type=_PackageIdArgument, help='Check the package ID of the generated resources table. ' 'Value must be integer in [0..127] range.') output_opts.add_argument('--apk-path', required=True, help='Path to output (partial) apk.') output_opts.add_argument( '--apk-info-path', required=True, help='Path to output info file for the partial apk.') output_opts.add_argument( '--srcjar-out', help='Path to srcjar to contain generated R.java.') output_opts.add_argument('--r-text-out', help='Path to store the generated R.txt file.') output_opts.add_argument('--proguard-file', help='Path to proguard.txt generated file') output_opts.add_argument( '--proguard-file-main-dex', help='Path to proguard.txt generated file for main dex') options = parser.parse_args(args) resource_utils.HandleCommonOptions(options) options.locale_whitelist = build_utils.ParseGnList( options.locale_whitelist) options.xxxhdpi_whitelist = build_utils.ParseGnList( options.xxxhdpi_whitelist) if options.check_resources_pkg_id is not None: if options.check_resources_pkg_id < 0: raise Exception( 'Package resource id should be integer in [0..127] range.') if options.shared_resources and options.app_as_shared_lib: raise Exception( 'Only one of --app-as-shared-lib or --shared-resources ' 'can be used.') return options
def _ParseArgs(args): """Parses command line options. Returns: An options object as from argparse.ArgumentParser.parse_args() """ parser, input_opts, output_opts = resource_utils.ResourceArgsParser() input_opts.add_argument('--aapt2-path', required=True, help='Path to the Android aapt2 tool.') input_opts.add_argument('--android-manifest', required=True, help='AndroidManifest.xml path.') group = input_opts.add_mutually_exclusive_group() group.add_argument( '--shared-resources', action='store_true', help='Make all resources in R.java non-final and allow the resource IDs ' 'to be reset to a different package index when the apk is loaded by ' 'another application at runtime.') group.add_argument( '--app-as-shared-lib', action='store_true', help='Same as --shared-resources, but also ensures all resource IDs are ' 'directly usable from the APK loaded as an application.') input_opts.add_argument( '--package-id', help='Custom package ID for resources (instead of 0x7f). Cannot be used ' 'with --shared-resources.') input_opts.add_argument( '--package-name-to-id-mapping', help= 'List containing mapping from package name to package IDs that will ' 'be assigned.') input_opts.add_argument( '--package-name', help='Package name that will be used to determine package ID.') input_opts.add_argument( '--arsc-package-name', help='Package name to use for resources.arsc file.') input_opts.add_argument( '--shared-resources-whitelist', help='An R.txt file acting as a whitelist for resources that should be ' 'non-final and have their package ID changed at runtime in R.java. ' 'Implies and overrides --shared-resources.') input_opts.add_argument( '--shared-resources-whitelist-locales', default='[]', help= 'Optional GN-list of locales. If provided, all strings corresponding' ' to this locale list will be kept in the final output for the ' 'resources identified through --shared-resources-whitelist, even ' 'if --locale-whitelist is being used.') input_opts.add_argument( '--use-resource-ids-path', help='Use resource IDs generated by aapt --emit-ids.') input_opts.add_argument('--support-zh-hk', action='store_true', help='Use zh-rTW resources for zh-rHK.') input_opts.add_argument('--debuggable', action='store_true', help='Whether to add android:debuggable="true".') input_opts.add_argument('--version-code', help='Version code for apk.') input_opts.add_argument('--version-name', help='Version name for apk.') input_opts.add_argument( '--locale-whitelist', default='[]', help='GN list of languages to include. All other language configs will ' 'be stripped out. List may include a combination of Android locales ' 'or Chrome locales.') input_opts.add_argument('--resource-blacklist-regex', default='', help='Do not include matching drawables.') input_opts.add_argument( '--resource-blacklist-exceptions', default='[]', help= 'GN list of globs that say which blacklisted images to include even ' 'when --resource-blacklist-regex is set.') input_opts.add_argument('--png-to-webp', action='store_true', help='Convert png files to webp format.') input_opts.add_argument('--webp-binary', default='', help='Path to the cwebp binary.') input_opts.add_argument( '--no-xml-namespaces', action='store_true', help='Whether to strip xml namespaces from processed xml resources.') output_opts.add_argument('--arsc-path', help='Apk output for arsc format.') output_opts.add_argument('--proto-path', help='Apk output for proto format.') group = input_opts.add_mutually_exclusive_group() group.add_argument( '--optimized-arsc-path', help='Output for `aapt2 optimize` for arsc format (enables the step).') group.add_argument( '--optimized-proto-path', help='Output for `aapt2 optimize` for proto format (enables the step).' ) input_opts.add_argument('--resources-config-path', help='Path to aapt2 resources config file.') output_opts.add_argument( '--info-path', help='Path to output info file for the partial apk.') output_opts.add_argument( '--srcjar-out', help='Path to srcjar to contain generated R.java.') output_opts.add_argument('--r-text-out', help='Path to store the generated R.txt file.') output_opts.add_argument('--proguard-file', help='Path to proguard.txt generated file.') output_opts.add_argument( '--proguard-file-main-dex', help='Path to proguard.txt generated file for main dex.') output_opts.add_argument('--emit-ids-out', help='Path to file produced by aapt2 --emit-ids.') options = parser.parse_args(args) resource_utils.HandleCommonOptions(options) options.locale_whitelist = build_utils.ParseGnList( options.locale_whitelist) options.shared_resources_whitelist_locales = build_utils.ParseGnList( options.shared_resources_whitelist_locales) options.resource_blacklist_exceptions = build_utils.ParseGnList( options.resource_blacklist_exceptions) if options.optimized_proto_path and not options.proto_path: # We could write to a temp file, but it's simpler to require it. parser.error('--optimized-proto-path requires --proto-path') if not options.arsc_path and not options.proto_path: parser.error('One of --arsc-path or --proto-path is required.') if options.package_name_to_id_mapping: package_names_list = build_utils.ParseGnList( options.package_name_to_id_mapping) options.package_name_to_id_mapping = _ListToDictionary( package_names_list, '=') return options