Jeff Gilbert | 1b605ee | 2017-10-30 18:41:46 -0700 | [diff] [blame] | 1 | #!/usr/bin/python2 |
Jamie Madill | 2be8c8c | 2016-04-28 14:39:15 -0400 | [diff] [blame] | 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 | |
| 14 | import sys, os, shutil |
| 15 | |
| 16 | # Set of search paths. |
| 17 | source_paths = [ |
Jamie Madill | 16e5409 | 2016-11-15 12:35:42 -0800 | [diff] [blame] | 18 | 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 Madill | 2be8c8c | 2016-04-28 14:39:15 -0400 | [diff] [blame] | 22 | 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 Madill | 768996c | 2016-06-08 13:32:26 -0700 | [diff] [blame] | 28 | script_dir = os.path.dirname(sys.argv[0]) |
| 29 | |
Jamie Madill | 2be8c8c | 2016-04-28 14:39:15 -0400 | [diff] [blame] | 30 | # Default Canary installation path. |
| 31 | chrome_folder = os.path.join(os.environ['LOCALAPPDATA'], 'Google', 'Chrome SxS', 'Application') |
| 32 | |
| 33 | # Find the most recent ANGLE DLLs |
| 34 | binary_name = 'libGLESv2.dll' |
| 35 | newest_folder = None |
| 36 | newest_mtime = None |
| 37 | for path in source_paths: |
Jamie Madill | 768996c | 2016-06-08 13:32:26 -0700 | [diff] [blame] | 38 | binary_path = os.path.join(script_dir, path, binary_name) |
Jamie Madill | 2be8c8c | 2016-04-28 14:39:15 -0400 | [diff] [blame] | 39 | 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 Madill | 768996c | 2016-06-08 13:32:26 -0700 | [diff] [blame] | 42 | newest_folder = os.path.join(script_dir, path) |
Jamie Madill | 2be8c8c | 2016-04-28 14:39:15 -0400 | [diff] [blame] | 43 | newest_mtime = binary_mtime |
| 44 | |
Jamie Madill | 768996c | 2016-06-08 13:32:26 -0700 | [diff] [blame] | 45 | if newest_folder is None: |
| 46 | sys.exit("Could not find ANGLE DLLs!") |
| 47 | |
Jamie Madill | 2be8c8c | 2016-04-28 14:39:15 -0400 | [diff] [blame] | 48 | source_folder = newest_folder |
| 49 | |
| 50 | # Is a folder a chrome binary directory? |
| 51 | def 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 | |
| 55 | sorted_chrome_bins = sorted([folder for folder in os.listdir(chrome_folder) if is_chrome_bin(folder)], reverse=True) |
| 56 | |
| 57 | dest_folder = os.path.join(chrome_folder, sorted_chrome_bins[0]) |
| 58 | |
| 59 | print('Copying DLLs from ' + source_folder + ' to ' + dest_folder + '.') |
| 60 | |
Yuly Novikov | ea58654 | 2016-11-10 17:33:43 -0500 | [diff] [blame] | 61 | for dll in ['libGLESv2.dll', 'libEGL.dll']: |
Jamie Madill | 2be8c8c | 2016-04-28 14:39:15 -0400 | [diff] [blame] | 62 | 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)) |