OLD | NEW |
(Empty) | |
| 1 # Copyright 2017 The WebRTC project authors. All Rights Reserved. |
| 2 # |
| 3 # Use of this source code is governed by a BSD-style license |
| 4 # that can be found in the LICENSE file in the root of the source |
| 5 # tree. An additional intellectual property rights grant can be found |
| 6 # in the file PATENTS. All contributing project authors may |
| 7 # be found in the AUTHORS file in the root of the source tree. |
| 8 |
| 9 """Compiles metal shader file into rtc_shaders.metallib. |
| 10 |
| 11 The produced metal library will be created in the output folder |
| 12 like so: |
| 13 oututDir/rtc_shaders.metallib |
| 14 The script is intended to be used as gn action. |
| 15 """ |
| 16 |
| 17 |
| 18 import argparse |
| 19 import subprocess |
| 20 import sys |
| 21 |
| 22 |
| 23 def main(): |
| 24 parser = argparse.ArgumentParser( |
| 25 description='A script to compile metal shaders.') |
| 26 parser.add_argument('-i', '--input', required=True, |
| 27 help='Path to input metal shaders.') |
| 28 parser.add_argument('-o', '--output', required=True, |
| 29 help='Path to output bundle.') |
| 30 args, _ = parser.parse_known_args() |
| 31 |
| 32 # TODO(denicija): replace the hardcoded iphoneos with |
| 33 # the proper sdk var when we add metal for mac. |
| 34 metal_air_args = [ |
| 35 'xcrun', |
| 36 '-sdk', |
| 37 'iphoneos', |
| 38 'metal', |
| 39 args.input, |
| 40 '-o', |
| 41 args.output+'/rtc_shaders.air' |
| 42 ] |
| 43 toolout = subprocess.Popen(metal_air_args) |
| 44 if toolout.wait() == 0: |
| 45 metal_lib_args = [ |
| 46 'xcrun', |
| 47 '-sdk', |
| 48 'iphoneos', |
| 49 'metallib', |
| 50 args.output+'/rtc_shaders.air', |
| 51 '-o', |
| 52 args.output+'/rtc_shaders.metallib' |
| 53 ] |
| 54 toolout = subprocess.Popen(metal_lib_args) |
| 55 toolout.wait() |
| 56 |
| 57 return toolout.returncode |
| 58 |
| 59 |
| 60 if __name__ == '__main__': |
| 61 sys.exit(main()) |
OLD | NEW |