| 1 |
# Copyright 2018 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 |
|
| 6 |
from . import util |
| 7 |
|
| 8 |
def compile_swiftshader(api, extra_tokens, swiftshader_root, ninja_root, cc, cxx, out): |
| 9 |
"""Build SwiftShader with CMake. |
| 10 |
|
| 11 |
Building SwiftShader works differently from any other Skia third_party lib. |
| 12 |
See discussion in skbug.com/40034635 for more detail. |
| 13 |
|
| 14 |
Args: |
| 15 |
swiftshader_root: root of the SwiftShader checkout. |
| 16 |
ninja_root: A folder containing a ninja binary |
| 17 |
cc, cxx: compiler binaries to use |
| 18 |
out: target directory for libvk_swiftshader.so |
| 19 |
""" |
| 20 |
swiftshader_opts = [ |
| 21 |
'-DSWIFTSHADER_BUILD_TESTS=OFF', |
| 22 |
'-DSWIFTSHADER_WARNINGS_AS_ERRORS=OFF', |
| 23 |
'-DREACTOR_ENABLE_MEMORY_SANITIZER_INSTRUMENTATION=OFF', # Way too slow. |
| 24 |
] |
| 25 |
env = { |
| 26 |
'CC': cc, |
| 27 |
'CXX': cxx, |
| 28 |
'PATH': api.path.pathsep.join([str(ninja_root), "%(PATH)s"]), |
| 29 |
# We arrange our MSAN/TSAN prebuilts a little differently than |
| 30 |
# SwiftShader's CMakeLists.txt expects, so we'll just keep our custom |
| 31 |
# setup (everything mentioning libcxx below) and point SwiftShader's |
| 32 |
# CMakeLists.txt at a harmless non-existent path. |
| 33 |
'SWIFTSHADER_MSAN_INSTRUMENTED_LIBCXX_PATH': '/totally/phony/path', |
| 34 |
} |
| 35 |
|
| 36 |
# Extra flags for MSAN/TSAN, if necessary. |
| 37 |
san = None |
| 38 |
if 'MSAN' in extra_tokens: |
| 39 |
san = ('msan','memory') |
| 40 |
|
| 41 |
if san: |
| 42 |
short,full = san |
| 43 |
clang_linux = str(api.vars.workdir.joinpath('clang_linux')) |
| 44 |
libcxx = clang_linux + '/' + short |
| 45 |
cflags = ' '.join([ |
| 46 |
'-fsanitize=' + full, |
| 47 |
'-stdlib=libc++', |
| 48 |
'-L%s/lib' % libcxx, |
| 49 |
'-lc++abi', |
| 50 |
'-I%s/include' % libcxx, |
| 51 |
'-I%s/include/c++/v1' % libcxx, |
| 52 |
'-Wno-unused-command-line-argument' # Are -lc++abi and -Llibcxx/lib always unused? |
| 53 |
]) |
| 54 |
swiftshader_opts.extend([ |
| 55 |
'-DSWIFTSHADER_{}=ON'.format(short.upper()), |
| 56 |
'-DCMAKE_C_FLAGS=%s' % cflags, |
| 57 |
'-DCMAKE_CXX_FLAGS=%s' % cflags, |
| 58 |
]) |
| 59 |
|
| 60 |
# Build SwiftShader. |
| 61 |
api.file.ensure_directory('makedirs swiftshader_out', out) |
| 62 |
with api.context(cwd=out, env=env): |
| 63 |
api.run(api.step, 'swiftshader cmake', |
| 64 |
cmd=['cmake'] + swiftshader_opts + [swiftshader_root, '-GNinja']) |
| 65 |
# See https://swiftshader-review.googlesource.com/c/SwiftShader/+/56452 for when the |
| 66 |
# deprecated targets were added. See skbug.com/40043473 for longer-term plans. |
| 67 |
api.run(api.step, 'swiftshader ninja', cmd=['ninja', '-C', out, 'vk_swiftshader']) |
| 68 |
|
| 69 |
|
| 70 |
def get_compile_flags(api, checkout_root, out_dir, workdir): |
| 71 |
skia_dir = checkout_root.joinpath('skia') |
| 72 |
compiler = api.vars.builder_cfg.get('compiler', '') |
| 73 |
configuration = api.vars.builder_cfg.get('configuration', '') |
| 74 |
extra_tokens = api.vars.extra_tokens |
| 75 |
os = api.vars.builder_cfg.get('os', '') |
| 76 |
target_arch = api.vars.builder_cfg.get('target_arch', '') |
| 77 |
|
| 78 |
clang_linux = str(workdir.joinpath('clang_linux')) |
| 79 |
if 'MSAN' in extra_tokens: |
| 80 |
clang_linux = str(workdir.joinpath('clang_ubuntu_noble')) |
| 81 |
win_toolchain = str(workdir.joinpath('win_toolchain')) |
| 82 |
dwritecore = str(workdir.joinpath('dwritecore')) |
| 83 |
|
| 84 |
cc, cxx, ccache = None, None, None |
| 85 |
extra_cflags = [] |
| 86 |
extra_ldflags = [] |
| 87 |
args = { |
| 88 |
'is_trivial_abi': 'true', |
| 89 |
'link_pool_depth': '2', |
| 90 |
'werror': 'true', |
| 91 |
} |
| 92 |
env = {} |
| 93 |
|
| 94 |
if os == 'Mac': |
| 95 |
extra_cflags.append( |
| 96 |
'-DREBUILD_IF_CHANGED_xcode_build_version=%s' % api.xcode.version) |
| 97 |
if 'iOS18' in extra_tokens: |
| 98 |
env['IPHONEOS_DEPLOYMENT_TARGET'] = '18.2' |
| 99 |
args['ios_min_target'] = '"18.0"' |
| 100 |
elif 'iOS' in extra_tokens: |
| 101 |
env['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0' |
| 102 |
args['ios_min_target'] = '"13.0"' |
| 103 |
else: |
| 104 |
# We have some machines on 11. |
| 105 |
env['MACOSX_DEPLOYMENT_TARGET'] = '11.0' |
| 106 |
|
| 107 |
# ccache + clang-tidy.sh chokes on the argument list. |
| 108 |
if api.vars.is_linux and 'Tidy' not in extra_tokens: |
| 109 |
ccache = workdir.joinpath('ccache_linux', 'bin', 'ccache') |
| 110 |
# As of 2020-02-07, the sum of each Debian10-Clang-x86 |
| 111 |
# non-flutter/android/chromebook build takes less than 75G cache space. |
| 112 |
env['CCACHE_MAXSIZE'] = '75G' |
| 113 |
|
| 114 |
args['cc_wrapper'] = '"%s"' % ccache |
| 115 |
|
| 116 |
env['CCACHE_DIR'] = workdir.joinpath('cache', 'ccache') |
| 117 |
env['CCACHE_MAXFILES'] = '0' |
| 118 |
# Compilers are unpacked from cipd with bogus timestamps, only contribute |
| 119 |
# compiler content to hashes. If Ninja ever uses absolute paths to changing |
| 120 |
# directories we'll also need to set a CCACHE_BASEDIR. |
| 121 |
env['CCACHE_COMPILERCHECK'] = 'content' |
| 122 |
|
| 123 |
if compiler == 'Clang' and api.vars.is_linux: |
| 124 |
cc = clang_linux + '/bin/clang' |
| 125 |
cxx = clang_linux + '/bin/clang++' |
| 126 |
extra_cflags .append('-B%s/bin' % clang_linux) |
| 127 |
extra_ldflags.append('-B%s/bin' % clang_linux) |
| 128 |
extra_ldflags.append('-fuse-ld=lld') |
| 129 |
extra_cflags.append('-DPLACEHOLDER_clang_linux_version=%s' % |
| 130 |
api.run.asset_version('clang_linux', skia_dir)) |
| 131 |
if 'Static' in extra_tokens: |
| 132 |
extra_ldflags.extend(['-static-libstdc++', '-static-libgcc']) |
| 133 |
|
| 134 |
elif compiler == 'Clang': |
| 135 |
cc, cxx = 'clang', 'clang++' |
| 136 |
elif compiler == 'GCC': |
| 137 |
cc, cxx = 'gcc', 'g++' |
| 138 |
# Newer GCC includes tons and tons of debugging symbols. This seems to |
| 139 |
# negatively affect our bots (potentially only in combination with other |
| 140 |
# bugs in Swarming or recipe code). Use g1 to reduce it a bit. |
| 141 |
extra_cflags.append('-g1') |
| 142 |
|
| 143 |
if 'Tidy' in extra_tokens: |
| 144 |
# Swap in clang-tidy.sh for clang++, but update PATH so it can find clang++. |
| 145 |
cxx = skia_dir.joinpath("tools/clang-tidy.sh") |
| 146 |
env['PATH'] = '%s:%%(PATH)s' % (clang_linux + '/bin') |
| 147 |
# Increase ClangTidy code coverage by enabling features. |
| 148 |
args.update({ |
| 149 |
'skia_enable_fontmgr_empty': 'true', |
| 150 |
'skia_enable_graphite': 'true', |
| 151 |
'skia_enable_pdf': 'true', |
| 152 |
'skia_use_dawn': 'true', |
| 153 |
'skia_use_expat': 'true', |
| 154 |
'skia_use_freetype': 'true', |
| 155 |
'skia_use_vulkan': 'true', |
| 156 |
}) |
| 157 |
|
| 158 |
if 'Fuzz' in extra_tokens: |
| 159 |
cc, cxx = 'clang', 'clang++' |
| 160 |
args['skia_build_fuzzers'] = 'true' |
| 161 |
|
| 162 |
if 'Coverage' in extra_tokens: |
| 163 |
# See https://clang.llvm.org/docs/SourceBasedCodeCoverage.html for |
| 164 |
# more info on using llvm to gather coverage information. |
| 165 |
extra_cflags.append('-fprofile-instr-generate') |
| 166 |
extra_cflags.append('-fcoverage-mapping') |
| 167 |
extra_ldflags.append('-fprofile-instr-generate') |
| 168 |
extra_ldflags.append('-fcoverage-mapping') |
| 169 |
|
| 170 |
if compiler != 'MSVC' and configuration == 'Debug': |
| 171 |
extra_cflags.append('-O1') |
| 172 |
if compiler != 'MSVC' and configuration == 'OptimizeForSize': |
| 173 |
# build IDs are required for Bloaty if we want to use strip to ignore debug symbols. |
| 174 |
# https://github.com/google/bloaty/blob/master/doc/using.md#debugging-stripped-binaries |
| 175 |
extra_ldflags.append('-Wl,--build-id=sha1') |
| 176 |
args.update({ |
| 177 |
'skia_use_runtime_icu': 'true', |
| 178 |
'skia_enable_optimize_size': 'true', |
| 179 |
'skia_use_jpeg_gainmaps': 'false', |
| 180 |
}) |
| 181 |
|
| 182 |
if 'Exceptions' in extra_tokens: |
| 183 |
extra_cflags.append('/EHsc') |
| 184 |
if 'Fast' in extra_tokens: |
| 185 |
extra_cflags.extend(['-march=native', '-fomit-frame-pointer', '-O3', |
| 186 |
'-ffp-contract=off']) |
| 187 |
|
| 188 |
if len(extra_tokens) == 1 and extra_tokens[0].startswith('SK'): |
| 189 |
extra_cflags.append('-D' + extra_tokens[0]) |
| 190 |
# If we're limiting Skia at all, drop skcms to portable code. |
| 191 |
if 'SK_CPU_LIMIT' in extra_tokens[0]: |
| 192 |
extra_cflags.append('-DSKCMS_PORTABLE') |
| 193 |
|
| 194 |
if 'MSAN' in extra_tokens: |
| 195 |
extra_ldflags.append('-L' + clang_linux + '/msan') |
| 196 |
elif 'TSAN' in extra_tokens: |
| 197 |
extra_ldflags.append('-L' + clang_linux + '/tsan') |
| 198 |
elif api.vars.is_linux and compiler == 'Clang': |
| 199 |
extra_ldflags.append('-L' + clang_linux + '/lib') |
| 200 |
|
| 201 |
if configuration != 'Debug': |
| 202 |
args['is_debug'] = 'false' |
| 203 |
if 'Dawn' in extra_tokens: |
| 204 |
util.set_dawn_args_and_env(args, env, api, extra_tokens, skia_dir) |
| 205 |
if 'ANGLE' in extra_tokens: |
| 206 |
args['skia_use_angle'] = 'true' |
| 207 |
if 'SwiftShader' in extra_tokens: |
| 208 |
swiftshader_root = skia_dir.joinpath('third_party', 'externals', 'swiftshader') |
| 209 |
# Swiftshader will need to have ninja be on the path |
| 210 |
ninja_root = skia_dir.joinpath('third_party', 'ninja') |
| 211 |
swiftshader_out = out_dir.joinpath('swiftshader_out') |
| 212 |
compile_swiftshader(api, extra_tokens, swiftshader_root, ninja_root, cc, cxx, swiftshader_out) |
| 213 |
args['skia_use_vulkan'] = 'true' |
| 214 |
extra_cflags.extend(['-DSK_GPU_TOOLS_VK_LIBRARY_NAME=%s' % |
| 215 |
api.vars.swarming_out_dir.joinpath('swiftshader_out', 'libvk_swiftshader.so'), |
| 216 |
]) |
| 217 |
if 'MSAN' in extra_tokens: |
| 218 |
args['skia_use_fontconfig'] = 'false' |
| 219 |
if 'ASAN' in extra_tokens: |
| 220 |
args['skia_enable_spirv_validation'] = 'false' |
| 221 |
if 'NoPrecompile' in extra_tokens: |
| 222 |
args['skia_enable_precompile'] = 'false' |
| 223 |
if 'Graphite' in extra_tokens: |
| 224 |
args['skia_enable_graphite'] = 'true' |
| 225 |
if 'Fontations' in extra_tokens: |
| 226 |
args['skia_use_fontations'] = 'true' |
| 227 |
args['skia_use_freetype'] = 'true' # we compare with freetype in tests |
| 228 |
args['skia_use_system_freetype2'] = 'false' |
| 229 |
if 'RustPNG' in extra_tokens: |
| 230 |
args['skia_use_rust_png_decode'] = 'true' |
| 231 |
args['skia_use_rust_png_encode'] = 'true' |
| 232 |
args['skia_use_libpng_decode'] = 'false' |
| 233 |
# TODO(b/356875275) set skia_use_libpng_encode to false also |
| 234 |
if 'RustBMP' in extra_tokens: |
| 235 |
args['skia_use_rust_bmp_decode'] = 'true' |
| 236 |
if 'FreeType' in extra_tokens: |
| 237 |
args['skia_use_freetype'] = 'true' |
| 238 |
args['skia_use_system_freetype2'] = 'false' |
| 239 |
extra_cflags.extend(['-DSK_USE_FREETYPE_EMBOLDEN']) |
| 240 |
|
| 241 |
if 'NoGPU' in extra_tokens: |
| 242 |
args['skia_enable_ganesh'] = 'false' |
| 243 |
if 'NoDEPS' in extra_tokens: |
| 244 |
args.update({ |
| 245 |
'is_official_build': 'true', |
| 246 |
'skia_enable_fontmgr_empty': 'true', |
| 247 |
'skia_enable_ganesh': 'true', |
| 248 |
|
| 249 |
'skia_enable_pdf': 'false', |
| 250 |
'skia_use_expat': 'false', |
| 251 |
'skia_use_freetype': 'false', |
| 252 |
'skia_use_harfbuzz': 'false', |
| 253 |
'skia_use_icu': 'false', |
| 254 |
'skia_use_libjpeg_turbo_decode': 'false', |
| 255 |
'skia_use_libjpeg_turbo_encode': 'false', |
| 256 |
'skia_use_libpng_decode': 'false', |
| 257 |
'skia_use_libpng_encode': 'false', |
| 258 |
'skia_use_libwebp_decode': 'false', |
| 259 |
'skia_use_libwebp_encode': 'false', |
| 260 |
'skia_use_vulkan': 'false', |
| 261 |
'skia_use_wuffs': 'false', |
| 262 |
'skia_use_zlib': 'false', |
| 263 |
}) |
| 264 |
elif configuration != 'OptimizeForSize': |
| 265 |
args.update({ |
| 266 |
'skia_use_client_icu': 'true', |
| 267 |
'skia_use_libgrapheme': 'true', |
| 268 |
}) |
| 269 |
|
| 270 |
if 'ICU4X' in extra_tokens: |
| 271 |
args['skia_use_icu4x'] = 'true' |
| 272 |
|
| 273 |
if 'Shared' in extra_tokens: |
| 274 |
args['is_component_build'] = 'true' |
| 275 |
if 'Vulkan' in extra_tokens and not 'Android' in extra_tokens and not 'Dawn' in extra_tokens: |
| 276 |
args['skia_use_vulkan'] = 'true' |
| 277 |
args['skia_enable_vulkan_debug_layers'] = 'true' |
| 278 |
# When running TSAN with Vulkan on NVidia, we experienced some timeouts. We found |
| 279 |
# a workaround (in GrContextFactory) that requires GL (in addition to Vulkan). |
| 280 |
if 'TSAN' in extra_tokens: |
| 281 |
args['skia_use_gl'] = 'true' |
| 282 |
else: |
| 283 |
args['skia_use_gl'] = 'false' |
| 284 |
if 'Direct3D' in extra_tokens and not 'Dawn' in extra_tokens: |
| 285 |
args['skia_use_direct3d'] = 'true' |
| 286 |
args['skia_use_gl'] = 'false' |
| 287 |
if 'Metal' in extra_tokens and not 'Dawn' in extra_tokens: |
| 288 |
args['skia_use_metal'] = 'true' |
| 289 |
args['skia_use_gl'] = 'false' |
| 290 |
if 'iOS' in extra_tokens or 'iOS18' in extra_tokens: |
| 291 |
# Bots use Chromium signing cert. |
| 292 |
args['skia_ios_identity'] = '".*83FNP.*"' |
| 293 |
# Get mobileprovision via the CIPD package. |
| 294 |
args['skia_ios_profile'] = '"%s"' % workdir.joinpath( |
| 295 |
'provisioning_profile_ios', |
| 296 |
'Upstream_Com_Testing_Provisioning_Profile.mobileprovision') |
| 297 |
if compiler == 'Clang' and 'Win' in os: |
| 298 |
args['clang_win'] = '"%s"' % workdir.joinpath('clang_win') |
| 299 |
extra_cflags.append('-DPLACEHOLDER_clang_win_version=%s' % |
| 300 |
api.run.asset_version('clang_win', skia_dir)) |
| 301 |
|
| 302 |
sanitize = '' |
| 303 |
for t in extra_tokens: |
| 304 |
if t.endswith('SAN'): |
| 305 |
sanitize = t |
| 306 |
if api.vars.is_linux and t == 'ASAN': |
| 307 |
# skbug.com/40040003 and skbug.com/40040004 |
| 308 |
extra_cflags.append('-DSK_ENABLE_SCOPED_LSAN_SUPPRESSIONS') |
| 309 |
if 'SafeStack' in extra_tokens: |
| 310 |
assert sanitize == '' |
| 311 |
sanitize = 'safe-stack' |
| 312 |
|
| 313 |
if 'Wuffs' in extra_tokens: |
| 314 |
args['skia_use_wuffs'] = 'true' |
| 315 |
|
| 316 |
if 'AVIF' in extra_tokens: |
| 317 |
args['skia_use_libavif'] = 'true' |
| 318 |
|
| 319 |
for (k,v) in { |
| 320 |
'cc': cc, |
| 321 |
'cxx': cxx, |
| 322 |
'sanitize': sanitize, |
| 323 |
'target_cpu': target_arch, |
| 324 |
'target_os': 'ios' if ('iOS' in extra_tokens or 'iOS18' in extra_tokens) else '', |
| 325 |
'win_sdk': win_toolchain + '/win_sdk' if 'Win' in os else '', |
| 326 |
'win_vc': win_toolchain + '/VC' if 'Win' in os else '', |
| 327 |
'skia_dwritecore_sdk': dwritecore if 'DWriteCore' in extra_tokens else '', |
| 328 |
}.items(): |
| 329 |
if v: |
| 330 |
args[k] = '"%s"' % v |
| 331 |
if extra_cflags: |
| 332 |
args['extra_cflags'] = extra_cflags |
| 333 |
if extra_ldflags: |
| 334 |
args['extra_ldflags'] = extra_ldflags |
| 335 |
|
| 336 |
return args, env, ccache |
| 337 |
|
| 338 |
|
| 339 |
def finalize_gn_flags(args): |
| 340 |
if args.get('extra_cflags'): |
| 341 |
args['extra_cflags'] = repr(args['extra_cflags']).replace("'", '"') |
| 342 |
if args.get('extra_ldflags'): |
| 343 |
args['extra_ldflags'] = repr(args['extra_ldflags']).replace("'", '"') |
| 344 |
return ' '.join('%s=%s' % (k,v) for (k,v) in sorted(args.items())) |
| 345 |
|
| 346 |
|
| 347 |
def compile_fn(api, checkout_root, out_dir): |
| 348 |
skia_dir = checkout_root.joinpath('skia') |
| 349 |
extra_tokens = api.vars.extra_tokens |
| 350 |
|
| 351 |
with api.context(cwd=skia_dir): |
| 352 |
api.run(api.step, 'fetch-gn', |
| 353 |
cmd=['python3', skia_dir.joinpath('bin', 'fetch-gn')], |
| 354 |
infra_step=True) |
| 355 |
|
| 356 |
api.run(api.step, 'fetch-ninja', |
| 357 |
cmd=['python3', skia_dir.joinpath('bin', 'fetch-ninja')], |
| 358 |
infra_step=True) |
| 359 |
|
| 360 |
if api.vars.builder_cfg.get('os', '') in ('Mac'): |
| 361 |
api.xcode.install() |
| 362 |
|
| 363 |
workdir = api.path.start_dir |
| 364 |
args, env, ccache = get_compile_flags(api, checkout_root, out_dir, workdir) |
| 365 |
gn_args = finalize_gn_flags(args) |
| 366 |
gn = skia_dir.joinpath('bin', 'gn') |
| 367 |
ninja_root = skia_dir.joinpath('third_party', 'ninja') |
| 368 |
ninja = skia_dir.joinpath(ninja_root, 'ninja') |
| 369 |
|
| 370 |
# Putting ninja on the path makes it easier for subcommands to find it |
| 371 |
# (e.g. when building Dawn via CMake+ninja) |
| 372 |
# Importantly, this needs to go *after* depot_tools, so we append it |
| 373 |
existing_path = env.get('PATH', '%(PATH)s') |
| 374 |
env['PATH'] = api.path.pathsep.join([existing_path, str(ninja_root)]) |
| 375 |
|
| 376 |
with api.context(cwd=skia_dir): |
| 377 |
with api.env(env): |
| 378 |
if ccache: |
| 379 |
api.run(api.step, 'ccache stats-start', cmd=[ccache, '-s']) |
| 380 |
api.run(api.step, 'gn gen', |
| 381 |
cmd=[gn, 'gen', out_dir, '--args=' + gn_args]) |
| 382 |
if 'Fontations' in extra_tokens: |
| 383 |
api.run(api.step, 'gn clean', |
| 384 |
cmd=[gn, 'clean', out_dir]) |
| 385 |
api.run(api.step, 'ninja', cmd=[ninja, '-C', out_dir]) |
| 386 |
if ccache: |
| 387 |
api.run(api.step, 'ccache stats-end', cmd=[ccache, '-s']) |
| 388 |
|
| 389 |
|
| 390 |
def copy_build_products(api, src, dst): |
| 391 |
util.copy_listed_files(api, src, dst, util.DEFAULT_BUILD_PRODUCTS) |
| 392 |
extra_tokens = api.vars.extra_tokens |
| 393 |
os = api.vars.builder_cfg.get('os', '') |
| 394 |
configuration = api.vars.builder_cfg.get('configuration', '') |
| 395 |
|
| 396 |
if 'SwiftShader' in extra_tokens: |
| 397 |
util.copy_listed_files(api, |
| 398 |
src.joinpath('swiftshader_out'), |
| 399 |
api.vars.swarming_out_dir.joinpath('swiftshader_out'), |
| 400 |
util.DEFAULT_BUILD_PRODUCTS) |
| 401 |
|
| 402 |
if configuration == 'OptimizeForSize': |
| 403 |
util.copy_listed_files(api, src, dst, ['skottie_tool_cpu', 'skottie_tool_gpu']) |
| 404 |
|
| 405 |
if os == 'Mac' and any('SAN' in t for t in extra_tokens): |
| 406 |
# The XSAN dylibs are in |
| 407 |
# Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib |
| 408 |
# /clang/11.0.0/lib/darwin, where 11.0.0 could change in future versions. |
| 409 |
xcode_clang_ver_dirs = api.file.listdir( |
| 410 |
'find XCode Clang version', |
| 411 |
api.vars.cache_dir.joinpath( |
| 412 |
'Xcode.app', 'Contents', 'Developer', 'Toolchains', |
| 413 |
'XcodeDefault.xctoolchain', 'usr', 'lib', 'clang'), |
| 414 |
test_data=['11.0.0']) |
| 415 |
# Allow both clang/16 and clang/16.0.0, so long as they are equivalent. |
| 416 |
assert len({api.path.realpath(d) for d in xcode_clang_ver_dirs}) == 1 |
| 417 |
dylib_dir = xcode_clang_ver_dirs[0].joinpath('lib', 'darwin') |
| 418 |
dylibs = api.file.glob_paths('find xSAN dylibs', dylib_dir, |
| 419 |
'libclang_rt.*san_osx_dynamic.dylib', |
| 420 |
test_data=[ |
| 421 |
'libclang_rt.asan_osx_dynamic.dylib', |
| 422 |
'libclang_rt.tsan_osx_dynamic.dylib', |
| 423 |
'libclang_rt.ubsan_osx_dynamic.dylib', |
| 424 |
]) |
| 425 |
for f in dylibs: |
| 426 |
api.file.copy('copy %s' % api.path.basename(f), f, dst) |