1# Copyright (c) 2012 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.
4
5{
6  'includes': [
7    'icu.gypi',
8  ],
9  'variables': {
10    'use_system_icu%': 0,
11    'icu_use_data_file_flag%': 0,
12    'want_separate_host_toolset%': 1,
13  },
14  'target_defaults': {
15    'direct_dependent_settings': {
16      'defines': [
17        # Tell ICU to not insert |using namespace icu;| into its headers,
18        # so that chrome's source explicitly has to use |icu::|.
19        'U_USING_ICU_NAMESPACE=0',
20        # We don't use ICU plugins and dyload is only necessary for them.
21        # NaCl-related builds also fail looking for dlfcn.h when it's enabled.
22        'U_ENABLE_DYLOAD=0',
23      ],
24    },
25    'defines': [
26      'U_USING_ICU_NAMESPACE=0',
27      'HAVE_DLOPEN=0',
28    ],
29    'conditions': [
30      ['component=="static_library"', {
31        'defines': [
32          'U_STATIC_IMPLEMENTATION',
33        ],
34      }],
35      ['(OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
36         or OS=="netbsd" or OS=="mac" or OS=="android" or OS=="qnx") and \
37        (target_arch=="arm" or target_arch=="ia32" or \
38         target_arch=="mipsel")', {
39        'target_conditions': [
40          ['_toolset=="host"', {
41            'cflags': [ '-m32' ],
42            'ldflags': [ '-m32' ],
43            'asflags': [ '-32' ],
44            'xcode_settings': {
45              'ARCHS': [ 'i386' ],
46            },
47          }],
48        ],
49      }],
50      ['(OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
51         or OS=="netbsd" or OS=="mac" or OS=="android" or OS=="qnx") and \
52        (target_arch=="arm64" or target_arch=="x64" or \
53         target_arch=="mipsel64")', {
54        'target_conditions': [
55          ['_toolset=="host"', {
56            'cflags': [ '-m64' ],
57            'ldflags': [ '-m64' ],
58            'asflags': [ '-64' ],
59            'xcode_settings': {
60              'ARCHS': [ 'x86_64' ],
61            },
62          }],
63        ],
64      }],
65    ],
66    'include_dirs': [
67      'source/common',
68      'source/i18n',
69    ],
70    'msvs_disabled_warnings': [4005, 4068, 4355, 4996, 4267],
71  },
72  'conditions': [
73    ['use_system_icu==0 or want_separate_host_toolset==1', {
74      'targets': [
75        {
76          'target_name': 'copy_icudtl_dat',
77          'type': 'none',
78          # icudtl.dat is the same for both host/target, so this only supports a
79          # single toolset. If a target requires that the .dat file be copied
80          # to the output directory, it should explicitly depend on this target
81          # with the host toolset (like copy_icudtl_dat#host).
82          'toolsets': [ 'host' ],
83          'copies': [{
84            'destination': '<(PRODUCT_DIR)',
85            'conditions': [
86              ['OS == "android"', {
87                'files': [
88                  'android/icudtl.dat',
89                ],
90              } , { # else: OS != android
91                'files': [
92                  'source/data/in/icudtl.dat',
93                ],
94              }],
95            ],
96          }],
97        },
98        {
99          'target_name': 'icudata',
100          'type': 'static_library',
101          'defines': [
102            'U_HIDE_DATA_SYMBOL',
103          ],
104          'sources': [
105             # These are hand-generated, but will do for now.  The linux
106             # version is an identical copy of the (mac) icudtl_dat.S file,
107             # modulo removal of the .private_extern and .const directives and
108             # with no leading underscore on the icudt52_dat symbol.
109             'android/icudtl_dat.S',
110             'linux/icudtl_dat.S',
111             'mac/icudtl_dat.S',
112          ],
113          'conditions': [
114            [ 'use_system_icu==1 and want_separate_host_toolset==1', {
115              'toolsets': ['host'],
116            }],
117            [ 'use_system_icu==0 and want_separate_host_toolset==1', {
118              'toolsets': ['host', 'target'],
119            }],
120            [ 'use_system_icu==0 and want_separate_host_toolset==0', {
121              'toolsets': ['target'],
122            }],
123            [ 'OS == "win" and icu_use_data_file_flag==0', {
124              'type': 'none',
125              'copies': [
126                {
127                  'destination': '<(PRODUCT_DIR)',
128                  'files': [
129                    'windows/icudt.dll',
130                  ],
131                },
132              ],
133            }],
134            [ 'icu_use_data_file_flag==1', {
135              # Remove any assembly data file.
136              'sources/': [['exclude', 'icudtl_dat']],
137              # Compile in the stub data symbol.
138              'sources': ['source/stubdata/stubdata.c'],
139
140              # Make sure any binary depending on this gets the data file.
141              'conditions': [
142                ['OS != "ios"', {
143                  'dependencies': [
144                    'copy_icudtl_dat#host',
145                  ],
146                } , { # else: OS=="ios"
147                  'link_settings': {
148                    'mac_bundle_resources': [
149                      'source/data/in/icudtl.dat',
150                    ],
151                  },
152                }], # OS!=ios
153              ], # conditions
154            }], # icu_use_data_file_flag
155          ], # conditions
156          'target_conditions': [
157            [ 'OS == "win" or OS == "mac" or OS == "ios" or '
158              '(OS == "android" and (_toolset != "host" or host_os != "linux")) or '
159              '(OS == "qnx" and (_toolset == "host" and host_os != "linux"))', {
160              'sources!': ['linux/icudtl_dat.S'],
161            }],
162            [ 'OS != "android" or _toolset == "host"', {
163              'sources!': ['android/icudtl_dat.S'],
164            }],
165            [ 'OS != "mac" and OS != "ios" and '
166              '((OS != "android" and OS != "qnx") or '
167              '_toolset != "host" or host_os != "mac")', {
168              'sources!': ['mac/icudtl_dat.S'],
169            }],
170          ], # target_conditions
171        },
172        {
173          'target_name': 'icui18n',
174          'type': '<(component)',
175          'sources': [
176            '<@(icui18n_sources)',
177          ],
178          'defines': [
179            'U_I18N_IMPLEMENTATION',
180          ],
181          'dependencies': [
182            'icuuc',
183          ],
184          'direct_dependent_settings': {
185            'include_dirs': [
186              'source/i18n',
187            ],
188          },
189          'variables': {
190            'clang_warning_flags': [
191              # ICU uses its own deprecated functions.
192              '-Wno-deprecated-declarations',
193              # ICU prefers `a && b || c` over `(a && b) || c`.
194              '-Wno-logical-op-parentheses',
195              # ICU has some `unsigned < 0` checks.
196              '-Wno-tautological-compare',
197              # Looks like a real issue, see http://crbug.com/114660
198              '-Wno-return-type-c-linkage',
199            ],
200          },
201          # Since ICU wants to internally use its own deprecated APIs, don't
202          # complain about it.
203          'cflags': [
204            '-Wno-deprecated-declarations',
205          ],
206          'cflags_cc': [
207            '-frtti',
208          ],
209          'xcode_settings': {
210            'GCC_ENABLE_CPP_RTTI': 'YES',       # -frtti
211          },
212          'msvs_settings': {
213            'VCCLCompilerTool': {
214              'RuntimeTypeInfo': 'true',
215            },
216          },
217          'conditions': [
218            [ 'use_system_icu==1 and want_separate_host_toolset==1', {
219              'toolsets': ['host'],
220            }],
221            [ 'use_system_icu==0 and want_separate_host_toolset==1', {
222              'toolsets': ['host', 'target'],
223            }],
224            [ 'use_system_icu==0 and want_separate_host_toolset==0', {
225              'toolsets': ['target'],
226            }],
227            ['OS == "android" and clang==0', {
228                # Disable sincos() optimization to avoid a linker error since
229                # Android's math library doesn't have sincos().  Either
230                # -fno-builtin-sin or -fno-builtin-cos works.
231                'cflags': [
232                    '-fno-builtin-sin',
233                ],
234            }],
235            [ 'OS == "win" and clang==1', {
236              # Note: General clang warnings should go in the
237              # clang_warning_flags block above.
238              'msvs_settings': {
239                'VCCLCompilerTool': {
240                  'AdditionalOptions': [
241                    # See http://bugs.icu-project.org/trac/ticket/11122
242                    '-Wno-inline-new-delete',
243                    '-Wno-implicit-exception-spec-mismatch',
244                  ],
245                },
246              },
247            }],
248            ['OS == "android" and use_system_stlport == 1', {
249              'target_conditions': [
250                ['_toolset == "target"', {
251                  # ICU requires RTTI, which is not present in the system's
252                  # stlport, so we have to include gabi++.
253                  'include_dirs': [
254                    '<(android_src)/abi/cpp/include',
255                  ],
256                }],
257              ],
258            }],
259          ], # conditions
260        },
261        {
262          'target_name': 'icuuc',
263          'type': '<(component)',
264          'sources': [
265            '<@(icuuc_sources)',
266          ],
267          'defines': [
268            'U_COMMON_IMPLEMENTATION',
269          ],
270          'dependencies': [
271            'icudata',
272          ],
273          'direct_dependent_settings': {
274            'include_dirs': [
275              'source/common',
276            ],
277            'conditions': [
278              [ 'component=="static_library"', {
279                'defines': [
280                  'U_STATIC_IMPLEMENTATION',
281                ],
282              }],
283            ],
284          },
285          'variables': {
286            'clang_warning_flags': [
287              # ICU uses its own deprecated functions.
288              '-Wno-deprecated-declarations',
289              # ICU prefers `a && b || c` over `(a && b) || c`.
290              '-Wno-logical-op-parentheses',
291              # ICU has some `unsigned < 0` checks.
292              '-Wno-tautological-compare',
293              # uresdata.c has switch(RES_GET_TYPE(x)) code. The
294              # RES_GET_TYPE macro returns an UResType enum, but some switch
295              # statement contains case values that aren't part of that
296              # enum (e.g. URES_TABLE32 which is in UResInternalType). This
297              # is on purpose.
298              '-Wno-switch',
299            ],
300          },
301          'cflags': [
302            # Since ICU wants to internally use its own deprecated APIs,
303            # don't complain about it.
304            '-Wno-deprecated-declarations',
305            '-Wno-unused-function',
306          ],
307          'cflags_cc': [
308            '-frtti',
309          ],
310          'xcode_settings': {
311            'GCC_ENABLE_CPP_RTTI': 'YES',       # -frtti
312          },
313          'msvs_settings': {
314            'VCCLCompilerTool': {
315              'RuntimeTypeInfo': 'true',
316            },
317          },
318          'all_dependent_settings': {
319            'msvs_settings': {
320              'VCLinkerTool': {
321                'AdditionalDependencies': [
322                  'advapi32.lib',
323                ],
324              },
325            },
326          },
327          'conditions': [
328            [ 'use_system_icu==1 and want_separate_host_toolset==1', {
329              'toolsets': ['host'],
330            }],
331            [ 'use_system_icu==0 and want_separate_host_toolset==1', {
332              'toolsets': ['host', 'target'],
333            }],
334            [ 'use_system_icu==0 and want_separate_host_toolset==0', {
335              'toolsets': ['target'],
336            }],
337            [ 'OS == "win" and icu_use_data_file_flag==0', {
338              'sources': [
339                'source/stubdata/stubdata.c',
340              ],
341            }],
342            [ 'OS == "win" and clang==1', {
343              # Note: General clang warnings should go in the
344              # clang_warning_flags block above.
345              'msvs_settings': {
346                'VCCLCompilerTool': {
347                  'AdditionalOptions': [
348                    # See http://bugs.icu-project.org/trac/ticket/11122
349                    '-Wno-inline-new-delete',
350                    '-Wno-implicit-exception-spec-mismatch',
351                  ],
352                },
353              },
354            }],
355            ['OS == "android" and use_system_stlport == 1', {
356              'target_conditions': [
357                ['_toolset == "target"', {
358                  # ICU requires RTTI, which is not present in the system's
359                  # stlport, so we have to include gabi++.
360                  'include_dirs': [
361                    '<(android_src)/abi/cpp/include',
362                  ],
363                }],
364              ],
365            }],
366          ], # conditions
367        },
368      ], # targets
369    }],
370    ['use_system_icu==1', {
371      'targets': [
372        {
373          'target_name': 'system_icu',
374          'type': 'none',
375          'conditions': [
376            ['OS=="android"', {
377              'direct_dependent_settings': {
378                'include_dirs': [
379                  '<(android_src)/external/icu/icu4c/source/common',
380                  '<(android_src)/external/icu/icu4c/source/i18n',
381                ],
382              },
383              'link_settings': {
384                'libraries': [
385                  '-licui18n',
386                  '-licuuc',
387                ],
388              },
389            }],
390            ['OS=="qnx"', {
391              'link_settings': {
392                'libraries': [
393                  '-licui18n',
394                  '-licuuc',
395                ],
396              },
397            }],
398            ['OS!="android" and OS!="qnx"', {
399              'link_settings': {
400                'ldflags': [
401                  '<!@(icu-config --ldflags)',
402                ],
403                'libraries': [
404                  '<!@(icu-config --ldflags-libsonly)',
405                ],
406              },
407            }],
408          ],
409        },
410        {
411          'target_name': 'icudata',
412          'type': 'none',
413          'dependencies': ['system_icu'],
414          'export_dependent_settings': ['system_icu'],
415          'toolsets': ['target'],
416        },
417        {
418          'target_name': 'icui18n',
419          'type': 'none',
420          'dependencies': ['system_icu'],
421          'export_dependent_settings': ['system_icu'],
422          'variables': {
423            'headers_root_path': 'source/i18n',
424            'header_filenames': [
425              # This list can easily be updated using the command below:
426              # find third_party/icu/source/i18n/unicode -iname '*.h' \
427              # -printf "'%p',\n" | \
428              # sed -e 's|third_party/icu/source/i18n/||' | sort -u
429              'unicode/alphaindex.h',
430              'unicode/basictz.h',
431              'unicode/calendar.h',
432              'unicode/choicfmt.h',
433              'unicode/coleitr.h',
434              'unicode/coll.h',
435              'unicode/compactdecimalformat.h',
436              'unicode/curramt.h',
437              'unicode/currpinf.h',
438              'unicode/currunit.h',
439              'unicode/datefmt.h',
440              'unicode/dcfmtsym.h',
441              'unicode/decimfmt.h',
442              'unicode/dtfmtsym.h',
443              'unicode/dtitvfmt.h',
444              'unicode/dtitvinf.h',
445              'unicode/dtptngen.h',
446              'unicode/dtrule.h',
447              'unicode/fieldpos.h',
448              'unicode/fmtable.h',
449              'unicode/format.h',
450              'unicode/fpositer.h',
451              'unicode/gender.h',
452              'unicode/gregocal.h',
453              'unicode/locdspnm.h',
454              'unicode/measfmt.h',
455              'unicode/measunit.h',
456              'unicode/measure.h',
457              'unicode/msgfmt.h',
458              'unicode/numfmt.h',
459              'unicode/numsys.h',
460              'unicode/plurfmt.h',
461              'unicode/plurrule.h',
462              'unicode/rbnf.h',
463              'unicode/rbtz.h',
464              'unicode/regex.h',
465              'unicode/region.h',
466              'unicode/search.h',
467              'unicode/selfmt.h',
468              'unicode/simpletz.h',
469              'unicode/smpdtfmt.h',
470              'unicode/sortkey.h',
471              'unicode/stsearch.h',
472              'unicode/tblcoll.h',
473              'unicode/timezone.h',
474              'unicode/tmunit.h',
475              'unicode/tmutamt.h',
476              'unicode/tmutfmt.h',
477              'unicode/translit.h',
478              'unicode/tzfmt.h',
479              'unicode/tznames.h',
480              'unicode/tzrule.h',
481              'unicode/tztrans.h',
482              'unicode/ucal.h',
483              'unicode/ucoleitr.h',
484              'unicode/ucol.h',
485              'unicode/ucsdet.h',
486              'unicode/ucurr.h',
487              'unicode/udateintervalformat.h',
488              'unicode/udat.h',
489              'unicode/udatpg.h',
490              'unicode/udisplaycontext.h',
491              'unicode/uformattable.h',
492              'unicode/ugender.h',
493              'unicode/uldnames.h',
494              'unicode/ulocdata.h',
495              'unicode/umsg.h',
496              'unicode/unirepl.h',
497              'unicode/unum.h',
498              'unicode/unumsys.h',
499              'unicode/upluralrules.h',
500              'unicode/uregex.h',
501              'unicode/uregion.h',
502              'unicode/usearch.h',
503              'unicode/uspoof.h',
504              'unicode/utmscale.h',
505              'unicode/utrans.h',
506              'unicode/vtzone.h',
507            ],
508          },
509          'includes': [
510            '../../build/shim_headers.gypi',
511          ],
512          'toolsets': ['target'],
513        },
514        {
515          'target_name': 'icuuc',
516          'type': 'none',
517          'dependencies': ['system_icu'],
518          'export_dependent_settings': ['system_icu'],
519          'variables': {
520            'headers_root_path': 'source/common',
521            'header_filenames': [
522              # This list can easily be updated using the command below:
523              # find third_party/icu/source/common/unicode -iname '*.h' \
524              # -printf "'%p',\n" | \
525              # sed -e 's|third_party/icu/source/common/||' | sort -u
526              'unicode/appendable.h',
527              'unicode/brkiter.h',
528              'unicode/bytestream.h',
529              'unicode/bytestriebuilder.h',
530              'unicode/bytestrie.h',
531              'unicode/caniter.h',
532              'unicode/chariter.h',
533              'unicode/dbbi.h',
534              'unicode/docmain.h',
535              'unicode/dtintrv.h',
536              'unicode/enumset.h',
537              'unicode/errorcode.h',
538              'unicode/icudataver.h',
539              'unicode/icuplug.h',
540              'unicode/idna.h',
541              'unicode/listformatter.h',
542              'unicode/localpointer.h',
543              'unicode/locid.h',
544              'unicode/messagepattern.h',
545              'unicode/normalizer2.h',
546              'unicode/normlzr.h',
547              'unicode/parseerr.h',
548              'unicode/parsepos.h',
549              'unicode/platform.h',
550              'unicode/ptypes.h',
551              'unicode/putil.h',
552              'unicode/rbbi.h',
553              'unicode/rep.h',
554              'unicode/resbund.h',
555              'unicode/schriter.h',
556              'unicode/std_string.h',
557              'unicode/strenum.h',
558              'unicode/stringpiece.h',
559              'unicode/stringtriebuilder.h',
560              'unicode/symtable.h',
561              'unicode/ubidi.h',
562              'unicode/ubrk.h',
563              'unicode/ucasemap.h',
564              'unicode/ucat.h',
565              'unicode/uchar.h',
566              'unicode/ucharstriebuilder.h',
567              'unicode/ucharstrie.h',
568              'unicode/uchriter.h',
569              'unicode/uclean.h',
570              'unicode/ucnv_cb.h',
571              'unicode/ucnv_err.h',
572              'unicode/ucnv.h',
573              'unicode/ucnvsel.h',
574              'unicode/uconfig.h',
575              'unicode/udata.h',
576              'unicode/uenum.h',
577              'unicode/uidna.h',
578              'unicode/uiter.h',
579              'unicode/uloc.h',
580              'unicode/umachine.h',
581              'unicode/umisc.h',
582              'unicode/unifilt.h',
583              'unicode/unifunct.h',
584              'unicode/unimatch.h',
585              'unicode/uniset.h',
586              'unicode/unistr.h',
587              'unicode/unorm2.h',
588              'unicode/unorm.h',
589              'unicode/uobject.h',
590              'unicode/urename.h',
591              'unicode/urep.h',
592              'unicode/ures.h',
593              'unicode/uscript.h',
594              'unicode/uset.h',
595              'unicode/usetiter.h',
596              'unicode/ushape.h',
597              'unicode/usprep.h',
598              'unicode/ustring.h',
599              'unicode/ustringtrie.h',
600              'unicode/utext.h',
601              'unicode/utf16.h',
602              'unicode/utf32.h',
603              'unicode/utf8.h',
604              'unicode/utf.h',
605              'unicode/utf_old.h',
606              'unicode/utrace.h',
607              'unicode/utypes.h',
608              'unicode/uvernum.h',
609              'unicode/uversion.h',
610            ],
611          },
612          'includes': [
613            '../../build/shim_headers.gypi',
614          ],
615          'toolsets': ['target'],
616        },
617      ], # targets
618    }],
619  ], # conditions
620}
621