Skip to content

Commit c65eb34

Browse files
herbderbySkia Commit-Bot
authored andcommitted
Update for XCode 11 include system
With XCode 11 there is no more /usr/include directory. This does not affect the XCode compilers, but does make goma compiler break. This finds the system includes the same way that the iOS builds currently do. The gn_to_bp.py tool runs gn with target_os == mac, but host_os != mac. In that case, the xcrun tool can not run, so make xcode_sysroot = "". This will allow the xcode compilers to work when using the android.bp to build things. TESTED: builds on mac with and without goma Change-Id: I9de6797c32760c59e62fe5ac505a3404e5eaf8e9 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/249537 Commit-Queue: Herb Derby <herb@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
1 parent 85b2051 commit c65eb34

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

gn/BUILD.gn

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ declare_args() {
1212
use_PIC = true
1313

1414
malloc = ""
15+
xcode_sysroot = ""
1516
}
1617

17-
if (is_ios) {
18+
if (is_ios && xcode_sysroot == "") {
1819
if (is_tvos) {
1920
sdk = "appletvos"
2021
if (target_cpu == "x86" || target_cpu == "x64") {
@@ -26,7 +27,16 @@ if (is_ios) {
2627
sdk = "iphonesimulator"
2728
}
2829
}
29-
ios_sysroot = exec_script("find_ios_sysroot.py", [ sdk ], "trim string")
30+
xcode_sysroot = exec_script("find_xcode_sysroot.py", [ sdk ], "trim string")
31+
}
32+
33+
# If building for mac on a mac then lookup all the system includes so that goma and the clang
34+
# shipped with chrome can find them. When the gn_to_bp.py tool is run, then the host_os != mac.
35+
# In this case leave the xcode_sysroot empty, and the cc/c++ that come with XCode will be able to
36+
# find needed include paths.
37+
if (is_mac && host_os == "mac" && xcode_sysroot == "") {
38+
xcode_sysroot =
39+
exec_script("find_xcode_sysroot.py", [ "macosx" ], "trim string")
3040
}
3141

3242
config("default") {
@@ -157,20 +167,20 @@ config("default") {
157167
}
158168
asmflags += [
159169
"-isysroot",
160-
ios_sysroot,
170+
xcode_sysroot,
161171
"-arch",
162172
_target,
163173
]
164174
cflags += [
165175
"-isysroot",
166-
ios_sysroot,
176+
xcode_sysroot,
167177
"-arch",
168178
_target,
169179
]
170180
cflags_cc += [ "-stdlib=libc++" ]
171181
ldflags += [
172182
"-isysroot",
173-
ios_sysroot,
183+
xcode_sysroot,
174184
"-arch",
175185
_target,
176186
"-stdlib=libc++",
@@ -184,7 +194,25 @@ config("default") {
184194
defines += [ "_GLIBCXX_DEBUG" ]
185195
}
186196
}
197+
187198
if (is_mac) {
199+
# If there was a xcode_sysroot set in args or calculated then use it, else don't set anything
200+
# because the XCode cc/c++ already know all this stuff.
201+
if (xcode_sysroot != "") {
202+
asmflags += [
203+
"-isysroot",
204+
xcode_sysroot,
205+
]
206+
cflags += [
207+
"-isysroot",
208+
xcode_sysroot,
209+
]
210+
ldflags += [
211+
"-isysroot",
212+
xcode_sysroot,
213+
]
214+
}
215+
188216
# Disable linker warnings. They're usually just annoyances like,
189217
# ld: warning: text-based stub file
190218
# /System/Library/Frameworks/foo.framework/foo.tbd and library file
File renamed without changes.

0 commit comments

Comments
 (0)