blob: 51a03590ff2143a56dbd422c4d5f97cf729f37ef [file] [log] [blame]
Jamie Madill2be8c8c2016-04-28 14:39:15 -04001#!/usr/bin/python
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 sys, os, shutil
15
16# Set of search paths.
17source_paths = [
Jamie Madill16e54092016-11-15 12:35:42 -080018 os.path.join('..', 'gyp', 'Debug_x64'),
19 os.path.join('..', 'gyp', 'Debug_Win32'),
20 os.path.join('..', 'gyp', 'Release_x64'),
21 os.path.join('..', 'gyp', 'Release_Win32'),
Jamie Madill2be8c8c2016-04-28 14:39:15 -040022 os.path.join('..', 'out', 'Debug'),
23 os.path.join('..', 'out', 'Debug_x64'),
24 os.path.join('..', 'out', 'Release'),
25 os.path.join('..', 'out', 'Release_x64'),
26]
27
Jamie Madill768996c2016-06-08 13:32:26 -070028script_dir = os.path.dirname(sys.argv[0])
29
Jamie Madill2be8c8c2016-04-28 14:39:15 -040030# Default Canary installation path.
31chrome_folder = os.path.join(os.environ['LOCALAPPDATA'], 'Google', 'Chrome SxS', 'Application')
32
33# Find the most recent ANGLE DLLs
34binary_name = 'libGLESv2.dll'
35newest_folder = None
36newest_mtime = None
37for path in source_paths:
Jamie Madill768996c2016-06-08 13:32:26 -070038 binary_path = os.path.join(script_dir, path, binary_name)
Jamie Madill2be8c8c2016-04-28 14:39:15 -040039 if os.path.exists(binary_path):
40 binary_mtime = os.path.getmtime(binary_path)
41 if (newest_folder is None) or (binary_mtime > newest_mtime):
Jamie Madill768996c2016-06-08 13:32:26 -070042 newest_folder = os.path.join(script_dir, path)
Jamie Madill2be8c8c2016-04-28 14:39:15 -040043 newest_mtime = binary_mtime
44
Jamie Madill768996c2016-06-08 13:32:26 -070045if newest_folder is None:
46 sys.exit("Could not find ANGLE DLLs!")
47
Jamie Madill2be8c8c2016-04-28 14:39:15 -040048source_folder = newest_folder
49
50# Is a folder a chrome binary directory?
51def is_chrome_bin(str):
52 chrome_file = os.path.join(chrome_folder, str)
53 return os.path.isdir(chrome_file) and all([char.isdigit() or char == '.' for char in str])
54
55sorted_chrome_bins = sorted([folder for folder in os.listdir(chrome_folder) if is_chrome_bin(folder)], reverse=True)
56
57dest_folder = os.path.join(chrome_folder, sorted_chrome_bins[0])
58
59print('Copying DLLs from ' + source_folder + ' to ' + dest_folder + '.')
60
Yuly Novikovea586542016-11-10 17:33:43 -050061for dll in ['libGLESv2.dll', 'libEGL.dll']:
Jamie Madill2be8c8c2016-04-28 14:39:15 -040062 src = os.path.join(source_folder, dll)
63 if os.path.exists(src):
64 # Make a backup of the original unmodified DLLs if they are present.
65 backup = os.path.join(source_folder, dll + '.backup')
66 if not os.path.exists(backup):
67 shutil.copyfile(src, backup)
68 shutil.copyfile(src, os.path.join(dest_folder, dll))