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