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 BUILD_BUILD_CONFIG_H_ 16 #define BUILD_BUILD_CONFIG_H_ 17 18 // A brief primer on #defines: 19 // 20 // - __ANDROID__ is automatically defined by the Android toolchain (see 21 // https://goo.gl/v61lXa). It's not defined when building host code. 22 // - __ANDROID_HOST__ is defined via -D by Android.mk when building host code 23 // within an Android checkout. 24 // - ANDROID is defined via -D when building code for either Android targets or 25 // hosts. Use __ANDROID__ and __ANDROID_HOST__ instead. 26 // - OS_ANDROID is a Chrome-specific define used to build Chrome for Android 27 // within the NDK. 28 29 // Android targets and hosts don't use tcmalloc. 30 #if defined(__ANDROID__) || defined(__ANDROID_HOST__) 31 #define NO_TCMALLOC 32 #endif // defined(__ANDROID__) || defined(__ANDROID_HOST__) 33 34 // Use the Chrome OS version of the code for both Android targets and Chrome OS builds. 35 #if !defined(__ANDROID_HOST__) 36 #define OS_CHROMEOS 1 37 #endif // !defined(__ANDROID_HOST__) 38 39 #if defined(__ANDROID__) // Android targets 40 41 #define __linux__ 1 42 #if defined(__BIONIC__) 43 #define __UCLIBC__ 1 44 #endif // defined(__BIONIC__) 45 46 #elif !defined(__ANDROID_HOST__) // Chrome OS 47 48 // TODO: Remove these once the GLib MessageLoopForUI isn't being used: 49 // https://crbug.com/361635 50 #define USE_GLIB 1 51 #define USE_OZONE 1 52 53 #endif // defined(__ANDROID__) 54 55 // A set of macros to use for platform detection. 56 #if defined(__native_client__) 57 // __native_client__ must be first, so that other OS_ defines are not set. 58 #define OS_NACL 1 59 // OS_NACL comes in two sandboxing technology flavors, SFI or Non-SFI. 60 // PNaCl toolchain defines __native_client_nonsfi__ macro in Non-SFI build 61 // mode, while it does not in SFI build mode. 62 #if defined(__native_client_nonsfi__) 63 #define OS_NACL_NONSFI 64 #else 65 #define OS_NACL_SFI 66 #endif 67 // Don't set OS_ANDROID; it's only used when building Chrome for Android. 68 #elif defined(__APPLE__) 69 // only include TargetConditions after testing ANDROID as some android builds 70 // on mac don't have this header available and it's not needed unless the target 71 // is really mac/ios. 72 #include <TargetConditionals.h> 73 #define OS_MACOSX 1 74 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE 75 #define OS_IOS 1 76 #endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE 77 #elif defined(__linux__) 78 #define OS_LINUX 1 79 // include a system header to pull in features.h for glibc/uclibc macros. 80 #include <unistd.h> 81 #if defined(__GLIBC__) && !defined(__UCLIBC__) 82 // we really are using glibc, not uClibc pretending to be glibc 83 #define LIBC_GLIBC 1 84 #endif 85 #elif defined(_WIN32) 86 #define OS_WIN 1 87 #define TOOLKIT_VIEWS 1 88 #elif defined(__FreeBSD__) 89 #define OS_FREEBSD 1 90 #elif defined(__OpenBSD__) 91 #define OS_OPENBSD 1 92 #elif defined(__sun) 93 #define OS_SOLARIS 1 94 #elif defined(__QNXNTO__) 95 #define OS_QNX 1 96 #else 97 #error Please add support for your platform in build/build_config.h 98 #endif 99 100 #if defined(USE_OPENSSL_CERTS) && defined(USE_NSS_CERTS) 101 #error Cannot use both OpenSSL and NSS for certificates 102 #endif 103 104 // For access to standard BSD features, use OS_BSD instead of a 105 // more specific macro. 106 #if defined(OS_FREEBSD) || defined(OS_OPENBSD) 107 #define OS_BSD 1 108 #endif 109 110 // For access to standard POSIXish features, use OS_POSIX instead of a 111 // more specific macro. 112 #if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_FREEBSD) || \ 113 defined(OS_OPENBSD) || defined(OS_SOLARIS) || defined(OS_ANDROID) || \ 114 defined(OS_NACL) || defined(OS_QNX) 115 #define OS_POSIX 1 116 #endif 117 118 // Use tcmalloc 119 #if (defined(OS_WIN) || defined(OS_LINUX) || defined(OS_ANDROID)) && \ 120 !defined(NO_TCMALLOC) 121 #define USE_TCMALLOC 1 122 #endif 123 124 // Compiler detection. 125 #if defined(__GNUC__) 126 #define COMPILER_GCC 1 127 #elif defined(_MSC_VER) 128 #define COMPILER_MSVC 1 129 #else 130 #error Please add support for your compiler in build/build_config.h 131 #endif 132 133 // Processor architecture detection. For more info on what's defined, see: 134 // http://msdn.microsoft.com/en-us/library/b0084kay.aspx 135 // http://www.agner.org/optimize/calling_conventions.pdf 136 // or with gcc, run: "echo | gcc -E -dM -" 137 #if defined(_M_X64) || defined(__x86_64__) 138 #define ARCH_CPU_X86_FAMILY 1 139 #define ARCH_CPU_X86_64 1 140 #define ARCH_CPU_64_BITS 1 141 #define ARCH_CPU_LITTLE_ENDIAN 1 142 #elif defined(_M_IX86) || defined(__i386__) 143 #define ARCH_CPU_X86_FAMILY 1 144 #define ARCH_CPU_X86 1 145 #define ARCH_CPU_32_BITS 1 146 #define ARCH_CPU_LITTLE_ENDIAN 1 147 #elif defined(__ARMEL__) 148 #define ARCH_CPU_ARM_FAMILY 1 149 #define ARCH_CPU_ARMEL 1 150 #define ARCH_CPU_32_BITS 1 151 #define ARCH_CPU_LITTLE_ENDIAN 1 152 #elif defined(__aarch64__) 153 #define ARCH_CPU_ARM_FAMILY 1 154 #define ARCH_CPU_ARM64 1 155 #define ARCH_CPU_64_BITS 1 156 #define ARCH_CPU_LITTLE_ENDIAN 1 157 #elif defined(__pnacl__) 158 #define ARCH_CPU_32_BITS 1 159 #define ARCH_CPU_LITTLE_ENDIAN 1 160 #elif defined(__MIPSEL__) 161 #if defined(__LP64__) 162 #define ARCH_CPU_MIPS_FAMILY 1 163 #define ARCH_CPU_MIPS64EL 1 164 #define ARCH_CPU_64_BITS 1 165 #define ARCH_CPU_LITTLE_ENDIAN 1 166 #else 167 #define ARCH_CPU_MIPS_FAMILY 1 168 #define ARCH_CPU_MIPSEL 1 169 #define ARCH_CPU_32_BITS 1 170 #define ARCH_CPU_LITTLE_ENDIAN 1 171 #endif 172 #else 173 #error Please add support for your architecture in build/build_config.h 174 #endif 175 176 // Type detection for wchar_t. 177 #if defined(OS_WIN) 178 #define WCHAR_T_IS_UTF16 179 #elif defined(OS_POSIX) && defined(COMPILER_GCC) && \ 180 defined(__WCHAR_MAX__) && \ 181 (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff) 182 #define WCHAR_T_IS_UTF32 183 #elif defined(OS_POSIX) && defined(COMPILER_GCC) && \ 184 defined(__WCHAR_MAX__) && \ 185 (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff) 186 // On Posix, we'll detect short wchar_t, but projects aren't guaranteed to 187 // compile in this mode (in particular, Chrome doesn't). This is intended for 188 // other projects using base who manage their own dependencies and make sure 189 // short wchar works for them. 190 #define WCHAR_T_IS_UTF16 191 #else 192 #error Please add support for your compiler in build/build_config.h 193 #endif 194 195 #if defined(OS_ANDROID) 196 // The compiler thinks std::string::const_iterator and "const char*" are 197 // equivalent types. 198 #define STD_STRING_ITERATOR_IS_CHAR_POINTER 199 // The compiler thinks base::string16::const_iterator and "char16*" are 200 // equivalent types. 201 #define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER 202 #endif 203 204 #endif // BUILD_BUILD_CONFIG_H_ 205