未验证 提交 fa0e464a 编写于 作者: D Dan Field 提交者: GitHub

use clang on Windows (#17407)

* use clang on Windows for everything but Android

This pulls the Clang build from Chromium. We should eventually switch to use the Fuchsia toolchain when it is available.
上级 152fc6ec
......@@ -527,6 +527,18 @@ deps = {
'dep_type': 'cipd',
},
# TODO(fxb/4443): Remove this when Fuchsia can provide the Windows Clang Toolchain
'src/third_party/llvm-build/Release+Asserts': {
'packages': [
{
'package': 'flutter/clang/win-amd64',
'version': 'git_revision:5ec206df8534d2dd8cb9217c3180e5ddba587393'
}
],
'condition': 'download_windows_deps',
'dep_type': 'cipd',
},
# Get the SDK from https://chrome-infra-packages.appspot.com/p/fuchsia/sdk/core at the 'latest' tag
# Get the toolchain from https://chrome-infra-packages.appspot.com/p/fuchsia/clang at the 'goma' tag
......@@ -624,6 +636,15 @@ hooks = [
'src/third_party/dart/third_party/7zip.tar.gz.sha1',
],
},
{
'name': 'dia_dll',
'pattern': '.',
'condition': 'download_windows_deps',
'action': [
'python',
'src/flutter/tools/dia_dll.py',
],
},
{
'name': 'linux_sysroot',
'pattern': '.',
......
#!/usr/bin/env python
# Copyright (c) 2012 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.
"""
This script is based on chromium/chromium/master/tools/clang/scripts/update.py.
It is used on Windows platforms to copy the correct msdia*.dll to the
clang folder, as a "gclient hook".
"""
import os
import shutil
import stat
import sys
# Path constants. (All of these should be absolute paths.)
THIS_DIR = os.path.abspath(os.path.dirname(__file__))
LLVM_BUILD_DIR = os.path.abspath(os.path.join(THIS_DIR, '..', '..', 'third_party',
'llvm-build', 'Release+Asserts'))
def GetDiaDll():
"""Get the location of msdia*.dll for the platform."""
# Bump after VC updates.
DIA_DLL = {
'2013': 'msdia120.dll',
'2015': 'msdia140.dll',
'2017': 'msdia140.dll',
'2019': 'msdia140.dll',
}
# Don't let vs_toolchain overwrite our environment.
environ_bak = os.environ
sys.path.append(os.path.join(THIS_DIR, '..', '..', 'build'))
import vs_toolchain
win_sdk_dir = vs_toolchain.SetEnvironmentAndGetSDKDir()
msvs_version = vs_toolchain.GetVisualStudioVersion()
if bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1'))):
dia_path = os.path.join(win_sdk_dir, '..', 'DIA SDK', 'bin', 'amd64')
else:
if 'GYP_MSVS_OVERRIDE_PATH' in os.environ:
vs_path = os.environ['GYP_MSVS_OVERRIDE_PATH']
else:
vs_path = vs_toolchain.DetectVisualStudioPath()
dia_path = os.path.join(vs_path, 'DIA SDK', 'bin', 'amd64')
os.environ = environ_bak
return os.path.join(dia_path, DIA_DLL[msvs_version])
def CopyFile(src, dst):
"""Copy a file from src to dst."""
print("Copying %s to %s" % (str(src), str(dst)))
shutil.copy(src, dst)
def CopyDiaDllTo(target_dir):
# This script always wants to use the 64-bit msdia*.dll.
dia_dll = GetDiaDll()
CopyFile(dia_dll, target_dir)
def main():
CopyDiaDllTo(os.path.join(LLVM_BUILD_DIR, 'bin'))
return 0
if __name__ == '__main__':
sys.exit(main())
......@@ -101,7 +101,13 @@ def to_gn_args(args):
gn_args['dart_component_kind'] = 'static_library' # Always link Dart in statically.
gn_args['is_debug'] = args.unoptimized
gn_args['android_full_debug'] = args.target_os == 'android' and args.unoptimized
gn_args['is_clang'] = not sys.platform.startswith(('cygwin', 'win'))
if args.clang is None:
# Android gen_snapshot currently isn't buildable with clang on Windows.
# For everything else, default to clang.
gn_args['is_clang'] = not (sys.platform.startswith(('cygwin', 'win')) and
args.target_os == 'android')
else:
gn_args['is_clang'] = args.clang
if args.target_os == 'android' or args.target_os == 'ios':
gn_args['skia_gl_standard'] = 'gles'
......@@ -314,8 +320,8 @@ def parse_args(args):
parser.add_argument('--lto', default=True, action='store_true')
parser.add_argument('--no-lto', dest='lto', action='store_false')
parser.add_argument('--clang', default=True, action='store_true')
parser.add_argument('--no-clang', dest='clang', action='store_false')
parser.add_argument('--clang', action='store_const', const=True)
parser.add_argument('--no-clang', dest='clang', action='store_const', const=False)
parser.add_argument('--clang-static-analyzer', default=False, action='store_true')
parser.add_argument('--no-clang-static-analyzer', dest='clang_static_analyzer', action='store_false')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册