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