[Android] Fix proguard
Gyp supports only very limited ways of changing behavior based upon CONFIGURATION_NAME. Particularly, it does not support the way that was supposed to enable/disable use of proguard. Instead of trying to switch behavior in gyp, instead pass CONFIGURATION_NAME, proguard_enabled, and proguard_enabled_dex_input_path to dex.py and switch the behavior there. This also extracts the dex actions into build/android/dex_action.gypi and uses that for the actions in both build/java.gypi and build/java_apk.gypi. BUG=240837 Review URL: https://chromiumcodereview.appspot.com/15231006 git-svn-id: http://src.chromium.org/svn/trunk/src/build@200958 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
Родитель
97bffd2336
Коммит
1753c2d759
|
@ -0,0 +1,61 @@
|
|||
# Copyright 2013 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
# This file is meant to be included into an action to provide a rule that dexes
|
||||
# compiled java files. If proguard_enabled == "true" and CONFIGURATION_NAME ==
|
||||
# "Release", then it will dex the proguard_enabled_input_path instead of the
|
||||
# normal dex_input_paths/dex_generated_input_paths.
|
||||
#
|
||||
# To use this, create a gyp target with the following form:
|
||||
# {
|
||||
# 'action_name': 'some name for the action'
|
||||
# 'actions': [
|
||||
# 'variables': {
|
||||
# 'dex_input_paths': [ 'files to dex (when proguard is not used) and add to input paths' ],
|
||||
# 'dex_generated_input_dirs': [ 'dirs that contain generated files to dex' ],
|
||||
# 'input_paths': [ 'additional files to be added to the list of inputs' ],
|
||||
#
|
||||
# # For targets that use proguard:
|
||||
# 'proguard_enabled': 'true',
|
||||
# 'proguard_enabled_input_path': 'path to dex when using proguard',
|
||||
# },
|
||||
# 'includes': [ 'relative/path/to/dex_action.gypi' ],
|
||||
# ],
|
||||
# },
|
||||
#
|
||||
|
||||
{
|
||||
'message': 'Creating dex file: <(output_path)',
|
||||
'variables': {
|
||||
'dex_input_paths': [],
|
||||
'dex_generated_input_dirs': [],
|
||||
'input_paths': [],
|
||||
'proguard_enabled%': 'false',
|
||||
'proguard_enabled_input_path%': '',
|
||||
},
|
||||
'inputs': [
|
||||
'<(DEPTH)/build/android/gyp/util/build_utils.py',
|
||||
'<(DEPTH)/build/android/gyp/util/md5_check.py',
|
||||
'<(DEPTH)/build/android/gyp/dex.py',
|
||||
'>@(input_paths)',
|
||||
'>@(dex_input_paths)',
|
||||
],
|
||||
'outputs': [
|
||||
'<(output_path)',
|
||||
],
|
||||
'action': [
|
||||
'python', '<(DEPTH)/build/android/gyp/dex.py',
|
||||
'--dex-path=<(output_path)',
|
||||
'--android-sdk-root=<(android_sdk_root)',
|
||||
'--configuration-name=<(CONFIGURATION_NAME)',
|
||||
'--proguard-enabled=<(proguard_enabled)',
|
||||
'--proguard-enabled-input-path=<(proguard_enabled_input_path)',
|
||||
|
||||
# TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja.
|
||||
'--ignore=>!(echo \'>(_inputs)\' | md5sum)',
|
||||
|
||||
'>@(dex_input_paths)',
|
||||
'>@(dex_generated_input_dirs)',
|
||||
]
|
||||
}
|
|
@ -31,6 +31,12 @@ def main(argv):
|
|||
parser = optparse.OptionParser()
|
||||
parser.add_option('--android-sdk-root', help='Android sdk root directory.')
|
||||
parser.add_option('--dex-path', help='Dex output path.')
|
||||
parser.add_option('--configuration-name',
|
||||
help='The build CONFIGURATION_NAME.')
|
||||
parser.add_option('--proguard-enabled',
|
||||
help='"true" if proguard is enabled.')
|
||||
parser.add_option('--proguard-enabled-input-path',
|
||||
help='Path to dex in Release mode when proguard is enabled.')
|
||||
parser.add_option('--stamp', help='Path to touch on success.')
|
||||
|
||||
# TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja.
|
||||
|
@ -38,6 +44,10 @@ def main(argv):
|
|||
|
||||
options, paths = parser.parse_args()
|
||||
|
||||
if (options.proguard_enabled == "true"
|
||||
and options.configuration_name == "Release"):
|
||||
paths = [options.proguard_enabled_input_path]
|
||||
|
||||
DoDex(options, paths)
|
||||
|
||||
if options.stamp:
|
||||
|
|
26
java.gypi
26
java.gypi
|
@ -282,27 +282,11 @@
|
|||
},
|
||||
{
|
||||
'action_name': 'dex_<(_target_name)',
|
||||
'message': 'Dexing <(_target_name) jar',
|
||||
'inputs': [
|
||||
'<(DEPTH)/build/android/gyp/util/build_utils.py',
|
||||
'<(DEPTH)/build/android/gyp/util/md5_check.py',
|
||||
'<(DEPTH)/build/android/gyp/dex.py',
|
||||
'<(jar_path)',
|
||||
],
|
||||
'outputs': [
|
||||
'<(dex_path)',
|
||||
],
|
||||
'action': [
|
||||
'python', '<(DEPTH)/build/android/gyp/dex.py',
|
||||
'--dex-path=<(dex_path)',
|
||||
'--android-sdk-root=<(android_sdk_root)',
|
||||
|
||||
# TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja.
|
||||
'--ignore=>!(echo \'>(_inputs)\' | md5sum)',
|
||||
|
||||
'<(jar_path)',
|
||||
]
|
||||
'variables': {
|
||||
'dex_input_paths': [ '<(jar_path)' ],
|
||||
'output_path': '<(dex_path)',
|
||||
},
|
||||
'includes': [ 'android/dex_action.gypi' ],
|
||||
},
|
||||
|
||||
],
|
||||
}
|
||||
|
|
|
@ -480,43 +480,19 @@
|
|||
},
|
||||
{
|
||||
'action_name': 'dex_<(_target_name)',
|
||||
'message': 'Dexing <(_target_name) jar',
|
||||
'variables': {
|
||||
'conditions': [
|
||||
['proguard_enabled=="true" and CONFIGURATION_NAME=="Release"', {
|
||||
'dex_inputs': [ '<(obfuscated_jar_path)' ],
|
||||
'dex_generated_inputs': [],
|
||||
}, {
|
||||
'dex_inputs': [
|
||||
'>@(library_dexed_jars_paths)',
|
||||
],
|
||||
'dex_generated_inputs': [
|
||||
'<(classes_dir)',
|
||||
],
|
||||
['proguard_enabled == "true"', {
|
||||
'input_paths': [ '<(obfuscate_stamp)' ],
|
||||
'proguard_enabled_input_path': '<(obfuscated_jar_path)',
|
||||
}],
|
||||
],
|
||||
'input_paths': [ '<(compile_stamp)' ],
|
||||
'dex_input_paths': [ '>@(library_dexed_jars_paths)' ],
|
||||
'dex_generated_input_dirs': [ '<(classes_dir)' ],
|
||||
'output_path': '<(dex_path)',
|
||||
},
|
||||
'inputs': [
|
||||
'<(DEPTH)/build/android/gyp/util/build_utils.py',
|
||||
'<(DEPTH)/build/android/gyp/util/md5_check.py',
|
||||
'<(DEPTH)/build/android/gyp/dex.py',
|
||||
'<(compile_stamp)',
|
||||
'>@(dex_inputs)',
|
||||
],
|
||||
'outputs': [
|
||||
'<(dex_path)',
|
||||
],
|
||||
'action': [
|
||||
'python', '<(DEPTH)/build/android/gyp/dex.py',
|
||||
'--dex-path=<(dex_path)',
|
||||
'--android-sdk-root=<(android_sdk_root)',
|
||||
|
||||
# TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja.
|
||||
'--ignore=>!(echo \'>(_inputs)\' | md5sum)',
|
||||
|
||||
'>@(dex_inputs)',
|
||||
'>@(dex_generated_inputs)',
|
||||
]
|
||||
'includes': [ 'android/dex_action.gypi' ],
|
||||
},
|
||||
{
|
||||
'action_name': 'ant package resources',
|
||||
|
|
Загрузка…
Ссылка в новой задаче