OLD | NEW |
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 2126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2137 directory name. If the argument is missing, raise a UserError saying | 2137 directory name. If the argument is missing, raise a UserError saying |
2138 that the given target requires that argument be given.""" | 2138 that the given target requires that argument be given.""" |
2139 dir = ARGUMENTS.get(argument) | 2139 dir = ARGUMENTS.get(argument) |
2140 if not dir: | 2140 if not dir: |
2141 raise UserError('%s must be set when invoking %s' % (argument, target)) | 2141 raise UserError('%s must be set when invoking %s' % (argument, target)) |
2142 return os.path.join(env.Dir('$MAIN_DIR').abspath, dir) | 2142 return os.path.join(env.Dir('$MAIN_DIR').abspath, dir) |
2143 | 2143 |
2144 pre_base_env.AddMethod(GetAbsDirArg) | 2144 pre_base_env.AddMethod(GetAbsDirArg) |
2145 | 2145 |
2146 | 2146 |
2147 pre_base_env.Append( | |
2148 CPPDEFINES = [ | |
2149 ['NACL_BUILD_ARCH', '${BUILD_ARCHITECTURE}' ], | |
2150 ['NACL_BUILD_SUBARCH', '${BUILD_SUBARCH}' ], | |
2151 ], | |
2152 ) | |
2153 | |
2154 def MakeGTestEnv(env): | 2147 def MakeGTestEnv(env): |
2155 # Create an environment to run unit tests using Gtest. | 2148 # Create an environment to run unit tests using Gtest. |
2156 gtest_env = env.Clone() | 2149 gtest_env = env.Clone() |
2157 | 2150 |
2158 # This became necessary for the arm cross TC v4.6 | 2151 # This became necessary for the arm cross TC v4.6 |
2159 # but probable applies to all new gcc TCs | 2152 # but probable applies to all new gcc TCs |
2160 gtest_env.Append(LINKFLAGS=['-pthread']) | 2153 gtest_env.Append(LINKFLAGS=['-pthread']) |
2161 | 2154 |
2162 # Define compile-time flag that communicates that we are compiling in the test | 2155 # Define compile-time flag that communicates that we are compiling in the test |
2163 # environment (rather than for the TCB). | 2156 # environment (rather than for the TCB). |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2445 '$WINASM -defsym @feat.00=1 -o $TARGET'), | 2438 '$WINASM -defsym @feat.00=1 -o $TARGET'), |
2446 PDB = '${TARGET.base}.pdb', | 2439 PDB = '${TARGET.base}.pdb', |
2447 # Strict doesn't currently work for Windows since some of the system | 2440 # Strict doesn't currently work for Windows since some of the system |
2448 # libraries like wsock32 are magical. | 2441 # libraries like wsock32 are magical. |
2449 LIBS_STRICT = False, | 2442 LIBS_STRICT = False, |
2450 TARGET_ARCH='x86_64' if base_env.Bit('build_x86_64') else 'x86', | 2443 TARGET_ARCH='x86_64' if base_env.Bit('build_x86_64') else 'x86', |
2451 ) | 2444 ) |
2452 | 2445 |
2453 windows_env.Append( | 2446 windows_env.Append( |
2454 CPPDEFINES = [ | 2447 CPPDEFINES = [ |
2455 ['NACL_WINDOWS', '1'], | |
2456 ['NACL_OSX', '0'], | |
2457 ['NACL_LINUX', '0'], | |
2458 ['NACL_ANDROID', '0'], | |
2459 ['_WIN32_WINNT', '0x0501'], | 2448 ['_WIN32_WINNT', '0x0501'], |
2460 ['__STDC_LIMIT_MACROS', '1'], | 2449 ['__STDC_LIMIT_MACROS', '1'], |
2461 ['NOMINMAX', '1'], | 2450 ['NOMINMAX', '1'], |
2462 # WIN32 is used by ppapi | 2451 # WIN32 is used by ppapi |
2463 ['WIN32', '1'], | 2452 ['WIN32', '1'], |
2464 # WIN32_LEAN_AND_MEAN tells windows.h to omit obsolete and rarely | 2453 # WIN32_LEAN_AND_MEAN tells windows.h to omit obsolete and rarely |
2465 # used #include files. This allows use of Winsock 2.0 which otherwise | 2454 # used #include files. This allows use of Winsock 2.0 which otherwise |
2466 # would conflict with Winsock 1.x included by windows.h. | 2455 # would conflict with Winsock 1.x included by windows.h. |
2467 ['WIN32_LEAN_AND_MEAN', ''], | 2456 ['WIN32_LEAN_AND_MEAN', ''], |
2468 ], | 2457 ], |
2469 LIBS = ['ws2_32', 'advapi32'], | 2458 LIBS = ['ws2_32', 'advapi32'], |
2470 # TODO(bsy) remove 4355 once cross-repo | 2459 # TODO(bsy) remove 4355 once cross-repo |
2471 # NACL_ALLOW_THIS_IN_INITIALIZER_LIST changes go in. | 2460 # NACL_ALLOW_THIS_IN_INITIALIZER_LIST changes go in. |
2472 CCFLAGS = ['/EHsc', '/WX', '/wd4355', '/wd4800'], | 2461 CCFLAGS = ['/EHsc', '/WX', '/wd4355', '/wd4800', |
| 2462 # build_config.h is injected as a header in all sources to |
| 2463 # provide macro definitions for the operating system and |
| 2464 # architecture. This is injected so it's never accidentally |
| 2465 # omitted in source files. |
| 2466 '/FI', '$SOURCE_ROOT/native_client/src/include/build_config.h'] |
2473 ) | 2467 ) |
2474 | 2468 |
2475 # This linker option allows us to ensure our builds are compatible with | 2469 # This linker option allows us to ensure our builds are compatible with |
2476 # Chromium, which uses it. | 2470 # Chromium, which uses it. |
2477 if windows_env.Bit('build_x86_32'): | 2471 if windows_env.Bit('build_x86_32'): |
2478 windows_env.Append(LINKFLAGS = "/safeseh") | 2472 windows_env.Append(LINKFLAGS = "/safeseh") |
2479 | 2473 |
2480 # We use the GNU assembler (gas) on Windows so that we can use the | 2474 # We use the GNU assembler (gas) on Windows so that we can use the |
2481 # same .S assembly files on all platforms. Microsoft's assembler uses | 2475 # same .S assembly files on all platforms. Microsoft's assembler uses |
2482 # a completely different syntax for x86 code. | 2476 # a completely different syntax for x86 code. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2518 '-Wall', | 2512 '-Wall', |
2519 '-pedantic', | 2513 '-pedantic', |
2520 '-Wextra', | 2514 '-Wextra', |
2521 '-Wno-long-long', | 2515 '-Wno-long-long', |
2522 '-Wswitch-enum', | 2516 '-Wswitch-enum', |
2523 '-Wsign-compare', | 2517 '-Wsign-compare', |
2524 '-Wundef', | 2518 '-Wundef', |
2525 '-fdiagnostics-show-option', | 2519 '-fdiagnostics-show-option', |
2526 '-fvisibility=hidden', | 2520 '-fvisibility=hidden', |
2527 '-fstack-protector', | 2521 '-fstack-protector', |
| 2522 # build_config.h is injected as a header in all sources to provide |
| 2523 # macro definitions for the operating system and architecture. This is |
| 2524 # injected so it's never accidentally omitted in source files. |
| 2525 '-include', '$SOURCE_ROOT/native_client/src/include/build_config.h', |
2528 ] + werror_flags, | 2526 ] + werror_flags, |
2529 # NOTE: pthread is only neeeded for libppNaClPlugin.so and on arm | 2527 # NOTE: pthread is only neeeded for libppNaClPlugin.so and on arm |
2530 LIBS = ['pthread'], | 2528 LIBS = ['pthread'], |
2531 CPPDEFINES = [['__STDC_LIMIT_MACROS', '1'], | 2529 CPPDEFINES = [['__STDC_LIMIT_MACROS', '1'], |
2532 ['__STDC_FORMAT_MACROS', '1'], | 2530 ['__STDC_FORMAT_MACROS', '1'], |
2533 ], | 2531 ], |
2534 ) | 2532 ) |
2535 # Android's stlport uses __STRICT_ANSI__ to exclude "long long". | 2533 # Android's stlport uses __STRICT_ANSI__ to exclude "long long". |
2536 # This breaks basically all C++ code that uses stlport. | 2534 # This breaks basically all C++ code that uses stlport. |
2537 if not unix_like_env.Bit('android'): | 2535 if not unix_like_env.Bit('android'): |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2569 | 2567 |
2570 mac_env.Append( | 2568 mac_env.Append( |
2571 CCFLAGS=['-mmacosx-version-min=' + mac_deployment_target], | 2569 CCFLAGS=['-mmacosx-version-min=' + mac_deployment_target], |
2572 LINKFLAGS=['-mmacosx-version-min=' + mac_deployment_target]) | 2570 LINKFLAGS=['-mmacosx-version-min=' + mac_deployment_target]) |
2573 | 2571 |
2574 subarch_flag = '-m%s' % mac_env['BUILD_SUBARCH'] | 2572 subarch_flag = '-m%s' % mac_env['BUILD_SUBARCH'] |
2575 mac_env.Append( | 2573 mac_env.Append( |
2576 CCFLAGS=[subarch_flag, '-fPIC'], | 2574 CCFLAGS=[subarch_flag, '-fPIC'], |
2577 ASFLAGS=[subarch_flag], | 2575 ASFLAGS=[subarch_flag], |
2578 LINKFLAGS=[subarch_flag, '-fPIC'], | 2576 LINKFLAGS=[subarch_flag, '-fPIC'], |
2579 CPPDEFINES = [['NACL_WINDOWS', '0'], | 2577 CPPDEFINES = [# defining _DARWIN_C_SOURCE breaks 10.4 |
2580 ['NACL_OSX', '1'], | |
2581 ['NACL_LINUX', '0'], | |
2582 ['NACL_ANDROID', '0'], | |
2583 # defining _DARWIN_C_SOURCE breaks 10.4 | |
2584 #['_DARWIN_C_SOURCE', '1'], | 2578 #['_DARWIN_C_SOURCE', '1'], |
2585 #['__STDC_LIMIT_MACROS', '1'] | 2579 #['__STDC_LIMIT_MACROS', '1'] |
2586 ], | 2580 ], |
2587 ) | 2581 ) |
| 2582 |
2588 return mac_env | 2583 return mac_env |
2589 | 2584 |
2590 (mac_debug_env, mac_optimized_env) = GenerateOptimizationLevels(MakeMacEnv()) | 2585 (mac_debug_env, mac_optimized_env) = GenerateOptimizationLevels(MakeMacEnv()) |
2591 | 2586 |
2592 | 2587 |
2593 def which(cmd, paths=os.environ.get('PATH', '').split(os.pathsep)): | 2588 def which(cmd, paths=os.environ.get('PATH', '').split(os.pathsep)): |
2594 for p in paths: | 2589 for p in paths: |
2595 if os.access(os.path.join(p, cmd), os.X_OK): | 2590 if os.access(os.path.join(p, cmd), os.X_OK): |
2596 return True | 2591 return True |
2597 return False | 2592 return False |
(...skipping 25 matching lines...) Expand all Loading... |
2623 # Note we let the compiler choose whether it's -marm or -mthumb by | 2618 # Note we let the compiler choose whether it's -marm or -mthumb by |
2624 # default. The hope is this will have the best chance of testing | 2619 # default. The hope is this will have the best chance of testing |
2625 # the prevailing compilation mode used for Chromium et al. | 2620 # the prevailing compilation mode used for Chromium et al. |
2626 env.Prepend(CCFLAGS=['-march=armv7-a']) | 2621 env.Prepend(CCFLAGS=['-march=armv7-a']) |
2627 | 2622 |
2628 # get_plugin_dirname.cc has a dependency on dladdr | 2623 # get_plugin_dirname.cc has a dependency on dladdr |
2629 env.Append(LIBS=['dl']) | 2624 env.Append(LIBS=['dl']) |
2630 | 2625 |
2631 def SetUpAndroidEnv(env): | 2626 def SetUpAndroidEnv(env): |
2632 env.FilterOut(CPPDEFINES=[['_LARGEFILE64_SOURCE', '1']]) | 2627 env.FilterOut(CPPDEFINES=[['_LARGEFILE64_SOURCE', '1']]) |
2633 env.FilterOut(CPPDEFINES=[['NACL_ANDROID', '0']]) | |
2634 env.Prepend(CPPDEFINES=[['NACL_ANDROID', '1']]) | |
2635 android_ndk_root = os.path.join('${SOURCE_ROOT}', 'third_party', | 2628 android_ndk_root = os.path.join('${SOURCE_ROOT}', 'third_party', |
2636 'android_tools', 'ndk') | 2629 'android_tools', 'ndk') |
2637 android_ndk_experimental_root = os.path.join('${SOURCE_ROOT}', | 2630 android_ndk_experimental_root = os.path.join('${SOURCE_ROOT}', |
2638 'third_party', 'android_tools', | 2631 'third_party', 'android_tools', |
2639 'ndk_experimental') | 2632 'ndk_experimental') |
2640 android_sdk_root = os.path.join('${SOURCE_ROOT}', 'third_party', | 2633 android_sdk_root = os.path.join('${SOURCE_ROOT}', 'third_party', |
2641 'android_tools', 'sdk') | 2634 'android_tools', 'sdk') |
2642 android_sdk_version = 21 | 2635 android_sdk_version = 21 |
2643 android_stlport_root = os.path.join(android_ndk_root, 'sources', 'cxx-stl', | 2636 android_stlport_root = os.path.join(android_ndk_root, 'sources', 'cxx-stl', |
2644 'stlport') | 2637 'stlport') |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2795 BUILD_TYPE_DESCRIPTION = 'Linux ${OPTIMIZATION_LEVEL} build', | 2788 BUILD_TYPE_DESCRIPTION = 'Linux ${OPTIMIZATION_LEVEL} build', |
2796 tools = ['target_platform_linux'], | 2789 tools = ['target_platform_linux'], |
2797 # 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 |
2798 # 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 |
2799 # doing. | 2792 # doing. |
2800 LINK = '$CXX', | 2793 LINK = '$CXX', |
2801 ) | 2794 ) |
2802 | 2795 |
2803 # Prepend so we can disable warnings via Append | 2796 # Prepend so we can disable warnings via Append |
2804 linux_env.Prepend( | 2797 linux_env.Prepend( |
2805 CPPDEFINES = [['NACL_WINDOWS', '0'], | 2798 CPPDEFINES = [['_DEFAULT_SOURCE', '1'], |
2806 ['NACL_OSX', '0'], | |
2807 ['NACL_LINUX', '1'], | |
2808 ['NACL_ANDROID', '0'], | |
2809 ['_DEFAULT_SOURCE', '1'], | |
2810 ['_BSD_SOURCE', '1'], | 2799 ['_BSD_SOURCE', '1'], |
2811 ['_POSIX_C_SOURCE', '199506'], | 2800 ['_POSIX_C_SOURCE', '199506'], |
2812 ['_XOPEN_SOURCE', '600'], | 2801 ['_XOPEN_SOURCE', '600'], |
2813 ['_GNU_SOURCE', '1'], | 2802 ['_GNU_SOURCE', '1'], |
2814 ['_LARGEFILE64_SOURCE', '1'], | 2803 ['_LARGEFILE64_SOURCE', '1'], |
2815 ], | 2804 ], |
2816 LIBS = ['rt'], | 2805 LIBS = ['rt'], |
2817 ) | 2806 ) |
2818 | 2807 |
2819 if linux_env.Bit('build_x86_32'): | 2808 if linux_env.Bit('build_x86_32'): |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3109 ['_GNU_SOURCE', 1], | 3098 ['_GNU_SOURCE', 1], |
3110 # strdup, and other common stuff | 3099 # strdup, and other common stuff |
3111 ['_DEFAULT_SOURCE', '1'], | 3100 ['_DEFAULT_SOURCE', '1'], |
3112 ['_BSD_SOURCE', '1'], | 3101 ['_BSD_SOURCE', '1'], |
3113 ['_POSIX_C_SOURCE', '199506'], | 3102 ['_POSIX_C_SOURCE', '199506'], |
3114 ['_XOPEN_SOURCE', '600'], | 3103 ['_XOPEN_SOURCE', '600'], |
3115 | 3104 |
3116 ['DYNAMIC_ANNOTATIONS_ENABLED', '1' ], | 3105 ['DYNAMIC_ANNOTATIONS_ENABLED', '1' ], |
3117 ['DYNAMIC_ANNOTATIONS_PREFIX', 'NACL_' ], | 3106 ['DYNAMIC_ANNOTATIONS_PREFIX', 'NACL_' ], |
3118 | 3107 |
3119 ['NACL_WINDOWS', '0'], | 3108 ['NACL_BUILD_ARCH', '${BUILD_ARCHITECTURE}'], |
3120 ['NACL_OSX', '0'], | 3109 ['NACL_BUILD_SUBARCH', '${BUILD_SUBARCH}'], |
3121 ['NACL_LINUX', '0'], | |
3122 ['NACL_ANDROID', '0'], | |
3123 ], | 3110 ], |
| 3111 CCFLAGS = [ |
| 3112 '-include', '$SOURCE_ROOT/native_client/src/include/build_config.h'], |
3124 ) | 3113 ) |
3125 | 3114 |
3126 def FixWindowsAssembler(env): | 3115 def FixWindowsAssembler(env): |
3127 if env.Bit('host_windows'): | 3116 if env.Bit('host_windows'): |
3128 # NOTE: This is needed because Windows builds are case-insensitive. | 3117 # NOTE: This is needed because Windows builds are case-insensitive. |
3129 # Without this we use nacl-as, which doesn't handle include directives, etc. | 3118 # Without this we use nacl-as, which doesn't handle include directives, etc. |
3130 env.Replace(ASCOM='${CCCOM}') | 3119 env.Replace(ASCOM='${CCCOM}') |
3131 | 3120 |
3132 FixWindowsAssembler(nacl_env) | 3121 FixWindowsAssembler(nacl_env) |
3133 | 3122 |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3474 | 3463 |
3475 nacl_env.AddMethod(NaClSdkLibrary) | 3464 nacl_env.AddMethod(NaClSdkLibrary) |
3476 | 3465 |
3477 | 3466 |
3478 # Special environment for untrusted test binaries that use raw syscalls | 3467 # Special environment for untrusted test binaries that use raw syscalls |
3479 def RawSyscallObjects(env, sources): | 3468 def RawSyscallObjects(env, sources): |
3480 raw_syscall_env = env.Clone() | 3469 raw_syscall_env = env.Clone() |
3481 raw_syscall_env.Append( | 3470 raw_syscall_env.Append( |
3482 CPPDEFINES = [ | 3471 CPPDEFINES = [ |
3483 ['USE_RAW_SYSCALLS', '1'], | 3472 ['USE_RAW_SYSCALLS', '1'], |
3484 ['NACL_BUILD_ARCH', '${BUILD_ARCHITECTURE}' ], | |
3485 ['NACL_BUILD_SUBARCH', '${BUILD_SUBARCH}' ], | |
3486 ], | 3473 ], |
3487 ) | 3474 ) |
3488 objects = [] | 3475 objects = [] |
3489 for source_file in sources: | 3476 for source_file in sources: |
3490 target_name = 'raw_' + os.path.basename(source_file).rstrip('.c') | 3477 target_name = 'raw_' + os.path.basename(source_file).rstrip('.c') |
3491 object = raw_syscall_env.ComponentObject(target_name, | 3478 object = raw_syscall_env.ComponentObject(target_name, |
3492 source_file) | 3479 source_file) |
3493 objects.append(object) | 3480 objects.append(object) |
3494 return objects | 3481 return objects |
3495 | 3482 |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4044 nacl_env.ValidateSdk() | 4031 nacl_env.ValidateSdk() |
4045 | 4032 |
4046 if BROKEN_TEST_COUNT > 0: | 4033 if BROKEN_TEST_COUNT > 0: |
4047 msg = "There are %d broken tests." % BROKEN_TEST_COUNT | 4034 msg = "There are %d broken tests." % BROKEN_TEST_COUNT |
4048 if GetOption('brief_comstr'): | 4035 if GetOption('brief_comstr'): |
4049 msg += " Add --verbose to the command line for more information." | 4036 msg += " Add --verbose to the command line for more information." |
4050 print msg | 4037 print msg |
4051 | 4038 |
4052 # separate warnings from actual build output | 4039 # separate warnings from actual build output |
4053 Banner('B U I L D - O U T P U T:') | 4040 Banner('B U I L D - O U T P U T:') |
OLD | NEW |