summaryrefslogtreecommitdiffstats
path: root/tools/gn/secondary/build/config/BUILDCONFIG.gn
blob: 10cb3b34e70e7375121eab8445ebced2a0660161 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# Copyright (c) 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# =============================================================================
# BUILD FLAGS
# =============================================================================
#
# This block lists input arguments to the build, along with their default
# values. GN requires listing them explicitly so it can validate input and have
# a central place to manage the build flags.
#
# If a value is specified on the command line, it will overwrite the defaults
# given here, otherwise the default will be injected into the root scope.
#
# KEEP IN ALPHABETICAL ORDER and write a good description for everything.
# Use "is_*" names for intrinsic platform descriptions and build modes, and
# "use_*" names for optional features libraries, and configurations.
declare_args() {
  # Set to build the Android version.
  is_android = false
  # Component build.
  is_component_build = true
  # ChromeOS build.
  is_chromeos = false
  # Debug build.
  is_debug = true
  # IOS build.
  is_ios = false

  # Set when building with the "untrusted" Native Client toolchain.
  #
  # Do not set directly, this will be set automatically when compiling targets
  # with a NaCl toolchain.
  is_nacl = false

  # Set to true when compiling with the Clang compiler. Typically this is used
  # to configure warnings.
  is_clang = false

  # ASH is enabled.
  use_ash = false
  # Aura is enabled.
  use_aura = false
  # Ozone is enabled.
  use_ozone = false
}

# =============================================================================
# SOURCES FILTERS
# =============================================================================
#
# These patterns filter out platform-specific files when assigning to the
# sources variable. The magic variable |sources_assignment_filter| is applied
# to each assignment or appending to the sources variable and matches are
# automatcally removed.
#
# We define lists of filters for each platform for all builds so they can
# be used by individual targets if necessary (a target can always change
# sources_assignment_filter on itself if it needs something more specific).
#
# Note that the patterns are NOT regular expressions. Only "*" and "\b" (path
# boundary = end of string or slash) are supported, and the entire string
# muct match the pattern (so you need "*.cc" to match all .cc files, for
# example).

windows_sources_filters = [
  "*_win.cc",
  "*_win.h",
  "*_win_unittest.cc",
  "*\bwin/*",
]
mac_sources_filters = [
  "*_mac.h",
  "*_mac.cc",
  "*_mac.mm",
  "*_mac_unittest.h",
  "*_mac_unittest.cc",
  "*_mac_unittest.mm",
  "*\bmac/*",
  "*_cocoa.h",
  "*_cocoa.cc",
  "*_cocoa.mm",
  "*_cocoa_unittest.h",
  "*_cocoa_unittest.cc",
  "*_cocoa_unittest.mm",
  "*\bcocoa/*",
]
ios_sources_filters = [
  "*_ios.h",
  "*_ios.cc",
  "*_ios.mm",
  "*_ios_unittest.h",
  "*_ios_unittest.cc",
  "*_ios_unittest.mm",
  "*\bios/*",
]
objective_c_sources_filters = [
  "*.mm",
]
linux_sources_filters = [
  "*_linux.h",
  "*_linux.cc",
  "*_linux_unittest.h",
  "*_linux_unittest.cc",
  "*\blinux/*",
  "*_x11.cc",
  "*_x11.h",
]
android_sources_filters = [
  "*_android.h",
  "*_android.cc",
  "*_android_unittest.h",
  "*_android_unittest.cc",
  "*\bandroid/*",
]
posix_sources_filters = [
  "*_posix.h",
  "*_posix.cc",
  "*_posix_unittest.h",
  "*_posix_unittest.cc",
  "*\bposix/*",
]

# Construct the full list of sources we're using for this platform.
sources_assignment_filter = []
if (is_win) {
  sources_assignment_filter += posix_sources_filters
} else {
  sources_assignment_filter += windows_sources_filters
}
if (!is_mac) {
  sources_assignment_filter += mac_sources_filters
}
if (!is_ios) {
  sources_assignment_filter += ios_sources_filters
}
if (!is_mac && !is_ios) {
  sources_assignment_filter += objective_c_sources_filters
}
if (!is_linux) {
  sources_assignment_filter += linux_sources_filters
}
if (!is_android) {
  sources_assignment_filter += android_sources_filters
}

# This is the actual set.
set_sources_assignment_filter(sources_assignment_filter)

# =============================================================================
# BUILD OPTIONS
# =============================================================================

if (is_component_build) {
  component_mode = "shared_library"
} else {
  component_mode = "static_library"
}

toolkit_uses_gtk = is_linux

# =============================================================================
# TARGET DEFAULTS
# =============================================================================
#
# Set up the default configuration for every build target of the given type.
# The values configured here will be automatically set on the scope of the
# corresponding target. Target definitions can add or remove to the settings
# here as needed.

# Holds all configs used for making native executables and libraries, to avoid
# duplication in each target below.
native_compiler_configs = [
  "//build/config:my_msvs",  # TODO(brettw) eraseme

  "//build/config/compiler:compiler",
  "//build/config/compiler:chromium_code",
  "//build/config/compiler:default_warnings",
  "//build/config/compiler:no_rtti",
  "//build/config/compiler:runtime_library",
]
if (is_win) {
  native_compiler_configs += "//build/config/win:sdk"
} else if (is_mac) {
  # TODO(brettw) this should be in an if (is_clang) block instead but I haven't
  # written an is_clang flag yet.
  native_compiler_configs += "//build/config/clang:find_bad_constructs"
}

if (is_debug) {
  native_compiler_configs += "//build/config:debug"
} else {
  native_compiler_configs += "//build/config:release"
}

set_defaults("executable") {
  configs = native_compiler_configs
  if (is_mac) {
    configs += "//build/config/mac:mac_dynamic_flags"
  } else if (is_linux) {
    configs += "//build/config/linux:executable_ldconfig"
  }
}

set_defaults("static_library") {
  configs = native_compiler_configs
}

set_defaults("shared_library") {
  configs = native_compiler_configs
  if (is_mac) {
    configs += "//build/config/mac:mac_dynamic_flags"
  }
}

# ==============================================================================
# TOOLCHAIN SETUP
# ==============================================================================

if (is_win) {
  set_default_toolchain("//build/toolchain/win:32")
} else if (is_linux) {
  set_default_toolchain("//build/toolchain/linux:gcc")
} else if (is_mac) {
  set_default_toolchain("//build/toolchain/mac:clang")
}