Index: build/java.gypi |
diff --git a/build/java.gypi b/build/java.gypi |
index 5318e2a35983cd4857cdd20b8770439db160fbd9..d08f31c66106b7491b7a560260b6fbd5d4ea37ae 100644 |
--- a/build/java.gypi |
+++ b/build/java.gypi |
@@ -44,6 +44,8 @@ |
# res_extra_dirs - A list of extra directories containing Android resources. |
# These directories may be generated at build time. |
# res_extra_files - A list of the files in res_extra_dirs. |
+# emma_should_instrument - If 1, and emma_coverage is 1, then this java target |
+# will be instrumented. |
{ |
'dependencies': [ |
@@ -55,8 +57,11 @@ |
'additional_src_dirs': [], |
'javac_includes': [], |
'jar_name': '<(_target_name).jar', |
- 'jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)', |
+ 'jar_dir': '<(PRODUCT_DIR)/lib.java', |
+ 'jar_path': '<(intermediate_dir)/<(jar_name)', |
+ 'jar_final_path': '<(jar_dir)/<(jar_name)', |
'jar_excluded_classes': [ '*/R.class', '*/R##*.class' ], |
+ 'instr_stamp': '<(intermediate_dir)/instr.stamp', |
'additional_input_paths': [], |
'dex_path': '<(PRODUCT_DIR)/lib.java/<(_target_name).dex.jar', |
'generated_src_dirs': ['>@(generated_R_dirs)'], |
@@ -75,22 +80,29 @@ |
'variables': { |
'variables': { |
'proguard_preprocess%': 0, |
+ 'emma_should_instrument%': 0, |
}, |
'conditions': [ |
['proguard_preprocess == 1', { |
'javac_jar_path': '<(intermediate_dir)/<(_target_name).pre.jar' |
}, { |
- 'javac_jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)' |
+ 'javac_jar_path': '<(jar_path)' |
+ }], |
+ ['emma_should_instrument != 0', { |
+ 'emma_instrument': '<(emma_coverage)', |
+ }, { |
+ 'emma_instrument': 0, |
}], |
], |
}, |
'javac_jar_path': '<(javac_jar_path)', |
+ 'emma_instrument': '<(emma_instrument)', |
}, |
# This all_dependent_settings is used for java targets only. This will add the |
# jar path to the classpath of dependent java targets. |
'all_dependent_settings': { |
'variables': { |
- 'input_jars_paths': ['<(jar_path)'], |
+ 'input_jars_paths': ['<(jar_final_path)'], |
'library_dexed_jars_paths': ['<(dex_path)'], |
}, |
}, |
@@ -320,21 +332,38 @@ |
] |
}, |
{ |
+ 'action_name': 'instr_jar_<(_target_name)', |
+ 'message': 'Instrumenting <(_target_name) jar', |
+ 'variables': { |
+ 'input_path': '<(jar_path)', |
+ 'output_path': '<(jar_final_path)', |
+ 'stamp_path': '<(instr_stamp)', |
+ 'instr_type': 'jar', |
+ }, |
+ 'outputs': [ |
+ '<(jar_final_path)', |
+ ], |
+ 'inputs': [ |
+ '<(jar_path)', |
+ ], |
+ 'includes': [ 'android/instr_action.gypi' ], |
+ }, |
+ { |
'action_name': 'jar_toc_<(_target_name)', |
'message': 'Creating <(_target_name) jar.TOC', |
'inputs': [ |
'<(DEPTH)/build/android/gyp/util/build_utils.py', |
'<(DEPTH)/build/android/gyp/util/md5_check.py', |
'<(DEPTH)/build/android/gyp/jar_toc.py', |
- '<(jar_path)', |
+ '<(jar_final_path)', |
], |
'outputs': [ |
- '<(jar_path).TOC', |
+ '<(jar_final_path).TOC', |
], |
'action': [ |
'python', '<(DEPTH)/build/android/gyp/jar_toc.py', |
- '--jar-path=<(jar_path)', |
- '--toc-path=<(jar_path).TOC', |
+ '--jar-path=<(jar_final_path)', |
+ '--toc-path=<(jar_final_path).TOC', |
# TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja. |
'--ignore=>!(echo \'>(_inputs)\' | md5sum)', |
@@ -343,7 +372,12 @@ |
{ |
'action_name': 'dex_<(_target_name)', |
'variables': { |
- 'dex_input_paths': [ '<(jar_path)' ], |
+ 'conditions': [ |
+ ['emma_instrument != 0', { |
+ 'dex_no_locals': 1, |
+ }], |
+ ], |
+ 'dex_input_paths': [ '<(jar_final_path)' ], |
'output_path': '<(dex_path)', |
}, |
'includes': [ 'android/dex_action.gypi' ], |