1#!/usr/bin/python3 2# 3# Copyright 2019 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_flex_bison_binaries.py: 8# Helper script to update the version of flex and bison in cloud storage. 9# These binaries are used to generate the ANGLE translator's lexer and parser. 10# This script relies on flex and bison binaries to be externally built which 11# is expected to be a rare operation. It currently only works on Windows and 12# Linux. It also will update the hashes stored in the tree. For more info see 13# README.md in this folder. 14 15import os 16import platform 17import shutil 18import sys 19 20sys.path.append('tools/') 21import angle_tools 22 23 24def main(): 25 if angle_tools.is_linux: 26 subdir = 'linux' 27 files = ['flex', 'bison'] 28 elif angle_tools.is_mac: 29 subdir = 'mac' 30 files = ['flex', 'bison'] 31 elif angle_tools.is_windows: 32 subdir = 'windows' 33 files = [ 34 'flex.exe', 'bison.exe', 'm4.exe', 'msys-2.0.dll', 'msys-iconv-2.dll', 35 'msys-intl-8.dll' 36 ] 37 else: 38 print('Script must be run on Linux, Mac or Windows.') 39 return 1 40 41 files = [os.path.join(sys.path[0], subdir, f) for f in files] 42 43 # Step 1: Upload to cloud storage 44 bucket = 'angle-flex-bison' 45 if not angle_tools.upload_to_google_storage(bucket, files): 46 print('Error upload to cloud storage') 47 return 1 48 49 # Step 2: Stage new SHA to git 50 if not angle_tools.stage_google_storage_sha1(files): 51 print('Error running git add') 52 return 2 53 54 print('') 55 print('The updated SHA has been staged for commit. Please commit and upload.') 56 print('Suggested commit message (please indicate flex/bison versions):') 57 print('----------------------------') 58 print('') 59 print('Update flex and bison binaries for %s.' % platform.system()) 60 print('') 61 print('These binaries were updated using %s.' % os.path.basename(__file__)) 62 print('Please see instructions in tools/flex-bison/README.md.') 63 print('') 64 print('flex is at version TODO.') 65 print('bison is at version TODO.') 66 print('') 67 print('Bug: None') 68 69 return 0 70 71 72if __name__ == '__main__': 73 sys.exit(main()) 74