Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
update.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# Copyright 2017 The Dart project authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5"""Pulls down tools required to build Dart."""
6
7import errno
8import os
9import platform
10import subprocess
11import sys
12
13THIS_DIR = os.path.abspath(os.path.dirname(__file__))
14DART_ROOT = os.path.abspath(os.path.join(THIS_DIR, '..', '..'))
15BUILDTOOLS = os.path.join(DART_ROOT, 'buildtools')
16TOOLS_BUILDTOOLS = os.path.join(DART_ROOT, 'tools', 'buildtools')
17
18sys.path.insert(0, os.path.join(DART_ROOT, 'tools'))
19import find_depot_tools
20
22
23
25 sha1_file = os.path.join(TOOLS_BUILDTOOLS, 'win', 'clang-format.exe.sha1')
26 output_dir = os.path.join(BUILDTOOLS, 'win', 'clang-format.exe')
27 downloader_script = os.path.join(DEPOT_PATH,
28 'download_from_google_storage.py')
29 download_cmd = [
30 sys.executable, downloader_script, '--no_auth', '--no_resume',
31 '--quiet', '--platform=win', '--bucket', 'chromium-clang-format', '-s',
32 sha1_file, '-o', output_dir
33 ]
34 return subprocess.call(download_cmd)
35
36
37def CreateSymlink(symlink, link_name):
38 try:
39 os.symlink(symlink, link_name)
40 except OSError as e:
41 if e.errno == errno.EEXIST:
42 os.remove(link_name)
43 os.symlink(symlink, link_name)
44 else:
45 raise e
46
47
48# On Mac and Linux we symlink clang-format and gn to the place where
49# 'git cl format' expects them to be.
51 if sys.platform == 'darwin':
52 platform = 'darwin'
53 tools = 'mac'
54 toolchain = 'mac-x64'
55 elif sys.platform.startswith('linux'):
56 platform = 'linux'
57 tools = 'linux64'
58 toolchain = 'linux-x64'
59 else:
60 print('Unknown platform: ' + sys.platform)
61 return 1
62
63 clang_format = os.path.join(BUILDTOOLS, toolchain, 'clang', 'bin',
64 'clang-format')
65 gn = os.path.join(BUILDTOOLS, 'gn')
66 dest_dir = os.path.join(BUILDTOOLS, tools)
67 if not os.path.exists(dest_dir):
68 os.makedirs(dest_dir)
69 clang_format_dest = os.path.join(dest_dir, 'clang-format')
70 gn_dest = os.path.join(dest_dir, 'gn')
71 CreateSymlink(clang_format, clang_format_dest)
72 CreateSymlink(gn, gn_dest)
73 return 0
74
75
76def main(argv):
77 arch_id = platform.machine()
78 # Don't try to download binaries if we're on an arm machine unless it is a
79 # Mac arm machine because the x64 binaries work using rosetta translation.
80 if ((arch_id.startswith('arm') and sys.platform != 'darwin') or
81 arch_id.startswith('aarch64')):
82 print('Not downloading buildtools binaries for ' + arch_id)
83 return 0
84 if sys.platform.startswith('win'):
86 return LinksForGitCLFormat()
87
88
89if __name__ == '__main__':
90 sys.exit(main(sys.argv))
void print(void *str)
Definition bridge.cpp:126
Definition main.py:1
CreateSymlink(symlink, link_name)
Definition update.py:37
main()
Definition update.py:69
LinksForGitCLFormat()
Definition update.py:50
UpdateClangFormatOnWindows()
Definition update.py:24