blob: fef6be50bded7db75515c2f2a2fd4d4821481de0 [file] [log] [blame]
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001// 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// Compiler:
9// COMPILER_MSVC / COMPILER_GCC
10// Processor:
11// ARCH_CPU_X86 / ARCH_CPU_X86_64 / ARCH_CPU_X86_FAMILY (X86 or X86_64)
12// ARCH_CPU_32_BITS / ARCH_CPU_64_BITS
13
14#ifndef BUILD_BUILD_CONFIG_H_
15#define BUILD_BUILD_CONFIG_H_
16
17#if defined(__APPLE__)
18#include <TargetConditionals.h>
19#endif
20
21// A set of macros to use for platform detection.
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010022#if defined(ANDROID)
23#define OS_ANDROID 1
24#elif defined(__APPLE__)
Torne (Richard Coles)58218062012-11-14 11:43:16 +000025#define OS_MACOSX 1
26#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
27#define OS_IOS 1
28#endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
Torne (Richard Coles)58218062012-11-14 11:43:16 +000029#elif defined(__native_client__)
30#define OS_NACL 1
31#elif defined(__linux__)
32#define OS_LINUX 1
33// Use TOOLKIT_GTK on linux if TOOLKIT_VIEWS isn't defined.
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010034#if !defined(TOOLKIT_VIEWS) && defined(USE_X11)
Torne (Richard Coles)58218062012-11-14 11:43:16 +000035#define TOOLKIT_GTK
36#endif
37#elif defined(_WIN32)
38#define OS_WIN 1
39#define TOOLKIT_VIEWS 1
40#elif defined(__FreeBSD__)
41#define OS_FREEBSD 1
42#define TOOLKIT_GTK
43#elif defined(__OpenBSD__)
44#define OS_OPENBSD 1
45#define TOOLKIT_GTK
46#elif defined(__sun)
47#define OS_SOLARIS 1
48#define TOOLKIT_GTK
49#else
50#error Please add support for your platform in build/build_config.h
51#endif
52
53#if defined(USE_OPENSSL) && defined(USE_NSS)
54#error Cannot use both OpenSSL and NSS
55#endif
56
57// For access to standard BSD features, use OS_BSD instead of a
58// more specific macro.
59#if defined(OS_FREEBSD) || defined(OS_OPENBSD)
60#define OS_BSD 1
61#endif
62
63// For access to standard POSIXish features, use OS_POSIX instead of a
64// more specific macro.
65#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_FREEBSD) || \
66 defined(OS_OPENBSD) || defined(OS_SOLARIS) || defined(OS_ANDROID) || \
67 defined(OS_NACL)
68#define OS_POSIX 1
69#endif
70
Torne (Richard Coles)58218062012-11-14 11:43:16 +000071// Use tcmalloc
72#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(NO_TCMALLOC)
73#define USE_TCMALLOC 1
74#endif
75
76// Compiler detection.
77#if defined(__GNUC__)
78#define COMPILER_GCC 1
79#elif defined(_MSC_VER)
80#define COMPILER_MSVC 1
81#else
82#error Please add support for your compiler in build/build_config.h
83#endif
84
85// Processor architecture detection. For more info on what's defined, see:
86// http://msdn.microsoft.com/en-us/library/b0084kay.aspx
87// http://www.agner.org/optimize/calling_conventions.pdf
88// or with gcc, run: "echo | gcc -E -dM -"
89#if defined(_M_X64) || defined(__x86_64__)
90#define ARCH_CPU_X86_FAMILY 1
91#define ARCH_CPU_X86_64 1
92#define ARCH_CPU_64_BITS 1
93#define ARCH_CPU_LITTLE_ENDIAN 1
94#elif defined(_M_IX86) || defined(__i386__)
95#define ARCH_CPU_X86_FAMILY 1
96#define ARCH_CPU_X86 1
97#define ARCH_CPU_32_BITS 1
98#define ARCH_CPU_LITTLE_ENDIAN 1
99#elif defined(__ARMEL__)
100#define ARCH_CPU_ARM_FAMILY 1
101#define ARCH_CPU_ARMEL 1
102#define ARCH_CPU_32_BITS 1
103#define ARCH_CPU_LITTLE_ENDIAN 1
104#elif defined(__pnacl__)
105#define ARCH_CPU_32_BITS 1
106#elif defined(__MIPSEL__)
107#define ARCH_CPU_MIPS_FAMILY 1
108#define ARCH_CPU_MIPSEL 1
109#define ARCH_CPU_32_BITS 1
110#define ARCH_CPU_LITTLE_ENDIAN 1
111#else
112#error Please add support for your architecture in build/build_config.h
113#endif
114
115// Type detection for wchar_t.
116#if defined(OS_WIN)
117#define WCHAR_T_IS_UTF16
118#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
119 defined(__WCHAR_MAX__) && \
120 (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
121#define WCHAR_T_IS_UTF32
122#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
123 defined(__WCHAR_MAX__) && \
124 (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)
125// On Posix, we'll detect short wchar_t, but projects aren't guaranteed to
126// compile in this mode (in particular, Chrome doesn't). This is intended for
127// other projects using base who manage their own dependencies and make sure
128// short wchar works for them.
129#define WCHAR_T_IS_UTF16
130#else
131#error Please add support for your compiler in build/build_config.h
132#endif
133
134#if defined(__ARMEL__) && !defined(OS_IOS)
135#define WCHAR_T_IS_UNSIGNED 1
136#elif defined(__MIPSEL__)
137#define WCHAR_T_IS_UNSIGNED 0
138#endif
139
140#if defined(OS_ANDROID)
141// The compiler thinks std::string::const_iterator and "const char*" are
142// equivalent types.
143#define STD_STRING_ITERATOR_IS_CHAR_POINTER
144// The compiler thinks base::string16::const_iterator and "char16*" are
145// equivalent types.
146#define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER
147#endif
148
149#endif // BUILD_BUILD_CONFIG_H_