Home | History | Annotate | Download | only in build
      1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 # This file is meant to be included into a target to provide a rule
      6 # to build Android APKs in a consistent manner.
      7 #
      8 # To use this, create a gyp target with the following form:
      9 # {
     10 #   'target_name': 'my_package_apk',
     11 #   'type': 'none',
     12 #   'variables': {
     13 #     'apk_name': 'MyPackage',
     14 #     'java_in_dir': 'path/to/package/root',
     15 #     'resource_dir': 'path/to/package/root/res',
     16 #   },
     17 #   'includes': ['path/to/this/gypi/file'],
     18 # }
     19 #
     20 # Required variables:
     21 #  apk_name - The final apk will be named <apk_name>.apk
     22 #  java_in_dir - The top-level java directory. The src should be in
     23 #    <(java_in_dir)/src.
     24 # Optional/automatic variables:
     25 #  additional_input_paths - These paths will be included in the 'inputs' list to
     26 #    ensure that this target is rebuilt when one of these paths changes.
     27 #  additional_res_dirs - Additional directories containing Android resources.
     28 #  additional_res_packages - Package names of the R.java files corresponding to
     29 #    each directory in additional_res_dirs.
     30 #  additional_src_dirs - Additional directories with .java files to be compiled
     31 #    and included in the output of this target.
     32 #  asset_location - The directory where assets are located.
     33 #  generated_src_dirs - Same as additional_src_dirs except used for .java files
     34 #    that are generated at build time. This should be set automatically by a
     35 #    target's dependencies. The .java files in these directories are not
     36 #    included in the 'inputs' list (unlike additional_src_dirs).
     37 #  input_jars_paths - The path to jars to be included in the classpath. This
     38 #    should be filled automatically by depending on the appropriate targets.
     39 #  is_test_apk - Set to 1 if building a test apk.  This prevents resources from
     40 #    dependencies from being re-included.
     41 #  native_lib_target - The target_name of the target which generates the final
     42 #    shared library to be included in this apk. A stripped copy of the
     43 #    library will be included in the apk.
     44 #  resource_dir - The directory for resources.
     45 #  R_package - A custom Java package to generate the resource file R.java in.
     46 #    By default, the package given in AndroidManifest.xml will be used.
     47 #  use_chromium_linker - Enable the content dynamic linker that allows sharing the
     48 #    RELRO section of the native libraries between the different processes.
     49 #  enable_chromium_linker_tests - Enable the content dynamic linker test support
     50 #    code. This allows a test APK to inject a Linker.TestRunner instance at
     51 #    runtime. Should only be used by the chromium_linker_test_apk target!!
     52 #  never_lint - Set to 1 to not run lint on this target.
     53 {
     54   'variables': {
     55     'tested_apk_obfuscated_jar_path%': '/',
     56     'tested_apk_dex_path%': '/',
     57     'additional_input_paths': [],
     58     'input_jars_paths': [],
     59     'library_dexed_jars_paths': [],
     60     'additional_src_dirs': [],
     61     'generated_src_dirs': [],
     62     'app_manifest_version_name%': '<(android_app_version_name)',
     63     'app_manifest_version_code%': '<(android_app_version_code)',
     64     # aapt generates this proguard.txt.
     65     'generated_proguard_file': '<(intermediate_dir)/proguard.txt',
     66     'proguard_enabled%': 'false',
     67     'proguard_flags_paths': ['<(generated_proguard_file)'],
     68     'jar_name': 'chromium_apk_<(_target_name).jar',
     69     'resource_dir%':'<(DEPTH)/build/android/ant/empty/res',
     70     'R_package%':'',
     71     'additional_R_text_files': [],
     72     'dependencies_res_zip_paths': [],
     73     'additional_res_packages': [],
     74     'is_test_apk%': 0,
     75     'extensions_to_not_compress%': '',
     76     'resource_input_paths': [],
     77     'intermediate_dir': '<(PRODUCT_DIR)/<(_target_name)',
     78     'asset_location%': '<(intermediate_dir)/assets',
     79     'codegen_stamp': '<(intermediate_dir)/codegen.stamp',
     80     'package_input_paths': [],
     81     'ordered_libraries_file': '<(intermediate_dir)/native_libraries.json',
     82     'native_libraries_template': '<(DEPTH)/base/android/java/templates/NativeLibraries.template',
     83     'native_libraries_java_dir': '<(intermediate_dir)/native_libraries_java/',
     84     'native_libraries_java_file': '<(native_libraries_java_dir)/NativeLibraries.java',
     85     'native_libraries_java_stamp': '<(intermediate_dir)/native_libraries_java.stamp',
     86     'native_libraries_template_data_dir': '<(intermediate_dir)/native_libraries/',
     87     'native_libraries_template_data_file': '<(native_libraries_template_data_dir)/native_libraries_array.h',
     88     'native_libraries_template_version_file': '<(native_libraries_template_data_dir)/native_libraries_version.h',
     89     'compile_stamp': '<(intermediate_dir)/compile.stamp',
     90     'lint_stamp': '<(intermediate_dir)/lint.stamp',
     91     'lint_result': '<(intermediate_dir)/lint_result.xml',
     92     'lint_config': '<(intermediate_dir)/lint_config.xml',
     93     'never_lint%': 0,
     94     'instr_stamp': '<(intermediate_dir)/instr.stamp',
     95     'jar_stamp': '<(intermediate_dir)/jar.stamp',
     96     'obfuscate_stamp': '<(intermediate_dir)/obfuscate.stamp',
     97     'strip_stamp': '<(intermediate_dir)/strip.stamp',
     98     'classes_dir': '<(intermediate_dir)/classes',
     99     'classes_final_dir': '<(intermediate_dir)/classes_instr',
    100     'javac_includes': [],
    101     'jar_excluded_classes': [],
    102     'jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)',
    103     'obfuscated_jar_path': '<(intermediate_dir)/obfuscated.jar',
    104     'test_jar_path': '<(PRODUCT_DIR)/test.lib.java/<(apk_name).jar',
    105     'dex_path': '<(intermediate_dir)/classes.dex',
    106     'emma_device_jar': '<(android_sdk_root)/tools/lib/emma_device.jar',
    107     'android_manifest_path%': '<(java_in_dir)/AndroidManifest.xml',
    108     'push_stamp': '<(intermediate_dir)/push.stamp',
    109     'link_stamp': '<(intermediate_dir)/link.stamp',
    110     'package_resources_stamp': '<(intermediate_dir)/package_resources.stamp',
    111     'resource_zip_path': '<(intermediate_dir)/<(_target_name).resources.zip',
    112     'resource_packaged_apk_name': '<(apk_name)-resources.ap_',
    113     'resource_packaged_apk_path': '<(intermediate_dir)/<(resource_packaged_apk_name)',
    114     'unsigned_apk_path': '<(intermediate_dir)/<(apk_name)-unsigned.apk',
    115     'final_apk_path%': '<(PRODUCT_DIR)/apks/<(apk_name).apk',
    116     'incomplete_apk_path': '<(intermediate_dir)/<(apk_name)-incomplete.apk',
    117     'apk_install_record': '<(intermediate_dir)/apk_install.record.stamp',
    118     'device_intermediate_dir': '/data/data/org.chromium.gyp_managed_install/<(_target_name)/<(CONFIGURATION_NAME)',
    119     'symlink_script_host_path': '<(intermediate_dir)/create_symlinks.sh',
    120     'symlink_script_device_path': '<(device_intermediate_dir)/create_symlinks.sh',
    121     'create_standalone_apk%': 1,
    122     'res_v14_verify_only%': 0,
    123     'variables': {
    124       'variables': {
    125         'native_lib_target%': '',
    126         'native_lib_version_name%': '',
    127         'use_chromium_linker%' : 0,
    128         'enable_chromium_linker_tests%': 0,
    129         'is_test_apk%': 0,
    130       },
    131       'conditions': [
    132         ['gyp_managed_install == 1 and native_lib_target != ""', {
    133           'unsigned_standalone_apk_path': '<(intermediate_dir)/<(apk_name)-standalone-unsigned.apk',
    134         }, {
    135           'unsigned_standalone_apk_path': '<(unsigned_apk_path)',
    136         }],
    137         ['gyp_managed_install == 1', {
    138           'apk_package_native_libs_dir': '<(intermediate_dir)/libs.managed',
    139         }, {
    140           'apk_package_native_libs_dir': '<(intermediate_dir)/libs',
    141         }],
    142         ['is_test_apk == 0 and emma_coverage != 0', {
    143           'emma_instrument%': 1,
    144         },{
    145           'emma_instrument%': 0,
    146         }],
    147       ],
    148     },
    149     'native_lib_target%': '',
    150     'native_lib_version_name%': '',
    151     'use_chromium_linker%' : 0,
    152     'enable_chromium_linker_tests%': 0,
    153     'emma_instrument%': '<(emma_instrument)',
    154     'apk_package_native_libs_dir': '<(apk_package_native_libs_dir)',
    155     'unsigned_standalone_apk_path': '<(unsigned_standalone_apk_path)',
    156     'extra_native_libs': [],
    157     'apk_dex_input_paths': [ '>@(library_dexed_jars_paths)' ],
    158   },
    159   # Pass the jar path to the apk's "fake" jar target.  This would be better as
    160   # direct_dependent_settings, but a variable set by a direct_dependent_settings
    161   # cannot be lifted in a dependent to all_dependent_settings.
    162   'all_dependent_settings': {
    163     'conditions': [
    164       ['proguard_enabled == "true"', {
    165         'variables': {
    166           'proguard_enabled': 'true',
    167         }
    168       }],
    169     ],
    170     'variables': {
    171       'apk_output_jar_path': '<(jar_path)',
    172       'tested_apk_obfuscated_jar_path': '<(obfuscated_jar_path)',
    173       'tested_apk_dex_path': '<(dex_path)',
    174     },
    175   },
    176   'conditions': [
    177     ['resource_dir!=""', {
    178       'variables': {
    179         'resource_input_paths': [ '<!@(find <(resource_dir) -name "*")' ]
    180       },
    181     }],
    182     ['R_package != ""', {
    183       'variables': {
    184         # We generate R.java in package R_package (in addition to the package
    185         # listed in the AndroidManifest.xml, which is unavoidable).
    186         'additional_res_packages': ['<(R_package)'],
    187         'additional_R_text_files': ['<(PRODUCT_DIR)/<(package_name)/R.txt'],
    188       },
    189     }],
    190     ['native_lib_target != "" and component == "shared_library"', {
    191       'dependencies': [
    192         '<(DEPTH)/build/android/setup.gyp:copy_system_libraries',
    193       ],
    194     }],
    195     ['use_chromium_linker == 1', {
    196       'dependencies': [
    197         '<(DEPTH)/base/base.gyp:chromium_android_linker',
    198       ],
    199     }],
    200     ['native_lib_target != ""', {
    201       'variables': {
    202         'generated_src_dirs': [ '<(native_libraries_java_dir)' ],
    203         'native_libs_paths': [
    204           '<(SHARED_LIB_DIR)/<(native_lib_target).>(android_product_extension)'
    205         ],
    206         'package_input_paths': [
    207           '<(apk_package_native_libs_dir)/<(android_app_abi)/gdbserver',
    208         ],
    209       },
    210       'copies': [
    211         {
    212           # gdbserver is always copied into the APK's native libs dir. The ant
    213           # build scripts (apkbuilder task) will only include it in a debug
    214           # build.
    215           'destination': '<(apk_package_native_libs_dir)/<(android_app_abi)',
    216           'files': [
    217             '<(android_gdbserver)',
    218           ],
    219         },
    220       ],
    221       'actions': [
    222         {
    223           'variables': {
    224             'conditions': [
    225               ['use_chromium_linker == 1', {
    226                 'variables': {
    227                   'linker_input_libraries': [
    228                     '<(SHARED_LIB_DIR)/libchromium_android_linker.>(android_product_extension)',
    229                   ],
    230                 }
    231               }, {
    232                 'variables': {
    233                   'linker_input_libraries': [],
    234                 },
    235               }],
    236             ],
    237             'input_libraries': [
    238               '<@(native_libs_paths)',
    239               '<@(extra_native_libs)',
    240               '<@(linker_input_libraries)',
    241             ],
    242           },
    243           'includes': ['../build/android/write_ordered_libraries.gypi'],
    244         },
    245         {
    246           'action_name': 'native_libraries_template_data_<(_target_name)',
    247           'message': 'Creating native_libraries_list.h for <(_target_name)',
    248           'inputs': [
    249             '<(DEPTH)/build/android/gyp/util/build_utils.py',
    250             '<(DEPTH)/build/android/gyp/create_native_libraries_header.py',
    251             '<(ordered_libraries_file)',
    252           ],
    253           'outputs': [
    254             '<(native_libraries_template_data_file)',
    255             '<(native_libraries_template_version_file)',
    256           ],
    257           'action': [
    258             'python', '<(DEPTH)/build/android/gyp/create_native_libraries_header.py',
    259             '--ordered-libraries=<(ordered_libraries_file)',
    260             '--version-name=<(native_lib_version_name)',
    261             '--native-library-list=<(native_libraries_template_data_file)',
    262             '--version-output=<(native_libraries_template_version_file)',
    263           ],
    264         },
    265         {
    266           'action_name': 'native_libraries_<(_target_name)',
    267           'variables': {
    268             'conditions': [
    269               ['use_chromium_linker == 1', {
    270                 'variables': {
    271                   'linker_gcc_preprocess_defines': [
    272                     '--defines', 'ENABLE_CHROMIUM_LINKER',
    273                   ],
    274                 }
    275               }, {
    276                 'variables': {
    277                   'linker_gcc_preprocess_defines': [],
    278                 },
    279               }],
    280               ['enable_chromium_linker_tests == 1', {
    281                 'variables': {
    282                   'linker_tests_gcc_preprocess_defines': [
    283                     '--defines', 'ENABLE_CHROMIUM_LINKER_TESTS',
    284                   ],
    285                 }
    286               }, {
    287                 'variables': {
    288                   'linker_tests_gcc_preprocess_defines': [],
    289                 },
    290               }],
    291             ],
    292             'gcc_preprocess_defines': [
    293               '<@(linker_gcc_preprocess_defines)',
    294               '<@(linker_tests_gcc_preprocess_defines)',
    295             ],
    296           },
    297           'message': 'Creating NativeLibraries.java for <(_target_name)',
    298           'inputs': [
    299             '<(DEPTH)/build/android/gyp/util/build_utils.py',
    300             '<(DEPTH)/build/android/gyp/gcc_preprocess.py',
    301             '<(native_libraries_template_data_file)',
    302             '<(native_libraries_template_version_file)',
    303             '<(native_libraries_template)',
    304           ],
    305           'outputs': [
    306             '<(native_libraries_java_stamp)',
    307           ],
    308           'action': [
    309             'python', '<(DEPTH)/build/android/gyp/gcc_preprocess.py',
    310             '--include-path=<(native_libraries_template_data_dir)',
    311             '--output=<(native_libraries_java_file)',
    312             '--template=<(native_libraries_template)',
    313             '--stamp=<(native_libraries_java_stamp)',
    314             '<@(gcc_preprocess_defines)',
    315           ],
    316         },
    317         {
    318           'action_name': 'strip_native_libraries',
    319           'variables': {
    320             'ordered_libraries_file%': '<(ordered_libraries_file)',
    321             'stripped_libraries_dir': '<(libraries_source_dir)',
    322             'input_paths': [
    323               '<@(native_libs_paths)',
    324               '<@(extra_native_libs)',
    325             ],
    326             'stamp': '<(strip_stamp)'
    327           },
    328           'includes': ['../build/android/strip_native_libraries.gypi'],
    329         },
    330       ],
    331       'conditions': [
    332         ['gyp_managed_install == 1', {
    333           'variables': {
    334             'libraries_top_dir': '<(intermediate_dir)/lib.stripped',
    335             'libraries_source_dir': '<(libraries_top_dir)/lib/<(android_app_abi)',
    336             'device_library_dir': '<(device_intermediate_dir)/lib.stripped',
    337             'configuration_name': '<(CONFIGURATION_NAME)',
    338           },
    339           'dependencies': [
    340             '<(DEPTH)/build/android/setup.gyp:get_build_device_configurations',
    341           ],
    342           'actions': [
    343             {
    344               'includes': ['../build/android/push_libraries.gypi'],
    345             },
    346             {
    347               'action_name': 'create device library symlinks',
    348               'message': 'Creating links on device for <(_target_name)',
    349               'inputs': [
    350                 '<(DEPTH)/build/android/gyp/util/build_utils.py',
    351                 '<(DEPTH)/build/android/gyp/create_device_library_links.py',
    352                 '<(apk_install_record)',
    353                 '<(build_device_config_path)',
    354                 '<(ordered_libraries_file)',
    355               ],
    356               'outputs': [
    357                 '<(link_stamp)'
    358               ],
    359               'action': [
    360                 'python', '<(DEPTH)/build/android/gyp/create_device_library_links.py',
    361                 '--build-device-configuration=<(build_device_config_path)',
    362                 '--libraries-json=<(ordered_libraries_file)',
    363                 '--script-host-path=<(symlink_script_host_path)',
    364                 '--script-device-path=<(symlink_script_device_path)',
    365                 '--target-dir=<(device_library_dir)',
    366                 '--apk=<(incomplete_apk_path)',
    367                 '--stamp=<(link_stamp)',
    368                 '--configuration-name=<(CONFIGURATION_NAME)',
    369               ],
    370             },
    371           ],
    372           'conditions': [
    373             ['create_standalone_apk == 1', {
    374               'actions': [
    375                 {
    376                   'action_name': 'create standalone APK',
    377                   'variables': {
    378                     'inputs': [
    379                       '<(ordered_libraries_file)',
    380                       '<(strip_stamp)',
    381                     ],
    382                     'input_apk_path': '<(unsigned_apk_path)',
    383                     'output_apk_path': '<(unsigned_standalone_apk_path)',
    384                     'libraries_top_dir%': '<(libraries_top_dir)',
    385                   },
    386                   'includes': [ 'android/create_standalone_apk_action.gypi' ],
    387                 },
    388               ],
    389             }],
    390           ],
    391         }, {
    392           # gyp_managed_install != 1
    393           'variables': {
    394             'libraries_source_dir': '<(apk_package_native_libs_dir)/<(android_app_abi)',
    395             'package_input_paths': [ '<(strip_stamp)' ],
    396           },
    397         }],
    398       ],
    399     }], # native_lib_target != ''
    400     ['gyp_managed_install == 0 or create_standalone_apk == 1', {
    401       'actions': [
    402         {
    403           'action_name': 'finalize standalone apk',
    404           'variables': {
    405             'input_apk_path': '<(unsigned_standalone_apk_path)',
    406             'output_apk_path': '<(final_apk_path)',
    407           },
    408           'includes': [ 'android/finalize_apk_action.gypi']
    409         },
    410       ],
    411     }],
    412     ['gyp_managed_install == 1', {
    413       'actions': [
    414         {
    415           'action_name': 'finalize incomplete apk',
    416           'variables': {
    417             'input_apk_path': '<(unsigned_apk_path)',
    418             'output_apk_path': '<(incomplete_apk_path)',
    419           },
    420           'includes': [ 'android/finalize_apk_action.gypi']
    421         },
    422         {
    423           'action_name': 'apk_install_<(_target_name)',
    424           'message': 'Installing <(apk_name).apk',
    425           'inputs': [
    426             '<(DEPTH)/build/android/gyp/util/build_utils.py',
    427             '<(DEPTH)/build/android/gyp/apk_install.py',
    428             '<(build_device_config_path)',
    429             '<(incomplete_apk_path)',
    430           ],
    431           'outputs': [
    432             '<(apk_install_record)',
    433           ],
    434           'action': [
    435             'python', '<(DEPTH)/build/android/gyp/apk_install.py',
    436             '--apk-path=<(incomplete_apk_path)',
    437             '--build-device-configuration=<(build_device_config_path)',
    438             '--install-record=<(apk_install_record)',
    439             '--configuration-name=<(CONFIGURATION_NAME)',
    440           ],
    441         },
    442       ],
    443     }],
    444     ['is_test_apk == 1', {
    445       'dependencies': [
    446         '<(DEPTH)/tools/android/android_tools.gyp:android_tools',
    447       ]
    448     }],
    449   ],
    450   'dependencies': [
    451     '<(DEPTH)/tools/android/md5sum/md5sum.gyp:md5sum',
    452   ],
    453   'actions': [
    454     {
    455       'action_name': 'process_resources',
    456       'message': 'processing resources for <(_target_name)',
    457       'variables': {
    458         # Write the inputs list to a file, so that its mtime is updated when
    459         # the list of inputs changes.
    460         'inputs_list_file': '>|(apk_codegen.<(_target_name).gypcmd >@(additional_input_paths) >@(resource_input_paths))',
    461         'process_resources_options': [],
    462         'conditions': [
    463           ['is_test_apk == 1', {
    464             'dependencies_res_zip_paths=': [],
    465             'additional_res_packages=': [],
    466           }],
    467           ['res_v14_verify_only == 1', {
    468             'process_resources_options': ['--v14-verify-only']
    469           }],
    470         ],
    471       },
    472       'inputs': [
    473         '<(DEPTH)/build/android/gyp/util/build_utils.py',
    474         '<(DEPTH)/build/android/gyp/process_resources.py',
    475         '<(android_manifest_path)',
    476         '>@(additional_input_paths)',
    477         '>@(resource_input_paths)',
    478         '>@(dependencies_res_zip_paths)',
    479         '>(inputs_list_file)',
    480       ],
    481       'outputs': [
    482         '<(resource_zip_path)',
    483         '<(generated_proguard_file)',
    484         '<(codegen_stamp)',
    485       ],
    486       'action': [
    487         'python', '<(DEPTH)/build/android/gyp/process_resources.py',
    488         '--android-sdk', '<(android_sdk)',
    489         '--android-sdk-tools', '<(android_sdk_tools)',
    490 
    491         '--android-manifest', '<(android_manifest_path)',
    492         '--dependencies-res-zips', '>(dependencies_res_zip_paths)',
    493 
    494         '--extra-res-packages', '>(additional_res_packages)',
    495         '--extra-r-text-files', '>(additional_R_text_files)',
    496 
    497         '--proguard-file', '<(generated_proguard_file)',
    498 
    499         '--resource-dirs', '<(resource_dir)',
    500         '--resource-zip-out', '<(resource_zip_path)',
    501 
    502         '--R-dir', '<(intermediate_dir)/gen',
    503 
    504         '--stamp', '<(codegen_stamp)',
    505 
    506         '<@(process_resources_options)',
    507       ],
    508     },
    509     {
    510       'action_name': 'javac_<(_target_name)',
    511       'message': 'Compiling java for <(_target_name)',
    512       'variables': {
    513         'gen_src_dirs': [
    514           '<(intermediate_dir)/gen',
    515           '>@(generated_src_dirs)',
    516         ],
    517         # If there is a separate find for additional_src_dirs, it will find the
    518         # wrong .java files when additional_src_dirs is empty.
    519         # TODO(thakis): Gyp caches >! evaluation by command. Both java.gypi and
    520         # java_apk.gypi evaluate the same command, and at the moment two targets
    521         # set java_in_dir to "java". Add a dummy comment here to make sure
    522         # that the two targets (one uses java.gypi, the other java_apk.gypi)
    523         # get distinct source lists. Medium-term, make targets list all their
    524         # Java files instead of using find. (As is, this will be broken if two
    525         # targets use the same java_in_dir and both use java_apk.gypi or
    526         # both use java.gypi.)
    527         'java_sources': ['>!@(find >(java_in_dir)/src >(additional_src_dirs) -name "*.java"  # apk)'],
    528 
    529       },
    530       'inputs': [
    531         '<(DEPTH)/build/android/gyp/util/build_utils.py',
    532         '<(DEPTH)/build/android/gyp/javac.py',
    533         '>@(java_sources)',
    534         '>@(input_jars_paths)',
    535         '<(codegen_stamp)',
    536       ],
    537       'conditions': [
    538         ['native_lib_target != ""', {
    539           'inputs': [ '<(native_libraries_java_stamp)' ],
    540         }],
    541       ],
    542       'outputs': [
    543         '<(compile_stamp)',
    544       ],
    545       'action': [
    546         'python', '<(DEPTH)/build/android/gyp/javac.py',
    547         '--output-dir=<(classes_dir)',
    548         '--classpath=>(input_jars_paths) <(android_sdk_jar)',
    549         '--src-gendirs=>(gen_src_dirs)',
    550         '--javac-includes=<(javac_includes)',
    551         '--chromium-code=<(chromium_code)',
    552         '--stamp=<(compile_stamp)',
    553         '>@(java_sources)',
    554       ],
    555     },
    556     {
    557       'variables': {
    558         'src_dirs': [
    559           '<(java_in_dir)/src',
    560           '>@(additional_src_dirs)',
    561         ],
    562         'stamp_path': '<(lint_stamp)',
    563         'result_path': '<(lint_result)',
    564         'config_path': '<(lint_config)',
    565       },
    566       'inputs': [
    567         '<(compile_stamp)',
    568       ],
    569       'outputs': [
    570         '<(lint_stamp)',
    571       ],
    572       'includes': [ 'android/lint_action.gypi' ],
    573     },
    574     {
    575       'action_name': 'instr_classes_<(_target_name)',
    576       'message': 'Instrumenting <(_target_name) classes',
    577       'variables': {
    578         'input_path': '<(classes_dir)',
    579         'output_path': '<(classes_final_dir)',
    580         'stamp_path': '<(instr_stamp)',
    581         'instr_type': 'classes',
    582       },
    583       'inputs': [
    584         '<(compile_stamp)',
    585       ],
    586       'outputs': [
    587         '<(instr_stamp)',
    588       ],
    589       'includes': [ 'android/instr_action.gypi' ],
    590     },
    591     {
    592       'action_name': 'jar_<(_target_name)',
    593       'message': 'Creating <(_target_name) jar',
    594       'inputs': [
    595         '<(DEPTH)/build/android/gyp/util/build_utils.py',
    596         '<(DEPTH)/build/android/gyp/util/md5_check.py',
    597         '<(DEPTH)/build/android/gyp/jar.py',
    598         '<(instr_stamp)',
    599       ],
    600       'outputs': [
    601         '<(jar_stamp)',
    602         '<(jar_path)',
    603       ],
    604       'action': [
    605         'python', '<(DEPTH)/build/android/gyp/jar.py',
    606         '--classes-dir=<(classes_final_dir)',
    607         '--jar-path=<(jar_path)',
    608         '--excluded-classes=<(jar_excluded_classes)',
    609         '--stamp=<(jar_stamp)',
    610       ]
    611     },
    612     {
    613       'action_name': 'obfuscate_<(_target_name)',
    614       'message': 'Obfuscating <(_target_name)',
    615       'variables': {
    616         'additional_obfuscate_options': [],
    617         'additional_obfuscate_input_paths': [],
    618         'proguard_out_dir': '<(intermediate_dir)/proguard',
    619         'proguard_input_jar_paths': [
    620           '>@(input_jars_paths)',
    621           '<(jar_path)',
    622         ],
    623         'target_conditions': [
    624           ['is_test_apk == 1', {
    625             'additional_obfuscate_options': [
    626               '--testapp',
    627             ],
    628           }],
    629           ['is_test_apk == 1 and tested_apk_obfuscated_jar_path != "/"', {
    630             'additional_obfuscate_options': [
    631               '--tested-apk-obfuscated-jar-path', '>(tested_apk_obfuscated_jar_path)',
    632             ],
    633             'additional_obfuscate_input_paths': [
    634               '>(tested_apk_obfuscated_jar_path).info',
    635             ],
    636           }],
    637           ['proguard_enabled == "true"', {
    638             'additional_obfuscate_options': [
    639               '--proguard-enabled',
    640             ],
    641           }],
    642         ],
    643         'obfuscate_input_jars_paths': [
    644           '>@(input_jars_paths)',
    645           '<(jar_path)',
    646         ],
    647       },
    648       'conditions': [
    649         ['is_test_apk == 1', {
    650           'outputs': [
    651             '<(test_jar_path)',
    652           ],
    653         }],
    654       ],
    655       'inputs': [
    656         '<(DEPTH)/build/android/gyp/apk_obfuscate.py',
    657         '<(DEPTH)/build/android/gyp/util/build_utils.py',
    658         '>@(proguard_flags_paths)',
    659         '>@(obfuscate_input_jars_paths)',
    660         '>@(additional_obfuscate_input_paths)',
    661         '<(instr_stamp)',
    662       ],
    663       'outputs': [
    664         '<(obfuscate_stamp)',
    665 
    666         # In non-Release builds, these paths will all be empty files.
    667         '<(obfuscated_jar_path)',
    668         '<(obfuscated_jar_path).info',
    669         '<(obfuscated_jar_path).dump',
    670         '<(obfuscated_jar_path).seeds',
    671         '<(obfuscated_jar_path).mapping',
    672         '<(obfuscated_jar_path).usage',
    673       ],
    674       'action': [
    675         'python', '<(DEPTH)/build/android/gyp/apk_obfuscate.py',
    676 
    677         '--configuration-name', '<(CONFIGURATION_NAME)',
    678 
    679         '--android-sdk', '<(android_sdk)',
    680         '--android-sdk-tools', '<(android_sdk_tools)',
    681         '--android-sdk-jar', '<(android_sdk_jar)',
    682 
    683         '--input-jars-paths=>(proguard_input_jar_paths)',
    684         '--proguard-configs=>(proguard_flags_paths)',
    685 
    686 
    687         '--test-jar-path', '<(test_jar_path)',
    688         '--obfuscated-jar-path', '<(obfuscated_jar_path)',
    689 
    690         '--proguard-jar-path', '<(android_sdk_root)/tools/proguard/lib/proguard.jar',
    691 
    692         '--stamp', '<(obfuscate_stamp)',
    693 
    694         '>@(additional_obfuscate_options)',
    695       ],
    696     },
    697     {
    698       'action_name': 'dex_<(_target_name)',
    699       'variables': {
    700         'output_path': '<(dex_path)',
    701         'dex_input_paths': [
    702           '>@(apk_dex_input_paths)',
    703           '<(jar_path)',
    704         ],
    705         'proguard_enabled_input_path': '<(obfuscated_jar_path)',
    706       },
    707       'target_conditions': [
    708         ['emma_instrument != 0', {
    709           'dex_no_locals': 1,
    710           'dex_input_paths': [
    711             '<(emma_device_jar)'
    712           ],
    713         }],
    714         ['is_test_apk == 1 and tested_apk_dex_path != "/"', {
    715           'variables': {
    716             'dex_additional_options': [
    717               '--excluded-paths-file', '>(tested_apk_dex_path).inputs'
    718             ],
    719           },
    720           'inputs': [
    721             '>(tested_apk_dex_path).inputs',
    722           ],
    723         }],
    724         ['proguard_enabled == "true"', {
    725           'inputs': [ '<(obfuscate_stamp)' ]
    726         }, {
    727           'inputs': [ '<(instr_stamp)' ]
    728         }],
    729       ],
    730       'includes': [ 'android/dex_action.gypi' ],
    731     },
    732     {
    733       'action_name': 'package_resources',
    734       'message': 'packaging resources for <(_target_name)',
    735       'variables': {
    736         'package_resource_zip_input_paths': [
    737           '<(resource_zip_path)',
    738           '>@(dependencies_res_zip_paths)',
    739         ],
    740       },
    741       'conditions': [
    742         ['is_test_apk == 1', {
    743           'variables': {
    744             'dependencies_res_zip_paths=': [],
    745             'additional_res_packages=': [],
    746           }
    747         }],
    748       ],
    749       'inputs': [
    750         # TODO: This isn't always rerun correctly, http://crbug.com/351928
    751         '<(DEPTH)/build/android/gyp/util/build_utils.py',
    752         '<(DEPTH)/build/android/gyp/package_resources.py',
    753         '<(android_manifest_path)',
    754 
    755         '>@(package_resource_zip_input_paths)',
    756 
    757         '<(codegen_stamp)',
    758       ],
    759       'outputs': [
    760         '<(resource_packaged_apk_path)',
    761       ],
    762       'action': [
    763         'python', '<(DEPTH)/build/android/gyp/package_resources.py',
    764         '--android-sdk', '<(android_sdk)',
    765         '--android-sdk-tools', '<(android_sdk_tools)',
    766 
    767         '--configuration-name', '<(CONFIGURATION_NAME)',
    768 
    769         '--android-manifest', '<(android_manifest_path)',
    770         '--version-code', '<(app_manifest_version_code)',
    771         '--version-name', '<(app_manifest_version_name)',
    772 
    773         '--asset-dir', '<(asset_location)',
    774         '--resource-zips', '>(package_resource_zip_input_paths)',
    775 
    776         '--no-compress', '<(extensions_to_not_compress)',
    777 
    778         '--apk-path', '<(resource_packaged_apk_path)',
    779       ],
    780     },
    781     {
    782       'action_name': 'ant_package_<(_target_name)',
    783       'message': 'Packaging <(_target_name)',
    784       'variables': {
    785         # Write the inputs list to a file, so that its mtime is updated when
    786         # the list of inputs changes.
    787         'inputs_list_file': '>|(apk_package.<(_target_name).gypcmd >@(package_input_paths))'
    788       },
    789       'inputs': [
    790         '<(DEPTH)/build/android/ant/apk-package.xml',
    791         '<(DEPTH)/build/android/gyp/util/build_utils.py',
    792         '<(DEPTH)/build/android/gyp/ant.py',
    793         '<(dex_path)',
    794         '<(codegen_stamp)',
    795         '<(obfuscate_stamp)',
    796         '<(resource_packaged_apk_path)',
    797         '>@(package_input_paths)',
    798         '>(inputs_list_file)',
    799       ],
    800       'outputs': [
    801         '<(unsigned_apk_path)',
    802       ],
    803       'action': [
    804         'python', '<(DEPTH)/build/android/gyp/ant.py',
    805         '-quiet',
    806         '-DANDROID_SDK_ROOT=<(android_sdk_root)',
    807         '-DANDROID_SDK_TOOLS=<(android_sdk_tools)',
    808         '-DRESOURCE_PACKAGED_APK_NAME=<(resource_packaged_apk_name)',
    809         '-DAPK_NAME=<(apk_name)',
    810         '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)',
    811         '-DNATIVE_LIBS_DIR=<(apk_package_native_libs_dir)',
    812         '-DOUT_DIR=<(intermediate_dir)',
    813         '-DUNSIGNED_APK_PATH=<(unsigned_apk_path)',
    814         '-DEMMA_INSTRUMENT=<(emma_instrument)',
    815         '-DEMMA_DEVICE_JAR=<(emma_device_jar)',
    816 
    817         '-Dbasedir=.',
    818         '-buildfile',
    819         '<(DEPTH)/build/android/ant/apk-package.xml',
    820       ]
    821     },
    822   ],
    823 }
    824