aboutsummaryrefslogtreecommitdiffhomepage
path: root/gn
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2017-01-30 14:00:54 -0500
committerGravatar Mike Klein <mtklein@chromium.org>2017-01-31 17:06:21 +0000
commit6d3b7aaf79b2cbacdf00bafc15ded2dfd2fa000a (patch)
tree8bc8a0847c44027d988ae4f7fae794955d298147 /gn
parent4427f165d792a93649e2b2673d3d8b89a35e8186 (diff)
gn: iOS packaging script
This is enough to run DM on my iPad. I've tweaks DM so that it can run as built by both GN and GYP. When we kill off GYP, all the dm_main() nonsense goes away. CQ_INCLUDE_TRYBOTS=skia.primary:Test-iOS-Clang-iPadMini4-GPU-GX6450-Arm7-Debug,Build-Mac-Clang-arm64-Debug-GN_iOS Change-Id: I59176bc203ee3180618b94ac5f9d291e0ad20b62 Reviewed-on: https://skia-review.googlesource.com/7757 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Hal Canary <halcanary@google.com>
Diffstat (limited to 'gn')
-rw-r--r--gn/BUILD.gn2
-rw-r--r--gn/package_ios.py67
2 files changed, 68 insertions, 1 deletions
diff --git a/gn/BUILD.gn b/gn/BUILD.gn
index ec3a1f1ee3..11ab560a2e 100644
--- a/gn/BUILD.gn
+++ b/gn/BUILD.gn
@@ -211,7 +211,7 @@ config("default") {
# If we can we'd like to not do that anymore. While we're building both ways, here's
# our clever hack to give each tool back its own main().
cflags += [
- "-Ddm_main=main",
+ "-DDM_DEFINE_MAIN",
"-Dnanobench_main=main",
"-Dtool_main=main",
"-Dtest_main=main",
diff --git a/gn/package_ios.py b/gn/package_ios.py
new file mode 100644
index 0000000000..ee8ab46b88
--- /dev/null
+++ b/gn/package_ios.py
@@ -0,0 +1,67 @@
+#!/usr/bin/env python2.7
+#
+# Copyright 2017 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+import re
+import shutil
+import subprocess
+import sys
+import tempfile
+
+# Arguments to the script:
+# app path to binary to package, e.g. out/Debug/dm
+# identity code signing identity, a long hex string
+# (run security find-identity -v -p codesigning | grep Google)
+# mobileprovision path to Google_Development.mobileprovision
+app, identity, mobileprovision = sys.argv[1:]
+
+out, app = os.path.split(app)
+
+pkg = os.path.join(out, app + '.app')
+if not os.path.exists(pkg):
+ os.mkdir(pkg)
+
+# The binary and .mobileprovision just get copied into the package.
+shutil.copy(os.path.join(out, app), pkg)
+shutil.copy(mobileprovision,
+ os.path.join(pkg, 'embedded.mobileprovision'))
+
+# Write a minimal Info.plist to name the package and point at the binary.
+with open(os.path.join(pkg, 'Info.plist'), 'w') as f:
+ f.write('''
+<plist version="1.0">
+ <dict>
+ <key>CFBundleExecutable</key> <string>{app}</string>
+ <key>CFBundleIdentifier</key> <string>com.google.{app}</string>
+ </dict>
+</plist>
+'''.format(app=app))
+
+# Extract the appliciation identitifer prefix from the .mobileprovision.
+m = re.search(r'''<key>ApplicationIdentifierPrefix</key>
+\t<array>
+\t<string>(.*)</string>''', open(mobileprovision).read(), re.MULTILINE)
+prefix = m.group(1)
+
+# Write a minimal entitlements file, then codesign.
+with tempfile.NamedTemporaryFile() as f:
+ f.write('''
+<plist version="1.0">
+ <dict>
+ <key>application-identifier</key> <string>{prefix}.com.google.{app}</string>
+ <key>get-task-allow</key> <true/>
+ </dict>
+</plist>
+'''.format(prefix=prefix, app=app))
+ f.flush()
+
+ subprocess.check_call(['codesign',
+ '--force',
+ '--sign', identity,
+ '--entitlements', f.name,
+ '--timestamp=none',
+ pkg])