Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / native_client / build / untrusted.gypi
1 # Copyright (c) 2011 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   'variables': {
7     'variables': {
8       # Enable -Werror by default, but put it in a variable so it can
9       # be optionally disabled.
10       'werror%': '-Werror',
11
12       'conditions': [
13         ['"<(target_arch)"=="arm"', {
14           # Settings for the newer GCC versions currently used only on ARM.
15           'NACL_RODATA_FLAG%': '-Trodata-segment',
16         }, {
17           # Settings for the older GCC version used on x86_32 and x86_64.
18           'NACL_RODATA_FLAG%': '--build-id,--section-start,.note.gnu.build-id',
19         }]
20       ],
21       # 1 to use goma.
22       'use_goma%': 0,
23     },
24     # See native_client/Sconstruct for more details.
25     # Expected address for beginning of data in for the IRT.
26     'NACL_IRT_DATA_START': '0x3ef00000',
27     # Expected address for beginning of code in for the IRT.
28     'NACL_IRT_TEXT_START': '0x0fa00000',
29     # Flag to pass to linker to set start of RODATA segment.
30     'NACL_RODATA_FLAG%': '<(NACL_RODATA_FLAG)',
31     # Default C compiler defines.
32     'nacl_default_defines': [
33       '__linux__',
34       '__STDC_LIMIT_MACROS=1',
35       '__STDC_FORMAT_MACROS=1',
36       '_GNU_SOURCE=1',
37       '_BSD_SOURCE=1',
38       '_POSIX_C_SOURCE=199506',
39       '_XOPEN_SOURCE=600',
40       'DYNAMIC_ANNOTATIONS_ENABLED=1',
41       'DYNAMIC_ANNOTATIONS_PREFIX=NACL_',
42     ],
43     'nacl_default_compile_flags': [
44       #'-std=gnu99',  Added by build_nexe
45       '-O2',
46       '-g',
47       '-Wall',
48       '-fdiagnostics-show-option',
49       '<(werror)',
50     ],
51     # The flag gomadir is one of the flag to enable goma on build_nexe.py.
52     # It should be set only if use_goma is true.
53     'conditions': [
54       ['use_goma==0', {
55         'gomadir%': '',
56       }],
57     ],
58   },
59   'conditions': [
60     ['target_arch=="ia32" or target_arch=="x64"', {
61       # Common defaults for all x86 nacl-gcc targets
62       'target_defaults': {
63         'conditions': [
64           ['OS=="win"', {
65             'variables': {
66               'nacl_glibc_tc_root': '<(DEPTH)/native_client/toolchain/win_x86',
67             },
68           }],
69           ['OS=="mac"', {
70             'variables': {
71               'nacl_glibc_tc_root': '<(DEPTH)/native_client/toolchain/mac_x86',
72             },
73           }],
74           ['OS=="linux"', {
75             'variables': {
76               'nacl_glibc_tc_root': '<(DEPTH)/native_client/toolchain/linux_x86',
77             },
78           }],
79         ],
80         'defines': [],
81         'sources': [],
82         'compile_flags': [],
83         'link_flags': [],
84         'include_dirs': [],
85         'variables': {
86           'nexe_target': '',
87           'nlib_target': '',
88           'nso_target': '',
89           'build_newlib': 0,
90           'build_glibc': 0,
91           'build_irt': 0,
92           'disable_glibc%': 0,
93           'extra_args': [],
94           'enable_x86_32': 1,
95           'enable_x86_64': 1,
96           'enable_arm': 0,
97           'enable_mips': 0,
98           'tc_lib_dir_newlib32': '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32',
99           'tc_lib_dir_newlib64': '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64',
100           'tc_lib_dir_glibc32': '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32',
101           'tc_lib_dir_glibc64': '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64',
102           'tc_lib_dir_irt32': '<(SHARED_INTERMEDIATE_DIR)/tc_irt/lib32',
103           'tc_lib_dir_irt64': '<(SHARED_INTERMEDIATE_DIR)/tc_irt/lib64',
104           'tc_include_dir_newlib': '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/include',
105           'tc_include_dir_glibc': '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/include',
106           'extra_deps': [],
107           'extra_deps_newlib64': [],
108           'extra_deps_newlib32': [],
109           'extra_deps_glibc64': [],
110           'extra_deps_glibc32': [],
111           'include_dirs': ['<(DEPTH)'],
112           'defines': [
113             '<@(nacl_default_defines)',
114             'NACL_BUILD_ARCH=x86',
115           ],
116           'sources': [],
117           'link_flags': [],
118           'get_sources': [
119             'scan_sources',
120             # This is needed to open the .c filenames, which are given
121             # relative to the .gyp file.
122             '-I.',
123             # This is needed to open the .h filenames, which are given
124             # relative to the native_client directory's parent.
125             '-I<(DEPTH)',
126           ],
127         },
128       },
129     }],
130     ['target_arch=="arm"', {
131       # Common defaults for all ARM nacl-gcc targets
132       'target_defaults': {
133         'defines': [],
134         'sources': [],
135         'compile_flags': [],
136         'link_flags': [],
137         'include_dirs': [],
138         'variables': {
139           'nexe_target': '',
140           'nlib_target': '',
141           'nso_target': '',
142           'build_newlib': 0,
143           'build_glibc': 0,
144           'build_irt': 0,
145           'disable_glibc%': 1,
146           'extra_args': [],
147           'enable_x86_32': 0,
148           'enable_x86_64': 0,
149           'enable_arm': 1,
150           'enable_mips': 0,
151           'extra_deps': [],
152           'extra_deps_newlib_arm': [],
153           'native_sources': [],
154           'tc_lib_dir_newlib_arm': '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm',
155           'tc_lib_dir_irt_arm': '<(SHARED_INTERMEDIATE_DIR)/tc_irt/libarm',
156           'tc_include_dir_newlib': '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/include',
157           'include_dirs': ['<(DEPTH)'],
158           'defines': [
159             '<@(nacl_default_defines)',
160             'NACL_BUILD_ARCH=arm',
161            ],
162            'sources': [],
163            'link_flags': [],
164            'get_sources': [
165              'scan_sources',
166              # This is needed to open the .c filenames, which are given
167              # relative to the .gyp file.
168              '-I.',
169              # This is needed to open the .h filenames, which are given
170              # relative to the native_client directory's parent.
171              '-I<(DEPTH)',
172            ],
173          },
174        },
175     }],
176     ['target_arch=="mipsel"', {
177       # Common defaults for all mips pnacl-clang targets
178       'target_defaults': {
179         'defines': [],
180         'sources': [],
181         'compile_flags': [],
182         'link_flags': [],
183         'include_dirs': [],
184         'variables': {
185           'nexe_target': '',
186           'nlib_target': '',
187           'nso_target': '',
188           'build_newlib': 0,
189           'build_glibc': 0,
190           'build_irt': 0,
191           'disable_glibc%': 1,
192           'extra_args': [],
193           'enable_x86_32': 0,
194           'enable_x86_64': 0,
195           'enable_arm': 0,
196           'enable_mips': 1,
197           'extra_deps': [],
198           'extra_deps_newlib_mips': [],
199           'native_sources': [],
200           'tc_lib_dir_newlib_mips': '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libmips',
201           'tc_lib_dir_irt_mips': '<(SHARED_INTERMEDIATE_DIR)/tc_irt/libmips',
202           'tc_include_dir_newlib': '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/include',
203           'include_dirs': ['<(DEPTH)'],
204           'defines': [
205             '<@(nacl_default_defines)',
206             'NACL_BUILD_ARCH=mips',
207            ],
208            'sources': [],
209            'link_flags': [],
210            'get_sources': [
211              'scan_sources',
212              # This is needed to open the .c filenames, which are given
213              # relative to the .gyp file.
214              '-I.',
215              # This is needed to open the .h filenames, which are given
216              # relative to the native_client directory's parent.
217              '-I<(DEPTH)',
218            ],
219          },
220        },
221     }],
222     ['target_arch=="ia32" or target_arch=="x64"', {
223       'target_defaults': {
224         # x86-64 newlib nexe action
225         'target_conditions': [
226            ['nexe_target!="" and build_newlib!=0 and enable_x86_64!=0', {
227              'variables': {
228                 'tool_name': 'newlib',
229                 'out_newlib64%': '<(PRODUCT_DIR)/>(nexe_target)_newlib_x64.nexe',
230                 'objdir_newlib64%': '>(INTERMEDIATE_DIR)/<(tool_name)-x86-64/>(_target_name)',
231              },
232              'actions': [
233                {
234                  'action_name': 'build newlib x86-64 nexe',
235                  'variables': {
236                    'source_list_newlib64%': '^|(<(tool_name)-x86-64.>(_target_name).source_list.gypcmd ^(_sources) ^(sources))',
237                  },
238                  'msvs_cygwin_shell': 0,
239                  'description': 'building >(out_newlib64)',
240                  'inputs': [
241                     '<(DEPTH)/native_client/build/build_nexe.py',
242                     '>!@pymod_do_main(>(get_sources) >(sources) >(_sources))',
243                     '>@(extra_deps)',
244                     '>@(extra_deps_newlib64)',
245                     '^(source_list_newlib64)',
246                     '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_x86_newlib/stamp.prep',
247                  ],
248                  'outputs': ['>(out_newlib64)'],
249                  'action': [
250                    'python',
251                    '<(DEPTH)/native_client/build/build_nexe.py',
252                    '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
253                    '>@(extra_args)',
254                    '--arch', 'x86-64',
255                    '--build', 'newlib_nexe',
256                    '--root', '<(DEPTH)',
257                    '--name', '>(out_newlib64)',
258                    '--objdir', '>(objdir_newlib64)',
259                    '--include-dirs=>(tc_include_dir_newlib) ^(include_dirs) >(_include_dirs)',
260                    '--compile_flags=-m64 ^(gcc_compile_flags) >(_gcc_compile_flags) ^(compile_flags) >(_compile_flags)',
261                    '--gomadir', '<(gomadir)',
262                    '--defines=^(defines) >(_defines)',
263                    '--link_flags=-B>(tc_lib_dir_newlib64) ^(link_flags) >(_link_flags)',
264                    '--source-list=^(source_list_newlib64)',
265                  ],
266                },
267              ],
268            }],
269            # x86-64 newlib library action
270            ['nlib_target!="" and build_newlib!=0 and enable_x86_64!=0', {
271              'variables': {
272                 'tool_name': 'newlib',
273                 'objdir_newlib64%': '>(INTERMEDIATE_DIR)/<(tool_name)-x86-64/>(_target_name)',
274                 'out_newlib64%': '<(SHARED_INTERMEDIATE_DIR)/tc_<(tool_name)/lib64/>(nlib_target)',
275              },
276              'actions': [
277                {
278                  'action_name': 'build newlib x86-64 nlib',
279                  'variables': {
280                    'source_list_newlib64%': '^|(<(tool_name)-x86-64.>(_target_name).source_list.gypcmd ^(_sources) ^(sources))',
281                  },
282                  'msvs_cygwin_shell': 0,
283                  'description': 'building >(out_newlib64)',
284                  'inputs': [
285                     '<(DEPTH)/native_client/build/build_nexe.py',
286                     '>!@pymod_do_main(>(get_sources) >(sources) >(_sources))',
287                     '>@(extra_deps)',
288                     '>@(extra_deps_newlib64)',
289                     '^(source_list_newlib64)',
290                     '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_x86_newlib/stamp.prep',
291                  ],
292                  'outputs': ['>(out_newlib64)'],
293                  'action': [
294                    'python',
295                    '<(DEPTH)/native_client/build/build_nexe.py',
296                    '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
297                    '>@(extra_args)',
298                    '--arch', 'x86-64',
299                    '--build', 'newlib_nlib',
300                    '--root', '<(DEPTH)',
301                    '--name', '>(out_newlib64)',
302                    '--objdir', '>(objdir_newlib64)',
303                    '--include-dirs=>(tc_include_dir_newlib) ^(include_dirs) >(_include_dirs)',
304                    '--compile_flags=-m64 ^(gcc_compile_flags) >(_gcc_compile_flags) ^(compile_flags) >(_compile_flags)',
305                    '--gomadir', '<(gomadir)',
306                    '--defines=^(defines) >(_defines)',
307                    '--link_flags=-B>(tc_lib_dir_newlib64) ^(link_flags) >(_link_flags)',
308                    '--source-list=^(source_list_newlib64)',
309                  ],
310                },
311              ],
312            }],
313            # x86-64 IRT nexe action
314            ['nexe_target!="" and build_irt!=0 and enable_x86_64!=0', {
315              'variables': {
316                 'tool_name': 'irt',
317                 'out_newlib64%': '<(PRODUCT_DIR)/>(nexe_target)_newlib_x64.nexe',
318                 'objdir_newlib64%': '>(INTERMEDIATE_DIR)/<(tool_name)-x86-64/>(_target_name)',
319              },
320              'actions': [
321                {
322                  'action_name': 'build IRT x86-64 nexe',
323                  'variables': {
324                    'source_list_newlib64%': '^|(<(tool_name)-x86-64.>(_target_name).source_list.gypcmd ^(_sources) ^(sources))',
325                  },
326                  'msvs_cygwin_shell': 0,
327                  'description': 'building >(out_newlib64)',
328                  'inputs': [
329                     '<(DEPTH)/native_client/build/build_nexe.py',
330                     '>!@pymod_do_main(>(get_sources) >(sources) >(_sources))',
331                     '>@(extra_deps)',
332                     '>@(extra_deps_newlib64)',
333                     '^(source_list_newlib64)',
334                     '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_x86_newlib/stamp.prep',
335                     '<(PRODUCT_DIR)/tls_edit<(EXECUTABLE_SUFFIX)',
336                  ],
337                  'outputs': ['>(out_newlib64)'],
338                  'action': [
339                    'python',
340                    '<(DEPTH)/native_client/build/build_nexe.py',
341                    '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
342                    '>@(extra_args)',
343                    '--arch', 'x86-64',
344                    '--build', 'newlib_nexe_pnacl',
345                    '--root', '<(DEPTH)',
346                    '--name', '>(out_newlib64)',
347                    '--objdir', '>(objdir_newlib64)',
348                    '--config-name', '<(CONFIGURATION_NAME)',
349                    '--include-dirs=>(tc_include_dir_newlib) ^(include_dirs) >(_include_dirs)',
350                    '--compile_flags=--target=x86_64-nacl -stdlib=libstdc++ ^(compile_flags) >(_compile_flags) -gline-tables-only ^(pnacl_compile_flags) >(_pnacl_compile_flags)',
351                    '--gomadir', '<(gomadir)',
352                    '--defines=^(defines) >(_defines)',
353                    '--link_flags=--target=x86_64-nacl -stdlib=libstdc++ -arch x86-64 --pnacl-allow-translate --pnacl-allow-native -Wn,-Trodata-segment=<(NACL_IRT_DATA_START) -Wn,-Ttext-segment=<(NACL_IRT_TEXT_START) -B>(tc_lib_dir_irt64) ^(link_flags) >(_link_flags)',
354                    '--source-list=^(source_list_newlib64)',
355                    '--tls-edit=<(PRODUCT_DIR)/tls_edit<(EXECUTABLE_SUFFIX)',
356                  ],
357                },
358              ],
359            }],
360            # x86-64 IRT library action
361            ['nlib_target!="" and build_irt!=0 and enable_x86_64!=0', {
362              'variables': {
363                 'tool_name': 'irt',
364                 'objdir_newlib64%': '>(INTERMEDIATE_DIR)/<(tool_name)-x86-64/>(_target_name)',
365                 'out_newlib64%': '<(SHARED_INTERMEDIATE_DIR)/tc_<(tool_name)/lib64/>(nlib_target)',
366              },
367              'actions': [
368                {
369                  'action_name': 'build irt x86-64 nlib',
370                  'variables': {
371                    'source_list_newlib64%': '^|(<(tool_name)-x86-64.>(_target_name).source_list.gypcmd ^(_sources) ^(sources))',
372                  },
373                  'msvs_cygwin_shell': 0,
374                  'description': 'building >(out_newlib64)',
375                  'inputs': [
376                     '<(DEPTH)/native_client/build/build_nexe.py',
377                     '>!@pymod_do_main(>(get_sources) >(sources) >(_sources))',
378                     '>@(extra_deps)',
379                     '>@(extra_deps_newlib64)',
380                     '^(source_list_newlib64)',
381                     '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_x86_newlib/stamp.prep',
382                  ],
383                  'outputs': ['>(out_newlib64)'],
384                  'action': [
385                    'python',
386                    '<(DEPTH)/native_client/build/build_nexe.py',
387                    '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
388                    '>@(extra_args)',
389                    '--arch', 'x86-64',
390                    '--build', 'newlib_nlib_pnacl',
391                    '--root', '<(DEPTH)',
392                    '--name', '>(out_newlib64)',
393                    '--objdir', '>(objdir_newlib64)',
394                    '--config-name', '<(CONFIGURATION_NAME)',
395                    '--include-dirs=>(tc_include_dir_newlib) ^(include_dirs) >(_include_dirs)',
396                    '--compile_flags=--target=x86_64-nacl -stdlib=libstdc++ ^(compile_flags) >(_compile_flags) -gline-tables-only ^(pnacl_compile_flags) >(_pnacl_compile_flags)',
397                    '--gomadir', '<(gomadir)',
398                    '--defines=^(defines) >(_defines)',
399                    '--link_flags=--target=x86_64-nacl -stdlib=libstdc++ -B>(tc_lib_dir_irt64) ^(link_flags) >(_link_flags)',
400                    '--source-list=^(source_list_newlib64)',
401                  ],
402                },
403              ],
404            }],
405            # x86-32 newlib nexe action
406            ['nexe_target!="" and build_newlib!=0 and enable_x86_32!=0', {
407              'variables': {
408                 'tool_name': 'newlib',
409                 'out_newlib32%': '<(PRODUCT_DIR)/>(nexe_target)_newlib_x32.nexe',
410                 'objdir_newlib32%': '>(INTERMEDIATE_DIR)/<(tool_name)-x86-32/>(_target_name)',
411              },
412              'actions': [
413                {
414                  'action_name': 'build newlib x86-32 nexe',
415                  'variables': {
416                    'source_list_newlib32%': '^|(<(tool_name)-x86-32.>(_target_name).source_list.gypcmd ^(_sources) ^(sources))',
417                  },
418                  'msvs_cygwin_shell': 0,
419                  'description': 'building >(out_newlib32)',
420                  'inputs': [
421                     '<(DEPTH)/native_client/build/build_nexe.py',
422                     '>!@pymod_do_main(>(get_sources) >(sources) >(_sources))',
423                     '>@(extra_deps)',
424                     '>@(extra_deps_newlib32)',
425                     '^(source_list_newlib32)',
426                     '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_x86_newlib/stamp.prep',
427                  ],
428                  'outputs': ['>(out_newlib32)'],
429                  'action': [
430                    'python',
431                    '<(DEPTH)/native_client/build/build_nexe.py',
432                    '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
433                    '>@(extra_args)',
434                    '--arch', 'x86-32',
435                    '--build', 'newlib_nexe',
436                    '--root', '<(DEPTH)',
437                    '--name', '>(out_newlib32)',
438                    '--objdir', '>(objdir_newlib32)',
439                    '--include-dirs=>(tc_include_dir_newlib) ^(include_dirs) >(_include_dirs)',
440                    '--compile_flags=-m32 ^(gcc_compile_flags) >(_gcc_compile_flags) ^(compile_flags) >(_compile_flags)',
441                    '--gomadir', '<(gomadir)',
442                    '--defines=^(defines) >(_defines)',
443                    '--link_flags=-m32 -B>(tc_lib_dir_newlib32) ^(link_flags) >(_link_flags)',
444                    '--source-list=^(source_list_newlib32)',
445                  ],
446                },
447              ],
448            }],
449            # x86-32 newlib library action
450            ['nlib_target!="" and build_newlib!=0 and enable_x86_32!=0', {
451              'variables': {
452                 'tool_name': 'newlib',
453                 'out_newlib32%': '<(SHARED_INTERMEDIATE_DIR)/tc_<(tool_name)/lib32/>(nlib_target)',
454                 'objdir_newlib32%': '>(INTERMEDIATE_DIR)/<(tool_name)-x86-32/>(_target_name)',
455              },
456              'actions': [
457                {
458                  'action_name': 'build newlib x86-32 nlib',
459                  'variables': {
460                    'source_list_newlib32%': '^|(<(tool_name)-x86-32.>(_target_name).source_list.gypcmd ^(_sources) ^(sources))',
461                  },
462                  'msvs_cygwin_shell': 0,
463                  'description': 'building >(out_newlib32)',
464                  'inputs': [
465                     '<(DEPTH)/native_client/build/build_nexe.py',
466                     '>!@pymod_do_main(>(get_sources) >(sources) >(_sources))',
467                     '>@(extra_deps)',
468                     '>@(extra_deps_newlib32)',
469                     '^(source_list_newlib32)',
470                     '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_x86_newlib/stamp.prep',
471                  ],
472                  'outputs': ['>(out_newlib32)'],
473                  'action': [
474                    'python',
475                    '<(DEPTH)/native_client/build/build_nexe.py',
476                    '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
477                    '>@(extra_args)',
478                    '--arch', 'x86-32',
479                    '--build', 'newlib_nlib',
480                    '--root', '<(DEPTH)',
481                    '--name', '>(out_newlib32)',
482                    '--objdir', '>(objdir_newlib32)',
483                    '--include-dirs=>(tc_include_dir_newlib) ^(include_dirs) >(_include_dirs)',
484                    '--compile_flags=-m32 ^(gcc_compile_flags) >(_gcc_compile_flags) ^(compile_flags) >(_compile_flags)',
485                    '--gomadir', '<(gomadir)',
486                    '--defines=^(defines) >(_defines)',
487                    '--link_flags=-m32 -B>(tc_lib_dir_newlib32) ^(link_flags) >(_link_flags)',
488                    '--source-list=^(source_list_newlib32)',
489                  ],
490                },
491              ],
492            }],
493            # x86-32 IRT nexe build
494            ['nexe_target!="" and build_irt!=0 and enable_x86_32!=0', {
495              'variables': {
496                 'tool_name': 'irt',
497                 'out_newlib32%': '<(PRODUCT_DIR)/>(nexe_target)_newlib_x32.nexe',
498                 'objdir_newlib32%': '>(INTERMEDIATE_DIR)/<(tool_name)-x86-32/>(_target_name)',
499              },
500              'actions': [
501                {
502                  'action_name': 'build IRT x86-32 nexe',
503                  'variables': {
504                    'source_list_newlib32%': '^|(<(tool_name)-x86-32.>(_target_name).source_list.gypcmd ^(_sources) ^(sources))',
505                  },
506                  'msvs_cygwin_shell': 0,
507                  'description': 'building >(out_newlib32)',
508                  'inputs': [
509                     '<(DEPTH)/native_client/build/build_nexe.py',
510                     '>!@pymod_do_main(>(get_sources) >(sources) >(_sources))',
511                     '>@(extra_deps)',
512                     '>@(extra_deps_newlib32)',
513                     '^(source_list_newlib32)',
514                     '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_x86_newlib/stamp.prep',
515                     '<(PRODUCT_DIR)/tls_edit<(EXECUTABLE_SUFFIX)',
516                  ],
517                  'outputs': ['>(out_newlib32)'],
518                  'action': [
519                    'python',
520                    '<(DEPTH)/native_client/build/build_nexe.py',
521                    '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
522                    '>@(extra_args)',
523                    '--arch', 'x86-32',
524                    '--build', 'newlib_nexe',
525                    '--root', '<(DEPTH)',
526                    '--name', '>(out_newlib32)',
527                    '--objdir', '>(objdir_newlib32)',
528                    '--include-dirs=>(tc_include_dir_newlib) ^(include_dirs) >(_include_dirs)',
529                    '--compile_flags=-m32 ^(gcc_compile_flags) >(_gcc_compile_flags) ^(compile_flags) >(_compile_flags)',
530                    '--gomadir', '<(gomadir)',
531                    '--defines=^(defines) >(_defines)',
532                    '--link_flags=-m32 -B>(tc_lib_dir_irt32) -Wl,-Trodata-segment=<(NACL_IRT_DATA_START) -Wl,-Ttext-segment=<(NACL_IRT_TEXT_START) ^(link_flags) >(_link_flags)',
533                    '--source-list=^(source_list_newlib32)',
534                    '--tls-edit=<(PRODUCT_DIR)/tls_edit<(EXECUTABLE_SUFFIX)',
535                  ],
536                },
537              ],
538            }],
539            # x86-32 IRT library build
540            ['nlib_target!="" and build_irt!=0 and enable_x86_32!=0', {
541              'variables': {
542                 'tool_name': 'irt',
543                 'out_newlib32%': '<(SHARED_INTERMEDIATE_DIR)/tc_<(tool_name)/lib32/>(nlib_target)',
544                 'objdir_newlib32%': '>(INTERMEDIATE_DIR)/<(tool_name)-x86-32/>(_target_name)',
545              },
546              'actions': [
547                {
548                  'action_name': 'build IRT x86-32 nlib',
549                  'variables': {
550                    'source_list_newlib32%': '^|(<(tool_name)-x86-32.>(_target_name).source_list.gypcmd ^(_sources) ^(sources))',
551                  },
552                  'msvs_cygwin_shell': 0,
553                  'description': 'building >(out_newlib32)',
554                  'inputs': [
555                     '<(DEPTH)/native_client/build/build_nexe.py',
556                     '>!@pymod_do_main(>(get_sources) >(sources) >(_sources))',
557                     '>@(extra_deps)',
558                     '>@(extra_deps_newlib32)',
559                     '^(source_list_newlib32)',
560                     '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_x86_newlib/stamp.prep',
561                  ],
562                  'outputs': ['>(out_newlib32)'],
563                  'action': [
564                    'python',
565                    '<(DEPTH)/native_client/build/build_nexe.py',
566                    '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
567                    '>@(extra_args)',
568                    '--arch', 'x86-32',
569                    '--build', 'newlib_nlib',
570                    '--root', '<(DEPTH)',
571                    '--name', '>(out_newlib32)',
572                    '--objdir', '>(objdir_newlib32)',
573                    '--include-dirs=>(tc_include_dir_newlib) ^(include_dirs) >(_include_dirs)',
574                    '--compile_flags=-m32 ^(gcc_compile_flags) >(_gcc_compile_flags) ^(compile_flags) >(_compile_flags)',
575                    '--gomadir', '<(gomadir)',
576                    '--defines=^(defines) >(_defines)',
577                    '--link_flags=-m32 -B>(tc_lib_dir_irt32) ^(link_flags) >(_link_flags)',
578                    '--source-list=^(source_list_newlib32)',
579                  ],
580                },
581              ],
582            }],
583         ],
584       },
585     }], # end x86 gcc nexe/nlib actions
586     ['target_arch=="arm"', {
587       'target_defaults': {
588         'target_conditions': [
589           # arm newlib nexe action
590           ['nexe_target!="" and build_newlib!=0', {
591             'variables': {
592                'tool_name': 'newlib',
593                'out_newlib_arm%': '<(PRODUCT_DIR)/>(nexe_target)_newlib_arm.nexe',
594                'objdir_newlib_arm%': '>(INTERMEDIATE_DIR)/<(tool_name)-arm/>(_target_name)',
595             },
596             'actions': [
597               {
598                 'action_name': 'build newlib arm nexe',
599                 'variables': {
600                   'source_list_newlib_arm%': '^|(<(tool_name)-arm.>(_target_name).source_list.gypcmd ^(_sources) ^(sources) ^(native_sources))',
601                 },
602                 'msvs_cygwin_shell': 0,
603                 'description': 'building >(out_newlib_arm)',
604                 'inputs': [
605                    '<(DEPTH)/native_client/build/build_nexe.py',
606                    '>!@pymod_do_main(>(get_sources) >(sources) >(_sources) >(native_sources))',
607                    '>@(extra_deps)',
608                    '>@(extra_deps_newlib_arm)',
609                    '^(source_list_newlib_arm)',
610                    '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_arm_newlib/stamp.prep',
611                 ],
612                 'outputs': ['>(out_newlib_arm)'],
613                 'action': [
614                   'python',
615                   '<(DEPTH)/native_client/build/build_nexe.py',
616                   '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
617                   '>@(extra_args)',
618                   '--arch', 'arm',
619                   '--build', 'newlib_nexe',
620                   '--root', '<(DEPTH)',
621                   '--name', '>(out_newlib_arm)',
622                   '--objdir', '>(objdir_newlib_arm)',
623                   '--include-dirs=>(tc_include_dir_newlib) ^(include_dirs) >(_include_dirs)',
624                   '--compile_flags=-Wno-unused-local-typedefs -Wno-psabi ^(gcc_compile_flags) >(_gcc_compile_flags) ^(compile_flags) >(_compile_flags)',
625                   '--gomadir', '<(gomadir)',
626                   '--defines=^(defines) >(_defines)',
627                   '--link_flags=-B>(tc_lib_dir_newlib_arm) ^(link_flags) >(_link_flags)',
628                   '--source-list=^(source_list_newlib_arm)',
629                 ],
630               },
631             ],
632           }],
633           # arm newlib library action
634           ['nlib_target!="" and build_newlib!=0', {
635             'variables': {
636               'tool_name': 'newlib',
637               'out_newlib_arm%': '<(SHARED_INTERMEDIATE_DIR)/tc_<(tool_name)/libarm/>(nlib_target)',
638               'objdir_newlib_arm%': '>(INTERMEDIATE_DIR)/<(tool_name)-arm/>(_target_name)',
639             },
640             'actions': [
641               {
642                 'action_name': 'build newlib arm nlib',
643                  'variables': {
644                    'source_list_newlib_arm%': '^|(<(tool_name)-arm.>(_target_name).source_list.gypcmd ^(_sources) ^(sources) ^(native_sources))',
645                  },
646                 'msvs_cygwin_shell': 0,
647                 'description': 'building >(out_newlib_arm)',
648                 'inputs': [
649                    '<(DEPTH)/native_client/build/build_nexe.py',
650                    '>!@pymod_do_main(>(get_sources) >(sources) >(_sources) >(native_sources))',
651                    '>@(extra_deps)',
652                    '>@(extra_deps_newlib_arm)',
653                    '^(source_list_newlib_arm)',
654                    '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_arm_newlib/stamp.prep',
655                 ],
656                 'outputs': ['>(out_newlib_arm)'],
657                 'action': [
658                   'python',
659                   '<(DEPTH)/native_client/build/build_nexe.py',
660                   '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
661                   '>@(extra_args)',
662                   '--arch', 'arm',
663                   '--build', 'newlib_nlib',
664                   '--root', '<(DEPTH)',
665                   '--name', '>(out_newlib_arm)',
666                   '--objdir', '>(objdir_newlib_arm)',
667                   '--include-dirs=>(tc_include_dir_newlib) ^(include_dirs) >(_include_dirs)',
668                   '--compile_flags=-Wno-unused-local-typedefs -Wno-psabi ^(gcc_compile_flags) >(_gcc_compile_flags) ^(compile_flags) >(_compile_flags)',
669                   '--gomadir', '<(gomadir)',
670                   '--defines=^(defines) >(_defines)',
671                   '--link_flags=-B>(tc_lib_dir_newlib_arm) ^(link_flags) >(_link_flags)',
672                   '--source-list=^(source_list_newlib_arm)',
673                 ],
674               },
675             ],
676           }],
677           # arm irt nexe action
678           ['nexe_target!="" and build_irt!=0', {
679             'variables': {
680                'tool_name': 'irt',
681                'out_newlib_arm%': '<(PRODUCT_DIR)/>(nexe_target)_newlib_arm.nexe',
682                'objdir_newlib_arm%': '>(INTERMEDIATE_DIR)/<(tool_name)-arm/>(_target_name)',
683             },
684             'actions': [
685               {
686                 'action_name': 'build IRT arm nexe',
687                 'variables': {
688                   'source_list_newlib_arm%': '^|(<(tool_name)-arm.>(_target_name).source_list.gypcmd ^(_sources) ^(sources) ^(native_sources))',
689                 },
690                 'msvs_cygwin_shell': 0,
691                 'description': 'building >(out_newlib_arm)',
692                 'inputs': [
693                    '<(DEPTH)/native_client/build/build_nexe.py',
694                    '>!@pymod_do_main(>(get_sources) >(sources) >(_sources) >(native_sources))',
695                    '>@(extra_deps)',
696                    '>@(extra_deps_newlib_arm)',
697                    '^(source_list_newlib_arm)',
698                    '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_arm_newlib/stamp.prep',
699                    '<(PRODUCT_DIR)/tls_edit<(EXECUTABLE_SUFFIX)',
700                 ],
701                 'outputs': ['>(out_newlib_arm)'],
702                 'action': [
703                   'python',
704                   '<(DEPTH)/native_client/build/build_nexe.py',
705                   '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
706                   '>@(extra_args)',
707                   '--arch', 'arm',
708                   '--build', 'newlib_nexe',
709                   '--root', '<(DEPTH)',
710                   '--name', '>(out_newlib_arm)',
711                   '--objdir', '>(objdir_newlib_arm)',
712                   '--include-dirs=>(tc_include_dir_newlib) ^(include_dirs) >(_include_dirs)',
713                   '--compile_flags=-Wno-unused-local-typedefs -Wno-psabi ^(gcc_compile_flags) >(_gcc_compile_flags) ^(compile_flags) >(_compile_flags)',
714                   '--gomadir', '<(gomadir)',
715                   '--defines=^(defines) >(_defines)',
716                   '--link_flags=-B>(tc_lib_dir_irt_arm) -Wl,-Trodata-segment=<(NACL_IRT_DATA_START) -Wl,-Ttext-segment=<(NACL_IRT_TEXT_START) ^(link_flags) >(_link_flags)',
717                   '--source-list=^(source_list_newlib_arm)',
718                   '--tls-edit=<(PRODUCT_DIR)/tls_edit<(EXECUTABLE_SUFFIX)',
719                 ],
720               },
721             ],
722           }],
723           # arm IRT library action
724           ['nlib_target!="" and build_irt!=0', {
725             'variables': {
726               'tool_name': 'irt',
727               'out_newlib_arm%': '<(SHARED_INTERMEDIATE_DIR)/tc_<(tool_name)/libarm/>(nlib_target)',
728               'objdir_newlib_arm%': '>(INTERMEDIATE_DIR)/<(tool_name)-arm/>(_target_name)',
729             },
730             'actions': [
731               {
732                 'action_name': 'build IRT arm nlib',
733                 'variables': {
734                   'source_list_newlib_arm%': '^|(<(tool_name)-arm.>(_target_name).source_list.gypcmd ^(_sources) ^(sources) ^(native_sources))',
735                 },
736                 'msvs_cygwin_shell': 0,
737                 'description': 'building >(out_newlib_arm)',
738                 'inputs': [
739                    '<(DEPTH)/native_client/build/build_nexe.py',
740                    '>!@pymod_do_main(>(get_sources) >(sources) >(_sources) >(native_sources))',
741                    '>@(extra_deps)',
742                    '>@(extra_deps_newlib_arm)',
743                    '^(source_list_newlib_arm)',
744                    '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_arm_newlib/stamp.prep',
745                 ],
746                 'outputs': ['>(out_newlib_arm)'],
747                 'action': [
748                   'python',
749                   '<(DEPTH)/native_client/build/build_nexe.py',
750                   '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
751                   '>@(extra_args)',
752                   '--arch', 'arm',
753                   '--build', 'newlib_nlib',
754                   '--root', '<(DEPTH)',
755                   '--name', '>(out_newlib_arm)',
756                   '--objdir', '>(objdir_newlib_arm)',
757                   '--include-dirs=>(tc_include_dir_newlib) ^(include_dirs) >(_include_dirs)',
758                   '--compile_flags=-Wno-unused-local-typedefs -Wno-psabi ^(gcc_compile_flags) >(_gcc_compile_flags) ^(compile_flags) >(_compile_flags)',
759                   '--gomadir', '<(gomadir)',
760                   '--defines=^(defines) >(_defines)',
761                   '--link_flags=-B>(tc_lib_dir_irt_arm) ^(link_flags) >(_link_flags)',
762                   '--source-list=^(source_list_newlib_arm)',
763                 ],
764               },
765             ],
766           }],
767         ], # end target_conditions for arm newlib (nexe/nlib)
768       },
769     }], # end target_arch = arm
770     ['target_arch=="mipsel"', {
771       'target_defaults': {
772         'target_conditions': [
773           # mips newlib nexe action
774           ['nexe_target!="" and build_newlib!=0', {
775             'variables': {
776                'tool_name': 'newlib',
777                'out_newlib_mips%': '<(PRODUCT_DIR)/>(nexe_target)_newlib_mips.nexe',
778                'objdir_newlib_mips%': '>(INTERMEDIATE_DIR)/<(tool_name)-mips/>(_target_name)',
779             },
780             'actions': [
781               {
782                 'action_name': 'build newlib mips nexe',
783                 'variables': {
784                   'source_list_newlib_mips%': '^|(<(tool_name)-mips.>(_target_name).source_list.gypcmd ^(_sources) ^(sources) ^(native_sources))',
785                 },
786                 'msvs_cygwin_shell': 0,
787                 'description': 'building >(out_newlib_mips)',
788                 'inputs': [
789                    '<(DEPTH)/native_client/build/build_nexe.py',
790                    '>!@pymod_do_main(>(get_sources) >(sources) >(_sources) >(native_sources))',
791                    '>@(extra_deps)',
792                    '>@(extra_deps_newlib_mips)',
793                    '^(source_list_newlib_mips)',
794                    '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_pnacl/stamp.prep',
795                 ],
796                 'outputs': ['>(out_newlib_mips)'],
797                 'action': [
798                   'python',
799                   '<(DEPTH)/native_client/build/build_nexe.py',
800                   '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
801                   '>@(extra_args)',
802                   '--arch', 'mips',
803                   '--build', 'newlib_nexe',
804                   '--root', '<(DEPTH)',
805                   '--name', '>(out_newlib_mips)',
806                   '--objdir', '>(objdir_newlib_mips)',
807                   '--include-dirs=>(tc_include_dir_newlib) ^(include_dirs) >(_include_dirs)',
808                   '--compile_flags=^(compile_flags) >(_compile_flags) ^(pnacl_compile_flags) >(_pnacl_compile_flags)',
809                   '--gomadir', '<(gomadir)',
810                   '--defines=^(defines) >(_defines)',
811                   '--link_flags=-arch mips -B>(tc_lib_dir_newlib_mips) ^(link_flags) >(_link_flags)',
812                   '--source-list=^(source_list_newlib_mips)',
813                 ],
814               },
815             ],
816           }],
817           # mips newlib library action
818           ['nlib_target!="" and build_newlib!=0', {
819             'variables': {
820               'tool_name': 'newlib',
821               'out_newlib_mips%': '<(SHARED_INTERMEDIATE_DIR)/tc_<(tool_name)/libmips/>(nlib_target)',
822               'objdir_newlib_mips%': '>(INTERMEDIATE_DIR)/<(tool_name)-mips/>(_target_name)',
823             },
824             'actions': [
825               {
826                 'action_name': 'build newlib mips nlib',
827                 'variables': {
828                   'source_list_newlib_mips%': '^|(<(tool_name)-mips.>(_target_name).source_list.gypcmd ^(_sources) ^(sources))',
829                 },
830                 'msvs_cygwin_shell': 0,
831                 'description': 'building >(out_newlib_mips)',
832                 'inputs': [
833                    '<(DEPTH)/native_client/build/build_nexe.py',
834                    '>!@pymod_do_main(>(get_sources) >(sources) >(_sources))',
835                    '>@(extra_deps)',
836                    '>@(extra_deps_newlib_mips)',
837                    '^(source_list_newlib_mips)',
838                    '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_pnacl/stamp.prep',
839                 ],
840                 'outputs': ['>(out_newlib_mips)'],
841                 'action': [
842                   'python',
843                   '<(DEPTH)/native_client/build/build_nexe.py',
844                   '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
845                   '>@(extra_args)',
846                   '--arch', 'mips',
847                   '--build', 'newlib_nlib',
848                   '--root', '<(DEPTH)',
849                   '--name', '>(out_newlib_mips)',
850                   '--objdir', '>(objdir_newlib_mips)',
851                   '--include-dirs=>(tc_include_dir_newlib) ^(include_dirs) >(_include_dirs)',
852                   '--compile_flags=^(compile_flags) >(_compile_flags) ^(pnacl_compile_flags) >(_pnacl_compile_flags)',
853                   '--gomadir', '<(gomadir)',
854                   '--defines=^(defines) >(_defines)',
855                   '--link_flags=-B>(tc_lib_dir_newlib_mips) ^(link_flags) >(_link_flags)',
856                   '--source-list=^(source_list_newlib_mips)',
857                 ],
858               },
859             ],
860           }],
861           # mips irt nexe action
862           ['nexe_target!="" and build_irt!=0', {
863             'variables': {
864                'tool_name': 'irt',
865                'out_newlib_mips%': '<(PRODUCT_DIR)/>(nexe_target)_newlib_mips.nexe',
866                'objdir_newlib_mips%': '>(INTERMEDIATE_DIR)/<(tool_name)-mips/>(_target_name)',
867             },
868             'actions': [
869               {
870                 'action_name': 'build IRT mips nexe',
871                 'variables': {
872                   'source_list_newlib_mips%': '^|(<(tool_name)-mips.>(_target_name).source_list.gypcmd ^(_sources) ^(sources))',
873                 },
874                 'msvs_cygwin_shell': 0,
875                 'description': 'building >(out_newlib_mips)',
876                 'inputs': [
877                    '<(DEPTH)/native_client/build/build_nexe.py',
878                    '>!@pymod_do_main(>(get_sources) >(sources) >(_sources))',
879                    '>@(extra_deps)',
880                    '>@(extra_deps_newlib_mips)',
881                    '^(source_list_newlib_mips)',
882                    '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_pnacl/stamp.prep',
883                    '<(PRODUCT_DIR)/tls_edit<(EXECUTABLE_SUFFIX)',
884                 ],
885                 'outputs': ['>(out_newlib_mips)'],
886                 'action': [
887                   'python',
888                   '<(DEPTH)/native_client/build/build_nexe.py',
889                   '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
890                   '>@(extra_args)',
891                   '--arch', 'mips',
892                   '--build', 'newlib_nexe',
893                   '--root', '<(DEPTH)',
894                   '--name', '>(out_newlib_mips)',
895                   '--objdir', '>(objdir_newlib_mips)',
896                   '--include-dirs=>(tc_include_dir_newlib) ^(include_dirs) >(_include_dirs)',
897                   '--compile_flags=-stdlib=libstdc++ ^(compile_flags) >(_compile_flags) ^(pnacl_compile_flags) >(_pnacl_compile_flags)',
898                   '--gomadir', '<(gomadir)',
899                   '--defines=^(defines) >(_defines)',
900                   '--link_flags=-arch mips -stdlib=libstdc++ --pnacl-allow-translate --pnacl-allow-native -Wt,-mtls-use-call --pnacl-disable-abi-check -Wl,-Trodata-segment=<(NACL_IRT_DATA_START) -Wl,-Ttext-segment=<(NACL_IRT_TEXT_START) -B>(tc_lib_dir_irt_mips) ^(link_flags) >(_link_flags)',
901                   '--source-list=^(source_list_newlib_mips)',
902                   '--tls-edit=<(PRODUCT_DIR)/tls_edit<(EXECUTABLE_SUFFIX)',
903                 ],
904               },
905             ],
906           }],
907           # mips IRT library action
908           ['nlib_target!="" and build_irt!=0', {
909             'variables': {
910               'tool_name': 'irt',
911               'out_newlib_mips%': '<(SHARED_INTERMEDIATE_DIR)/tc_<(tool_name)/libmips/>(nlib_target)',
912               'objdir_newlib_mips%': '>(INTERMEDIATE_DIR)/<(tool_name)-mips/>(_target_name)',
913             },
914             'actions': [
915               {
916                 'action_name': 'build IRT mips nlib',
917                 'variables': {
918                   'source_list_newlib_mips%': '^|(<(tool_name)-mips.>(_target_name).source_list.gypcmd ^(_sources) ^(sources))',
919                 },
920                 'msvs_cygwin_shell': 0,
921                 'description': 'building >(out_newlib_mips)',
922                 'inputs': [
923                    '<(DEPTH)/native_client/build/build_nexe.py',
924                    '>!@pymod_do_main(>(get_sources) >(sources) >(_sources))',
925                    '>@(extra_deps)',
926                    '>@(extra_deps_newlib_mips)',
927                    '^(source_list_newlib_mips)',
928                    '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_pnacl/stamp.prep',
929                 ],
930                 'outputs': ['>(out_newlib_mips)'],
931                 'action': [
932                   'python',
933                   '<(DEPTH)/native_client/build/build_nexe.py',
934                   '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
935                   '>@(extra_args)',
936                   '--arch', 'mips',
937                   '--build', 'newlib_nlib',
938                   '--root', '<(DEPTH)',
939                   '--name', '>(out_newlib_mips)',
940                   '--objdir', '>(objdir_newlib_mips)',
941                   '--include-dirs=>(tc_include_dir_newlib) ^(include_dirs) >(_include_dirs)',
942                   '--compile_flags=-stdlib=libstdc++ ^(compile_flags) >(_compile_flags) ^(pnacl_compile_flags) >(_pnacl_compile_flags)',
943                   '--gomadir', '<(gomadir)',
944                   '--defines=^(defines) >(_defines)',
945                   '--link_flags=-stdlib=libstdc++ -B>(tc_lib_dir_irt_mips) ^(link_flags) >(_link_flags)',
946                   '--source-list=^(source_list_newlib_mips)',
947                 ],
948               },
949             ],
950           }],
951         ], # end target_conditions for mips newlib
952       },
953     }], # end target_arch = mips
954     ['target_arch=="ia32" or target_arch=="x64"', {
955       'target_defaults': {
956         # x86-64 glibc nexe action
957         'target_conditions': [
958            ['nexe_target!="" and build_glibc!=0 and enable_x86_64!=0 and disable_glibc==0', {
959              'variables': {
960                 'tool_name': 'glibc',
961                 'out_glibc64%': '<(PRODUCT_DIR)/>(nexe_target)_glibc_x64.nexe',
962                 'objdir_glibc64%': '>(INTERMEDIATE_DIR)/<(tool_name)-x86-64/>(_target_name)',
963              },
964              'actions': [
965                {
966                  'action_name': 'build glibc x86-64 nexe',
967                  'variables': {
968                    'source_list_glibc64%': '^|(<(tool_name)-x86-64.>(_target_name).source_list.gypcmd ^(_sources) ^(sources))',
969                  },
970                  'msvs_cygwin_shell': 0,
971                  'description': 'building >(out_glibc64)',
972                  'inputs': [
973                     '<(DEPTH)/native_client/build/build_nexe.py',
974                     '>!@pymod_do_main(>(get_sources) >(sources) >(_sources))',
975                     '>@(extra_deps)',
976                     '>@(extra_deps_glibc64)',
977                     '^(source_list_glibc64)',
978                     '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_x86_glibc/stamp.prep',
979                  ],
980                  'outputs': ['>(out_glibc64)'],
981                  'action': [
982                    'python',
983                    '<(DEPTH)/native_client/build/build_nexe.py',
984                    '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
985                    '>@(extra_args)',
986                    '--arch', 'x86-64',
987                    '--build', 'glibc_nexe',
988                    '--root', '<(DEPTH)',
989                    '--name', '>(out_glibc64)',
990                    '--objdir', '>(objdir_glibc64)',
991                    '--include-dirs=>(tc_include_dir_glibc) ^(include_dirs) >(_include_dirs)',
992                    '--compile_flags=-m64 ^(gcc_compile_flags) >(_gcc_compile_flags) ^(compile_flags) >(_compile_flags)',
993                    '--gomadir', '<(gomadir)',
994                    '--defines=^(defines) >(_defines)',
995                    '--link_flags=-B>(tc_lib_dir_glibc64) ^(link_flags) >(_link_flags)',
996                    '--source-list=^(source_list_glibc64)',
997                  ],
998                },
999              ],
1000            }],
1001            # x86-32 glibc nexe action
1002            ['nexe_target!="" and build_glibc!=0 and enable_x86_32!=0 and disable_glibc==0', {
1003              'variables': {
1004                 'tool_name': 'glibc',
1005                 'out_glibc32%': '<(PRODUCT_DIR)/>(nexe_target)_glibc_x32.nexe',
1006                 'objdir_glibc32%': '>(INTERMEDIATE_DIR)/<(tool_name)-x86-32/>(_target_name)',
1007              },
1008              'actions': [
1009                {
1010                  'action_name': 'build glibc x86-32 nexe',
1011                  'variables': {
1012                    'source_list_glibc32%': '^|(<(tool_name)-x86-32.>(_target_name).source_list.gypcmd ^(_sources) ^(sources))',
1013                  },
1014                  'msvs_cygwin_shell': 0,
1015                  'description': 'building >(out_glibc32)',
1016                  'inputs': [
1017                     '<(DEPTH)/native_client/build/build_nexe.py',
1018                     '>!@pymod_do_main(>(get_sources) >(sources) >(_sources))',
1019                     '>@(extra_deps)',
1020                     '>@(extra_deps_glibc32)',
1021                     '^(source_list_glibc32)',
1022                     '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_x86_glibc/stamp.prep',
1023                  ],
1024                  'outputs': ['>(out_glibc32)'],
1025                  'action': [
1026                    'python',
1027                    '<(DEPTH)/native_client/build/build_nexe.py',
1028                    '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
1029                    '>@(extra_args)',
1030                    '--arch', 'x86-32',
1031                    '--build', 'glibc_nexe',
1032                    '--root', '<(DEPTH)',
1033                    '--name', '>(out_glibc32)',
1034                    '--objdir', '>(objdir_glibc32)',
1035                    '--include-dirs=>(tc_include_dir_glibc) ^(include_dirs) >(_include_dirs)',
1036                    '--compile_flags=-m32 ^(gcc_compile_flags) >(_gcc_compile_flags) ^(compile_flags) >(_compile_flags)',
1037                    '--gomadir', '<(gomadir)',
1038                    '--defines=^(defines) >(_defines)',
1039                    '--link_flags=-m32 -B>(tc_lib_dir_glibc32) ^(link_flags) >(_link_flags)',
1040                    '--source-list=^(source_list_glibc32)',
1041                  ],
1042                },
1043              ],
1044            }],
1045            # x86-64 glibc static library action
1046            ['nlib_target!="" and build_glibc!=0 and enable_x86_64!=0 and disable_glibc==0', {
1047              'variables': {
1048                 'tool_name': 'glibc',
1049                 'objdir_glibc64%': '>(INTERMEDIATE_DIR)/<(tool_name)-x86-64/>(_target_name)',
1050                 'out_glibc64%': '<(SHARED_INTERMEDIATE_DIR)/tc_<(tool_name)/lib64/>(nlib_target)',
1051              },
1052              'actions': [
1053                {
1054                  'action_name': 'build glibc x86-64 nlib',
1055                  'variables': {
1056                    'source_list_glibc64%': '^|(<(tool_name)-x86-64.>(_target_name).source_list.gypcmd ^(_sources) ^(sources))',
1057                  },
1058                  'msvs_cygwin_shell': 0,
1059                  'description': 'building >(out_glibc64)',
1060                  'inputs': [
1061                     '<(DEPTH)/native_client/build/build_nexe.py',
1062                     '>!@pymod_do_main(>(get_sources) >(sources) >(_sources))',
1063                     '>@(extra_deps)',
1064                     '>@(extra_deps_glibc64)',
1065                     '^(source_list_glibc64)',
1066                     '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_x86_glibc/stamp.prep',
1067                  ],
1068                  'outputs': ['>(out_glibc64)'],
1069                  'action': [
1070                    'python',
1071                    '<(DEPTH)/native_client/build/build_nexe.py',
1072                    '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
1073                    '>@(extra_args)',
1074                    '--arch', 'x86-64',
1075                    '--build', 'glibc_nlib',
1076                    '--root', '<(DEPTH)',
1077                    '--name', '>(out_glibc64)',
1078                    '--objdir', '>(objdir_glibc64)',
1079                    '--include-dirs=>(tc_include_dir_glibc) ^(include_dirs) >(_include_dirs)',
1080                    '--compile_flags=-m64 ^(gcc_compile_flags) >(_gcc_compile_flags) ^(compile_flags) >(_compile_flags)',
1081                    '--gomadir', '<(gomadir)',
1082                    '--defines=^(defines) >(_defines)',
1083                    '--link_flags=-B>(tc_lib_dir_glibc64) ^(link_flags) >(_link_flags)',
1084                    '--source-list=^(source_list_glibc64)',
1085                  ],
1086                },
1087              ],
1088            }],
1089            # x86-32 glibc static library action
1090            ['nlib_target!="" and build_glibc!=0 and enable_x86_32!=0 and disable_glibc==0', {
1091              'variables': {
1092                 'tool_name': 'glibc',
1093                 'out_glibc32%': '<(SHARED_INTERMEDIATE_DIR)/tc_<(tool_name)/lib32/>(nlib_target)',
1094                 'objdir_glibc32%': '>(INTERMEDIATE_DIR)/<(tool_name)-x86-32/>(_target_name)',
1095              },
1096              'actions': [
1097                {
1098                  'action_name': 'build glibc x86-32 nlib',
1099                  'variables': {
1100                    'source_list_glibc32%': '^|(<(tool_name)-x86-32.>(_target_name).source_list.gypcmd ^(_sources) ^(sources))',
1101                  },
1102                  'msvs_cygwin_shell': 0,
1103                  'description': 'building >(out_glibc32)',
1104                  'inputs': [
1105                     '<(DEPTH)/native_client/build/build_nexe.py',
1106                     '>!@pymod_do_main(>(get_sources) >(sources) >(_sources))',
1107                     '>@(extra_deps)',
1108                     '>@(extra_deps_glibc32)',
1109                     '^(source_list_glibc32)',
1110                     '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_x86_glibc/stamp.prep',
1111                  ],
1112                  'outputs': ['>(out_glibc32)'],
1113                  'action': [
1114                    'python',
1115                    '<(DEPTH)/native_client/build/build_nexe.py',
1116                    '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
1117                    '>@(extra_args)',
1118                    '--arch', 'x86-32',
1119                    '--build', 'glibc_nlib',
1120                    '--root', '<(DEPTH)',
1121                    '--name', '>(out_glibc32)',
1122                    '--objdir', '>(objdir_glibc32)',
1123                    '--include-dirs=>(tc_include_dir_glibc) ^(include_dirs) >(_include_dirs)',
1124                    '--compile_flags=-m32 ^(gcc_compile_flags) >(_gcc_compile_flags) ^(compile_flags) >(_compile_flags)',
1125                    '--gomadir', '<(gomadir)',
1126                    '--defines=^(defines) >(_defines)',
1127                    '--link_flags=-m32 -B>(tc_lib_dir_glibc32) ^(link_flags) >(_link_flags)',
1128                    '--source-list=^(source_list_glibc32)',
1129                  ],
1130                },
1131              ],
1132            }],
1133            # x86-64 glibc shared library action
1134            ['nso_target!="" and build_glibc!=0 and enable_x86_64!=0 and disable_glibc==0', {
1135              'variables': {
1136                 'tool_name': 'glibc',
1137                 'objdir_glibc64%': '>(INTERMEDIATE_DIR)/<(tool_name)-x86-64-so/>(_target_name)',
1138                 'out_glibc64%': '<(SHARED_INTERMEDIATE_DIR)/tc_<(tool_name)/lib64/>(nso_target)',
1139              },
1140              'actions': [
1141                {
1142                  'action_name': 'build glibc x86-64 nso',
1143                  'variables': {
1144                    'source_list_glibc64%': '^|(<(tool_name)-x86-64-so.>(_target_name).source_list.gypcmd ^(_sources) ^(sources))',
1145                  },
1146                  'msvs_cygwin_shell': 0,
1147                  'description': 'building >(out_glibc64)',
1148                  'inputs': [
1149                     '<(DEPTH)/native_client/build/build_nexe.py',
1150                     '>!@pymod_do_main(>(get_sources) >(sources) >(_sources))',
1151                     '>@(extra_deps)',
1152                     '>@(extra_deps_glibc64)',
1153                     '^(source_list_glibc64)',
1154                     '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_x86_glibc/stamp.prep',
1155                  ],
1156                  'outputs': ['>(out_glibc64)'],
1157                  'action': [
1158                    'python',
1159                    '<(DEPTH)/native_client/build/build_nexe.py',
1160                    '>@(extra_args)',
1161                    '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
1162                    '--arch', 'x86-64',
1163                    '--build', 'glibc_nso',
1164                    '--root', '<(DEPTH)',
1165                    '--name', '>(out_glibc64)',
1166                    '--objdir', '>(objdir_glibc64)',
1167                    '--include-dirs=>(tc_include_dir_glibc) ^(include_dirs) >(_include_dirs)',
1168                    '--compile_flags=-m64 -fPIC ^(gcc_compile_flags) >(_gcc_compile_flags) ^(compile_flags) >(_compile_flags)',
1169                    '--gomadir', '<(gomadir)',
1170                    '--defines=^(defines) >(_defines)',
1171                    '--link_flags=-B>(tc_lib_dir_glibc64) ^(link_flags) >(_link_flags)',
1172                    '--source-list=^(source_list_glibc64)',
1173                  ],
1174                },
1175              ],
1176            }],
1177            # x86-32 glibc shared library action
1178            ['nso_target!="" and build_glibc!=0 and enable_x86_32!=0 and disable_glibc==0', {
1179              'variables': {
1180                 'tool_name': 'glibc',
1181                 'out_glibc32%': '<(SHARED_INTERMEDIATE_DIR)/tc_<(tool_name)/lib32/>(nso_target)',
1182                 'objdir_glibc32%': '>(INTERMEDIATE_DIR)/<(tool_name)-x86-32-so/>(_target_name)',
1183              },
1184              'actions': [
1185                {
1186                  'action_name': 'build glibc x86-32 nso',
1187                  'variables': {
1188                    'source_list_glibc32%': '^|(<(tool_name)-x86-32-so.>(_target_name).source_list.gypcmd ^(_sources) ^(sources))',
1189                  },
1190                  'msvs_cygwin_shell': 0,
1191                  'description': 'building >(out_glibc32)',
1192                  'inputs': [
1193                     '<(DEPTH)/native_client/build/build_nexe.py',
1194                     '>!@pymod_do_main(>(get_sources) >(sources) >(_sources))',
1195                     '>@(extra_deps)',
1196                     '>@(extra_deps_glibc32)',
1197                     '^(source_list_glibc32)',
1198                     '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_x86_glibc/stamp.prep',
1199                  ],
1200                  'outputs': ['>(out_glibc32)'],
1201                  'action': [
1202                    'python',
1203                    '<(DEPTH)/native_client/build/build_nexe.py',
1204                    '>@(extra_args)',
1205                    '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
1206                    '--arch', 'x86-32',
1207                    '--build', 'glibc_nso',
1208                    '--root', '<(DEPTH)',
1209                    '--name', '>(out_glibc32)',
1210                    '--objdir', '>(objdir_glibc32)',
1211                    '--include-dirs=>(tc_include_dir_glibc) ^(include_dirs) >(_include_dirs)',
1212                    '--compile_flags=-m32 -fPIC ^(gcc_compile_flags) >(_gcc_compile_flags) ^(compile_flags) >(_compile_flags)',
1213                    '--gomadir', '<(gomadir)',
1214                    '--defines=^(defines) >(_defines)',
1215                    '--link_flags=-m32 -B>(tc_lib_dir_glibc32) ^(link_flags) >(_link_flags)',
1216                    '--source-list=^(source_list_glibc32)',
1217                  ],
1218                },
1219              ],
1220            }],
1221         ], # end target_conditions for glibc (nexe/nlib/nso, x86-32/64)
1222       },
1223     }], # end target_arch == ia32 or x64
1224   ],
1225   # Common defaults for pnacl targets
1226   'target_defaults': {
1227     'gcc_compile_flags': [],
1228     'pnacl_compile_flags': [],
1229     'variables': {
1230       'disable_pnacl%': 0,
1231       'build_pnacl_newlib': 0,
1232       'pnacl_native_biased': 0,
1233       'nexe_target': '',
1234       'nlib_target': '',
1235       'extra_deps_pnacl_newlib': [],
1236       'tc_lib_dir_pnacl_newlib': '<(SHARED_INTERMEDIATE_DIR)/tc_pnacl_newlib/lib',
1237       'tc_lib_dir_pnacl_translate' :'<(SHARED_INTERMEDIATE_DIR)/tc_pnacl_translate',
1238       'tc_include_dir_pnacl_newlib': '<(SHARED_INTERMEDIATE_DIR)/tc_pnacl_newlib/include',
1239       'compile_flags': [
1240         '<@(nacl_default_compile_flags)',
1241       ],
1242       'gcc_compile_flags': [
1243         '-fomit-frame-pointer',
1244         # A debugger should be able to unwind IRT call frames. As the IRT is
1245         # compiled with high level of optimizations and without debug info,
1246         # compiler is requested to generate unwind tables explicitly. This
1247         # is the default behavior on x86-64 and when compiling C++ with
1248         # exceptions enabled, the change is for the benefit of x86-32 C.
1249         # These are only required for the IRT but are here for all
1250         # nacl-gcc-compiled binaries because the IRT depends on other libs
1251         '-fasynchronous-unwind-tables',
1252       ],
1253       'pnacl_compile_flags': [
1254         '-Wno-extra-semi',
1255         '-Wno-unused-private-field',
1256         '-Wno-char-subscripts',
1257         '-Wno-unused-function',
1258       ],
1259     },
1260     'target_conditions': [
1261       # pnacl actions for building pexes and translating them
1262       ['nexe_target!="" and disable_pnacl==0 and build_pnacl_newlib!=0 '
1263        'and pnacl_native_biased==0', {
1264          'variables': {
1265            'out_pnacl_newlib_x86_32_nexe%': '<(PRODUCT_DIR)/>(nexe_target)_pnacl_newlib_x32.nexe',
1266            'out_pnacl_newlib_x86_64_nexe%': '<(PRODUCT_DIR)/>(nexe_target)_pnacl_newlib_x64.nexe',
1267            'out_pnacl_newlib_arm_nexe%': '<(PRODUCT_DIR)/>(nexe_target)_pnacl_newlib_arm.nexe',
1268            'out_pnacl_newlib_mips_nexe%': '<(PRODUCT_DIR)/>(nexe_target)_pnacl_newlib_mips.nexe',
1269            'tool_name': 'pnacl_newlib',
1270            'inst_dir': '<(SHARED_INTERMEDIATE_DIR)/tc_pnacl_newlib',
1271            'out_pnacl_newlib%': '<(PRODUCT_DIR)/>(nexe_target)_newlib.pexe',
1272            'objdir_pnacl_newlib%': '>(INTERMEDIATE_DIR)/<(tool_name)/>(_target_name)',
1273            'link_flags': [
1274              '-O3',
1275            ],
1276            'translate_flags': [],
1277          },
1278          'actions': [
1279            {
1280              'action_name': 'build newlib pexe',
1281              'variables': {
1282                'source_list_pnacl_newlib%': '^|(<(tool_name).>(_target_name).source_list.gypcmd ^(_sources) ^(sources))',
1283              },
1284              'msvs_cygwin_shell': 0,
1285              'description': 'building >(out_pnacl_newlib)',
1286              'inputs': [
1287                '<(DEPTH)/native_client/build/build_nexe.py',
1288                '>!@pymod_do_main(>(get_sources) >(sources) >(_sources))',
1289                '>@(extra_deps)',
1290                '>@(extra_deps_pnacl_newlib)',
1291                '^(source_list_pnacl_newlib)',
1292                '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_pnacl/stamp.prep',
1293              ],
1294              'outputs': ['>(out_pnacl_newlib)'],
1295              'action': [
1296                'python',
1297                '<(DEPTH)/native_client/build/build_nexe.py',
1298                '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
1299                '>@(extra_args)',
1300                '--arch', 'pnacl',
1301                '--build', 'newlib_pexe',
1302                '--root', '<(DEPTH)',
1303                '--name', '>(out_pnacl_newlib)',
1304                '--objdir', '>(objdir_pnacl_newlib)',
1305                '--include-dirs=>(tc_include_dir_pnacl_newlib) ^(include_dirs) >(_include_dirs)',
1306                '--compile_flags=^(compile_flags) >(_compile_flags) ^(pnacl_compile_flags) >(_pnacl_compile_flags)',
1307                '--gomadir', '<(gomadir)',
1308                '--defines=^(defines) >(_defines)',
1309                '--link_flags=-B<(SHARED_INTERMEDIATE_DIR)/tc_pnacl_newlib/lib ^(link_flags) >(_link_flags)',
1310                '--source-list=^(source_list_pnacl_newlib)',
1311              ],
1312            }],
1313          'target_conditions': [
1314            [ 'enable_x86_32!=0', {
1315              'actions': [{
1316                'action_name': 'translate newlib pexe to x86-32 nexe',
1317                'msvs_cygwin_shell': 0,
1318                'description': 'translating >(out_pnacl_newlib_x86_32_nexe)',
1319                'inputs': [
1320                  # Having this in the input somehow causes devenv warnings
1321                  # when building pnacl browser tests.
1322                  # '<(DEPTH)/native_client/build/build_nexe.py',
1323                  '>(out_pnacl_newlib)',
1324                ],
1325                'outputs': [ '>(out_pnacl_newlib_x86_32_nexe)' ],
1326                'action' : [
1327                  'python',
1328                  '<(DEPTH)/native_client/build/build_nexe.py',
1329                  '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
1330                  '--arch', 'x86-32',
1331                  '--build', 'newlib_translate',
1332                  '--root', '<(DEPTH)',
1333                  '--name', '>(out_pnacl_newlib_x86_32_nexe)',
1334                  '--link_flags=^(translate_flags) >(translate_flags) -Wl,-L>(tc_lib_dir_pnacl_translate)/lib-x86-32',
1335                  '>(out_pnacl_newlib)',
1336                ],
1337              }],
1338            }],
1339            [ 'enable_x86_64!=0', {
1340              'actions': [{
1341                'action_name': 'translate newlib pexe to x86-64 nexe',
1342                'msvs_cygwin_shell': 0,
1343                'description': 'translating >(out_pnacl_newlib_x86_64_nexe)',
1344                'inputs': [
1345                  # Having this in the input somehow causes devenv warnings
1346                  # when building pnacl browser tests.
1347                  # '<(DEPTH)/native_client/build/build_nexe.py',
1348                  '>(out_pnacl_newlib)',
1349                ],
1350                'outputs': [ '>(out_pnacl_newlib_x86_64_nexe)' ],
1351                'action' : [
1352                  'python',
1353                  '<(DEPTH)/native_client/build/build_nexe.py',
1354                  '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
1355                  '--arch', 'x86-64',
1356                  '--build', 'newlib_translate',
1357                  '--root', '<(DEPTH)',
1358                  '--name', '>(out_pnacl_newlib_x86_64_nexe)',
1359                  '--link_flags=^(translate_flags) >(translate_flags) -Wl,-L>(tc_lib_dir_pnacl_translate)/lib-x86-64',
1360                  '>(out_pnacl_newlib)',
1361                ],
1362              }],
1363            }],
1364            [ 'enable_arm!=0', {
1365              'actions': [{
1366                'action_name': 'translate newlib pexe to ARM nexe',
1367                'msvs_cygwin_shell': 0,
1368                'description': 'translating >(out_pnacl_newlib_arm_nexe)',
1369                'inputs': [
1370                  # Having this in the input somehow causes devenv warnings
1371                  # when building pnacl browser tests.
1372                  # '<(DEPTH)/native_client/build/build_nexe.py',
1373                  '>(out_pnacl_newlib)',
1374                ],
1375                'outputs': [ '>(out_pnacl_newlib_arm_nexe)' ],
1376                'action' : [
1377                  'python',
1378                  '<(DEPTH)/native_client/build/build_nexe.py',
1379                  '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
1380                  '--arch', 'arm',
1381                  '--build', 'newlib_translate',
1382                  '--root', '<(DEPTH)',
1383                  '--name', '>(out_pnacl_newlib_arm_nexe)',
1384                  '--link_flags=^(translate_flags) >(translate_flags) -Wl,-L>(tc_lib_dir_pnacl_translate)/lib-arm',
1385                  '>(out_pnacl_newlib)',
1386                ],
1387              }],
1388            }],
1389            [ 'enable_mips!=0', {
1390              'actions': [{
1391                'action_name': 'translate newlib pexe to MIPS nexe',
1392                'msvs_cygwin_shell': 0,
1393                'description': 'translating >(out_pnacl_newlib_mips_nexe)',
1394                'inputs': [
1395                  # Having this in the input somehow causes devenv warnings
1396                  # when building pnacl browser tests.
1397                  # '<(DEPTH)/native_client/build/build_nexe.py',
1398                  '>(out_pnacl_newlib)',
1399                ],
1400                'outputs': [ '>(out_pnacl_newlib_mips_nexe)' ],
1401                'action' : [
1402                  'python',
1403                  '<(DEPTH)/native_client/build/build_nexe.py',
1404                  '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
1405                  '--arch', 'mips',
1406                  '--build', 'newlib_translate',
1407                  '--root', '<(DEPTH)',
1408                  '--name', '>(out_pnacl_newlib_mips_nexe)',
1409                  '--link_flags=^(translate_flags) >(translate_flags) -Wl,-L>(tc_lib_dir_pnacl_translate)/lib-mips',
1410                  '>(out_pnacl_newlib)',
1411                ],
1412              }],
1413            }],
1414          ],
1415        }],  # end pnacl actions for building pexes and translating to nexes
1416       # pnacl action for building portable bitcode libraries
1417       ['nlib_target!="" and disable_pnacl==0 and build_pnacl_newlib!=0'
1418        'and pnacl_native_biased==0', {
1419          'variables': {
1420            'tool_name': 'pnacl_newlib',
1421            'objdir_pnacl_newlib%': '>(INTERMEDIATE_DIR)/<(tool_name)-pnacl/>(_target_name)',
1422            'out_pnacl_newlib%': '<(SHARED_INTERMEDIATE_DIR)/tc_<(tool_name)/lib/>(nlib_target)',
1423          },
1424          'actions': [
1425            {
1426              'action_name': 'build newlib plib',
1427              'variables': {
1428                'source_list_pnacl_newlib%': '^|(<(tool_name).>(_target_name).source_list.gypcmd ^(_sources) ^(sources))',
1429              },
1430              'msvs_cygwin_shell': 0,
1431              'description': 'building >(out_pnacl_newlib)',
1432              'inputs': [
1433                '<(DEPTH)/native_client/build/build_nexe.py',
1434                '>!@pymod_do_main(>(get_sources) >(sources) >(_sources))',
1435                '>@(extra_deps)',
1436                '>@(extra_deps_pnacl_newlib)',
1437                '^(source_list_pnacl_newlib)',
1438                '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_pnacl/stamp.prep',
1439              ],
1440              'outputs': ['>(out_pnacl_newlib)'],
1441              'action': [
1442                'python',
1443                '<(DEPTH)/native_client/build/build_nexe.py',
1444                '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
1445                '>@(extra_args)',
1446                '--arch', 'pnacl',
1447                '--build', 'newlib_plib',
1448                '--root', '<(DEPTH)',
1449                '--name', '>(out_pnacl_newlib)',
1450                '--objdir', '>(objdir_pnacl_newlib)',
1451                '--include-dirs=>(tc_include_dir_pnacl_newlib) ^(include_dirs) >(_include_dirs)',
1452                '--compile_flags=^(compile_flags) >(_compile_flags) ^(pnacl_compile_flags) >(_pnacl_compile_flags)',
1453                '--gomadir', '<(gomadir)',
1454                '--defines=^(defines) >(_defines)',
1455                '--link_flags=-B>(tc_lib_dir_pnacl_newlib) ^(link_flags) >(_link_flags)',
1456                '--source-list=^(source_list_pnacl_newlib)',
1457              ],
1458            },
1459          ],
1460        }], # end pnacl actions for bitcode libraries
1461     ], # end target conditions for pnacl pexe/plib
1462     # pnacl actions for building ABI-biased native libraries
1463     'conditions': [
1464       # ARM
1465       ['target_arch=="arm"', {
1466         'target_conditions': [
1467           ['disable_pnacl==0 and pnacl_native_biased==1 and nlib_target!="" and build_pnacl_newlib!=0', {
1468             'variables': {
1469                'tool_name': 'pnacl_newlib_arm',
1470                'out_pnacl_newlib_arm%': '<(SHARED_INTERMEDIATE_DIR)/tc_<(tool_name)/libarm/>(nlib_target)',
1471                'objdir_pnacl_newlib_arm%': '>(INTERMEDIATE_DIR)/<(tool_name)/>(_target_name)',
1472              },
1473             'actions': [
1474               {
1475                 'action_name': 'build newlib arm nlib (via pnacl)',
1476                 'variables': {
1477                   'source_list_pnacl_newlib_arm%': '^|(<(tool_name).>(_target_name).source_list.gypcmd ^(_sources) ^(sources))',
1478                 },
1479                 'msvs_cygwin_shell': 0,
1480                 'description': 'building >(out_pnacl_newlib_arm)',
1481                 'inputs': [
1482                   '<(DEPTH)/native_client/build/build_nexe.py',
1483                   '>!@pymod_do_main(>(get_sources) >(sources) >(_sources))',
1484                   '>@(extra_deps)',
1485                   '>@(extra_deps_pnacl_newlib)',
1486                   '^(source_list_pnacl_newlib_arm)',
1487                   '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_pnacl/stamp.prep'
1488                 ],
1489                 'outputs': ['>(out_pnacl_newlib_arm)'],
1490                 'action': [
1491                   'python',
1492                   '<(DEPTH)/native_client/build/build_nexe.py',
1493                   '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
1494                   '>@(extra_args)',
1495                   '--arch', 'arm',
1496                   '--build', 'newlib_nlib_pnacl',
1497                   '--root', '<(DEPTH)',
1498                   '--name', '>(out_pnacl_newlib_arm)',
1499                   '--objdir', '>(objdir_pnacl_newlib_arm)',
1500                   '--include-dirs=>(tc_include_dir_pnacl_newlib) ^(include_dirs) >(_include_dirs)',
1501                   '--compile_flags=--target=armv7-unknown-nacl-gnueabi -mfloat-abi=hard --pnacl-allow-translate -arch arm ^(compile_flags) >(_compile_flags) ^(pnacl_compile_flags) >(_pnacl_compile_flags)',
1502                   '--gomadir', '<(gomadir)',
1503                   '--defines=^(defines) >(_defines)',
1504                   '--link_flags=-B>(tc_lib_dir_pnacl_newlib) ^(link_flags) >(_link_flags)',
1505                   '--source-list=^(source_list_pnacl_newlib_arm)',
1506                 ],
1507               },
1508             ],
1509           }],
1510         ],
1511       }], # end ARM
1512       # ia32 or x64 (want to build both for Windows)
1513       ['target_arch=="ia32" or target_arch=="x64"', {
1514         'target_conditions': [
1515           # x64
1516           ['enable_x86_64!=0 and disable_pnacl==0 and pnacl_native_biased==1 '
1517            'and nlib_target!="" and build_pnacl_newlib!=0', {
1518              'variables': {
1519                'tool_name': 'pnacl_newlib_x86_64',
1520                'out_pnacl_newlib_x86_64%': '<(SHARED_INTERMEDIATE_DIR)/tc_<(tool_name)/lib-x86-64/>(nlib_target)',
1521                'objdir_pnacl_newlib_x86_64%': '>(INTERMEDIATE_DIR)/<(tool_name)/>(_target_name)',
1522              },
1523              'actions': [
1524                {
1525                  'action_name': 'build newlib x86-64 nlib (via pnacl)',
1526                  'variables': {
1527                    'source_list_pnacl_newlib_x86_64%': '^|(<(tool_name).>(_target_name).source_list.gypcmd ^(_sources) ^(sources))',
1528                  },
1529                  'msvs_cygwin_shell': 0,
1530                  'description': 'building >(out_pnacl_newlib_x86_64)',
1531                  'inputs': [
1532                    '<(DEPTH)/native_client/build/build_nexe.py',
1533                    '>!@pymod_do_main(>(get_sources) >(sources) >(_sources))',
1534                    '>@(extra_deps)',
1535                    '>@(extra_deps_pnacl_newlib)',
1536                    '^(source_list_pnacl_newlib_x86_64)',
1537                    '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_pnacl/stamp.prep'
1538                  ],
1539                  'outputs': ['>(out_pnacl_newlib_x86_64)'],
1540                  'action': [
1541                    'python',
1542                    '<(DEPTH)/native_client/build/build_nexe.py',
1543                    '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
1544                    '>@(extra_args)',
1545                    '--arch', 'x86-64',
1546                    '--build', 'newlib_nlib_pnacl',
1547                    '--root', '<(DEPTH)',
1548                    '--name', '>(out_pnacl_newlib_x86_64)',
1549                    '--objdir', '>(objdir_pnacl_newlib_x86_64)',
1550                    '--include-dirs=>(tc_include_dir_pnacl_newlib) ^(include_dirs) >(_include_dirs)',
1551                    '--compile_flags=--target=x86_64-unknown-nacl --pnacl-allow-translate -arch x86-64 ^(compile_flags) >(_compile_flags) ^(pnacl_compile_flags) >(_pnacl_compile_flags)',
1552                    '--gomadir', '<(gomadir)',
1553                    '--defines=^(defines) >(_defines)',
1554                    '--link_flags=-B>(tc_lib_dir_pnacl_newlib) ^(link_flags) >(_link_flags)',
1555                    '--source-list=^(source_list_pnacl_newlib_x86_64)',
1556                  ],
1557                },
1558              ],
1559            }], # end x64
1560           # ia32
1561           ['enable_x86_32!=0 and disable_pnacl==0 and pnacl_native_biased==1 '
1562            'and nlib_target!="" and build_pnacl_newlib!=0', {
1563              'variables': {
1564                'tool_name': 'pnacl_newlib_x86_32',
1565                'out_pnacl_newlib_x86_32%': '<(SHARED_INTERMEDIATE_DIR)/tc_<(tool_name)/lib-x86-32/>(nlib_target)',
1566                'objdir_pnacl_newlib_x86_32%': '>(INTERMEDIATE_DIR)/<(tool_name)/>(_target_name)',
1567              },
1568              'actions': [
1569                {
1570                  'action_name': 'build newlib x86-32 nlib (via pnacl)',
1571                  'variables': {
1572                    'source_list_pnacl_newlib_x86_32%': '^|(<(tool_name).>(_target_name).source_list.gypcmd ^(_sources) ^(sources))',
1573                  },
1574                  'msvs_cygwin_shell': 0,
1575                  'description': 'building >(out_pnacl_newlib_x86_32)',
1576                  'inputs': [
1577                    '<(DEPTH)/native_client/build/build_nexe.py',
1578                    '>!@pymod_do_main(>(get_sources) >(sources) >(_sources))',
1579                    '>@(extra_deps)',
1580                    '>@(extra_deps_pnacl_newlib)',
1581                    '^(source_list_pnacl_newlib_x86_32)',
1582                    '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/<(OS)_pnacl/stamp.prep'
1583                  ],
1584                  'outputs': ['>(out_pnacl_newlib_x86_32)'],
1585                  'action': [
1586                    'python',
1587                    '<(DEPTH)/native_client/build/build_nexe.py',
1588                    '-t', '<(SHARED_INTERMEDIATE_DIR)/sdk/toolchain/',
1589                    '>@(extra_args)',
1590                    '--arch', 'x86-32',
1591                    '--build', 'newlib_nlib_pnacl',
1592                    '--root', '<(DEPTH)',
1593                    '--name', '>(out_pnacl_newlib_x86_32)',
1594                    '--objdir', '>(objdir_pnacl_newlib_x86_32)',
1595                    '--include-dirs=>(tc_include_dir_pnacl_newlib) ^(include_dirs) >(_include_dirs)',
1596                    '--compile_flags=--target=i686-unknown-nacl --pnacl-allow-translate -arch x86-32 ^(compile_flags) >(_compile_flags) ^(pnacl_compile_flags) >(_pnacl_compile_flags)',
1597                    '--gomadir', '<(gomadir)',
1598                    '--defines=^(defines) >(_defines)',
1599                    '--link_flags=-B>(tc_lib_dir_pnacl_newlib) ^(link_flags) >(_link_flags)',
1600                    '--source-list=^(source_list_pnacl_newlib_x86_32)',
1601                  ],
1602                },
1603              ],
1604            }], # end ia32
1605         ], # end ia32 or x64
1606         # TODO(jvoung): implement MIPS clause.
1607         # Do they want the IRT ABI to be biased toward --target=mipsel-...-nacl
1608         # or do they want it to be le32 along with -expand-byval, etc.
1609         # (then the shim isn't necessary)?
1610       }], # end pnacl actions for building ABI-biased native libraries
1611     ], # end conditions for pnacl biased nlib
1612   },
1613 }