1# Copyright (c) 2013 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  'includes': [
7    '../build/common_untrusted.gypi',
8  ],
9  'target_defaults': {
10    # We need to override the variables in untrusted.gypi outside of a
11    # target_condition block because the target_condition block in
12    # untrusted gypi is fully evaluated and interpolated before any of the
13    # target_condition blocks in this file are expanded.  This means that any
14    # variables overriden inside a target_condition block in this file will not
15    # affect the values in untrusted.gypi.
16    'variables': {
17      'test_files': [],
18      'generate_nmf%': 1,
19      'nacl_newlib_out_dir': '<(PRODUCT_DIR)/>(nexe_destination_dir)/newlib',
20      'nacl_glibc_out_dir': '<(PRODUCT_DIR)/>(nexe_destination_dir)/glibc',
21      'nacl_pnacl_newlib_out_dir': '<(PRODUCT_DIR)/>(nexe_destination_dir)/pnacl',
22      'nacl_pnacl_newlib_nonsfi_out_dir': '<(PRODUCT_DIR)/>(nexe_destination_dir)/nonsfi',
23      'target_conditions': [
24        ['nexe_target!=""', {
25          # These variables are used for nexe building and for library building.
26          'out_newlib32%': '>(nacl_newlib_out_dir)/>(nexe_target)_newlib_x86_32.nexe',
27          'out_newlib64%': '>(nacl_newlib_out_dir)/>(nexe_target)_newlib_x86_64.nexe',
28          'out_newlib_arm%': '>(nacl_newlib_out_dir)/>(nexe_target)_newlib_arm.nexe',
29          'out_newlib_mips%': '>(nacl_newlib_out_dir)/>(nexe_target)_newlib_mips32.nexe',
30          'nmf_newlib%': '>(nacl_newlib_out_dir)/>(nexe_target).nmf',
31          'out_glibc32%': '>(nacl_glibc_out_dir)/>(nexe_target)_glibc_x86_32.nexe',
32          'out_glibc64%': '>(nacl_glibc_out_dir)/>(nexe_target)_glibc_x86_64.nexe',
33          'out_glibc_arm%': '>(nacl_glibc_out_dir)/>(nexe_target)_glibc_arm.nexe',
34          'nmf_glibc%': '>(nacl_glibc_out_dir)/>(nexe_target).nmf',
35          'out_pnacl_newlib%': '>(nacl_pnacl_newlib_out_dir)/>(nexe_target)_newlib_pnacl.pexe',
36          'nmf_pnacl_newlib%': '>(nacl_pnacl_newlib_out_dir)/>(nexe_target).nmf',
37          'out_pnacl_newlib_x86_32_nonsfi_nexe': '>(nacl_pnacl_newlib_nonsfi_out_dir)/>(nexe_target)_pnacl_newlib_x32_nonsfi.nexe',
38          'nmf_pnacl_newlib_nonsfi%': '>(nacl_pnacl_newlib_nonsfi_out_dir)/>(nexe_target).nmf',
39        }],
40      ],
41    },
42    'dependencies': [
43       '<(DEPTH)/native_client/src/untrusted/nacl/nacl.gyp:nacl_lib',
44       '<(DEPTH)/native_client/src/untrusted/pthread/pthread.gyp:pthread_lib',
45       '<(DEPTH)/ppapi/ppapi_nacl.gyp:ppapi_cpp_lib',
46       '<(DEPTH)/ppapi/native_client/native_client.gyp:ppapi_lib',
47    ],
48    'target_conditions': [
49      ['test_files!=[] and build_newlib==1', {
50        'copies': [
51          {
52            'destination': '>(nacl_newlib_out_dir)',
53            'files': [
54              '>@(test_files)',
55            ],
56          },
57        ],
58      }],
59      ['test_files!=[] and "<(target_arch)"!="arm" and "<(target_arch)"!="mipsel" and disable_glibc==0 and build_glibc==1', {
60        'copies': [
61          {
62            'destination': '>(nacl_glibc_out_dir)',
63            'files': [
64              '>@(test_files)',
65            ],
66          },
67        ],
68      }],
69      # Nonsfi pnacl copy is covered below.
70      ['test_files!=[] and build_pnacl_newlib==1 and disable_pnacl==0', {
71        'copies': [
72          {
73            'destination': '>(nacl_pnacl_newlib_out_dir)',
74            'files': [
75              '>@(test_files)',
76            ],
77          },
78        ],
79      }],
80      ['test_files!=[] and build_pnacl_newlib==1 and enable_x86_32_nonsfi==1', {
81        'copies': [
82          {
83            'destination': '>(nacl_pnacl_newlib_nonsfi_out_dir)',
84            'files': [
85              '>@(test_files)',
86            ],
87          },
88        ],
89      }],
90      ['nexe_target!=""', {
91        'variables': {
92          # Patch over the fact that untrusted.gypi doesn't define these in all
93          # cases.
94          'enable_x86_64%': 0,
95          'enable_x86_32%': 0,
96          'enable_arm%': 0,
97          'enable_mips%': 0,
98          'include_dirs': [
99            '<(DEPTH)',
100          ],
101          'link_flags': [
102            '-lppapi_cpp',
103            '-lppapi',
104            '-pthread',
105          ],
106          'extra_args': [
107            '--strip-all',
108          ],
109          'create_nmf': '<(DEPTH)/native_client_sdk/src/tools/create_nmf.py',
110          'create_nmf_args_portable%': [],
111          'create_nonsfi_test_nmf': '<(DEPTH)/ppapi/tests/create_nonsfi_test_nmf.py',
112        },
113        'target_conditions': [
114          ['generate_nmf==1 and build_newlib==1', {
115            'actions': [
116              {
117                'action_name': 'Generate NEWLIB NMF',
118                'inputs': ['>(create_nmf)'],
119                'outputs': ['>(nmf_newlib)'],
120                'action': [
121                  'python',
122                  '>(create_nmf)',
123                  '--output=>(nmf_newlib)',
124                  '>@(create_nmf_args_portable)',
125                ],
126                'target_conditions': [
127                  ['enable_x86_64==1', {
128                    'inputs': ['>(out_newlib64)'],
129                    'action': ['>(out_newlib64)'],
130                  }],
131                  ['enable_x86_32==1', {
132                    'inputs': ['>(out_newlib32)'],
133                    'action': ['>(out_newlib32)'],
134                  }],
135                  ['enable_arm==1', {
136                    'inputs': ['>(out_newlib_arm)'],
137                    'action': ['>(out_newlib_arm)'],
138                  }],
139                  ['enable_mips==1', {
140                    'inputs': ['>(out_newlib_mips)'],
141                    'action': ['>(out_newlib_mips)'],
142                  }],
143                ],
144              },
145            ],
146          }],
147          ['"<(target_arch)"!="arm" and "<(target_arch)"!="mipsel" and generate_nmf==1 and disable_glibc==0 and build_glibc==1', {
148            'variables': {
149              # NOTE: Use /lib, not /lib64 here; it is a symbolic link which
150              # doesn't work on Windows.
151              'libdir_glibc64': '>(nacl_glibc_tc_root)/x86_64-nacl/lib',
152              'libdir_glibc32': '>(nacl_glibc_tc_root)/x86_64-nacl/lib32',
153              'nacl_objdump': '>(nacl_glibc_tc_root)/bin/x86_64-nacl-objdump',
154            },
155            'actions': [
156              {
157                'action_name': 'Generate GLIBC NMF and copy libs',
158                'inputs': ['>(create_nmf)'],
159                # NOTE: There is no explicit dependency for the lib32
160                # and lib64 directories created in the PRODUCT_DIR.
161                # They are created as a side-effect of NMF creation.
162                'outputs': ['>(nmf_glibc)'],
163                'action': [
164                  'python',
165                  '>(create_nmf)',
166                  '--objdump=>(nacl_objdump)',
167                  '--output=>(nmf_glibc)',
168                  '--path-prefix=>(nexe_target)_libs',
169                  '--stage-dependencies=<(nacl_glibc_out_dir)',
170                  '>@(create_nmf_args_portable)',
171                ],
172                'target_conditions': [
173                  ['enable_x86_64==1', {
174                    'inputs': ['>(out_glibc64)'],
175                    'action': [
176                      '>(out_glibc64)',
177                      '--library-path=>(libdir_glibc64)',
178                      '--library-path=>(tc_lib_dir_glibc64)',
179                    ],
180                  }],
181                  ['enable_x86_32==1', {
182                    'inputs': ['>(out_glibc32)'],
183                    'action': [
184                      '>(out_glibc32)',
185                      '--library-path=>(libdir_glibc32)',
186                      '--library-path=>(tc_lib_dir_glibc32)',
187                    ],
188                  }],
189                  # TODO(ncbray) handle arm case.  We don't have ARM glibc yet.
190                ],
191              },
192            ],
193          }],
194          ['generate_nmf==1 and build_pnacl_newlib==1 and disable_pnacl==0', {
195            'actions': [
196              {
197                'action_name': 'Generate PNACL NEWLIB NMF',
198                # NOTE: create_nmf must be first, it is the script python
199                # executes below.
200                'inputs': ['>(create_nmf)', '>(out_pnacl_newlib)'],
201                'outputs': ['>(nmf_pnacl_newlib)'],
202                'action': [
203                  'python',
204                  '>(create_nmf)',
205                  '--output=>(nmf_pnacl_newlib)',
206                  '>(out_pnacl_newlib)',
207                  '>@(create_nmf_args_portable)',
208                ],
209              },
210            ],
211          }],
212          ['generate_nmf==1 and build_pnacl_newlib==1 and disable_pnacl==0 and enable_x86_32_nonsfi==1', {
213            'actions': [
214              {
215                'action_name': 'Generate PNACL NEWLIB nonsfi NMF',
216                # If we add support for ARM, we should split the dependency on
217                # out_pnacl_newlib_x86_32_nonsfi_nexe to 'target_conditions',
218                # similar to build_newlib=1 config declared above.
219                'inputs': ['>(create_nonsfi_test_nmf)',
220                           '>(out_pnacl_newlib_x86_32_nonsfi_nexe)'],
221                'outputs': ['>(nmf_pnacl_newlib_nonsfi)'],
222                'action': [
223                  'python',
224                  '>(create_nonsfi_test_nmf)',
225                  '--output=>(nmf_pnacl_newlib_nonsfi)',
226                  '--program=>(out_pnacl_newlib_x86_32_nonsfi_nexe)',
227                  '>@(create_nmf_args_portable)'
228                ],
229              },
230            ],
231          }],
232        ],
233      }],
234    ],
235  },
236}
237