Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import argparse | 5 import argparse |
| 6 import errno | 6 import errno |
| 7 import os | 7 import os |
| 8 import subprocess | 8 import subprocess |
| 9 import sys | 9 import sys |
| 10 | 10 |
| 11 def MakeDirectories(path): | 11 def MakeDirectories(path): |
| 12 try: | 12 try: |
| 13 os.makedirs(path) | 13 os.makedirs(path) |
| 14 except OSError as exc: | 14 except OSError as exc: |
| 15 if exc.errno == errno.EEXIST and os.path.isdir(path): | 15 if exc.errno == errno.EEXIST and os.path.isdir(path): |
| 16 return 0 | 16 return 0 |
| 17 else: | 17 else: |
| 18 return -1 | 18 return -1 |
| 19 | 19 |
| 20 return 0 | 20 return 0 |
| 21 | 21 |
| 22 | 22 |
| 23 def ProcessInfoPlist(args): | 23 def ProcessInfoPlist(args): |
| 24 output_plist_file = os.path.abspath(os.path.join(args.output, 'Info.plist')) | 24 output_plist_file = os.path.abspath(os.path.join(args.output, 'Info.plist')) |
| 25 return subprocess.check_call([ | 25 return subprocess.check_call([ |
| 26 '/usr/bin/env', | 26 '/usr/bin/env', |
| 27 'xcrun', | 27 'xcrun', |
| 28 'plutil' | 28 'plutil', |
| 29 '-convert', | 29 '-convert', |
| 30 'binary1', | 30 'binary1', |
| 31 '-o', | 31 '-o', |
| 32 output_plist_file, | 32 output_plist_file, |
| 33 '--', | 33 '--', |
| 34 args.input, | 34 args.input, |
| 35 ]) | 35 ]) |
| 36 | 36 |
| 37 | 37 |
| 38 def ProcessNIB(args): | 38 def ProcessNIB(args): |
| 39 output_nib_file = os.path.join(os.path.abspath(args.output), | 39 output_nib_file = os.path.join(os.path.abspath(args.output), |
| 40 "%s.nib" % os.path.splitext(os.path.basename(args.input))[0]) | 40 "%s.nib" % os.path.splitext(os.path.basename(args.input))[0]) |
| 41 | 41 |
| 42 return subprocess.check_call([ | 42 return subprocess.check_call([ |
| 43 '/usr/bin/env', | 43 '/usr/bin/env', |
| 44 'xcrun', | 44 'xcrun', |
| 45 'ibtool', | 45 'ibtool', |
| 46 '--module', | 46 '--module', |
| 47 args.module, | 47 args.module, |
| 48 '--auto-activate-custom-fonts', | 48 '--auto-activate-custom-fonts', |
| 49 '--target-device', | 49 '--target-device', |
| 50 'mac', | 50 'mac', |
| 51 '--compile', | 51 '--compile', |
| 52 output_nib_file, | 52 output_nib_file, |
| 53 os.path.abspath(args.input), | 53 os.path.abspath(args.input), |
| 54 ]) | 54 ]) |
| 55 | 55 |
| 56 | 56 |
| 57 def GenerateProjectStructure(args): | 57 def GenerateProjectStructure(args): |
| 58 application_path = os.path.join( args.dir, args.name + ".app", "Contents" ) | 58 application_path = os.path.join( args.dir, args.name + ".app", "Contents" ) |
|
Nico
2016/03/29 21:41:15
do you want to add MacOS here while you're here to
| |
| 59 return MakeDirectories( application_path ) | 59 return MakeDirectories( application_path ) |
| 60 | 60 |
| 61 | 61 |
| 62 def main(): | 62 def main(): |
| 63 parser = argparse.ArgumentParser(description='A script that aids in ' | 63 parser = argparse.ArgumentParser(description='A script that aids in ' |
| 64 'the creation of an Mac application') | 64 'the creation of an Mac application') |
| 65 | 65 |
| 66 subparsers = parser.add_subparsers() | 66 subparsers = parser.add_subparsers() |
| 67 | 67 |
| 68 # Plist Parser | 68 # Plist Parser |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 90 | 90 |
| 91 dir_struct_parser.add_argument('-d', dest='dir', help='Out directory') | 91 dir_struct_parser.add_argument('-d', dest='dir', help='Out directory') |
| 92 dir_struct_parser.add_argument('-n', dest='name', help='App name') | 92 dir_struct_parser.add_argument('-n', dest='name', help='App name') |
| 93 | 93 |
| 94 args = parser.parse_args() | 94 args = parser.parse_args() |
| 95 return args.func(args) | 95 return args.func(args) |
| 96 | 96 |
| 97 | 97 |
| 98 if __name__ == '__main__': | 98 if __name__ == '__main__': |
| 99 sys.exit(main()) | 99 sys.exit(main()) |
| OLD | NEW |