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..55ed44ab65bd1f63e37011309bca637eb87c7d70 |
--- /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() |
+ |
+ return toolout.returncode |
+ |
+ |
+if __name__ == '__main__': |
+ sys.exit(main()) |