Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: SConstruct

Issue 788193003: Create a build_config header file. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: mac gypi2 Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | build/common.gypi » ('j') | build/common.gypi » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #! -*- python -*- 1 #! -*- python -*-
2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. 2 # Copyright (c) 2012 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 import atexit 6 import atexit
7 import json 7 import json
8 import os 8 import os
9 import platform 9 import platform
10 import re 10 import re
(...skipping 2124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2135 directory name. If the argument is missing, raise a UserError saying 2135 directory name. If the argument is missing, raise a UserError saying
2136 that the given target requires that argument be given.""" 2136 that the given target requires that argument be given."""
2137 dir = ARGUMENTS.get(argument) 2137 dir = ARGUMENTS.get(argument)
2138 if not dir: 2138 if not dir:
2139 raise UserError('%s must be set when invoking %s' % (argument, target)) 2139 raise UserError('%s must be set when invoking %s' % (argument, target))
2140 return os.path.join(env.Dir('$MAIN_DIR').abspath, dir) 2140 return os.path.join(env.Dir('$MAIN_DIR').abspath, dir)
2141 2141
2142 pre_base_env.AddMethod(GetAbsDirArg) 2142 pre_base_env.AddMethod(GetAbsDirArg)
2143 2143
2144 2144
2145 pre_base_env.Append(
2146 CPPDEFINES = [
2147 ['NACL_BUILD_ARCH', '${BUILD_ARCHITECTURE}' ],
2148 ['NACL_BUILD_SUBARCH', '${BUILD_SUBARCH}' ],
2149 ],
2150 )
2151
2152 def MakeGTestEnv(env): 2145 def MakeGTestEnv(env):
2153 # Create an environment to run unit tests using Gtest. 2146 # Create an environment to run unit tests using Gtest.
2154 gtest_env = env.Clone() 2147 gtest_env = env.Clone()
2155 2148
2156 # This became necessary for the arm cross TC v4.6 2149 # This became necessary for the arm cross TC v4.6
2157 # but probable applies to all new gcc TCs 2150 # but probable applies to all new gcc TCs
2158 gtest_env.Append(LINKFLAGS=['-pthread']) 2151 gtest_env.Append(LINKFLAGS=['-pthread'])
2159 2152
2160 # Define compile-time flag that communicates that we are compiling in the test 2153 # Define compile-time flag that communicates that we are compiling in the test
2161 # environment (rather than for the TCB). 2154 # environment (rather than for the TCB).
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
2443 '$WINASM -defsym @feat.00=1 -o $TARGET'), 2436 '$WINASM -defsym @feat.00=1 -o $TARGET'),
2444 PDB = '${TARGET.base}.pdb', 2437 PDB = '${TARGET.base}.pdb',
2445 # Strict doesn't currently work for Windows since some of the system 2438 # Strict doesn't currently work for Windows since some of the system
2446 # libraries like wsock32 are magical. 2439 # libraries like wsock32 are magical.
2447 LIBS_STRICT = False, 2440 LIBS_STRICT = False,
2448 TARGET_ARCH='x86_64' if base_env.Bit('build_x86_64') else 'x86', 2441 TARGET_ARCH='x86_64' if base_env.Bit('build_x86_64') else 'x86',
2449 ) 2442 )
2450 2443
2451 windows_env.Append( 2444 windows_env.Append(
2452 CPPDEFINES = [ 2445 CPPDEFINES = [
2453 ['NACL_WINDOWS', '1'],
2454 ['NACL_OSX', '0'],
2455 ['NACL_LINUX', '0'],
2456 ['NACL_ANDROID', '0'],
2457 ['_WIN32_WINNT', '0x0501'], 2446 ['_WIN32_WINNT', '0x0501'],
2458 ['__STDC_LIMIT_MACROS', '1'], 2447 ['__STDC_LIMIT_MACROS', '1'],
2459 ['NOMINMAX', '1'], 2448 ['NOMINMAX', '1'],
2460 # WIN32 is used by ppapi 2449 # WIN32 is used by ppapi
2461 ['WIN32', '1'], 2450 ['WIN32', '1'],
2462 # WIN32_LEAN_AND_MEAN tells windows.h to omit obsolete and rarely 2451 # WIN32_LEAN_AND_MEAN tells windows.h to omit obsolete and rarely
2463 # used #include files. This allows use of Winsock 2.0 which otherwise 2452 # used #include files. This allows use of Winsock 2.0 which otherwise
2464 # would conflict with Winsock 1.x included by windows.h. 2453 # would conflict with Winsock 1.x included by windows.h.
2465 ['WIN32_LEAN_AND_MEAN', ''], 2454 ['WIN32_LEAN_AND_MEAN', ''],
2466 ], 2455 ],
2467 LIBS = ['ws2_32', 'advapi32'], 2456 LIBS = ['ws2_32', 'advapi32'],
2468 # TODO(bsy) remove 4355 once cross-repo 2457 # TODO(bsy) remove 4355 once cross-repo
2469 # NACL_ALLOW_THIS_IN_INITIALIZER_LIST changes go in. 2458 # NACL_ALLOW_THIS_IN_INITIALIZER_LIST changes go in.
2470 CCFLAGS = ['/EHsc', '/WX', '/wd4355', '/wd4800'], 2459 CCFLAGS = ['/EHsc', '/WX', '/wd4355', '/wd4800',
2460 # build_config.h is injected as a header in all sources to
Mark Seaborn 2014/12/29 17:51:03 Nit: indent by 1 space less
teravest 2014/12/29 22:29:28 Done.
2461 # provide macro definitions for the operating system and
2462 # architecture. This is injected so it's never accidentally
2463 # omitted in source files.
2464 '/FI', '$SOURCE_ROOT/native_client/src/include/build_config.h']
2471 ) 2465 )
2472 2466
2473 # This linker option allows us to ensure our builds are compatible with 2467 # This linker option allows us to ensure our builds are compatible with
2474 # Chromium, which uses it. 2468 # Chromium, which uses it.
2475 if windows_env.Bit('build_x86_32'): 2469 if windows_env.Bit('build_x86_32'):
2476 windows_env.Append(LINKFLAGS = "/safeseh") 2470 windows_env.Append(LINKFLAGS = "/safeseh")
2477 2471
2478 # We use the GNU assembler (gas) on Windows so that we can use the 2472 # We use the GNU assembler (gas) on Windows so that we can use the
2479 # same .S assembly files on all platforms. Microsoft's assembler uses 2473 # same .S assembly files on all platforms. Microsoft's assembler uses
2480 # a completely different syntax for x86 code. 2474 # a completely different syntax for x86 code.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2516 '-Wall', 2510 '-Wall',
2517 '-pedantic', 2511 '-pedantic',
2518 '-Wextra', 2512 '-Wextra',
2519 '-Wno-long-long', 2513 '-Wno-long-long',
2520 '-Wswitch-enum', 2514 '-Wswitch-enum',
2521 '-Wsign-compare', 2515 '-Wsign-compare',
2522 '-Wundef', 2516 '-Wundef',
2523 '-fdiagnostics-show-option', 2517 '-fdiagnostics-show-option',
2524 '-fvisibility=hidden', 2518 '-fvisibility=hidden',
2525 '-fstack-protector', 2519 '-fstack-protector',
2520 # build_config.h is injected as a header in all sources to provide
2521 # macro definitions for the operating system and architecture. This is
2522 # injected so it's never accidentally omitted in source files.
2523 '-include', '$SOURCE_ROOT/native_client/src/include/build_config.h',
2526 ] + werror_flags, 2524 ] + werror_flags,
2527 # NOTE: pthread is only neeeded for libppNaClPlugin.so and on arm 2525 # NOTE: pthread is only neeeded for libppNaClPlugin.so and on arm
2528 LIBS = ['pthread'], 2526 LIBS = ['pthread'],
2529 CPPDEFINES = [['__STDC_LIMIT_MACROS', '1'], 2527 CPPDEFINES = [['__STDC_LIMIT_MACROS', '1'],
2530 ['__STDC_FORMAT_MACROS', '1'], 2528 ['__STDC_FORMAT_MACROS', '1'],
2531 ], 2529 ],
2532 ) 2530 )
2533 # Android's stlport uses __STRICT_ANSI__ to exclude "long long". 2531 # Android's stlport uses __STRICT_ANSI__ to exclude "long long".
2534 # This breaks basically all C++ code that uses stlport. 2532 # This breaks basically all C++ code that uses stlport.
2535 if not unix_like_env.Bit('android'): 2533 if not unix_like_env.Bit('android'):
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2567 2565
2568 mac_env.Append( 2566 mac_env.Append(
2569 CCFLAGS=['-mmacosx-version-min=' + mac_deployment_target], 2567 CCFLAGS=['-mmacosx-version-min=' + mac_deployment_target],
2570 LINKFLAGS=['-mmacosx-version-min=' + mac_deployment_target]) 2568 LINKFLAGS=['-mmacosx-version-min=' + mac_deployment_target])
2571 2569
2572 subarch_flag = '-m%s' % mac_env['BUILD_SUBARCH'] 2570 subarch_flag = '-m%s' % mac_env['BUILD_SUBARCH']
2573 mac_env.Append( 2571 mac_env.Append(
2574 CCFLAGS=[subarch_flag, '-fPIC'], 2572 CCFLAGS=[subarch_flag, '-fPIC'],
2575 ASFLAGS=[subarch_flag], 2573 ASFLAGS=[subarch_flag],
2576 LINKFLAGS=[subarch_flag, '-fPIC'], 2574 LINKFLAGS=[subarch_flag, '-fPIC'],
2577 CPPDEFINES = [['NACL_WINDOWS', '0'], 2575 CPPDEFINES = [# defining _DARWIN_C_SOURCE breaks 10.4
2578 ['NACL_OSX', '1'],
2579 ['NACL_LINUX', '0'],
2580 ['NACL_ANDROID', '0'],
2581 # defining _DARWIN_C_SOURCE breaks 10.4
2582 #['_DARWIN_C_SOURCE', '1'], 2576 #['_DARWIN_C_SOURCE', '1'],
2583 #['__STDC_LIMIT_MACROS', '1'] 2577 #['__STDC_LIMIT_MACROS', '1']
2584 ], 2578 ],
2585 ) 2579 )
2580
2586 return mac_env 2581 return mac_env
2587 2582
2588 (mac_debug_env, mac_optimized_env) = GenerateOptimizationLevels(MakeMacEnv()) 2583 (mac_debug_env, mac_optimized_env) = GenerateOptimizationLevels(MakeMacEnv())
2589 2584
2590 2585
2591 def which(cmd, paths=os.environ.get('PATH', '').split(os.pathsep)): 2586 def which(cmd, paths=os.environ.get('PATH', '').split(os.pathsep)):
2592 for p in paths: 2587 for p in paths:
2593 if os.access(os.path.join(p, cmd), os.X_OK): 2588 if os.access(os.path.join(p, cmd), os.X_OK):
2594 return True 2589 return True
2595 return False 2590 return False
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
2793 BUILD_TYPE_DESCRIPTION = 'Linux ${OPTIMIZATION_LEVEL} build', 2788 BUILD_TYPE_DESCRIPTION = 'Linux ${OPTIMIZATION_LEVEL} build',
2794 tools = ['target_platform_linux'], 2789 tools = ['target_platform_linux'],
2795 # TODO(bradnelson): this should really be able to live in unix_like_env 2790 # TODO(bradnelson): this should really be able to live in unix_like_env
2796 # but can't due to what the target_platform_x module is 2791 # but can't due to what the target_platform_x module is
2797 # doing. 2792 # doing.
2798 LINK = '$CXX', 2793 LINK = '$CXX',
2799 ) 2794 )
2800 2795
2801 # Prepend so we can disable warnings via Append 2796 # Prepend so we can disable warnings via Append
2802 linux_env.Prepend( 2797 linux_env.Prepend(
2803 CPPDEFINES = [['NACL_WINDOWS', '0'], 2798 CPPDEFINES = [['_DEFAULT_SOURCE', '1'],
2804 ['NACL_OSX', '0'],
2805 ['NACL_LINUX', '1'],
2806 ['NACL_ANDROID', '0'],
2807 ['_DEFAULT_SOURCE', '1'],
2808 ['_BSD_SOURCE', '1'], 2799 ['_BSD_SOURCE', '1'],
2809 ['_POSIX_C_SOURCE', '199506'], 2800 ['_POSIX_C_SOURCE', '199506'],
2810 ['_XOPEN_SOURCE', '600'], 2801 ['_XOPEN_SOURCE', '600'],
2811 ['_GNU_SOURCE', '1'], 2802 ['_GNU_SOURCE', '1'],
2812 ['_LARGEFILE64_SOURCE', '1'], 2803 ['_LARGEFILE64_SOURCE', '1'],
2813 ], 2804 ],
2814 LIBS = ['rt'], 2805 LIBS = ['rt'],
2815 ) 2806 )
2816 2807
2817 if linux_env.Bit('build_x86_32'): 2808 if linux_env.Bit('build_x86_32'):
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
3111 ['_POSIX_C_SOURCE', '199506'], 3102 ['_POSIX_C_SOURCE', '199506'],
3112 ['_XOPEN_SOURCE', '600'], 3103 ['_XOPEN_SOURCE', '600'],
3113 3104
3114 ['DYNAMIC_ANNOTATIONS_ENABLED', '1' ], 3105 ['DYNAMIC_ANNOTATIONS_ENABLED', '1' ],
3115 ['DYNAMIC_ANNOTATIONS_PREFIX', 'NACL_' ], 3106 ['DYNAMIC_ANNOTATIONS_PREFIX', 'NACL_' ],
3116 3107
3117 ['NACL_WINDOWS', '0'], 3108 ['NACL_WINDOWS', '0'],
3118 ['NACL_OSX', '0'], 3109 ['NACL_OSX', '0'],
3119 ['NACL_LINUX', '0'], 3110 ['NACL_LINUX', '0'],
3120 ['NACL_ANDROID', '0'], 3111 ['NACL_ANDROID', '0'],
3112 ['NACL_BUILD_ARCH', '${BUILD_ARCHITECTURE}' ],
Mark Seaborn 2014/12/29 17:51:03 Can you inject build_config.h for untrusted code t
teravest 2014/12/29 22:29:28 I'm getting some strange errors when doing so: /us
Mark Seaborn 2015/01/02 04:18:31 That is from the Scons build, right? Does it fail
3113 ['NACL_BUILD_SUBARCH', '${BUILD_SUBARCH}' ],
3121 ], 3114 ],
3122 ) 3115 )
3123 3116
3124 def FixWindowsAssembler(env): 3117 def FixWindowsAssembler(env):
3125 if env.Bit('host_windows'): 3118 if env.Bit('host_windows'):
3126 # NOTE: This is needed because Windows builds are case-insensitive. 3119 # NOTE: This is needed because Windows builds are case-insensitive.
3127 # Without this we use nacl-as, which doesn't handle include directives, etc. 3120 # Without this we use nacl-as, which doesn't handle include directives, etc.
3128 env.Replace(ASCOM='${CCCOM}') 3121 env.Replace(ASCOM='${CCCOM}')
3129 3122
3130 FixWindowsAssembler(nacl_env) 3123 FixWindowsAssembler(nacl_env)
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
3474 3467
3475 nacl_env.AddMethod(NaClSdkLibrary) 3468 nacl_env.AddMethod(NaClSdkLibrary)
3476 3469
3477 3470
3478 # Special environment for untrusted test binaries that use raw syscalls 3471 # Special environment for untrusted test binaries that use raw syscalls
3479 def RawSyscallObjects(env, sources): 3472 def RawSyscallObjects(env, sources):
3480 raw_syscall_env = env.Clone() 3473 raw_syscall_env = env.Clone()
3481 raw_syscall_env.Append( 3474 raw_syscall_env.Append(
3482 CPPDEFINES = [ 3475 CPPDEFINES = [
3483 ['USE_RAW_SYSCALLS', '1'], 3476 ['USE_RAW_SYSCALLS', '1'],
3484 ['NACL_BUILD_ARCH', '${BUILD_ARCHITECTURE}' ],
3485 ['NACL_BUILD_SUBARCH', '${BUILD_SUBARCH}' ],
3486 ], 3477 ],
3487 ) 3478 )
3488 objects = [] 3479 objects = []
3489 for source_file in sources: 3480 for source_file in sources:
3490 target_name = 'raw_' + os.path.basename(source_file).rstrip('.c') 3481 target_name = 'raw_' + os.path.basename(source_file).rstrip('.c')
3491 object = raw_syscall_env.ComponentObject(target_name, 3482 object = raw_syscall_env.ComponentObject(target_name,
3492 source_file) 3483 source_file)
3493 objects.append(object) 3484 objects.append(object)
3494 return objects 3485 return objects
3495 3486
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
4044 nacl_env.ValidateSdk() 4035 nacl_env.ValidateSdk()
4045 4036
4046 if BROKEN_TEST_COUNT > 0: 4037 if BROKEN_TEST_COUNT > 0:
4047 msg = "There are %d broken tests." % BROKEN_TEST_COUNT 4038 msg = "There are %d broken tests." % BROKEN_TEST_COUNT
4048 if GetOption('brief_comstr'): 4039 if GetOption('brief_comstr'):
4049 msg += " Add --verbose to the command line for more information." 4040 msg += " Add --verbose to the command line for more information."
4050 print msg 4041 print msg
4051 4042
4052 # separate warnings from actual build output 4043 # separate warnings from actual build output
4053 Banner('B U I L D - O U T P U T:') 4044 Banner('B U I L D - O U T P U T:')
OLDNEW
« no previous file with comments | « no previous file | build/common.gypi » ('j') | build/common.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698