1#!/usr/bin/python2 2# 3# Copyright 2016 The ANGLE Project Authors. All rights reserved. 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6# 7# update_canary_angle.py: 8# Helper script that copies Windows ANGLE DLLs into the Canary 9# application directory. Much faster than compiling Chrome from 10# source. The script checks for the most recent DLLs in a set of 11# search paths, and copies that into the most recent Canary 12# binary folder. Only works on Windows. 13 14import glob, sys, os, shutil 15 16# Set of search paths. 17script_dir = os.path.dirname(sys.argv[0]) 18os.chdir(os.path.join(script_dir, "..")) 19 20source_paths = glob.glob('out/*') 21 22# Default Canary installation path. 23chrome_folder = os.path.join(os.environ['LOCALAPPDATA'], 'Google', 'Chrome SxS', 'Application') 24 25# Find the most recent ANGLE DLLs 26binary_name = 'libGLESv2.dll' 27newest_folder = None 28newest_mtime = None 29for path in source_paths: 30 binary_path = os.path.join(path, binary_name) 31 if os.path.exists(binary_path): 32 binary_mtime = os.path.getmtime(binary_path) 33 if (newest_folder is None) or (binary_mtime > newest_mtime): 34 newest_folder = path 35 newest_mtime = binary_mtime 36 37if newest_folder is None: 38 sys.exit("Could not find ANGLE DLLs!") 39 40source_folder = newest_folder 41 42 43# Is a folder a chrome binary directory? 44def is_chrome_bin(str): 45 chrome_file = os.path.join(chrome_folder, str) 46 return os.path.isdir(chrome_file) and all([char.isdigit() or char == '.' for char in str]) 47 48 49sorted_chrome_bins = sorted( 50 [folder for folder in os.listdir(chrome_folder) if is_chrome_bin(folder)], reverse=True) 51 52dest_folder = os.path.join(chrome_folder, sorted_chrome_bins[0]) 53 54print('Copying DLLs from ' + source_folder + ' to ' + dest_folder + '.') 55 56for dll in ['libGLESv2.dll', 'libEGL.dll']: 57 src = os.path.join(source_folder, dll) 58 if os.path.exists(src): 59 # Make a backup of the original unmodified DLLs if they are present. 60 backup = os.path.join(source_folder, dll + '.backup') 61 if not os.path.exists(backup): 62 shutil.copyfile(src, backup) 63 shutil.copyfile(src, os.path.join(dest_folder, dll)) 64 shutil.copyfile(src + ".pdb", os.path.join(dest_folder, dll + ".pdb")) 65