Blink roll 25b6bd3a7a131ffe68d809546ad1a20707915cdc:3a503f41ae42e5b79cfcd2ff10e65afde...
[chromium-blink-merge.git] / components / cronet.gypi
blob6a97a426c3dfcb696fd9d9d32570a848582b2a25
1 # Copyright 2014 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.
6   'conditions': [
7     ['OS=="android"', {
8       # TODO(mef): Figure out what needs to be done for gn script.
9       'targets': [
10         {
11           'target_name': 'cronet_jni_headers',
12           'type': 'none',
13           'sources': [
14             'cronet/android/java/src/org/chromium/net/CronetUrlRequest.java',
15             'cronet/android/java/src/org/chromium/net/CronetUrlRequestContext.java',
16             'cronet/android/java/src/org/chromium/net/ChromiumUrlRequest.java',
17             'cronet/android/java/src/org/chromium/net/ChromiumUrlRequestContext.java',
18           ],
19           'variables': {
20             'jni_gen_package': 'cronet',
21           },
22           'includes': [ '../build/jni_generator.gypi' ],
23         },
24         {
25           'target_name': 'cronet_url_request_java',
26           'type': 'none',
27           'variables': {
28             'source_file': 'cronet/android/chromium_url_request.h',
29           },
30           'includes': [ '../build/android/java_cpp_enum.gypi' ],
31         },
32         {
33           'target_name': 'net_request_priority_java',
34           'type': 'none',
35           'variables': {
36             'source_file': '../net/base/request_priority.h',
37           },
38           'includes': [ '../build/android/java_cpp_enum.gypi' ],
39         },
40         {
41           'target_name': 'cronet_url_request_context_config_list',
42           'type': 'none',
43           'sources': [
44             'cronet/android/java/src/org/chromium/net/UrlRequestContextConfigList.template',
45           ],
46           'variables': {
47             'package_name': 'org/chromium/cronet',
48             'template_deps': ['cronet/url_request_context_config_list.h'],
49           },
50           'includes': [ '../build/android/java_cpp_template.gypi' ],
51         },
52         {
53           'target_name': 'cronet_version',
54           'type': 'none',
55           'variables': {
56             'lastchange_path': '<(DEPTH)/build/util/LASTCHANGE',
57             'version_py_path': '<(DEPTH)/build/util/version.py',
58             'version_path': '<(DEPTH)/chrome/VERSION',
59             'template_input_path': 'cronet/android/java/src/org/chromium/net/Version.template',
60             'output_path': '<(SHARED_INTERMEDIATE_DIR)/templates/<(_target_name)/org/chromium/cronet/Version.java',
61           },
62           'direct_dependent_settings': {
63             'variables': {
64               # Ensure that the output directory is used in the class path
65               # when building targets that depend on this one.
66               'generated_src_dirs': [
67                 '<(SHARED_INTERMEDIATE_DIR)/templates/<(_target_name)',
68               ],
69               # Ensure dependents are rebuilt when the generated Java file changes.
70               'additional_input_paths': [
71                 '<(output_path)',
72               ],
73             },
74           },
75           'actions': [
76             {
77               'action_name': 'cronet_version',
78               'inputs': [
79                 '<(template_input_path)',
80                 '<(version_path)',
81                 '<(lastchange_path)',
82               ],
83               'outputs': [
84                 '<(output_path)',
85               ],
86               'action': [
87                 'python',
88                 '<(version_py_path)',
89                 '-f', '<(version_path)',
90                 '-f', '<(lastchange_path)',
91                 '<(template_input_path)',
92                 '<(output_path)',
93               ],
94               'message': 'Generating version information',
95             },
96           ],
97         },
98         {
99           'target_name': 'cronet_static',
100           'type': 'static_library',
101           'dependencies': [
102             '../base/base.gyp:base',
103             '../base/base.gyp:base_i18n',
104             '../third_party/icu/icu.gyp:icui18n',
105             '../third_party/icu/icu.gyp:icuuc',
106             'cronet_jni_headers',
107             'cronet_url_request_context_config_list',
108             'cronet_url_request_java',
109             'cronet_version',
110             '../net/net.gyp:net',
111           ],
112           'sources': [
113             'cronet/url_request_context_config.cc',
114             'cronet/url_request_context_config.h',
115             'cronet/url_request_context_config_list.h',
116             'cronet/android/chromium_url_request.cc',
117             'cronet/android/chromium_url_request.h',
118             'cronet/android/chromium_url_request_error_list.h',
119             'cronet/android/chromium_url_request_priority_list.h',
120             'cronet/android/chromium_url_request_context.cc',
121             'cronet/android/chromium_url_request_context.h',
122             'cronet/android/cronet_loader.cc',
123             'cronet/android/cronet_loader.h',
124             'cronet/android/cronet_url_request.cc',
125             'cronet/android/cronet_url_request.h',
126             'cronet/android/cronet_url_request_adapter.cc',
127             'cronet/android/cronet_url_request_adapter.h',
128             'cronet/android/cronet_url_request_context.cc',
129             'cronet/android/cronet_url_request_context.h',
130             'cronet/android/cronet_url_request_context_adapter.cc',
131             'cronet/android/cronet_url_request_context_adapter.h',
132             'cronet/android/url_request_adapter.cc',
133             'cronet/android/url_request_adapter.h',
134             'cronet/android/url_request_context_adapter.cc',
135             'cronet/android/url_request_context_adapter.h',
136             'cronet/android/wrapped_channel_upload_element_reader.cc',
137             'cronet/android/wrapped_channel_upload_element_reader.h',
138           ],
139           'cflags': [
140             '-DLOGGING=1',
141             '-fdata-sections',
142             '-ffunction-sections',
143             '-fno-rtti',
144             '-fvisibility=hidden',
145             '-fvisibility-inlines-hidden',
146             '-Wno-sign-promo',
147             '-Wno-missing-field-initializers',
148           ],
149           'ldflags': [
150             '-llog',
151             '-landroid',
152             '-Wl,--gc-sections',
153             '-Wl,--exclude-libs,ALL'
154           ],
155           'conditions': [
156             [ 'use_icu_alternatives_on_android == 1', {
157                 'dependencies!': [
158                   '../base/base.gyp:base_i18n',
159                   '../third_party/icu/icu.gyp:icui18n',
160                   '../third_party/icu/icu.gyp:icuuc',
161                 ]
162               },
163             ],
164           ],
165         },
166         {
167           'target_name': 'libcronet',
168           'type': 'shared_library',
169           'sources': [
170             'cronet/android/cronet_jni.cc',
171           ],
172           'dependencies': [
173             'cronet_static',
174             '../base/base.gyp:base',
175             '../net/net.gyp:net',
176             '../url/url.gyp:url_lib',
177           ],
178         },
179         { # cronet_stub.jar defines HttpUrlRequest interface and provides its
180           # its implementation using HttpUrlConnection (not the Chromium stack).
181           'target_name': 'cronet_stub',
182           'type': 'none',
183           'dependencies': [
184             'cronet_url_request_context_config_list',
185             'cronet_version',
186           ],
187           'variables': {
188             'java_in_dir': 'cronet/android/java',
189             'javac_includes': [
190               '**/ChunkedWritableByteChannel.java',
191               '**/ExtendedResponseInfo.java',
192               '**/HttpUrlConnection*.java',
193               '**/HttpUrlRequest*.java',
194               '**/ResponseInfo.java',
195               '**/ResponseTooLargeException.java',
196               '**/UrlRequest.java',
197               '**/UrlRequestContext.java',
198               '**/UrlRequestContextConfig.java',
199               '**/UrlRequestContextConfigList.java',
200               '**/UrlRequestException.java',
201               '**/UrlRequestListener.java',
202               '**/UserAgent.java',
203               '**/Version.java',
204             ],
205           },
206           'includes': [ '../build/java.gypi' ],
207         },
208         { # cronet.jar implements HttpUrlRequest interface using Chromium stack
209           # in native libcronet.so library.
210           'target_name': 'cronet',
211           'type': 'none',
212           'dependencies': [
213             '../base/base.gyp:base',
214             'cronet_stub',
215             'cronet_url_request_java',
216             'libcronet',
217             'net_request_priority_java',
218           ],
219           'variables': {
220             'java_in_dir': 'cronet/android/java',
221             'javac_includes': [
222               '**/ChromiumAsyncUrlRequest.java',
223               '**/ChromiumUrlRequest.java',
224               '**/ChromiumUrlRequestContext.java',
225               '**/ChromiumUrlRequestError.java',
226               '**/ChromiumUrlRequestFactory.java',
227               '**/ChromiumUrlRequestPriority.java',
228               '**/CronetResponseInfo.java',
229               '**/CronetUrlRequest.java',
230               '**/CronetUrlRequestContext.java',
231               '**/CronetUrlRequestFactory.java',
232               '**/RequestPriority.java',
233             ],
234           },
235           'includes': [ '../build/java.gypi' ],
236         },
237         {
238           'target_name': 'cronet_sample_apk',
239           'type': 'none',
240           'dependencies': [
241             'cronet',
242             'cronet_stub',
243           ],
244           'variables': {
245             'apk_name': 'CronetSample',
246             'java_in_dir': 'cronet/android/sample',
247             'resource_dir': 'cronet/android/sample/res',
248             'native_lib_target': 'libcronet',
249             'proguard_enabled': 'true',
250             'proguard_flags_paths': [
251               'cronet/android/proguard.cfg',
252               'cronet/android/sample/javatests/proguard.cfg',
253             ],
254           },
255           'includes': [ '../build/java_apk.gypi' ],
256         },
257         {
258           # cronet_sample_apk creates a .jar as a side effect. Any java targets
259           # that need that .jar in their classpath should depend on this target,
260           # cronet_sample_apk_java. Dependents of cronet_sample_apk receive its
261           # jar path in the variable 'apk_output_jar_path'. This target should
262           # only be used by targets which instrument cronet_sample_apk.
263           'target_name': 'cronet_sample_apk_java',
264           'type': 'none',
265           'dependencies': [
266             'cronet_sample_apk',
267           ],
268           'includes': [ '../build/apk_fake_jar.gypi' ],
269         },
270         {
271           'target_name': 'cronet_sample_test_apk',
272           'type': 'none',
273           'dependencies': [
274             'cronet',
275             'cronet_sample_apk_java',
276             'cronet_stub',
277             '../base/base.gyp:base_java_test_support',
278           ],
279           'variables': {
280             'apk_name': 'CronetSampleTest',
281             'java_in_dir': 'cronet/android/sample/javatests',
282             'resource_dir': 'cronet/android/sample/res',
283             'is_test_apk': 1,
284           },
285           'includes': [ '../build/java_apk.gypi' ],
286         },
287         {
288           'target_name': 'cronet_tests_jni_headers',
289           'type': 'none',
290           'sources': [
291             'cronet/android/test/src/org/chromium/cronet_test_apk/CronetTestUtil.java',
292             'cronet/android/test/src/org/chromium/cronet_test_apk/MockUrlRequestJobFactory.java',
293             'cronet/android/test/src/org/chromium/cronet_test_apk/UploadTestServer.java',
294             'cronet/android/test/src/org/chromium/cronet_test_apk/NetworkChangeNotifierUtil.java',
295           ],
296           'variables': {
297             'jni_gen_package': 'cronet_tests',
298           },
299           'includes': [ '../build/jni_generator.gypi' ],
300         },
301         {
302           'target_name': 'libcronet_tests',
303           'type': 'shared_library',
304           'sources': [
305             'cronet/android/test/cronet_test_jni.cc',
306             'cronet/android/test/mock_url_request_job_factory.cc',
307             'cronet/android/test/mock_url_request_job_factory.h',
308             'cronet/android/test/upload_test_server.cc',
309             'cronet/android/test/upload_test_server.h',
310             'cronet/android/test/network_change_notifier_util.cc',
311             'cronet/android/test/network_change_notifier_util.h',
312           ],
313           'dependencies': [
314             'cronet_static',
315             'cronet_tests_jni_headers',
316             '../base/base.gyp:base',
317             '../net/net.gyp:net',
318             '../net/net.gyp:net_test_support',
319             '../net/net.gyp:quic_tools',
320             '../url/url.gyp:url_lib',
321             '../base/base.gyp:base_i18n',
322             '../third_party/icu/icu.gyp:icui18n',
323             '../third_party/icu/icu.gyp:icuuc',
324           ],
325           'conditions': [
326             ['use_icu_alternatives_on_android==1',
327               {
328                 'sources': [
329                   '../net/base/directory_lister.cc',
330                   '../net/base/directory_lister.h',
331                   '../net/url_request/url_request_file_job.cc',
332                   '../net/url_request/url_request_file_job.h',
333                 ]
334               }
335             ],
336           ],
337         },
338         {
339           'target_name': 'cronet_test_apk',
340           'type': 'none',
341           'dependencies': [
342             'cronet',
343           ],
344           'variables': {
345             'apk_name': 'CronetTest',
346             'java_in_dir': 'cronet/android/test',
347             'resource_dir': 'cronet/android/test/res',
348             'asset_location': 'cronet/android/test/assets',
349             'native_lib_target': 'libcronet_tests',
350           },
351           'includes': [ '../build/java_apk.gypi' ],
352         },
353         {
354           # cronet_test_apk creates a .jar as a side effect. Any java targets
355           # that need that .jar in their classpath should depend on this target,
356           # cronet_test_apk_java. Dependents of cronet_test_apk receive its
357           # jar path in the variable 'apk_output_jar_path'. This target should
358           # only be used by targets which instrument cronet_test_apk.
359           'target_name': 'cronet_test_apk_java',
360           'type': 'none',
361           'dependencies': [
362             'cronet_test_apk',
363           ],
364           'includes': [ '../build/apk_fake_jar.gypi' ],
365         },
366         {
367           'target_name': 'cronet_test_instrumentation_apk',
368           'type': 'none',
369           'dependencies': [
370             'cronet_test_apk_java',
371             '../base/base.gyp:base_java_test_support',
372           ],
373           'variables': {
374             'apk_name': 'CronetTestInstrumentation',
375             'java_in_dir': 'cronet/android/test/javatests',
376             'resource_dir': 'cronet/android/test/res',
377             'is_test_apk': 1,
378           },
379           'includes': [ '../build/java_apk.gypi' ],
380         },
381       ],
382     }],  # OS=="android"
383     ['OS=="android" and use_icu_alternatives_on_android==1', {
384       'targets': [
385         {
386           'target_name': 'cronet_package',
387           'type': 'none',
388           'dependencies': [
389             'libcronet',
390             'cronet',
391             'cronet_stub',
392           ],
393           'variables': {
394             'native_lib': 'libcronet.>(android_product_extension)',
395             'java_lib': 'cronet.jar',
396             'java_stub_lib': 'cronet_stub.jar',
397             'java_src_lib': 'cronet-src.jar',
398             'java_sample_src_lib': 'cronet-sample-src.jar',
399             'lib_java_dir': '<(PRODUCT_DIR)/lib.java',
400             'package_dir': '<(PRODUCT_DIR)/cronet',
401             'intermediate_dir': '<(SHARED_INTERMEDIATE_DIR)/cronet',
402             'jar_extract_dir': '<(intermediate_dir)/cronet_jar_extract',
403             'jar_excluded_classes': [
404               '*/library_loader/*',
405             ],
406             'jar_extract_stamp': '<(intermediate_dir)/jar_extract.stamp',
407             'cronet_jar_stamp': '<(intermediate_dir)/cronet_jar.stamp',
408           },
409           'actions': [
410             {
411               'action_name': 'strip libcronet',
412               'inputs': ['<(SHARED_LIB_DIR)/<(native_lib)'],
413               'outputs': ['<(package_dir)/libs/<(android_app_abi)/<(native_lib)'],
414               'action': [
415                 '<(android_strip)',
416                 '--strip-unneeded',
417                 '<@(_inputs)',
418                 '-o',
419                 '<@(_outputs)',
420               ],
421             },
422             {
423               'action_name': 'extracting from jars',
424               'inputs':  [
425                 '<(lib_java_dir)/<(java_lib)',
426                 '<(lib_java_dir)/base_java.jar',
427                 '<(lib_java_dir)/net_java.jar',
428                 '<(lib_java_dir)/url_java.jar',
429               ],
430               'outputs': ['<(jar_extract_stamp)', '<(jar_extract_dir)'],
431               'action': [
432                 'python',
433                 'cronet/tools/extract_from_jars.py',
434                 '--classes-dir=<(jar_extract_dir)',
435                 '--jars=<@(_inputs)',
436                 '--stamp=<(jar_extract_stamp)',
437               ],
438             },
439             {
440               'action_name': 'jar_<(_target_name)',
441               'message': 'Creating <(_target_name) jar',
442               'inputs': [
443                 '<(DEPTH)/build/android/gyp/util/build_utils.py',
444                 '<(DEPTH)/build/android/gyp/util/md5_check.py',
445                 '<(DEPTH)/build/android/gyp/jar.py',
446                 '<(jar_extract_stamp)',
447               ],
448               'outputs': [
449                 '<(package_dir)/<(java_lib)',
450                 '<(cronet_jar_stamp)',
451               ],
452               'action': [
453                 'python', '<(DEPTH)/build/android/gyp/jar.py',
454                 '--classes-dir=<(jar_extract_dir)',
455                 '--jar-path=<(package_dir)/<(java_lib)',
456                 '--excluded-classes=<@(jar_excluded_classes)',
457                 '--stamp=<(cronet_jar_stamp)',
458               ]
459             },
460             {
461               'action_name': 'jar_src_<(_target_name)',
462               'inputs': ['cronet/tools/jar_src.py'] ,
463               'outputs': ['<(package_dir)/<(java_src_lib)'],
464               'action': [
465                 'python',
466                 '<@(_inputs)',
467                 '--src-dir=cronet/android/java/src',
468                 '--jar-path=<(package_dir)/<(java_src_lib)',
469               ],
470             },
471             {
472               'action_name': 'jar_sample_src_<(_target_name)',
473               'inputs': ['cronet/tools/jar_src.py'] ,
474               'outputs': ['<(package_dir)/<(java_sample_src_lib)'],
475               'action': [
476                 'python',
477                 '<@(_inputs)',
478                 '--src-dir=cronet/android/sample',
479                 '--jar-path=<(package_dir)/<(java_sample_src_lib)',
480               ],
481             },
482             {
483               'action_name': 'generate licenses',
484               'inputs': ['cronet/tools/cronet_licenses.py'] ,
485               'outputs': ['<(package_dir)/LICENSE'],
486               'action': [
487                 'python',
488                 '<@(_inputs)',
489                 'license',
490                 '<@(_outputs)',
491               ],
492             },
493           ],
494           'copies': [
495             {
496               'destination': '<(package_dir)',
497               'files': [
498                 '../AUTHORS',
499                 '../chrome/VERSION',
500                 'cronet/android/proguard.cfg',
501                 '<(lib_java_dir)/<(java_stub_lib)'
502               ],
503             },
504             {
505               'destination': '<(package_dir)/symbols/<(android_app_abi)',
506               'files': [
507                 '<(SHARED_LIB_DIR)/<(native_lib)',
508               ],
509             },
510           ],
511         },
512       ],
513     }],  # OS=="android" and use_icu_alternatives_on_android==1
514   ],