16 except OSError
as exc:
17 if exc.errno == errno.EEXIST
and os.path.isdir(path):
24 parser = argparse.ArgumentParser()
26 '--output', type=str, required=
True, help=
'The location to generate the Metal library to.'
28 parser.add_argument(
'--depfile', type=str, required=
True, help=
'The location of the depfile.')
34 help=
'The source file to compile. Can be specified multiple times.'
39 choices=[
'mac',
'ios',
'ios-simulator'],
40 help=
'Select the platform.'
43 '--metal-version', required=
True, help=
'The language standard version to compile for.'
46 args = parser.parse_args()
56 if args.platform ==
'mac':
60 elif args.platform ==
'ios':
64 elif args.platform ==
'ios-simulator':
69 raise 'Unknown target platform'
75 '-Wno-unused-variable',
83 '-frecord-sources=flat',
92 if args.platform ==
'mac':
94 '--std=macos-metal%s' % args.metal_version,
95 '-mmacos-version-min=10.14',
97 elif args.platform ==
'ios':
99 '--std=ios-metal%s' % args.metal_version,
100 '-mios-version-min=11.0',
102 elif args.platform ==
'ios-simulator':
104 '--std=ios-metal%s' % args.metal_version,
105 '-miphonesimulator-version-min=11.0',
108 raise 'Unknown target platform'
110 command += args.source
113 subprocess.check_output(command, stderr=subprocess.STDOUT, text=
True)
114 except subprocess.CalledProcessError
as cpe:
116 return cpe.returncode
121if __name__ ==
'__main__':
122 if sys.platform !=
'darwin':
123 raise Exception(
'This script only runs on Mac')
def print(*args, **kwargs)