Path: blob/main_old/tools/glslang/update_glslang_binary.py
2576 views
#!/usr/bin/python21#2# Copyright 2019 The ANGLE Project Authors. All rights reserved.3# Use of this source code is governed by a BSD-style license that can be4# found in the LICENSE file.5#6# update_glslang_binary.py:7# Helper script to update the version of glslang in cloud storage.8# This glslang is used to precompile Vulkan shaders. This script builds9# glslang and uploads it to the bucket for Windows or Linux. It10# currently only works on Windows and Linux. It also will update the11# hashes stored in the tree. For more info see README.md in this folder.1213import os14import platform15import shutil16import subprocess17import sys1819sys.path.append('tools/')20import angle_tools2122gn_args = """is_clang = true23is_debug = false24angle_enable_vulkan = true"""252627def main():28if not angle_tools.is_windows and not angle_tools.is_linux:29print('Script must be run on Linux or Windows.')30return 13132# Step 1: Generate an output directory33out_dir = os.path.join('out', 'glslang_release')3435if not os.path.isdir(out_dir):36os.mkdir(out_dir)3738args_gn = os.path.join(out_dir, 'args.gn')39if not os.path.isfile(args_gn):40with open(args_gn, 'w') as f:41f.write(gn_args)42f.close()4344gn_exe = angle_tools.get_exe_name('gn', '.bat')4546# Step 2: Generate the ninja build files in the output directory47if subprocess.call([gn_exe, 'gen', out_dir]) != 0:48print('Error calling gn')49return 25051# Step 3: Compile glslang_validator52if subprocess.call(['ninja', '-C', out_dir, 'glslang_validator']) != 0:53print('Error calling ninja')54return 35556# Step 4: Copy glslang_validator to the tools/glslang directory57glslang_exe = angle_tools.get_exe_name('glslang_validator', '.exe')5859glslang_src = os.path.join(out_dir, glslang_exe)60glslang_dst = os.path.join(sys.path[0], glslang_exe)6162shutil.copy(glslang_src, glslang_dst)6364# Step 5: Delete the build directory65shutil.rmtree(out_dir)6667# Step 6: Upload to cloud storage68if not angle_tools.upload_to_google_storage('angle-glslang-validator', [glslang_dst]):69print('Error upload to cloud storage')70return 47172# Step 7: Stage new SHA to git73if not angle_tools.stage_google_storage_sha1([glslang_dst]):74print('Error running git add')75return 57677print('')78print('The updated SHA has been staged for commit. Please commit and upload.')79print('Suggested commit message:')80print('----------------------------')81print('')82print('Update glslang_validator binary for %s.' % platform.system())83print('')84print('This binary was updated using %s.' % os.path.basename(__file__))85print('Please see instructions in tools/glslang/README.md.')86print('')87print('Bug: None')8889return 0909192if __name__ == '__main__':93sys.exit(main())949596