OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2011 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2011 The Native Client Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Nacl SDK tool SCons.""" | 6 """Nacl SDK tool SCons.""" |
7 | 7 |
8 import __builtin__ | 8 import __builtin__ |
9 import re | 9 import re |
10 import os | 10 import os |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 # Force -fPIC when compiling for shared libraries. | 191 # Force -fPIC when compiling for shared libraries. |
192 env.AppendUnique(SHCCFLAGS=['-fPIC'], | 192 env.AppendUnique(SHCCFLAGS=['-fPIC'], |
193 ) | 193 ) |
194 | 194 |
195 def _SetEnvForPnacl(env, root): | 195 def _SetEnvForPnacl(env, root): |
196 arch = env['TARGET_FULLARCH'] | 196 arch = env['TARGET_FULLARCH'] |
197 assert arch in ['arm', 'x86-32', 'x86-64'] | 197 assert arch in ['arm', 'x86-32', 'x86-64'] |
198 | 198 |
199 arch_flag = ' -arch %s' % arch | 199 arch_flag = ' -arch %s' % arch |
200 shlibsuffix = '.so' | 200 shlibsuffix = '.so' |
201 if env['BUILD_TYPE'] == 'nacl_extra_sdk': | |
202 arch_flag = '' | |
203 shlibsuffix = '.pso' | |
204 | 201 |
205 env['PNACL_ROOT'] = root | 202 env['PNACL_ROOT'] = root |
206 pnacl_sdk_lib = '${PNACL_ROOT}/libs-bitcode' | 203 pnacl_sdk_lib = '${PNACL_ROOT}/libs-bitcode' |
207 #TODO(robertm): remove NACL_SDK_INCLUDE ASAP | 204 #TODO(robertm): remove NACL_SDK_INCLUDE ASAP |
208 pnacl_sdk_include = '${PNACL_ROOT}/sysroot/include' | 205 pnacl_sdk_include = '${PNACL_ROOT}/sysroot/include' |
209 pnacl_sdk_ar = '${PNACL_ROOT}/bin/pnacl-ar' | 206 pnacl_sdk_ar = '${PNACL_ROOT}/bin/pnacl-ar' |
210 pnacl_sdk_nm = '${PNACL_ROOT}/bin/pnacl-nm' | 207 pnacl_sdk_nm = '${PNACL_ROOT}/bin/pnacl-nm' |
211 pnacl_sdk_ranlib = '${PNACL_ROOT}/bin/pnacl-ranlib' | 208 pnacl_sdk_ranlib = '${PNACL_ROOT}/bin/pnacl-ranlib' |
212 | 209 |
213 pnacl_sdk_cc = '${PNACL_ROOT}/bin/pnacl-gcc' | 210 pnacl_sdk_cc = '${PNACL_ROOT}/bin/pnacl-gcc' |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 return native_env | 293 return native_env |
297 | 294 |
298 | 295 |
299 # This adds architecture specific defines for the target architecture. | 296 # This adds architecture specific defines for the target architecture. |
300 # These are normally omitted by PNaCl. | 297 # These are normally omitted by PNaCl. |
301 # For example: __i686__, __arm__, __x86_64__ | 298 # For example: __i686__, __arm__, __x86_64__ |
302 def AddBiasForPNaCl(env): | 299 def AddBiasForPNaCl(env): |
303 assert(env.Bit('bitcode')) | 300 assert(env.Bit('bitcode')) |
304 | 301 |
305 if env.Bit('target_arm'): | 302 if env.Bit('target_arm'): |
306 env.Append(CCFLAGS=['--pnacl-arm-bias']) | 303 env.AppendUnique(CCFLAGS=['--pnacl-arm-bias'], |
307 env.Append(CXXFLAGS=['--pnacl-arm-bias']) | 304 CXXFLAGS=['--pnacl-arm-bias']) |
308 elif env.Bit('target_x86_32'): | 305 elif env.Bit('target_x86_32'): |
309 env.Append(CCFLAGS=['--pnacl-i686-bias']) | 306 env.AppendUnique(CCFLAGS=['--pnacl-i686-bias'], |
310 env.Append(CXXFLAGS=['--pnacl-i686-bias']) | 307 CXXFLAGS=['--pnacl-i686-bias']) |
311 elif env.Bit('target_x86_64'): | 308 elif env.Bit('target_x86_64'): |
312 env.Append(CCFLAGS=['--pnacl-x86_64-bias']) | 309 env.AppendUnique(CCFLAGS=['--pnacl-x86_64-bias'], |
313 env.Append(CXXFLAGS=['--pnacl-x86_64-bias']) | 310 CXXFLAGS=['--pnacl-x86_64-bias']) |
314 else: | 311 else: |
315 raise Exception("Unknown architecture!") | 312 raise Exception("Unknown architecture!") |
316 | 313 |
317 | 314 |
318 def ValidateSdk(env): | 315 def ValidateSdk(env): |
319 checkables = ['${NACL_SDK_INCLUDE}/stdio.h'] | 316 checkables = ['${NACL_SDK_INCLUDE}/stdio.h'] |
320 for c in checkables: | 317 for c in checkables: |
321 if os.path.exists(env.subst(c)): | 318 if os.path.exists(env.subst(c)): |
322 continue | 319 continue |
323 # Windows build does not use cygwin and so can not see nacl subdirectory | 320 # Windows build does not use cygwin and so can not see nacl subdirectory |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 # if bitcode=1 use pnacl toolchain | 395 # if bitcode=1 use pnacl toolchain |
399 if env.Bit('bitcode'): | 396 if env.Bit('bitcode'): |
400 _SetEnvForPnacl(env, root) | 397 _SetEnvForPnacl(env, root) |
401 elif env.Bit('target_x86'): | 398 elif env.Bit('target_x86'): |
402 _SetEnvForX86Sdk(env, root) | 399 _SetEnvForX86Sdk(env, root) |
403 else: | 400 else: |
404 print "ERROR: unknown TARGET_ARCHITECTURE: ", env['TARGET_ARCHITECTURE'] | 401 print "ERROR: unknown TARGET_ARCHITECTURE: ", env['TARGET_ARCHITECTURE'] |
405 assert 0 | 402 assert 0 |
406 | 403 |
407 env.Prepend(LIBPATH='${NACL_SDK_LIB}') | 404 env.Prepend(LIBPATH='${NACL_SDK_LIB}') |
OLD | NEW |