mirrored from https://chromium.googlesource.com/angle/angle
- Notifications
You must be signed in to change notification settings - Fork 645
/
Copy pathupdate_chrome_angle.py
executable file
·118 lines (95 loc) · 4.04 KB
/
update_chrome_angle.py
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
#!/usr/bin/python3
#
# Copyright 2016 The ANGLE Project Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# update_chrome_angle.py:
# Helper script that copies ANGLE libraries into the Chromium Canary (on Windows and macOS)
# or Dev (on Linux) installed directory. Testing ANGLE this way is much faster than compiling
# Chromium from source. The script checks for the most recent build in a set of search paths,
# and copies that into:
#
# - /opt/google/chrome-unstable on Linux
# - the most recent Canary installation folder on Windows.
# - /Applications/Google\ Chrome\ Canary.app on macOS
#
importglob, sys, os, shutil
# Set of search paths.
script_dir=os.path.dirname(sys.argv[0])
os.chdir(os.path.join(script_dir, ".."))
source_paths=glob.glob('out/*')
is_windows=sys.platform=='cygwin'orsys.platform.startswith('win')
is_macos=sys.platform=='darwin'
ifis_windows:
# Default Canary installation path.
chrome_folder=os.path.join(os.environ['LOCALAPPDATA'], 'Google', 'Chrome SxS', 'Application')
libs_to_copy= ['libGLESv2.dll', 'libEGL.dll']
optional_libs_to_copy= []
elifis_macos:
chrome_folder='/Applications/Google Chrome Canary.app/Contents/Frameworks/Google Chrome Framework.framework/Libraries'
libs_to_copy= ['libGLESv2.dylib', 'libEGL.dylib']
optional_libs_to_copy= [
'libc++_chrome.dylib',
'libchrome_zlib.dylib',
'libthird_party_abseil-cpp_absl.dylib',
'libvk_swiftshader.dylib',
]
else:
# Must be Linux
chrome_folder='/opt/google/chrome-unstable'
libs_to_copy= ['libGLESv2.so', 'libEGL.so']
optional_libs_to_copy= ['libchrome_zlib.so', 'libabsl.so', 'libc++.so']
# Find the most recent ANGLE DLLs
binary_name=libs_to_copy[0]
newest_folder=None
newest_mtime=None
forpathinsource_paths:
binary_path=os.path.join(path, binary_name)
ifos.path.exists(binary_path):
binary_mtime=os.path.getmtime(binary_path)
if (newest_folderisNone) or (binary_mtime>newest_mtime):
newest_folder=path
newest_mtime=binary_mtime
ifnewest_folderisNone:
sys.exit("Could not find ANGLE binaries!")
source_folder=newest_folder
ifis_windows:
# Is a folder a chrome binary directory?
defis_chrome_bin(str):
chrome_file=os.path.join(chrome_folder, str)
returnos.path.isdir(chrome_file) andall([char.isdigit() orchar=='.'forcharinstr])
sorted_chrome_bins=sorted(
[folderforfolderinos.listdir(chrome_folder) ifis_chrome_bin(folder)], reverse=True)
dest_folder=os.path.join(chrome_folder, sorted_chrome_bins[0])
else:
dest_folder=chrome_folder
print('Copying binaries from '+source_folder+' to '+dest_folder+'.')
defcopy_file(src, dst):
print(' - '+src+' --> '+dst)
ifis_macosandos.path.isfile(dst):
# For the codesign to work, the original file must be removed
os.remove(dst)
shutil.copyfile(src, dst)
defdo_copy(filename, is_optional):
src=os.path.join(source_folder, filename)
ifos.path.exists(src):
# No backup is made. Any backup becomes stale on the next update and could be a cause for
# confusion. Reintall Chromium if it needs to be recovered.
dst=os.path.join(dest_folder, filename)
copy_file(src, dst)
ifis_windows:
copy_file(src+'.pdb', dst+'.pdb')
elifnotis_optional:
print(' - COULD NOT FIND "'+src+'"')
forfilenameinlibs_to_copy:
do_copy(filename, False)
# Optionally copy the following, which are needed for a component build
# (i.e. is_component_build = true, which is the default)
forfilenameinoptional_libs_to_copy:
do_copy(filename, True)
ifis_macos:
# Clear all attributes, codesign doesn't work otherwise
os.system('xattr -cr /Applications/Google\ Chrome\ Canary.app')
# Re-sign the bundle
os.system('codesign --force --sign - --deep /Applications/Google\ Chrome\ Canary.app')