Index: base/base.gyp |
diff --git a/base/base.gyp b/base/base.gyp |
index 02c8585557d6f20a1fe04e3abc225fcb75d1c67a..cd9942b35c9d5c58791dc7b65ff1046347e165ab 100644 |
--- a/base/base.gyp |
+++ b/base/base.gyp |
@@ -153,7 +153,7 @@ |
}, |
{ |
'target_name': 'base_unittests', |
- 'type': 'executable', |
+ 'type': '<(gtest_target_type)', |
'sources': [ |
# Tests. |
'android/jni_android_unittest.cc', |
@@ -334,6 +334,11 @@ |
'android/jni_generator/jni_generator.gyp:jni_generator_tests', |
], |
}], |
+ ['OS=="android" and "<(gtest_target_type)"=="shared_library"', { |
+ 'dependencies': [ |
+ '../testing/android/native_test.gyp:native_test_native_code', |
+ ], |
+ }], |
['use_glib==1', { |
'sources!': [ |
'file_version_info_unittest.cc', |
@@ -655,5 +660,74 @@ |
}, |
], |
}], |
+ # Special target to wrap a <(gtest_target_type)==shared_library |
+ # base_unittests into an android apk for execution. |
+ # TODO(jrg): lib.target comes from _InstallableTargetInstallPath() |
+ # in the gyp make generator. What is the correct way to extract |
+ # this path from gyp and into 'raw' for input to antfiles? |
+ # Hard-coding in the gypfile seems a poor choice. |
+ # TODO(jrg): there has to be a shorter way to do all this. Try |
+ # and convert this entire target cluster into ~5 lines that can be |
+ # trivially copied to other projects with only a deps change, such |
+ # as with a new gtest_target_type called |
+ # 'shared_library_apk_wrapper' that does a lot of this magically. |
+ ['OS=="android" and "<(gtest_target_type)"=="shared_library"', { |
+ 'targets': [ |
+ { |
+ 'target_name': 'base_unittests_apk', |
+ 'type': 'none', |
+ 'dependencies': [ |
+ 'base_unittests', |
+ ], |
+ 'actions': [ |
+ { |
+ # Generate apk files (including source and antfile) from |
+ # a template. |
+ 'action_name': 'generate_base_unittests_apk', |
+ 'dependencies': [ |
+ 'base', # So that android/java/java.gyp:base_java is built |
+ 'base_unittests', |
bulach
2012/04/12 15:51:42
not quite clear what's the benefit of having two a
John Grabowski
2012/04/13 01:11:37
I like 2 and 3.
I don't like 1; Chrome philosophy
|
+ ], |
+ 'inputs': [ |
+ '../testing/android/generate_native_test.py', |
+ '<(PRODUCT_DIR)/lib.target/libbase_unittests.so', |
+ '<(PRODUCT_DIR)/chromium_base.jar' |
+ ], |
+ 'outputs': [ |
+ '<(PRODUCT_DIR)/base_unittests_apk/AndroidManifest.xml' |
+ ], |
+ 'action': [ |
+ '../testing/android/generate_native_test.py', |
+ '--native_library', |
+ '<(PRODUCT_DIR)/lib.target/libbase_unittests.so', |
+ '--jars', |
+ '<(PRODUCT_DIR)/chromium_base.jar', |
+ '--output', |
+ '<(PRODUCT_DIR)/base_unittests_apk' |
+ ], |
+ }, |
+ { |
+ # Build the generated template file, wrapping the |
+ # relevant .so and jar. |
+ 'action_name': 'build_base_unittests_apk', |
+ 'dependencies': [ |
+ 'generate_base_unittests_apk', |
+ ], |
+ 'inputs': [ |
+ '<(PRODUCT_DIR)/base_unittests_apk/AndroidManifest.xml' |
+ ], |
+ 'outputs': [ |
+ '<(PRODUCT_DIR)/ChromeNativeTests_base_unittests-debug.apk', |
+ ], |
+ 'action': [ |
+ 'ant', |
+ '-DPRODUCT_DIR=<(PRODUCT_DIR)', |
+ '-buildfile', |
+ '<(PRODUCT_DIR)/base_unittests_apk/native_test_apk.xml', |
+ ] |
+ }, |
+ ] |
+ }], |
+ }], |
], |
} |