forked from electron/electron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
toolchain.gypi
264 lines (248 loc) · 7.58 KB
/
toolchain.gypi
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
{
'variables': {
# Clang stuff.
'make_clang_dir%': 'vendor/llvm-build/Release+Asserts',
# Set this to true when building with Clang.
'clang%': 1,
'variables': {
# The minimum OS X SDK version to use.
'mac_sdk_min%': '10.10',
# Set ARM architecture version.
'arm_version%': 7,
# Set NEON compilation flags.
'arm_neon%': 1,
# Abosulte path to source root.
'source_root%': '<!(node <(DEPTH)/tools/atom_source_root.js)',
},
# Copy conditionally-set variables out one scope.
'mac_sdk_min%': '<(mac_sdk_min)',
'arm_version%': '<(arm_version)',
'arm_neon%': '<(arm_neon)',
'source_root%': '<(source_root)',
# Variables to control Link-Time Optimization (LTO).
'use_lto%': 0,
'use_lto_o2%': 0,
'conditions': [
# Do not use Clang on Windows.
['OS=="win"', {
'clang%': 0,
}], # OS=="win"
# Search for the available version of SDK.
['OS=="mac"', {
'mac_sdk%': '<!(python <(DEPTH)/tools/mac/find_sdk.py <(mac_sdk_min))',
}],
['OS=="linux"', {
'variables': {
# The system libdir used for this ABI.
'system_libdir%': 'lib',
# Setting the path to sysroot.
'conditions': [
['target_arch=="arm"', {
# sysroot needs to be an absolute path otherwise it generates
# incorrect results when passed to pkg-config
'sysroot%': '<(source_root)/vendor/debian_wheezy_arm-sysroot',
}],
['target_arch=="ia32"', {
'sysroot%': '<(source_root)/vendor/debian_wheezy_i386-sysroot',
}],
['target_arch=="x64"', {
'sysroot%': '<(source_root)/vendor/debian_wheezy_amd64-sysroot',
}],
],
},
# Copy conditionally-set variables out one scope.
'sysroot%': '<(sysroot)',
'system_libdir%': '<(system_libdir)',
# Redirect pkg-config to search from sysroot.
'pkg-config%': '<(source_root)/tools/linux/pkg-config-wrapper "<(sysroot)" "<(target_arch)" "<(system_libdir)"',
}],
# Set default compiler flags depending on ARM version.
['arm_version==6', {
'arm_arch%': 'armv6',
'arm_tune%': '',
'arm_fpu%': 'vfp',
'arm_float_abi%': 'softfp',
'arm_thumb%': 0,
}], # arm_version==6
['arm_version==7', {
'arm_arch%': 'armv7-a',
'arm_tune%': 'generic-armv7-a',
'conditions': [
['arm_neon==1', {
'arm_fpu%': 'neon',
}, {
'arm_fpu%': 'vfpv3-d16',
}],
],
'arm_float_abi%': 'hard',
'arm_thumb%': 1,
}], # arm_version==7
],
},
'conditions': [
# Setup building with clang.
['clang==1', {
'make_global_settings': [
['CC', '<(make_clang_dir)/bin/clang'],
['CXX', '<(make_clang_dir)/bin/clang++'],
['CC.host', '$(CC)'],
['CXX.host', '$(CXX)'],
],
'target_defaults': {
'cflags_cc': [
'-std=c++11',
],
'xcode_settings': {
'CC': '<(make_clang_dir)/bin/clang',
'LDPLUSPLUS': '<(make_clang_dir)/bin/clang++',
'OTHER_CFLAGS': [
'-fcolor-diagnostics',
],
'GCC_C_LANGUAGE_STANDARD': 'c99', # -std=c99
'CLANG_CXX_LIBRARY': 'libc++', # -stdlib=libc++
'CLANG_CXX_LANGUAGE_STANDARD': 'c++11', # -std=c++11
},
'target_conditions': [
['_type in ["executable", "shared_library"]', {
'xcode_settings': {
# On some machines setting CLANG_CXX_LIBRARY doesn't work for
# linker.
'OTHER_LDFLAGS': [ '-stdlib=libc++' ],
},
}],
],
},
}], # clang==1
# Specify the SDKROOT.
['OS=="mac"', {
'target_defaults': {
'xcode_settings': {
'SDKROOT': 'macosx<(mac_sdk)', # -isysroot
},
},
}],
# Setup sysroot environment.
['OS=="linux" and target_arch in ["arm", "ia32", "x64"]', {
'target_defaults': {
'target_conditions': [
['_toolset=="target"', {
'cflags': [
'--sysroot=<(sysroot)',
],
'ldflags': [
'--sysroot=<(sysroot)',
'<!(<(source_root)/tools/linux/sysroot_ld_path.sh <(sysroot))',
],
}]
],
},
}], # sysroot
# Setup cross-compilation on Linux.
['OS=="linux"', {
'target_defaults': {
'target_conditions': [
['target_arch=="ia32" and _toolset=="target"', {
'asflags': [
'-32',
],
'cflags': [
'-msse2',
'-mfpmath=sse',
'-mmmx', # Allows mmintrin.h for MMX intrinsics.
'-m32',
],
'ldflags': [
'-m32',
],
}], # target_arch=="ia32" and _toolset=="target"
['target_arch=="x64" and _toolset=="target"', {
'cflags': [
'-m64',
'-march=x86-64',
],
'ldflags': [
'-m64',
],
}], # target_arch=="x64" and _toolset=="target"
['target_arch=="arm" and _toolset=="target"', {
'conditions': [
['clang==0', {
'cflags_cc': [
'-Wno-abi',
],
}],
['clang==1 and arm_arch!=""', {
'cflags': [
'-target arm-linux-gnueabihf',
],
'ldflags': [
'-target arm-linux-gnueabihf',
],
}],
['arm_arch!=""', {
'cflags': [
'-march=<(arm_arch)',
],
'conditions': [
['use_lto==1 or use_lto_o2==1', {
'ldflags': [
'-march=<(arm_arch)',
],
}],
],
}],
['arm_tune!=""', {
'cflags': [
'-mtune=<(arm_tune)',
],
'conditions': [
['use_lto==1 or use_lto_o2==1', {
'ldflags': [
'-mtune=<(arm_tune)',
],
}],
],
}],
['arm_fpu!=""', {
'cflags': [
'-mfpu=<(arm_fpu)',
],
'conditions': [
['use_lto==1 or use_lto_o2==1', {
'ldflags': [
'-mfpu=<(arm_fpu)',
],
}],
],
}],
['arm_float_abi!=""', {
'cflags': [
'-mfloat-abi=<(arm_float_abi)',
],
'conditions': [
['use_lto==1 or use_lto_o2==1', {
'ldflags': [
'-mfloat-abi=<(arm_float_abi)',
],
}],
],
}],
['arm_thumb==1', {
'cflags': [
'-mthumb',
],
'conditions': [
['use_lto==1 or use_lto_o2==1', {
'ldflags': [
'-mthumb',
],
}],
],
}],
],
}], # target_arch=="arm" and _toolset=="target"
],
},
}], # OS=="linux"
],
}