Home | History | Annotate | Download | only in build
      1 // Copyright (c) 2012 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 // This file adds defines about the platform we're currently building on.
      6 //  Operating System:
      7 //    OS_WIN / OS_MACOSX / OS_LINUX / OS_POSIX (MACOSX or LINUX) /
      8 //    OS_NACL (NACL_SFI or NACL_NONSFI) / OS_NACL_SFI / OS_NACL_NONSFI
      9 //  Compiler:
     10 //    COMPILER_MSVC / COMPILER_GCC
     11 //  Processor:
     12 //    ARCH_CPU_X86 / ARCH_CPU_X86_64 / ARCH_CPU_X86_FAMILY (X86 or X86_64)
     13 //    ARCH_CPU_32_BITS / ARCH_CPU_64_BITS
     14 
     15 #ifndef BASE_BUILD_BUILD_CONFIG_H_
     16 #define BASE_BUILD_BUILD_CONFIG_H_
     17 
     18 // Add Brillo-specific defines.
     19 #if defined(__BRILLO__)
     20 #define __linux__ 1
     21 #define NO_TCMALLOC
     22 // Unset ANDROID, which is just used for building Chrome on Android.
     23 #undef ANDROID
     24 
     25 #if defined(__BIONIC__)
     26 #define __UCLIBC__ 1
     27 #define OS_CHROMEOS 1
     28 #endif // __BIONIC__
     29 
     30 #endif
     31 
     32 // A set of macros to use for platform detection.
     33 #if defined(__native_client__)
     34 // __native_client__ must be first, so that other OS_ defines are not set.
     35 #define OS_NACL 1
     36 // OS_NACL comes in two sandboxing technology flavors, SFI or Non-SFI.
     37 // PNaCl toolchain defines __native_client_nonsfi__ macro in Non-SFI build
     38 // mode, while it does not in SFI build mode.
     39 #if defined(__native_client_nonsfi__)
     40 #define OS_NACL_NONSFI
     41 #else
     42 #define OS_NACL_SFI
     43 #endif
     44 #elif defined(ANDROID)
     45 #define OS_ANDROID 1
     46 #elif defined(__APPLE__)
     47 // only include TargetConditions after testing ANDROID as some android builds
     48 // on mac don't have this header available and it's not needed unless the target
     49 // is really mac/ios.
     50 #include <TargetConditionals.h>
     51 #define OS_MACOSX 1
     52 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
     53 #define OS_IOS 1
     54 #endif  // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
     55 #elif defined(__linux__)
     56 #define OS_LINUX 1
     57 // include a system header to pull in features.h for glibc/uclibc macros.
     58 #include <unistd.h>
     59 #if defined(__GLIBC__) && !defined(__UCLIBC__)
     60 // we really are using glibc, not uClibc pretending to be glibc
     61 #define LIBC_GLIBC 1
     62 #endif
     63 #elif defined(_WIN32)
     64 #define OS_WIN 1
     65 #define TOOLKIT_VIEWS 1
     66 #elif defined(__FreeBSD__)
     67 #define OS_FREEBSD 1
     68 #elif defined(__OpenBSD__)
     69 #define OS_OPENBSD 1
     70 #elif defined(__sun)
     71 #define OS_SOLARIS 1
     72 #elif defined(__QNXNTO__)
     73 #define OS_QNX 1
     74 #else
     75 #error Please add support for your platform in build/build_config.h
     76 #endif
     77 
     78 #if defined(USE_OPENSSL) && defined(USE_NSS)
     79 #error Cannot use both OpenSSL and NSS
     80 #endif
     81 
     82 // For access to standard BSD features, use OS_BSD instead of a
     83 // more specific macro.
     84 #if defined(OS_FREEBSD) || defined(OS_OPENBSD)
     85 #define OS_BSD 1
     86 #endif
     87 
     88 // For access to standard POSIXish features, use OS_POSIX instead of a
     89 // more specific macro.
     90 #if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_FREEBSD) ||     \
     91     defined(OS_OPENBSD) || defined(OS_SOLARIS) || defined(OS_ANDROID) ||  \
     92     defined(OS_NACL) || defined(OS_QNX)
     93 #define OS_POSIX 1
     94 #endif
     95 
     96 // Use tcmalloc
     97 #if (defined(OS_WIN) || defined(OS_LINUX) || defined(OS_ANDROID)) && \
     98     !defined(NO_TCMALLOC)
     99 #define USE_TCMALLOC 1
    100 #endif
    101 
    102 // Compiler detection.
    103 #if defined(__GNUC__)
    104 #define COMPILER_GCC 1
    105 #elif defined(_MSC_VER)
    106 #define COMPILER_MSVC 1
    107 #else
    108 #error Please add support for your compiler in build/build_config.h
    109 #endif
    110 
    111 // Processor architecture detection.  For more info on what's defined, see:
    112 //   http://msdn.microsoft.com/en-us/library/b0084kay.aspx
    113 //   http://www.agner.org/optimize/calling_conventions.pdf
    114 //   or with gcc, run: "echo | gcc -E -dM -"
    115 #if defined(_M_X64) || defined(__x86_64__)
    116 #define ARCH_CPU_X86_FAMILY 1
    117 #define ARCH_CPU_X86_64 1
    118 #define ARCH_CPU_64_BITS 1
    119 #define ARCH_CPU_LITTLE_ENDIAN 1
    120 #elif defined(_M_IX86) || defined(__i386__)
    121 #define ARCH_CPU_X86_FAMILY 1
    122 #define ARCH_CPU_X86 1
    123 #define ARCH_CPU_32_BITS 1
    124 #define ARCH_CPU_LITTLE_ENDIAN 1
    125 #elif defined(__ARMEL__)
    126 #define ARCH_CPU_ARM_FAMILY 1
    127 #define ARCH_CPU_ARMEL 1
    128 #define ARCH_CPU_32_BITS 1
    129 #define ARCH_CPU_LITTLE_ENDIAN 1
    130 #elif defined(__aarch64__)
    131 #define ARCH_CPU_ARM_FAMILY 1
    132 #define ARCH_CPU_ARM64 1
    133 #define ARCH_CPU_64_BITS 1
    134 #define ARCH_CPU_LITTLE_ENDIAN 1
    135 #elif defined(__pnacl__)
    136 #define ARCH_CPU_32_BITS 1
    137 #define ARCH_CPU_LITTLE_ENDIAN 1
    138 #elif defined(__MIPSEL__)
    139 #if defined(__LP64__)
    140 #define ARCH_CPU_MIPS64_FAMILY 1
    141 #define ARCH_CPU_MIPS64EL 1
    142 #define ARCH_CPU_64_BITS 1
    143 #define ARCH_CPU_LITTLE_ENDIAN 1
    144 #else
    145 #define ARCH_CPU_MIPS_FAMILY 1
    146 #define ARCH_CPU_MIPSEL 1
    147 #define ARCH_CPU_32_BITS 1
    148 #define ARCH_CPU_LITTLE_ENDIAN 1
    149 #endif
    150 #elif defined(__mips__)
    151 #if defined(__LP64__)
    152 #define ARCH_CPU_MIPS64_FAMILY 1
    153 #define ARCH_CPU_64_BITS 1
    154 #define ARCH_CPU_BIG_ENDIAN 1
    155 #else
    156 #define ARCH_CPU_MIPS_FAMILY 1
    157 #define ARCH_CPU_32_BITS 1
    158 #define ARCH_CPU_BIG_ENDIAN 1
    159 #endif
    160 #else
    161 #error Please add support for your architecture in build/build_config.h
    162 #endif
    163 
    164 #if defined(OS_ANDROID)
    165 // The compiler thinks std::string::const_iterator and "const char*" are
    166 // equivalent types.
    167 #define STD_STRING_ITERATOR_IS_CHAR_POINTER
    168 // The compiler thinks base::string16::const_iterator and "char16*" are
    169 // equivalent types.
    170 #define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER
    171 #endif
    172 
    173 #endif  // BASE_BUILD_BUILD_CONFIG_H_
    174