Remove apk-codegen.xml
process_resources.py already implements almost everything from apk-codegen.xml so just use that instead. BUG=359249,375324,375431 Review URL: https://codereview.chromium.org/295473002 git-svn-id: http://src.chromium.org/svn/trunk/src/build@272783 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
Родитель
9e92697803
Коммит
5dddf7b2a6
|
@ -1,98 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2005-2008 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<project default="-code-gen">
|
||||
<property name="verbose" value="false" />
|
||||
|
||||
<property name="out.dir" location="${OUT_DIR}" />
|
||||
<property name="out.absolute.dir" location="${out.dir}" />
|
||||
<property name="out.res.absolute.dir" location="${out.dir}/res" />
|
||||
<property name="gen.absolute.dir" value="${out.dir}/gen"/>
|
||||
|
||||
<!-- tools location -->
|
||||
<property name="sdk.dir" location="${ANDROID_SDK_ROOT}"/>
|
||||
<property name="android.sdk.tools.dir" location="${ANDROID_SDK_TOOLS}" />
|
||||
<property name="aapt" location="${android.sdk.tools.dir}/aapt" />
|
||||
<property name="project.target.android.jar" location="${ANDROID_SDK_JAR}" />
|
||||
|
||||
<!-- jar file from where the tasks are loaded -->
|
||||
<path id="android.antlibs">
|
||||
<pathelement path="${sdk.dir}/tools/lib/ant-tasks.jar" />
|
||||
</path>
|
||||
|
||||
<!-- Custom tasks -->
|
||||
<taskdef resource="anttasks.properties" classpathref="android.antlibs" />
|
||||
|
||||
<!--
|
||||
Include additional resource folders in the apk, e.g. content/.../res. We
|
||||
list the res folders in project.library.res.folder.path and the
|
||||
corresponding java packages in project.library.packages, which must be
|
||||
semicolon-delimited while ADDITIONAL_RES_PACKAGES is space-delimited, hence
|
||||
the replacestring filterchain task.
|
||||
-->
|
||||
<path id="project.library.res.folder.path">
|
||||
<filelist files="${ADDITIONAL_RES_DIRS}"/>
|
||||
</path>
|
||||
<path id="project.library.bin.r.file.path">
|
||||
<filelist files="${ADDITIONAL_R_TEXT_FILES}"/>
|
||||
</path>
|
||||
|
||||
<loadresource property="project.library.packages">
|
||||
<propertyresource name="ADDITIONAL_RES_PACKAGES"/>
|
||||
<filterchain>
|
||||
<replacestring from=" " to=";"/>
|
||||
</filterchain>
|
||||
</loadresource>
|
||||
<!-- Set to empty if not set by the loadresource above -->
|
||||
<property name="project.library.packages" value=""/>
|
||||
|
||||
<property name="resource.absolute.dir" value="${RESOURCE_DIR}"/>
|
||||
|
||||
<property name="manifest.file" value="${ANDROID_MANIFEST}" />
|
||||
<property name="manifest.abs.file" location="${manifest.file}" />
|
||||
|
||||
<!-- Intermediate files -->
|
||||
<property name="resource.package.file.name" value="${APK_NAME}.ap_" />
|
||||
|
||||
<property name="aapt.ignore.assets" value="" />
|
||||
|
||||
<!-- Code Generation: compile resources (aapt -> R.java), aidl -->
|
||||
<target name="-code-gen">
|
||||
<mkdir dir="${out.absolute.dir}" />
|
||||
<mkdir dir="${out.res.absolute.dir}" />
|
||||
<mkdir dir="${gen.absolute.dir}" />
|
||||
|
||||
<aapt executable="${aapt}"
|
||||
command="package"
|
||||
verbose="${verbose}"
|
||||
manifest="${manifest.abs.file}"
|
||||
androidjar="${project.target.android.jar}"
|
||||
rfolder="${gen.absolute.dir}"
|
||||
nonConstantId="false"
|
||||
libraryResFolderPathRefid="project.library.res.folder.path"
|
||||
libraryPackagesRefid="project.library.packages"
|
||||
libraryRFileRefid="project.library.bin.r.file.path"
|
||||
ignoreAssets="${aapt.ignore.assets}"
|
||||
binFolder="${out.absolute.dir}"
|
||||
proguardFile="${out.absolute.dir}/proguard.txt">
|
||||
<res path="${out.res.absolute.dir}" />
|
||||
<res path="${resource.absolute.dir}" />
|
||||
</aapt>
|
||||
|
||||
<touch file="${STAMP}" />
|
||||
</target>
|
||||
</project>
|
|
@ -51,20 +51,6 @@
|
|||
<property name="version.code" value="${APP_MANIFEST_VERSION_CODE}"/>
|
||||
<property name="version.name" value="${APP_MANIFEST_VERSION_NAME}"/>
|
||||
|
||||
<property name="aapt.resource.filter" value="" />
|
||||
<!-- 'aapt.ignore.assets' is the list of file patterns to ignore under /res and /assets.
|
||||
Default is "!.svn:!.git:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~"
|
||||
|
||||
Overall patterns syntax is:
|
||||
[!][<dir>|<file>][*suffix-match|prefix-match*|full-match]:more:patterns...
|
||||
|
||||
- The first character flag ! avoids printing a warning.
|
||||
- Pattern can have the flag "<dir>" to match only directories
|
||||
or "<file>" to match only files. Default is to match both.
|
||||
- Match is not case-sensitive.
|
||||
-->
|
||||
<property name="aapt.ignore.assets" value="" />
|
||||
|
||||
<!--
|
||||
Include additional resource folders in the apk, e.g. content/.../res. We
|
||||
list the res folders in project.library.res.folder.path and the
|
||||
|
@ -96,19 +82,7 @@
|
|||
<!-- Intermediate files -->
|
||||
<property name="resource.package.file.name" value="${APK_NAME}.ap_" />
|
||||
|
||||
<target name="-crunch">
|
||||
<!-- Updates the pre-processed PNG cache -->
|
||||
<exec executable="${aapt}" taskName="crunch">
|
||||
<arg value="crunch" />
|
||||
<arg value="-v" />
|
||||
<arg value="-S" />
|
||||
<arg path="${resource.absolute.dir}" />
|
||||
<arg value="-C" />
|
||||
<arg path="${out.res.absolute.dir}" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="-package-resources" depends="-crunch">
|
||||
<target name="-package-resources">
|
||||
<aapt
|
||||
executable="${aapt}"
|
||||
command="package"
|
||||
|
@ -121,13 +95,13 @@
|
|||
apkfolder="${out.absolute.dir}"
|
||||
nocrunch="${build.packaging.nocrunch}"
|
||||
resourcefilename="${resource.package.file.name}"
|
||||
resourcefilter="${aapt.resource.filter}"
|
||||
resourcefilter=""
|
||||
libraryResFolderPathRefid="project.library.res.folder.path"
|
||||
libraryPackagesRefid="project.library.packages"
|
||||
libraryRFileRefid="project.library.bin.r.file.path"
|
||||
previousBuildType=""
|
||||
buildType="${build.target}"
|
||||
ignoreAssets="${aapt.ignore.assets}">
|
||||
ignoreAssets="">
|
||||
<res path="${out.res.absolute.dir}" />
|
||||
<res path="${resource.absolute.dir}" />
|
||||
<!-- <nocompress /> forces no compression on any files in assets or res/raw -->
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
import optparse
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
import shutil
|
||||
|
||||
|
@ -24,10 +25,10 @@ def ParseArgs():
|
|||
parser.add_option('--android-sdk-tools',
|
||||
help='path to the Android SDK build tools folder')
|
||||
parser.add_option('--R-dir', help='directory to hold generated R.java')
|
||||
parser.add_option('--res-dirs',
|
||||
parser.add_option('--dependencies-res-dirs',
|
||||
help='directories containing resources to be packaged')
|
||||
parser.add_option('--crunch-input-dir',
|
||||
help='directory containing images to be crunched')
|
||||
parser.add_option('--resource-dir',
|
||||
help='directory containing this target\'s resources.')
|
||||
parser.add_option('--crunch-output-dir',
|
||||
help='directory to hold crunched resources')
|
||||
parser.add_option('--non-constant-id', action='store_true')
|
||||
|
@ -35,19 +36,60 @@ def ParseArgs():
|
|||
parser.add_option('--android-manifest', help='AndroidManifest.xml path')
|
||||
parser.add_option('--stamp', help='File to touch on success')
|
||||
|
||||
parser.add_option(
|
||||
'--extra-res-packages',
|
||||
help='Additional package names to generate R.java files for')
|
||||
parser.add_option(
|
||||
'--extra-r-text-files',
|
||||
help='For each additional package, the R.txt file should contain a '
|
||||
'list of resources to be included in the R.java file in the format '
|
||||
'generated by aapt')
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if args:
|
||||
parser.error('No positional arguments should be given.')
|
||||
|
||||
# Check that required options have been provided.
|
||||
required_options = ('android_sdk', 'android_sdk_tools', 'R_dir',
|
||||
'res_dirs', 'crunch_input_dir', 'crunch_output_dir')
|
||||
required_options = (
|
||||
'android_sdk',
|
||||
'android_sdk_tools',
|
||||
'android_manifest',
|
||||
'dependencies_res_dirs',
|
||||
'resource_dir',
|
||||
'crunch_output_dir',
|
||||
'R_dir',
|
||||
)
|
||||
build_utils.CheckOptions(options, parser, required=required_options)
|
||||
|
||||
return options
|
||||
|
||||
|
||||
def CreateExtraRJavaFiles(
|
||||
r_dir, extra_packages, extra_r_text_files):
|
||||
if len(extra_packages) != len(extra_r_text_files):
|
||||
raise Exception('--extra-res-packages and --extra-r-text-files'
|
||||
'should have the same length')
|
||||
|
||||
java_files = build_utils.FindInDirectory(r_dir, "R.java")
|
||||
if len(java_files) != 1:
|
||||
return
|
||||
r_java_file = java_files[0]
|
||||
r_java_contents = open(r_java_file).read()
|
||||
|
||||
for package in extra_packages:
|
||||
package_r_java_dir = os.path.join(r_dir, *package.split('.'))
|
||||
build_utils.MakeDirectory(package_r_java_dir)
|
||||
package_r_java_path = os.path.join(package_r_java_dir, 'R.java')
|
||||
open(package_r_java_path, 'w').write(
|
||||
re.sub(r'package [.\w]*;', 'package %s;' % package, r_java_contents))
|
||||
# TODO(cjhopman): These extra package's R.java files should be filtered to
|
||||
# only contain the resources listed in their R.txt files. At this point, we
|
||||
# have already compiled those other libraries, so doing this would only
|
||||
# affect how the code in this .apk target could refer to the resources.
|
||||
|
||||
|
||||
|
||||
def MoveImagesToNonMdpiFolders(res_root):
|
||||
"""Move images from drawable-*-mdpi-* folders to drawable-* folders.
|
||||
|
||||
|
@ -95,6 +137,7 @@ def main():
|
|||
android_jar = os.path.join(options.android_sdk, 'android.jar')
|
||||
aapt = os.path.join(options.android_sdk_tools, 'aapt')
|
||||
|
||||
build_utils.DeleteDirectory(options.R_dir)
|
||||
build_utils.MakeDirectory(options.R_dir)
|
||||
|
||||
# Generate R.java. This R.java contains non-final constants and is used only
|
||||
|
@ -110,21 +153,30 @@ def main():
|
|||
'-I', android_jar,
|
||||
'--output-text-symbols', options.R_dir,
|
||||
'-J', options.R_dir]
|
||||
res_dirs = shlex.split(options.res_dirs)
|
||||
for res_dir in res_dirs:
|
||||
all_res_dirs = ([options.resource_dir]
|
||||
+ shlex.split(options.dependencies_res_dirs))
|
||||
for res_dir in all_res_dirs:
|
||||
package_command += ['-S', res_dir]
|
||||
if options.non_constant_id:
|
||||
package_command.append('--non-constant-id')
|
||||
if options.custom_package:
|
||||
package_command += ['--custom-package', options.custom_package]
|
||||
|
||||
build_utils.CheckOutput(package_command)
|
||||
|
||||
if options.extra_res_packages:
|
||||
CreateExtraRJavaFiles(
|
||||
options.R_dir,
|
||||
build_utils.ParseGypList(options.extra_res_packages),
|
||||
build_utils.ParseGypList(options.extra_r_text_files))
|
||||
|
||||
# Crunch image resources. This shrinks png files and is necessary for 9-patch
|
||||
# images to display correctly.
|
||||
build_utils.DeleteDirectory(options.crunch_output_dir)
|
||||
build_utils.MakeDirectory(options.crunch_output_dir)
|
||||
aapt_cmd = [aapt,
|
||||
'crunch',
|
||||
'-S', options.crunch_input_dir,
|
||||
'-S', options.resource_dir,
|
||||
'-C', options.crunch_output_dir]
|
||||
build_utils.CheckOutput(aapt_cmd, fail_func=DidCrunchFail)
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ def CheckOptions(options, parser, required=None):
|
|||
if not required:
|
||||
return
|
||||
for option_name in required:
|
||||
if not getattr(options, option_name):
|
||||
if getattr(options, option_name) is None:
|
||||
parser.error('--%s is required' % option_name.replace('_', '-'))
|
||||
|
||||
def WriteJson(obj, path, only_if_changed=False):
|
||||
|
|
|
@ -156,8 +156,8 @@
|
|||
'android_manifest': '<(DEPTH)/build/android/AndroidManifest.xml',
|
||||
# Include the dependencies' res dirs so that references to
|
||||
# resources in dependencies can be resolved.
|
||||
'all_res_dirs': ['<@(res_input_dirs)',
|
||||
'>@(dependencies_res_input_dirs)',],
|
||||
'dependencies_res_dirs': ['<@(res_extra_dirs)',
|
||||
'>@(dependencies_res_input_dirs)',],
|
||||
# Write the inputs list to a file, so that its mtime is updated when
|
||||
# the list of inputs changes.
|
||||
'inputs_list_file': '>|(java_resources.<(_target_name).gypcmd >@(resource_input_paths) >@(dependencies_res_files))'
|
||||
|
@ -177,8 +177,8 @@
|
|||
'--android-sdk', '<(android_sdk)',
|
||||
'--android-sdk-tools', '<(android_sdk_tools)',
|
||||
'--R-dir', '<(R_dir)',
|
||||
'--res-dirs', '>(all_res_dirs)',
|
||||
'--crunch-input-dir', '>(res_dir)',
|
||||
'--dependencies-res-dirs', '>(dependencies_res_dirs)',
|
||||
'--resource-dir', '<(res_dir)',
|
||||
'--crunch-output-dir', '<(res_crunched_dir)',
|
||||
'--android-manifest', '<(android_manifest)',
|
||||
'--non-constant-id',
|
||||
|
|
|
@ -433,8 +433,13 @@
|
|||
],
|
||||
'actions': [
|
||||
{
|
||||
'action_name': 'ant_codegen_<(_target_name)',
|
||||
'message': 'Generating R.java for <(_target_name)',
|
||||
'action_name': 'process_resources',
|
||||
'message': 'processing resources for <(_target_name)',
|
||||
'variables': {
|
||||
# Write the inputs list to a file, so that its mtime is updated when
|
||||
# the list of inputs changes.
|
||||
'inputs_list_file': '>|(apk_codegen.<(_target_name).gypcmd >@(additional_input_paths) >@(resource_input_paths))',
|
||||
},
|
||||
'conditions': [
|
||||
['is_test_apk == 1', {
|
||||
'variables': {
|
||||
|
@ -443,15 +448,9 @@
|
|||
}
|
||||
}],
|
||||
],
|
||||
'variables': {
|
||||
# Write the inputs list to a file, so that its mtime is updated when
|
||||
# the list of inputs changes.
|
||||
'inputs_list_file': '>|(apk_codegen.<(_target_name).gypcmd >@(additional_input_paths) >@(resource_input_paths))'
|
||||
},
|
||||
'inputs': [
|
||||
'<(DEPTH)/build/android/ant/apk-codegen.xml',
|
||||
'<(DEPTH)/build/android/gyp/util/build_utils.py',
|
||||
'<(DEPTH)/build/android/gyp/ant.py',
|
||||
'<(DEPTH)/build/android/gyp/process_resources.py',
|
||||
'<(android_manifest_path)',
|
||||
'>@(additional_input_paths)',
|
||||
'>@(resource_input_paths)',
|
||||
|
@ -461,23 +460,22 @@
|
|||
'<(codegen_stamp)',
|
||||
],
|
||||
'action': [
|
||||
'python', '<(DEPTH)/build/android/gyp/ant.py',
|
||||
'-quiet',
|
||||
'-DADDITIONAL_RES_DIRS=>(additional_res_dirs)',
|
||||
'-DADDITIONAL_RES_PACKAGES=>(additional_res_packages)',
|
||||
'-DADDITIONAL_R_TEXT_FILES=>(additional_R_text_files)',
|
||||
'-DANDROID_MANIFEST=<(android_manifest_path)',
|
||||
'-DANDROID_SDK_JAR=<(android_sdk_jar)',
|
||||
'-DANDROID_SDK_ROOT=<(android_sdk_root)',
|
||||
'-DANDROID_SDK_VERSION=<(android_sdk_version)',
|
||||
'-DANDROID_SDK_TOOLS=<(android_sdk_tools)',
|
||||
'-DOUT_DIR=<(intermediate_dir)',
|
||||
'-DRESOURCE_DIR=<(resource_dir)',
|
||||
'python', '<(DEPTH)/build/android/gyp/process_resources.py',
|
||||
'--android-sdk', '<(android_sdk)',
|
||||
'--android-sdk-tools', '<(android_sdk_tools)',
|
||||
|
||||
'-DSTAMP=<(codegen_stamp)',
|
||||
'-Dbasedir=.',
|
||||
'-buildfile',
|
||||
'<(DEPTH)/build/android/ant/apk-codegen.xml',
|
||||
'--android-manifest', '<(android_manifest_path)',
|
||||
'--dependencies-res-dirs', '>(additional_res_dirs)',
|
||||
|
||||
'--extra-res-packages', '>(additional_res_packages)',
|
||||
'--extra-r-text-files', '>(additional_R_text_files)',
|
||||
|
||||
'--resource-dir', '<(resource_dir)',
|
||||
'--crunch-output-dir', '<(intermediate_dir)/res',
|
||||
|
||||
'--R-dir', '<(intermediate_dir)/gen',
|
||||
|
||||
'--stamp', '<(codegen_stamp)',
|
||||
],
|
||||
},
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче