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