Hash :
bab0e717
Author :
Date :
2021-10-04T14:09:53
Update script to install ANGLE binaries in installed Chromium Useful when debugging a WebGL test, the script that installs ANGLE binaries in Chrome Canary on Windows is updated to also allow installing ANGLE binaries in Chrome Dev on Linux. On Linux, the script needs to run as root. Bug: angleproject:6507 Change-Id: I812d3a85528217dab478b1e8a0f266ae231f10af Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3202554 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
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
#!/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) 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.
#
# Only works on Linux and Windows.
import glob, 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' or sys.platform.startswith('win')
if is_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 = []
else:
# Must be Linux
chrome_folder = '/opt/google/chrome-unstable'
libs_to_copy = ['libGLESv2.so', 'libEGL.so']
# Optionally copy the following, which are needed for a component build
# (i.e. is_component_build = true, which is the default)
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
for path in source_paths:
binary_path = os.path.join(path, binary_name)
if os.path.exists(binary_path):
binary_mtime = os.path.getmtime(binary_path)
if (newest_folder is None) or (binary_mtime > newest_mtime):
newest_folder = path
newest_mtime = binary_mtime
if newest_folder is None:
sys.exit("Could not find ANGLE binaries!")
source_folder = newest_folder
if is_windows:
# Is a folder a chrome binary directory?
def is_chrome_bin(str):
chrome_file = os.path.join(chrome_folder, str)
return os.path.isdir(chrome_file) and all([char.isdigit() or char == '.' for char in str])
sorted_chrome_bins = sorted(
[folder for folder in os.listdir(chrome_folder) if is_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 + '.')
def copy_file(src, dst):
print(' - ' + src + ' --> ' + dst)
shutil.copyfile(src, dst)
def do_copy(filename, is_optional):
src = os.path.join(source_folder, filename)
if os.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)
if is_windows:
copy_file(src + '.pdb', dst + '.pdb')
elif not is_optional:
print(' - COULD NOT FIND "' + src + '"')
for filename in libs_to_copy:
do_copy(filename, False)
for filename in optional_libs_to_copy:
do_copy(filename, True)