Chromium Code Reviews| Index: webrtc/sdk/objc/compile_metal_lib.py |
| diff --git a/webrtc/sdk/objc/compile_metal_lib.py b/webrtc/sdk/objc/compile_metal_lib.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c9b7a7206acf4a176cf8f5383ab83e946db75353 |
| --- /dev/null |
| +++ b/webrtc/sdk/objc/compile_metal_lib.py |
| @@ -0,0 +1,61 @@ |
| +# Copyright 2017 The WebRTC project authors. All Rights Reserved. |
| +# |
| +# Use of this source code is governed by a BSD-style license |
| +# that can be found in the LICENSE file in the root of the source |
| +# tree. An additional intellectual property rights grant can be found |
| +# in the file PATENTS. All contributing project authors may |
| +# be found in the AUTHORS file in the root of the source tree. |
| + |
| +"""Compiles metal shader file into rtc_shaders.metallib. |
| + |
| +The produced metal library will be created in the output folder |
| +like so: |
| + oututDir/rtc_shaders.metallib |
| +The script is intended to be used as gn action. |
| +""" |
| + |
| + |
| +import argparse |
| +import subprocess |
| +import sys |
| + |
| + |
| +def main(): |
| + parser = argparse.ArgumentParser( |
| + description='A script to compile metal shaders.') |
| + parser.add_argument('-i', '--input', required=True, |
| + help='Path to input metal shaders.') |
| + parser.add_argument('-o', '--output', required=True, |
| + help='Path to output bundle.') |
| + args, _ = parser.parse_known_args() |
| + |
| + # TODO(denicija): replace the hardcoded iphoneos with |
| + # the proper sdk var when we add metal for mac. |
| + metal_air_args = [ |
| + 'xcrun', |
| + '-sdk', |
| + 'iphoneos', |
| + 'metal', |
| + args.input, |
| + '-o', |
| + args.output+'/rtc_shaders.air' |
| + ] |
| + toolout = subprocess.Popen(metal_air_args) |
| + if toolout.wait() == 0: |
| + metal_lib_args = [ |
| + 'xcrun', |
| + '-sdk', |
| + 'iphoneos', |
| + 'metallib', |
| + args.output+'/rtc_shaders.air', |
| + '-o', |
| + args.output+'/rtc_shaders.metallib' |
| + ] |
| + toolout = subprocess.Popen(metal_lib_args) |
| + toolout.wait() |
| + |
| + sys.exit(toolout.returncode) |
|
kthelgason
2017/02/02 15:22:36
return this instead of sys.exit.
kjellander_webrtc
2017/02/03 09:03:17
+1
daniela-webrtc
2017/02/07 10:43:59
Done.
|
| + |
| + |
| +if __name__ == '__main__': |
| + sys.exit(main()) |