• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) IBM Corporation and Others. All Rights Reserved.
2# very loosely based on icu.gyp from Chromium:
3# Copyright (c) 2012 The Chromium Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7
8{
9  'variables': {
10    'icu_src_derb': [
11      '<(icu_path)/source/tools/genrb/derb.c',
12      '<(icu_path)/source/tools/genrb/derb.cpp'
13    ],
14  },
15  'includes': [ '../../icu_config.gypi' ],
16  'targets': [
17    {
18      # a target for additional uconfig defines, target only
19      'target_name': 'icu_uconfig_target',
20      'type': 'none',
21      'toolsets': [ 'target' ],
22      'direct_dependent_settings': {
23        'defines': []
24      },
25    },
26    {
27      # a target to hold uconfig defines.
28      # for now these are hard coded, but could be defined.
29      'target_name': 'icu_uconfig',
30      'type': 'none',
31      'toolsets': [ 'host', 'target' ],
32      'direct_dependent_settings': {
33        'defines': [
34          'UCONFIG_NO_SERVICE=1',
35          'U_ENABLE_DYLOAD=0',
36          'U_STATIC_IMPLEMENTATION=1',
37          'U_HAVE_STD_STRING=1',
38          # TODO(srl295): reenable following pending
39          # https://code.google.com/p/v8/issues/detail?id=3345
40          # (saves some space)
41          'UCONFIG_NO_BREAK_ITERATION=0',
42        ],
43      }
44    },
45    {
46      # a target to hold common settings.
47      # make any target that is ICU implementation depend on this.
48      'target_name': 'icu_implementation',
49      'toolsets': [ 'host', 'target' ],
50      'type': 'none',
51      'direct_dependent_settings': {
52        'conditions': [
53          [ 'os_posix == 1 and OS != "mac" and OS != "ios"', {
54            'cflags': [ '-Wno-deprecated-declarations', '-Wno-strict-aliasing' ],
55            'cflags_cc': [ '-frtti' ],
56            'cflags_cc!': [ '-fno-rtti' ],
57          }],
58          [ 'OS == "mac" or OS == "ios"', {
59            'xcode_settings': {'GCC_ENABLE_CPP_RTTI': 'YES' },
60          }],
61          [ 'OS == "win"', {
62            'msvs_settings': {
63              'VCCLCompilerTool': {'RuntimeTypeInfo': 'true'},
64            }
65          }],
66        ],
67        'msvs_settings': {
68          'VCCLCompilerTool': {
69            'RuntimeTypeInfo': 'true',
70            'ExceptionHandling': '1',
71            'AdditionalOptions': [ '/source-charset:utf-8' ],
72          },
73        },
74        'configurations': {
75          # TODO: why does this need to be redefined for Release and Debug?
76          # Maybe this should be pushed into common.gypi with an "if v8 i18n"?
77          'Release': {
78            'msvs_settings': {
79              'VCCLCompilerTool': {
80                'RuntimeTypeInfo': 'true',
81                'ExceptionHandling': '1',
82              },
83            },
84          },
85          'Debug': {
86            'msvs_settings': {
87              'VCCLCompilerTool': {
88                'RuntimeTypeInfo': 'true',
89                'ExceptionHandling': '1',
90              },
91            },
92          },
93        },
94        'defines': [
95          'U_ATTRIBUTE_DEPRECATED=',
96          'U_STATIC_IMPLEMENTATION=1',
97        ],
98      },
99    },
100    {
101      'target_name': 'icui18n',
102      'toolsets': [ 'target', 'host' ],
103      'conditions' : [
104        ['_toolset=="target"', {
105          'type': '<(library)',
106          'sources': [
107            '<@(icu_src_i18n)'
108          ],
109          'include_dirs': [
110            '<(icu_path)/source/i18n',
111          ],
112          'defines': [
113            'U_I18N_IMPLEMENTATION=1',
114          ],
115          'dependencies': [ 'icuucx', 'icu_implementation', 'icu_uconfig', 'icu_uconfig_target' ],
116          'direct_dependent_settings': {
117            'include_dirs': [
118              '<(icu_path)/source/i18n',
119            ],
120          },
121          'export_dependent_settings': [ 'icuucx', 'icu_uconfig_target' ],
122        }],
123        ['_toolset=="host"', {
124          'type': 'none',
125          'dependencies': [ 'icutools#host' ],
126          'export_dependent_settings': [ 'icutools' ],
127        }],
128      ],
129    },
130    # This exports actual ICU data
131    {
132      'target_name': 'icudata',
133      'type': '<(library)',
134      'toolsets': [ 'target' ],
135      'conditions': [
136        [ 'OS == "win"', {
137          'conditions': [
138            [ 'icu_small == "false"', { # and OS=win
139              # full data - just build the full data file, then we are done.
140              'sources': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness)_dat.<(icu_asm_ext)' ],
141              'dependencies': [ 'genccode#host' ],
142              'actions': [
143                {
144                  'action_name': 'icudata',
145                  'msvs_quote_cmd': 0,
146                  'inputs': [ '<(icu_data_in)' ],
147                  'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness)_dat.<(icu_asm_ext)' ],
148                  # on Windows, we can go directly to .obj file (-o) option.
149                  'action': [ '<(PRODUCT_DIR)/genccode<(EXECUTABLE_SUFFIX)',
150                              '<@(icu_asm_opts)', # -o
151                              '-d', '<(SHARED_INTERMEDIATE_DIR)',
152                              '-n', 'icudata',
153                              '-e', 'icudt<(icu_ver_major)',
154                              '<@(_inputs)' ],
155                },
156              ],
157            }, { # icu_small == TRUE and OS == win
158              # link against stub data primarily
159              # then, use icupkg and genccode to rebuild data
160              'dependencies': [ 'icustubdata', 'genccode#host', 'icupkg#host', 'genrb#host', 'iculslocs#host' ],
161              'export_dependent_settings': [ 'icustubdata' ],
162              'actions': [
163                {
164                  # trim down ICU
165                  'action_name': 'icutrim',
166                  'msvs_quote_cmd': 0,
167                  'inputs': [ '<(icu_data_in)', 'icu_small.json' ],
168                  'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/icutmp/icudt<(icu_ver_major)<(icu_endianness).dat' ],
169                  'action': [ '<(python)',
170                              'icutrim.py',
171                              '-P', '<(PRODUCT_DIR)/.', # '.' suffix is a workaround against GYP assumptions :(
172                              '-D', '<(icu_data_in)',
173                              '--delete-tmp',
174                              '-T', '<(SHARED_INTERMEDIATE_DIR)/icutmp',
175                              '-F', 'icu_small.json',
176                              '-O', 'icudt<(icu_ver_major)<(icu_endianness).dat',
177                              '-v',
178                              '-L', '<(icu_locales)'],
179                },
180                {
181                  # build final .dat -> .obj
182                  'action_name': 'genccode',
183                  'msvs_quote_cmd': 0,
184                  'inputs': [ '<(SHARED_INTERMEDIATE_DIR)/icutmp/icudt<(icu_ver_major)<(icu_endianness).dat' ],
185                  'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness)_dat.<(icu_asm_ext)' ],
186                  'action': [ '<(PRODUCT_DIR)/genccode<(EXECUTABLE_SUFFIX)',
187                              '<@(icu_asm_opts)', # -o
188                              '-d', '<(SHARED_INTERMEDIATE_DIR)/',
189                              '-n', 'icudata',
190                              '-e', 'icusmdt<(icu_ver_major)',
191                              '<@(_inputs)' ],
192                },
193              ],
194              # This file contains the small ICU data.
195              'sources': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness)_dat.<(icu_asm_ext)' ],
196            } ] ], #end of OS==win and icu_small == true
197        }, { # OS != win
198          'conditions': [
199            [ 'icu_small == "false"', {
200              # full data - no trim needed
201              'sources': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)_dat.<(icu_asm_ext)' ],
202              'dependencies': [ 'genccode#host', 'icupkg#host', 'icu_implementation#host', 'icu_uconfig' ],
203              'include_dirs': [
204                '<(icu_path)/source/common',
205              ],
206              'actions': [
207                {
208                   # Copy the .dat file, swapping endianness if needed.
209                   'action_name': 'icupkg',
210                   'inputs': [ '<(icu_data_in)' ],
211                   'outputs':[ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness).dat' ],
212                   'action': [ '<(PRODUCT_DIR)/icupkg<(EXECUTABLE_SUFFIX)',
213                               '-t<(icu_endianness)',
214                               '<@(_inputs)',
215                               '<@(_outputs)',
216                             ],
217                },
218                {
219                   # Rename without the endianness marker (icudt64l.dat -> icudt64.dat)
220                   'action_name': 'copy',
221                   'inputs': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness).dat' ],
222                   'outputs':[ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major).dat' ],
223                   'action': [ 'cp',
224                               '<@(_inputs)',
225                               '<@(_outputs)',
226                             ],
227                },
228                {
229                  # convert full ICU data file to .c, or .S, etc.
230                  'action_name': 'icudata',
231                  'inputs': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major).dat' ],
232                  'outputs':[ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)_dat.<(icu_asm_ext)' ],
233                  'action': [ '<(PRODUCT_DIR)/genccode<(EXECUTABLE_SUFFIX)',
234                              '-e', 'icudt<(icu_ver_major)',
235                              '-d', '<(SHARED_INTERMEDIATE_DIR)',
236                              '<@(icu_asm_opts)',
237                              '-f', 'icudt<(icu_ver_major)_dat',
238                              '<@(_inputs)' ],
239                },
240              ], # end actions
241            }, { # icu_small == true ( and OS != win )
242              # link against stub data (as primary data)
243              # then, use icupkg and genccode to rebuild small data
244              'dependencies': [ 'icustubdata', 'genccode#host', 'icupkg#host', 'genrb#host', 'iculslocs#host',
245                               'icu_implementation', 'icu_uconfig' ],
246              'export_dependent_settings': [ 'icustubdata' ],
247              'actions': [
248                {
249                  # Trim down ICU.
250                  # Note that icupkg is invoked automatically, swapping endianness if needed.
251                  'action_name': 'icutrim',
252                  'inputs': [ '<(icu_data_in)', 'icu_small.json' ],
253                  'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/icutmp/icudt<(icu_ver_major)<(icu_endianness).dat' ],
254                  'action': [ '<(python)',
255                              'icutrim.py',
256                              '-P', '<(PRODUCT_DIR)',
257                              '-D', '<(icu_data_in)',
258                              '--delete-tmp',
259                              '-T', '<(SHARED_INTERMEDIATE_DIR)/icutmp',
260                              '-F', 'icu_small.json',
261                              '-O', 'icudt<(icu_ver_major)<(icu_endianness).dat',
262                              '-v',
263                              '-L', '<(icu_locales)'],
264                }, {
265                  # rename to get the final entrypoint name right (icudt64l.dat -> icusmdt64.dat)
266                   'action_name': 'rename',
267                   'inputs': [ '<(SHARED_INTERMEDIATE_DIR)/icutmp/icudt<(icu_ver_major)<(icu_endianness).dat' ],
268                   'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/icutmp/icusmdt<(icu_ver_major).dat' ],
269                   'action': [ 'cp',
270                               '<@(_inputs)',
271                               '<@(_outputs)',
272                             ],
273                }, {
274                  # For icu-small, always use .c, don't try to use .S, etc.
275                  'action_name': 'genccode',
276                  'inputs': [ '<(SHARED_INTERMEDIATE_DIR)/icutmp/icusmdt<(icu_ver_major).dat' ],
277                  'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/icusmdt<(icu_ver_major)_dat.<(icu_asm_ext)' ],
278                  'action': [ '<(PRODUCT_DIR)/genccode<(EXECUTABLE_SUFFIX)',
279                              '<@(icu_asm_opts)',
280                              '-d', '<(SHARED_INTERMEDIATE_DIR)',
281                              '<@(_inputs)' ],
282                },
283              ],
284              # This file contains the small ICU data
285              'sources': [ '<(SHARED_INTERMEDIATE_DIR)/icusmdt<(icu_ver_major)_dat.<(icu_asm_ext)' ],
286              # for umachine.h
287              'include_dirs': [
288                '<(icu_path)/source/common',
289              ],
290            }]], # end icu_small == true
291        }]], # end OS != win
292    }, # end icudata
293    # icustubdata is a tiny (~1k) symbol with no ICU data in it.
294    # tools must link against it as they are generating the full data.
295    {
296      'target_name': 'icustubdata',
297      'type': '<(library)',
298      'toolsets': [ 'target' ],
299      'dependencies': [ 'icu_implementation' ],
300      'sources': [
301        '<@(icu_src_stubdata)'
302      ],
303      'include_dirs': [
304        '<(icu_path)/source/common',
305      ],
306    },
307    # this target is for v8 consumption.
308    # it is icuuc + stubdata
309    # it is only built for target
310    {
311      'target_name': 'icuuc',
312      'type': 'none',
313      'toolsets': [ 'target', 'host' ],
314      'conditions' : [
315        ['_toolset=="host"', {
316          'dependencies': [ 'icutools#host' ],
317          'export_dependent_settings': [ 'icutools' ],
318        }],
319        ['_toolset=="target"', {
320          'dependencies': [ 'icuucx', 'icudata' ],
321          'export_dependent_settings': [ 'icuucx', 'icudata' ],
322        }],
323      ],
324    },
325    # This is the 'real' icuuc.
326    {
327      'target_name': 'icuucx',
328      'type': '<(library)',
329      'dependencies': [ 'icu_implementation', 'icu_uconfig', 'icu_uconfig_target' ],
330      'toolsets': [ 'target' ],
331      'sources': [
332        '<@(icu_src_common)',
333      ],
334          ## if your compiler can dead-strip, this will
335          ## make ZERO difference to binary size.
336          ## Made ICU-specific for future-proofing.
337      'conditions': [
338        [ 'OS == "solaris"', { 'defines': [
339          '_XOPEN_SOURCE_EXTENDED=0',
340        ]}],
341      ],
342      'include_dirs': [
343        '<(icu_path)/source/common',
344      ],
345      'defines': [
346        'U_COMMON_IMPLEMENTATION=1',
347      ],
348      'cflags_c': ['-std=c99'],
349      'export_dependent_settings': [ 'icu_uconfig', 'icu_uconfig_target' ],
350      'direct_dependent_settings': {
351        'include_dirs': [
352          '<(icu_path)/source/common',
353        ],
354        'conditions': [
355          [ 'OS=="win"', {
356            'link_settings': {
357              'libraries': [ '-lAdvAPI32.lib', '-lUser32.lib' ],
358            },
359          }],
360        ],
361      },
362    },
363    # tools library. This builds all of ICU together.
364    {
365      'target_name': 'icutools',
366      'type': '<(library)',
367      'toolsets': [ 'host' ],
368      'dependencies': [ 'icu_implementation', 'icu_uconfig' ],
369      'sources': [
370        '<@(icu_src_tools)',
371        '<@(icu_src_common)',
372        '<@(icu_src_i18n)',
373        '<@(icu_src_stubdata)',
374      ],
375      'sources!': [
376        '<(icu_path)/source/tools/toolutil/udbgutil.cpp',
377        '<(icu_path)/source/tools/toolutil/udbgutil.h',
378        '<(icu_path)/source/tools/toolutil/dbgutil.cpp',
379        '<(icu_path)/source/tools/toolutil/dbgutil.h',
380      ],
381      'include_dirs': [
382        '<(icu_path)/source/common',
383        '<(icu_path)/source/i18n',
384        '<(icu_path)/source/tools/toolutil',
385      ],
386      'defines': [
387        'U_COMMON_IMPLEMENTATION=1',
388        'U_I18N_IMPLEMENTATION=1',
389        'U_IO_IMPLEMENTATION=1',
390        'U_TOOLUTIL_IMPLEMENTATION=1',
391        #'DEBUG=0', # http://bugs.icu-project.org/trac/ticket/10977
392      ],
393      'cflags_c': ['-std=c99'],
394      'conditions': [
395        ['OS == "solaris"', {
396          'defines': [ '_XOPEN_SOURCE_EXTENDED=0' ]
397        }]
398      ],
399      'direct_dependent_settings': {
400        'include_dirs': [
401          '<(icu_path)/source/common',
402          '<(icu_path)/source/i18n',
403          '<(icu_path)/source/tools/toolutil',
404        ],
405        'conditions': [
406          [ 'OS=="win"', {
407            'link_settings': {
408              'libraries': [ '-lAdvAPI32.lib', '-lUser32.lib' ],
409            },
410          }],
411        ],
412      },
413      'export_dependent_settings': [ 'icu_uconfig' ],
414    },
415    # This tool is needed to rebuild .res files from .txt,
416    # or to build index (res_index.txt) files for small-icu
417    {
418      'target_name': 'genrb',
419      'type': 'executable',
420      'toolsets': [ 'host' ],
421      'dependencies': [ 'icutools', 'icu_implementation' ],
422      'sources': [
423        '<@(icu_src_genrb)'
424      ],
425      # derb is a separate executable
426      # (which is not currently built)
427      'sources!': [
428        '<@(icu_src_derb)',
429        'no-op.cc',
430      ],
431      'conditions': [
432        # Avoid excessive LTO
433        ['enable_lto=="true"', {
434          'ldflags': [ '-fno-lto' ],
435        }],
436      ],
437    },
438    # This tool is used to rebuild res_index.res manifests
439    {
440      'target_name': 'iculslocs',
441      'toolsets': [ 'host' ],
442      'type': 'executable',
443      'dependencies': [ 'icutools' ],
444      'sources': [
445        'iculslocs.cc',
446        'no-op.cc',
447      ],
448      'conditions': [
449        # Avoid excessive LTO
450        ['enable_lto=="true"', {
451          'ldflags': [ '-fno-lto' ],
452        }],
453      ],
454    },
455    # This tool is used to package, unpackage, repackage .dat files
456    # and convert endianesses
457    {
458      'target_name': 'icupkg',
459      'toolsets': [ 'host' ],
460      'type': 'executable',
461      'dependencies': [ 'icutools' ],
462      'sources': [
463        '<@(icu_src_icupkg)',
464        'no-op.cc',
465      ],
466      'conditions': [
467        # Avoid excessive LTO
468        ['enable_lto=="true"', {
469          'ldflags': [ '-fno-lto' ],
470        }],
471      ],
472    },
473    # this is used to convert .dat directly into .obj
474    {
475      'target_name': 'genccode',
476      'toolsets': [ 'host' ],
477      'type': 'executable',
478      'dependencies': [ 'icutools' ],
479      'sources': [
480        '<@(icu_src_genccode)',
481        'no-op.cc',
482      ],
483      'conditions': [
484        # Avoid excessive LTO
485        ['enable_lto=="true"', {
486          'ldflags': [ '-fno-lto' ],
487        }],
488      ],
489    },
490  ],
491}
492