|
218 | 218 | 'target_name': 'icudata',
|
219 | 219 | 'type': '<(library)',
|
220 | 220 | 'toolsets': [ 'target' ],
|
| 221 | + 'include_dirs': ['<(icu_path)/source/common', ], |
| 222 | + 'export_dependent_settings': ['icustubdata'], |
| 223 | + |
| 224 | + # ============== logic flow =============== |
| 225 | + # so we have a 2x2 matrix: win +/- vs. icu_small +/- |
| 226 | + # 1 - For small+ we trim the pre-build dat '<(icu_data_in)' |
| 227 | + # 2 - For win- && small- we need we need to repack '<(icu_data_in)' for endiness |
| 228 | + # 3 - everybody likes the <(icu_symbol_name) different, |
| 229 | + # and for some reason are sensitive to <(icudata_genccode_input) |
| 230 | + |
| 231 | + # ============== Gattchas ============== |
| 232 | + # 1 - genccode can only output .c files on non-windows |
| 233 | + # but it can directly compile to .o file on windows. |
| 234 | + # 2 - need to repack for endiness only on non-windows |
| 235 | + # 3 - '<(PRODUCT_DIR)/.' the '/.' suffix is so that GYP will not to make |
| 236 | + # a mess of this argument is the case it ends a backslash `\` |
| 237 | + # 4 - `--delete-tmp` deletes the whole content of the directory -T points |
| 238 | + # to before it operates, so we need a special <(icudata_trim_temp) |
| 239 | + # directory and then copy/rename the files back out |
| 240 | + |
| 241 | + # ============== refack comment ============== |
| 242 | + # IMHO the simplest/robust way was to parameterize the tasks, and set the |
| 243 | + # parameters in a 4 clause condition. This way I was able to make the GYP |
| 244 | + # output stay as close as I could to the previus state |
| 245 | + |
| 246 | + # P.S./TODO the situation where the `.gyp` file is in `tools/icu` while |
| 247 | + # the code is in `deps/` makes it cumbersome for a human to reason about |
| 248 | + |
| 249 | + |
| 250 | + 'variables': { |
| 251 | + 'icu_output_prefix': 'icudt<(icu_ver_major)', |
| 252 | + 'icu_output_prefix_sm': 'icusmdt<(icu_ver_major)', |
| 253 | + 'icudata_trim_temp': '<(SHARED_INTERMEDIATE_DIR)/icutmp', |
| 254 | + 'icudata_trim_name': '<(icu_output_prefix)<(icu_endianness).dat', |
| 255 | + 'icudata_trim_output': '<(icudata_trim_temp)/>(icudata_trim_name)', |
| 256 | + 'icudata_output_name_win': '>(icu_output_prefix)<(icu_endianness)_dat.obj', |
| 257 | + 'icudata_output_name_psx': '>(icu_symbol_name)_dat.c', |
| 258 | + 'icudata_genccode_extra_args': [ '-o', '-n', 'icudata', '-e', '>(icu_symbol_name)' ], |
| 259 | + 'icudata_genccode_output': '<(SHARED_INTERMEDIATE_DIR)/>(icudata_genccode_output_name)', |
| 260 | + }, |
| 261 | + 'dependencies': [ 'genccode#host', 'icupkg#host', 'genrb#host', |
| 262 | + 'iculslocs#host', 'icu_implementation', 'icustubdata', |
| 263 | + 'icu_uconfig' ], |
| 264 | + 'sources': ['<(icudata_genccode_output)'], |
| 265 | + |
221 | 266 | 'conditions': [
|
222 |
| - [ 'OS == "win"', { |
223 |
| - 'conditions': [ |
224 |
| - [ 'icu_small == "false"', { # and OS=win |
225 |
| - # full data - just build the full data file, then we are done. |
226 |
| - 'sources': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness)_dat.obj' ], |
227 |
| - 'dependencies': [ 'genccode#host' ], |
228 |
| - 'actions': [ |
229 |
| - { |
230 |
| - 'action_name': 'icudata', |
231 |
| - 'msvs_quote_cmd': 0, |
232 |
| - 'inputs': [ '<(icu_data_in)' ], |
233 |
| - 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness)_dat.obj' ], |
234 |
| - 'action': [ '<(PRODUCT_DIR)/genccode', |
235 |
| - '-o', |
236 |
| - '-d', '<(SHARED_INTERMEDIATE_DIR)', |
237 |
| - '-n', 'icudata', |
238 |
| - '-e', 'icudt<(icu_ver_major)', |
239 |
| - '<@(_inputs)' ], |
240 |
| - }, |
241 |
| - ], |
242 |
| - }, { # icu_small == TRUE and OS == win |
243 |
| - # link against stub data primarily |
244 |
| - # then, use icupkg and genccode to rebuild data |
245 |
| - 'dependencies': [ 'icustubdata', 'genccode#host', 'icupkg#host', 'genrb#host', 'iculslocs#host' ], |
246 |
| - 'export_dependent_settings': [ 'icustubdata' ], |
247 |
| - 'actions': [ |
248 |
| - { |
249 |
| - # trim down ICU |
250 |
| - 'action_name': 'icutrim', |
251 |
| - 'msvs_quote_cmd': 0, |
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)/.', # '.' suffix is a workaround against GYP assumptions :( |
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 |
| - { |
266 |
| - # build final .dat -> .obj |
267 |
| - 'action_name': 'genccode', |
268 |
| - 'msvs_quote_cmd': 0, |
269 |
| - 'inputs': [ '<(SHARED_INTERMEDIATE_DIR)/icutmp/icudt<(icu_ver_major)<(icu_endianness).dat' ], |
270 |
| - 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness)_dat.obj' ], |
271 |
| - 'action': [ '<(PRODUCT_DIR)/genccode', |
272 |
| - '-o', |
273 |
| - '-d', '<(SHARED_INTERMEDIATE_DIR)/', |
274 |
| - '-n', 'icudata', |
275 |
| - '-e', 'icusmdt<(icu_ver_major)', |
276 |
| - '<@(_inputs)' ], |
277 |
| - }, |
278 |
| - ], |
279 |
| - # This file contains the small ICU data. |
280 |
| - 'sources': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness)_dat.obj' ], |
281 |
| - } ] ], #end of OS==win and icu_small == true |
282 |
| - }, { # OS != win |
283 |
| - 'conditions': [ |
284 |
| - [ 'icu_small == "false"', { |
285 |
| - # full data - just build the full data file, then we are done. |
286 |
| - 'sources': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)_dat.c' ], |
287 |
| - 'dependencies': [ 'genccode#host', 'icupkg#host', 'icu_implementation#host', 'icu_uconfig' ], |
288 |
| - 'include_dirs': [ |
289 |
| - '<(icu_path)/source/common', |
290 |
| - ], |
291 |
| - 'actions': [ |
292 |
| - { |
293 |
| - # Swap endianness (if needed), or at least copy the file |
294 |
| - 'action_name': 'icupkg', |
295 |
| - 'inputs': [ '<(icu_data_in)' ], |
296 |
| - 'outputs':[ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness).dat' ], |
297 |
| - 'action': [ '<(PRODUCT_DIR)/icupkg', |
298 |
| - '-t<(icu_endianness)', |
299 |
| - '<@(_inputs)', |
300 |
| - '<@(_outputs)', |
301 |
| - ], |
302 |
| - }, |
303 |
| - { |
304 |
| - # Rename without the endianness marker |
305 |
| - 'action_name': 'copy', |
306 |
| - 'inputs': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness).dat' ], |
307 |
| - 'outputs':[ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major).dat' ], |
308 |
| - 'action': [ 'cp', |
309 |
| - '<@(_inputs)', |
310 |
| - '<@(_outputs)', |
311 |
| - ], |
312 |
| - }, |
313 |
| - { |
314 |
| - 'action_name': 'icudata', |
315 |
| - 'inputs': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major).dat' ], |
316 |
| - 'outputs':[ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)_dat.c' ], |
317 |
| - 'action': [ '<(PRODUCT_DIR)/genccode', |
318 |
| - '-e', 'icudt<(icu_ver_major)', |
319 |
| - '-d', '<(SHARED_INTERMEDIATE_DIR)', |
320 |
| - '-f', 'icudt<(icu_ver_major)_dat', |
321 |
| - '<@(_inputs)' ], |
322 |
| - }, |
323 |
| - ], # end actions |
324 |
| - }, { # icu_small == true ( and OS != win ) |
325 |
| - # link against stub data (as primary data) |
326 |
| - # then, use icupkg and genccode to rebuild small data |
327 |
| - 'dependencies': [ 'icustubdata', 'genccode#host', 'icupkg#host', 'genrb#host', 'iculslocs#host', |
328 |
| - 'icu_implementation', 'icu_uconfig' ], |
329 |
| - 'export_dependent_settings': [ 'icustubdata' ], |
330 |
| - 'actions': [ |
331 |
| - { |
332 |
| - # trim down ICU |
333 |
| - 'action_name': 'icutrim', |
334 |
| - 'inputs': [ '<(icu_data_in)', 'icu_small.json' ], |
335 |
| - 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/icutmp/icudt<(icu_ver_major)<(icu_endianness).dat' ], |
336 |
| - 'action': [ 'python', |
337 |
| - 'icutrim.py', |
338 |
| - '-P', '<(PRODUCT_DIR)', |
339 |
| - '-D', '<(icu_data_in)', |
340 |
| - '--delete-tmp', |
341 |
| - '-T', '<(SHARED_INTERMEDIATE_DIR)/icutmp', |
342 |
| - '-F', 'icu_small.json', |
343 |
| - '-O', 'icudt<(icu_ver_major)<(icu_endianness).dat', |
344 |
| - '-v', |
345 |
| - '-L', '<(icu_locales)'], |
346 |
| - }, { |
347 |
| - # rename to get the final entrypoint name right |
348 |
| - 'action_name': 'rename', |
349 |
| - 'inputs': [ '<(SHARED_INTERMEDIATE_DIR)/icutmp/icudt<(icu_ver_major)<(icu_endianness).dat' ], |
350 |
| - 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/icutmp/icusmdt<(icu_ver_major).dat' ], |
351 |
| - 'action': [ 'cp', |
352 |
| - '<@(_inputs)', |
353 |
| - '<@(_outputs)', |
354 |
| - ], |
355 |
| - }, { |
356 |
| - # build final .dat -> .obj |
357 |
| - 'action_name': 'genccode', |
358 |
| - 'inputs': [ '<(SHARED_INTERMEDIATE_DIR)/icutmp/icusmdt<(icu_ver_major).dat' ], |
359 |
| - 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/icusmdt<(icu_ver_major)_dat.c' ], |
360 |
| - 'action': [ '<(PRODUCT_DIR)/genccode', |
361 |
| - '-d', '<(SHARED_INTERMEDIATE_DIR)', |
362 |
| - '<@(_inputs)' ], |
363 |
| - }, |
364 |
| - ], |
365 |
| - # This file contains the small ICU data |
366 |
| - 'sources': [ '<(SHARED_INTERMEDIATE_DIR)/icusmdt<(icu_ver_major)_dat.c' ], |
367 |
| - # for umachine.h |
368 |
| - 'include_dirs': [ |
369 |
| - '<(icu_path)/source/common', |
370 |
| - ], |
371 |
| - }]], # end icu_small == true |
372 |
| - }]], # end OS != win |
373 |
| - }, # end icudata |
| 267 | + ['OS == "win" and icu_small == "true"', |
| 268 | + { |
| 269 | + 'variables': { |
| 270 | + 'icu_symbol_name': '<(icu_output_prefix_sm)', |
| 271 | + 'icudata_genccode_output_name': '<(icudata_output_name_win)', |
| 272 | + 'icudata_genccode_input': '<(SHARED_INTERMEDIATE_DIR)/>(icudata_trim_name)', |
| 273 | + } |
| 274 | + } |
| 275 | + ], |
| 276 | + ['OS == "win" and icu_small == "false"', |
| 277 | + { |
| 278 | + 'variables': { |
| 279 | + 'icu_symbol_name': '<(icu_output_prefix)', |
| 280 | + 'icudata_genccode_output_name': '<(icudata_output_name_win)', |
| 281 | + # for windows with full-icu, genccode runs directly on input |
| 282 | + 'icudata_genccode_input': '<(icu_data_in)', |
| 283 | + } |
| 284 | + } |
| 285 | + ], |
| 286 | + ['OS != "win" and icu_small == "true"', |
| 287 | + { |
| 288 | + 'variables': { |
| 289 | + 'icu_symbol_name': '<(icu_output_prefix_sm)', |
| 290 | + 'icudata_genccode_output_name': '<(icudata_output_name_psx)', |
| 291 | + 'icudata_genccode_extra_args=': [ ], |
| 292 | + 'icudata_genccode_input': '<(icudata_trim_temp)/>(icu_symbol_name).dat', |
| 293 | + } |
| 294 | + } |
| 295 | + ], |
| 296 | + ['OS != "win" and icu_small == "false"', |
| 297 | + { |
| 298 | + 'variables': { |
| 299 | + 'icu_symbol_name': '<(icu_output_prefix)', |
| 300 | + 'icudata_genccode_output_name': '<(icudata_output_name_psx)', |
| 301 | + 'icudata_genccode_extra_args=': [ '-f', '>(icu_symbol_name)_dat', '-e', '>(icu_symbol_name)' ], |
| 302 | + 'icudata_genccode_input': '<(SHARED_INTERMEDIATE_DIR)/>(icu_symbol_name).dat' |
| 303 | + }, |
| 304 | + 'actions': [ |
| 305 | + { |
| 306 | + # Swap endianness (if needed), or at least rename the file |
| 307 | + 'action_name': 'icudata-pkg', |
| 308 | + 'inputs': [ '<(icu_data_in)' ], |
| 309 | + 'outputs':[ '>(icudata_genccode_input)' ], |
| 310 | + 'action': [ '<(PRODUCT_DIR)/icupkg', |
| 311 | + '-t<(icu_endianness)', |
| 312 | + '<@(_inputs)', |
| 313 | + '<@(_outputs)' ], |
| 314 | + } |
| 315 | + ] |
| 316 | + } |
| 317 | + ], |
| 318 | + # if icu_small == "true" we trim |
| 319 | + ['icu_small == "true"', { |
| 320 | + 'actions': [ |
| 321 | + { |
| 322 | + 'action_name': 'icudata-trim', |
| 323 | + 'msvs_quote_cmd': 0, |
| 324 | + 'inputs': [ '<(icu_data_in)', 'icu_small.json' ], |
| 325 | + # icudata_trim_output = icudata_trim_temp (-T) + icudata_trim_name (-O) |
| 326 | + 'outputs': [ '<(icudata_trim_output)' ], |
| 327 | + 'action': [ 'python', 'icutrim.py', |
| 328 | + '-P', '<(PRODUCT_DIR)/.', # '.' suffix is a workaround against GYP assumptions :( |
| 329 | + '-D', '<(icu_data_in)', |
| 330 | + '--delete-tmp', |
| 331 | + '-T', '<(icudata_trim_temp)', |
| 332 | + '-F', 'icu_small.json', |
| 333 | + '-O', '>(icudata_trim_name)', |
| 334 | + '-v', |
| 335 | + '-L', '<(icu_locales)'], |
| 336 | + }, { |
| 337 | + 'action_name': 'icudata-trim-copy', |
| 338 | + 'msvs_quote_cmd': 0, |
| 339 | + 'inputs': ['<(icudata_trim_output)'], |
| 340 | + 'outputs': ['>(icudata_genccode_input)'], |
| 341 | + 'action': ['cp', '<@(_inputs)', '<@(_outputs)'], |
| 342 | + } |
| 343 | + ], |
| 344 | + }], |
| 345 | + [ '1==1', { # using '1' just for symmetry |
| 346 | + # full data - just build the full data file, then we are done. |
| 347 | + # depending on `icu_small` flag, we chose the naming, and the args |
| 348 | + 'actions': [ |
| 349 | + { |
| 350 | + 'action_name': 'icudata-genccode', |
| 351 | + 'msvs_quote_cmd': 0, |
| 352 | + 'inputs': [ '>(icudata_genccode_input)' ], |
| 353 | + 'outputs':[ '<(icudata_genccode_output)' ], |
| 354 | + 'action': [ '<(PRODUCT_DIR)/genccode', |
| 355 | + '-d', '<(SHARED_INTERMEDIATE_DIR)', |
| 356 | + '>@(icudata_genccode_extra_args)', |
| 357 | + '<@(_inputs)' ], |
| 358 | + }, |
| 359 | + ], |
| 360 | + } ], |
| 361 | + ], # end conditions |
| 362 | + }, # end target_name: icudata |
| 363 | + |
| 364 | + |
374 | 365 | # icustubdata is a tiny (~1k) symbol with no ICU data in it.
|
375 | 366 | # tools must link against it as they are generating the full data.
|
376 | 367 | {
|
|
525 | 516 | },
|
526 | 517 | 'export_dependent_settings': [ 'icu_uconfig' ],
|
527 | 518 | },
|
528 |
| - # This tool is needed to rebuild .res files from .txt, |
529 |
| - # or to build index (res_index.txt) files for small-icu |
| 519 | + |
| 520 | + |
| 521 | + # ==================================== |
| 522 | + # Helper tools |
| 523 | + # ==================================== |
| 524 | + |
| 525 | + # rebuild .res files from .txt, or build index (res_index.txt) for small-icu |
530 | 526 | {
|
531 | 527 | 'target_name': 'genrb',
|
532 | 528 | 'type': 'executable',
|
|
542 | 538 | 'no-op.cc',
|
543 | 539 | ],
|
544 | 540 | },
|
545 |
| - # This tool is used to rebuild res_index.res manifests |
| 541 | + |
| 542 | + # rebuild res_index.res manifests |
546 | 543 | {
|
547 | 544 | 'target_name': 'iculslocs',
|
548 | 545 | 'toolsets': [ 'host' ],
|
|
553 | 550 | 'no-op.cc',
|
554 | 551 | ],
|
555 | 552 | },
|
556 |
| - # This tool is used to package, unpackage, repackage .dat files |
557 |
| - # and convert endianesses |
| 553 | + |
| 554 | + # package, unpackage, repackage .dat files, and convert endianesses |
558 | 555 | {
|
559 | 556 | 'target_name': 'icupkg',
|
560 | 557 | 'toolsets': [ 'host' ],
|
|
565 | 562 | 'no-op.cc',
|
566 | 563 | ],
|
567 | 564 | },
|
568 |
| - # this is used to convert .dat directly into .obj |
| 565 | + |
| 566 | + # convert .dat directly into .obj |
569 | 567 | {
|
570 | 568 | 'target_name': 'genccode',
|
571 | 569 | 'toolsets': [ 'host' ],
|
|
0 commit comments