• 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          '_CRT_SECURE_NO_DEPRECATE=',
97          'U_STATIC_IMPLEMENTATION=1',
98        ],
99      },
100    },
101    {
102      'target_name': 'icui18n',
103      'toolsets': [ 'target', 'host' ],
104      'conditions' : [
105        ['_toolset=="target"', {
106          'type': '<(library)',
107          'sources': [
108            '<@(icu_src_i18n)'
109          ],
110          'include_dirs': [
111            '<(icu_path)/source/i18n',
112          ],
113          'defines': [
114            'U_I18N_IMPLEMENTATION=1',
115          ],
116          'dependencies': [ 'icuucx', 'icu_implementation', 'icu_uconfig', 'icu_uconfig_target' ],
117          'direct_dependent_settings': {
118            'include_dirs': [
119              '<(icu_path)/source/i18n',
120            ],
121          },
122          'export_dependent_settings': [ 'icuucx', 'icu_uconfig_target' ],
123        }],
124        ['_toolset=="host"', {
125          'type': 'none',
126          'dependencies': [ 'icutools#host' ],
127          'export_dependent_settings': [ 'icutools' ],
128        }],
129      ],
130    },
131    # This exports actual ICU data
132    {
133      'target_name': 'icudata',
134      'type': '<(library)',
135      'toolsets': [ 'target' ],
136      'conditions': [
137        [ 'OS == "win"', {
138          'conditions': [
139            [ 'icu_small == "false"', { # and OS=win
140              # full data - just build the full data file, then we are done.
141              'sources': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness)_dat.<(icu_asm_ext)' ],
142              'dependencies': [ 'genccode#host' ],
143              'actions': [
144                {
145                  'action_name': 'icudata',
146                  'msvs_quote_cmd': 0,
147                  'inputs': [ '<(icu_data_in)' ],
148                  'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness)_dat.<(icu_asm_ext)' ],
149                  # on Windows, we can go directly to .obj file (-o) option.
150                  'action': [ '<(PRODUCT_DIR)/genccode<(EXECUTABLE_SUFFIX)',
151                              '<@(icu_asm_opts)', # -o
152                              '-d', '<(SHARED_INTERMEDIATE_DIR)',
153                              '-n', 'icudata',
154                              '-e', 'icudt<(icu_ver_major)',
155                              '<@(_inputs)' ],
156                },
157              ],
158            }, { # icu_small == TRUE and OS == win
159              # link against stub data primarily
160              # then, use icupkg and genccode to rebuild data
161              'dependencies': [ 'icustubdata', 'genccode#host', 'icupkg#host', 'genrb#host', 'iculslocs#host' ],
162              'export_dependent_settings': [ 'icustubdata' ],
163              'actions': [
164                {
165                  # trim down ICU
166                  'action_name': 'icutrim',
167                  'msvs_quote_cmd': 0,
168                  'inputs': [ '<(icu_data_in)', 'icu_small.json' ],
169                  'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/icutmp/icudt<(icu_ver_major)<(icu_endianness).dat' ],
170                  'action': [ 'python',
171                              'icutrim.py',
172                              '-P', '<(PRODUCT_DIR)/.', # '.' suffix is a workaround against GYP assumptions :(
173                              '-D', '<(icu_data_in)',
174                              '--delete-tmp',
175                              '-T', '<(SHARED_INTERMEDIATE_DIR)/icutmp',
176                              '-F', 'icu_small.json',
177                              '-O', 'icudt<(icu_ver_major)<(icu_endianness).dat',
178                              '-v',
179                              '-L', '<(icu_locales)'],
180                },
181                {
182                  # build final .dat -> .obj
183                  'action_name': 'genccode',
184                  'msvs_quote_cmd': 0,
185                  'inputs': [ '<(SHARED_INTERMEDIATE_DIR)/icutmp/icudt<(icu_ver_major)<(icu_endianness).dat' ],
186                  'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness)_dat.<(icu_asm_ext)' ],
187                  'action': [ '<(PRODUCT_DIR)/genccode<(EXECUTABLE_SUFFIX)',
188                              '<@(icu_asm_opts)', # -o
189                              '-d', '<(SHARED_INTERMEDIATE_DIR)/',
190                              '-n', 'icudata',
191                              '-e', 'icusmdt<(icu_ver_major)',
192                              '<@(_inputs)' ],
193                },
194              ],
195              # This file contains the small ICU data.
196              'sources': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness)_dat.<(icu_asm_ext)' ],
197            } ] ], #end of OS==win and icu_small == true
198        }, { # OS != win
199          'conditions': [
200            [ 'icu_small == "false"', {
201              # full data - no trim needed
202              'sources': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)_dat.<(icu_asm_ext)' ],
203              'dependencies': [ 'genccode#host', 'icupkg#host', 'icu_implementation#host', 'icu_uconfig' ],
204              'include_dirs': [
205                '<(icu_path)/source/common',
206              ],
207              'actions': [
208                {
209                   # Copy the .dat file, swapping endianness if needed.
210                   'action_name': 'icupkg',
211                   'inputs': [ '<(icu_data_in)' ],
212                   'outputs':[ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness).dat' ],
213                   'action': [ '<(PRODUCT_DIR)/icupkg<(EXECUTABLE_SUFFIX)',
214                               '-t<(icu_endianness)',
215                               '<@(_inputs)',
216                               '<@(_outputs)',
217                             ],
218                },
219                {
220                   # Rename without the endianness marker (icudt64l.dat -> icudt64.dat)
221                   'action_name': 'copy',
222                   'inputs': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness).dat' ],
223                   'outputs':[ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major).dat' ],
224                   'action': [ 'cp',
225                               '<@(_inputs)',
226                               '<@(_outputs)',
227                             ],
228                },
229                {
230                  # convert full ICU data file to .c, or .S, etc.
231                  'action_name': 'icudata',
232                  'inputs': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major).dat' ],
233                  'outputs':[ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)_dat.<(icu_asm_ext)' ],
234                  'action': [ '<(PRODUCT_DIR)/genccode<(EXECUTABLE_SUFFIX)',
235                              '-e', 'icudt<(icu_ver_major)',
236                              '-d', '<(SHARED_INTERMEDIATE_DIR)',
237                              '<@(icu_asm_opts)',
238                              '-f', 'icudt<(icu_ver_major)_dat',
239                              '<@(_inputs)' ],
240                },
241              ], # end actions
242            }, { # icu_small == true ( and OS != win )
243              # link against stub data (as primary data)
244              # then, use icupkg and genccode to rebuild small data
245              'dependencies': [ 'icustubdata', 'genccode#host', 'icupkg#host', 'genrb#host', 'iculslocs#host',
246                               'icu_implementation', 'icu_uconfig' ],
247              'export_dependent_settings': [ 'icustubdata' ],
248              'actions': [
249                {
250                  # Trim down ICU.
251                  # Note that icupkg is invoked automatically, swapping endianness if needed.
252                  'action_name': 'icutrim',
253                  'inputs': [ '<(icu_data_in)', 'icu_small.json' ],
254                  'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/icutmp/icudt<(icu_ver_major)<(icu_endianness).dat' ],
255                  'action': [ 'python',
256                              'icutrim.py',
257                              '-P', '<(PRODUCT_DIR)',
258                              '-D', '<(icu_data_in)',
259                              '--delete-tmp',
260                              '-T', '<(SHARED_INTERMEDIATE_DIR)/icutmp',
261                              '-F', 'icu_small.json',
262                              '-O', 'icudt<(icu_ver_major)<(icu_endianness).dat',
263                              '-v',
264                              '-L', '<(icu_locales)'],
265                }, {
266                  # rename to get the final entrypoint name right (icudt64l.dat -> icusmdt64.dat)
267                   'action_name': 'rename',
268                   'inputs': [ '<(SHARED_INTERMEDIATE_DIR)/icutmp/icudt<(icu_ver_major)<(icu_endianness).dat' ],
269                   'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/icutmp/icusmdt<(icu_ver_major).dat' ],
270                   'action': [ 'cp',
271                               '<@(_inputs)',
272                               '<@(_outputs)',
273                             ],
274                }, {
275                  # For icu-small, always use .c, don't try to use .S, etc.
276                  'action_name': 'genccode',
277                  'inputs': [ '<(SHARED_INTERMEDIATE_DIR)/icutmp/icusmdt<(icu_ver_major).dat' ],
278                  'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/icusmdt<(icu_ver_major)_dat.<(icu_asm_ext)' ],
279                  'action': [ '<(PRODUCT_DIR)/genccode<(EXECUTABLE_SUFFIX)',
280                              '<@(icu_asm_opts)',
281                              '-d', '<(SHARED_INTERMEDIATE_DIR)',
282                              '<@(_inputs)' ],
283                },
284              ],
285              # This file contains the small ICU data
286              'sources': [ '<(SHARED_INTERMEDIATE_DIR)/icusmdt<(icu_ver_major)_dat.<(icu_asm_ext)' ],
287              # for umachine.h
288              'include_dirs': [
289                '<(icu_path)/source/common',
290              ],
291            }]], # end icu_small == true
292        }]], # end OS != win
293    }, # end icudata
294    # icustubdata is a tiny (~1k) symbol with no ICU data in it.
295    # tools must link against it as they are generating the full data.
296    {
297      'target_name': 'icustubdata',
298      'type': '<(library)',
299      'toolsets': [ 'target' ],
300      'dependencies': [ 'icu_implementation' ],
301      'sources': [
302        '<@(icu_src_stubdata)'
303      ],
304      'include_dirs': [
305        '<(icu_path)/source/common',
306      ],
307    },
308    # this target is for v8 consumption.
309    # it is icuuc + stubdata
310    # it is only built for target
311    {
312      'target_name': 'icuuc',
313      'type': 'none',
314      'toolsets': [ 'target', 'host' ],
315      'conditions' : [
316        ['_toolset=="host"', {
317          'dependencies': [ 'icutools#host' ],
318          'export_dependent_settings': [ 'icutools' ],
319        }],
320        ['_toolset=="target"', {
321          'dependencies': [ 'icuucx', 'icudata' ],
322          'export_dependent_settings': [ 'icuucx', 'icudata' ],
323        }],
324      ],
325    },
326    # This is the 'real' icuuc.
327    {
328      'target_name': 'icuucx',
329      'type': '<(library)',
330      'dependencies': [ 'icu_implementation', 'icu_uconfig', 'icu_uconfig_target' ],
331      'toolsets': [ 'target' ],
332      'sources': [
333        '<@(icu_src_common)',
334      ],
335          ## if your compiler can dead-strip, this will
336          ## make ZERO difference to binary size.
337          ## Made ICU-specific for future-proofing.
338      'conditions': [
339        [ 'OS == "solaris"', { 'defines': [
340          '_XOPEN_SOURCE_EXTENDED=0',
341        ]}],
342      ],
343      'include_dirs': [
344        '<(icu_path)/source/common',
345      ],
346      'defines': [
347        'U_COMMON_IMPLEMENTATION=1',
348      ],
349      'cflags_c': ['-std=c99'],
350      'export_dependent_settings': [ 'icu_uconfig', 'icu_uconfig_target' ],
351      'direct_dependent_settings': {
352        'include_dirs': [
353          '<(icu_path)/source/common',
354        ],
355        'conditions': [
356          [ 'OS=="win"', {
357            'link_settings': {
358              'libraries': [ '-lAdvAPI32.lib', '-lUser32.lib' ],
359            },
360          }],
361        ],
362      },
363    },
364    # tools library. This builds all of ICU together.
365    {
366      'target_name': 'icutools',
367      'type': '<(library)',
368      'toolsets': [ 'host' ],
369      'dependencies': [ 'icu_implementation', 'icu_uconfig' ],
370      'sources': [
371        '<@(icu_src_tools)',
372        '<@(icu_src_common)',
373        '<@(icu_src_i18n)',
374        '<@(icu_src_stubdata)',
375      ],
376      'sources!': [
377        '<(icu_path)/source/tools/toolutil/udbgutil.cpp',
378        '<(icu_path)/source/tools/toolutil/udbgutil.h',
379        '<(icu_path)/source/tools/toolutil/dbgutil.cpp',
380        '<(icu_path)/source/tools/toolutil/dbgutil.h',
381      ],
382      'include_dirs': [
383        '<(icu_path)/source/common',
384        '<(icu_path)/source/i18n',
385        '<(icu_path)/source/tools/toolutil',
386      ],
387      'defines': [
388        'U_COMMON_IMPLEMENTATION=1',
389        'U_I18N_IMPLEMENTATION=1',
390        'U_IO_IMPLEMENTATION=1',
391        'U_TOOLUTIL_IMPLEMENTATION=1',
392        #'DEBUG=0', # http://bugs.icu-project.org/trac/ticket/10977
393      ],
394      'cflags_c': ['-std=c99'],
395      'conditions': [
396        ['OS == "solaris"', {
397          'defines': [ '_XOPEN_SOURCE_EXTENDED=0' ]
398        }]
399      ],
400      'direct_dependent_settings': {
401        'include_dirs': [
402          '<(icu_path)/source/common',
403          '<(icu_path)/source/i18n',
404          '<(icu_path)/source/tools/toolutil',
405        ],
406        'conditions': [
407          [ 'OS=="win"', {
408            'link_settings': {
409              'libraries': [ '-lAdvAPI32.lib', '-lUser32.lib' ],
410            },
411          }],
412        ],
413      },
414      'export_dependent_settings': [ 'icu_uconfig' ],
415    },
416    # This tool is needed to rebuild .res files from .txt,
417    # or to build index (res_index.txt) files for small-icu
418    {
419      'target_name': 'genrb',
420      'type': 'executable',
421      'toolsets': [ 'host' ],
422      'dependencies': [ 'icutools' ],
423      'sources': [
424        '<@(icu_src_genrb)'
425      ],
426      # derb is a separate executable
427      # (which is not currently built)
428      'sources!': [
429        '<@(icu_src_derb)',
430        'no-op.cc',
431      ],
432    },
433    # This tool is used to rebuild res_index.res manifests
434    {
435      'target_name': 'iculslocs',
436      'toolsets': [ 'host' ],
437      'type': 'executable',
438      'dependencies': [ 'icutools' ],
439      'sources': [
440        'iculslocs.cc',
441        'no-op.cc',
442      ],
443    },
444    # This tool is used to package, unpackage, repackage .dat files
445    # and convert endianesses
446    {
447      'target_name': 'icupkg',
448      'toolsets': [ 'host' ],
449      'type': 'executable',
450      'dependencies': [ 'icutools' ],
451      'sources': [
452        '<@(icu_src_icupkg)',
453        'no-op.cc',
454      ],
455    },
456    # this is used to convert .dat directly into .obj
457    {
458      'target_name': 'genccode',
459      'toolsets': [ 'host' ],
460      'type': 'executable',
461      'dependencies': [ 'icutools' ],
462      'sources': [
463        '<@(icu_src_genccode)',
464        'no-op.cc',
465      ],
466    },
467  ],
468}
469