Path: blob/main_old/scripts/update_canary_angle.py
1693 views
#!/usr/bin/python21#2# Copyright 2016 The ANGLE Project Authors. All rights reserved.3# Use of this source code is governed by a BSD-style license that can be4# found in the LICENSE file.5#6# update_canary_angle.py:7# Helper script that copies Windows ANGLE DLLs into the Canary8# application directory. Much faster than compiling Chrome from9# source. The script checks for the most recent DLLs in a set of10# search paths, and copies that into the most recent Canary11# binary folder. Only works on Windows.1213import glob, sys, os, shutil1415# Set of search paths.16script_dir = os.path.dirname(sys.argv[0])17os.chdir(os.path.join(script_dir, ".."))1819source_paths = glob.glob('out/*')2021# Default Canary installation path.22chrome_folder = os.path.join(os.environ['LOCALAPPDATA'], 'Google', 'Chrome SxS', 'Application')2324# Find the most recent ANGLE DLLs25binary_name = 'libGLESv2.dll'26newest_folder = None27newest_mtime = None28for path in source_paths:29binary_path = os.path.join(path, binary_name)30if os.path.exists(binary_path):31binary_mtime = os.path.getmtime(binary_path)32if (newest_folder is None) or (binary_mtime > newest_mtime):33newest_folder = path34newest_mtime = binary_mtime3536if newest_folder is None:37sys.exit("Could not find ANGLE DLLs!")3839source_folder = newest_folder404142# Is a folder a chrome binary directory?43def is_chrome_bin(str):44chrome_file = os.path.join(chrome_folder, str)45return os.path.isdir(chrome_file) and all([char.isdigit() or char == '.' for char in str])464748sorted_chrome_bins = sorted(49[folder for folder in os.listdir(chrome_folder) if is_chrome_bin(folder)], reverse=True)5051dest_folder = os.path.join(chrome_folder, sorted_chrome_bins[0])5253print('Copying DLLs from ' + source_folder + ' to ' + dest_folder + '.')5455for dll in ['libGLESv2.dll', 'libEGL.dll']:56src = os.path.join(source_folder, dll)57if os.path.exists(src):58# Make a backup of the original unmodified DLLs if they are present.59backup = os.path.join(source_folder, dll + '.backup')60if not os.path.exists(backup):61shutil.copyfile(src, backup)62shutil.copyfile(src, os.path.join(dest_folder, dll))63shutil.copyfile(src + ".pdb", os.path.join(dest_folder, dll + ".pdb"))646566