1#!/usr/bin/env python2.7
2#
3# Copyright 2017 Google Inc.
4#
5# Use of this source code is governed by a BSD-style license that can be
6# found in the LICENSE file.
7
8import os
9import sys
10
11# Arguments to the script:
12#  app              path to binary to package, e.g. out/Debug/gen/dm
13#  bundle_prefix    the first part of the bundle ID, e.g. com.google (no trailing '.')
14#                   the app name will be appended to this to create the full bundle ID
15app,bundle_prefix = sys.argv[1:3]
16
17out, app = os.path.split(app)
18
19# Write a minimal Info.plist to name the package and point at the binary.
20with open(os.path.join(out, app + '_Info.plist'), 'w') as f:
21  f.write('''
22<plist version="1.0">
23  <dict>
24    <key>CFBundleVersion</key> <string>0.1.0</string>
25    <key>CFBundleShortVersionString</key> <string>0.1.0</string>
26    <key>CFBundleExecutable</key> <string>{app}</string>
27    <key>CFBundleIdentifier</key> <string>{bundle_prefix}.{app}</string>
28    <key>CFBundlePackageType</key> <string>APPL</string>
29    <key>LSRequiresIPhoneOS</key> <true/>
30    <key>UIDeviceFamily</key> <array>
31      <integer>1</integer>
32      <integer>2</integer>
33    </array>
34    <key>UILaunchStoryboardName</key> <string>LaunchScreen</string>
35  </dict>
36</plist>
37'''.format(app=app, bundle_prefix=bundle_prefix))
38