1#!/usr/bin/python2 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_windows: 29 subdir = 'windows' 30 files = [ 31 'flex.exe', 'bison.exe', 'm4.exe', 'msys-2.0.dll', 'msys-iconv-2.dll', 32 'msys-intl-8.dll' 33 ] 34 else: 35 print('Script must be run on Linux or Windows.') 36 return 1 37 38 files = [os.path.join(sys.path[0], subdir, f) for f in files] 39 40 # Step 1: Upload to cloud storage 41 if not angle_tools.upload_to_google_storage('angle-flex-bison', files): 42 print('Error upload to cloud storage') 43 return 1 44 45 # Step 2: Stage new SHA to git 46 if not angle_tools.stage_google_storage_sha1(files): 47 print('Error running git add') 48 return 2 49 50 print('') 51 print('The updated SHA has been staged for commit. Please commit and upload.') 52 print('Suggested commit message (please indicate flex/bison versions):') 53 print('----------------------------') 54 print('') 55 print('Update flex and bison binaries for %s.' % platform.system()) 56 print('') 57 print('These binaries were updated using %s.' % os.path.basename(__file__)) 58 print('Please see instructions in tools/flex-bison/README.md.') 59 print('') 60 print('flex is at version TODO.') 61 print('bison is at version TODO.') 62 print('') 63 print('Bug: None') 64 65 return 0 66 67 68if __name__ == '__main__': 69 sys.exit(main()) 70