Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # coding: utf-8 | 2 # coding: utf-8 |
3 | 3 |
4 import os | 4 import os |
5 import shutil | 5 import shutil |
6 import subprocess | 6 import subprocess |
7 import sys | 7 import sys |
8 import time | 8 import time |
9 | 9 |
10 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | 10 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) |
11 BUILD_DIR = os.path.join(BASE_DIR, "build") | 11 BUILD_DIR = os.path.join(BASE_DIR, "build") |
12 BUILD_NUMBER = time.strftime("%Y%m%d%H%M", time.gmtime()) | 12 BUILD_NUMBER = time.strftime("%Y%m%d%H%M", time.gmtime()) |
13 RELEASE_APP_PROVISIONING_PROFILE = "00d92821-2b0f-4036-9b2d-541ce10d0429" | 13 RELEASE_APP_PROVISIONING_PROFILE = "00d92821-2b0f-4036-9b2d-541ce10d0429" |
14 RELEASE_EXTENSION_PROVISIONING_PROFILE = "a30dba35-c866-4331-8967-28b9cab60ca2" | 14 RELEASE_EXTENSION_PROVISIONING_PROFILE = "a30dba35-c866-4331-8967-28b9cab60ca2" |
15 DEVBUILD_APP_PROVISIONING_PROFILE = "2591efa4-c166-4956-a62a-e3a0cd41f5a3" | 15 DEVBUILD_APP_PROVISIONING_PROFILE = "2591efa4-c166-4956-a62a-e3a0cd41f5a3" |
16 DEVBUILD_EXTENSION_PROVISIONING_PROFILE = "c4495b74-44a8-499e-ad28-4190912bad0b" | 16 DEVBUILD_EXTENSION_PROVISIONING_PROFILE = "c4495b74-44a8-499e-ad28-4190912bad0b" |
17 | 17 |
18 def print_usage(): | 18 def print_usage(): |
19 print >>sys.stderr, "Usage: %s release|devbuild" % \ | 19 print >>sys.stderr, "Usage: %s release|devbuild" % \ |
20 os.path.basename(sys.argv[0]) | 20 os.path.basename(sys.argv[0]) |
21 | 21 |
22 def build_dependencies(): | 22 def build_dependencies(): |
23 subprocess.check_call(["pod", "install"]) | 23 subprocess.check_call(["pod", "install"]) |
24 subprocess.check_call(["xcodebuild", | 24 subprocess.check_call(["xcodebuild", |
25 "-workspace", "AdblockPlusSafari.xcworkspace", | 25 "-workspace", "AdblockPlusSafari.xcworkspace", |
26 "-scheme", "Pods-AdblockPlusSafariExtension", | 26 "-scheme", "Pods-AdblockPlusSafariExtension", |
27 "CONFIGURATION_BUILD_DIR=" + BUILD_DIR, | 27 "CONFIGURATION_BUILD_DIR=" + BUILD_DIR, |
28 "build"]) | 28 "archive"]) |
29 | 29 |
30 def build_apps(build_type): | 30 def build_app(build_type, build_name): |
31 if build_type == "release": | 31 if build_type == "release": |
32 build_configuration = "Release" | 32 build_configuration = "Release" |
33 app_provisioning_profile = RELEASE_APP_PROVISIONING_PROFILE | 33 app_provisioning_profile = RELEASE_APP_PROVISIONING_PROFILE |
34 extension_provisioning_profile = RELEASE_EXTENSION_PROVISIONING_PROFILE | 34 extension_provisioning_profile = RELEASE_EXTENSION_PROVISIONING_PROFILE |
35 else: | 35 else: |
36 build_configuration = "Devbuild Release" | 36 build_configuration = "Devbuild Release" |
37 app_provisioning_profile = DEVBUILD_APP_PROVISIONING_PROFILE | 37 app_provisioning_profile = DEVBUILD_APP_PROVISIONING_PROFILE |
38 extension_provisioning_profile = DEVBUILD_EXTENSION_PROVISIONING_PROFILE | 38 extension_provisioning_profile = DEVBUILD_EXTENSION_PROVISIONING_PROFILE |
39 | 39 archive_path = os.path.join(BUILD_DIR, build_name + ".xcarchive") |
40 subprocess.check_call(["xcodebuild", | 40 subprocess.check_call(["xcodebuild", |
41 "-configuration", build_configuration, | 41 "-configuration", build_configuration, |
42 "-scheme", "AdblockPlusSafari", | |
42 "CONFIGURATION_BUILD_DIR=" + BUILD_DIR, | 43 "CONFIGURATION_BUILD_DIR=" + BUILD_DIR, |
43 "BUILD_NUMBER=" + BUILD_NUMBER, | 44 "BUILD_NUMBER=" + BUILD_NUMBER, |
44 "APP_PROVISIONING_PROFILE=" + app_provisioning_profile, | 45 "APP_PROVISIONING_PROFILE=" + app_provisioning_profile, |
45 "EXTENSION_PROVISIONING_PROFILE=" + extension_provision ing_profile, | 46 "EXTENSION_PROVISIONING_PROFILE=" + extension_provision ing_profile, |
46 "build"]) | 47 "ENABLE_BITCODE=NO", |
Felix Dahlke
2016/01/28 17:25:55
I couldn't make `-exportArchive` work without doin
| |
48 "archive", | |
49 "-archivePath", archive_path]) | |
50 return archive_path | |
47 | 51 |
48 def package(build_type): | 52 def package_app(archive_path, build_type, build_name): |
49 if build_type == "release": | 53 subprocess.check_call(["xcodebuild", |
50 package_name = "adblockplussafariios-release-%s.ipa" % BUILD_NUMBER | 54 "-exportArchive", |
pavel
2016/01/27 14:04:01
Forewarning: Python noob deducting multiparam prin
Felix Dahlke
2016/01/27 16:29:03
No you're quite right, I'll change that.
| |
51 else: | 55 "-archivePath", archive_path, |
52 package_name = "adblockplussafariios-devbuild-%s.ipa" % BUILD_NUMBER | 56 "-exportPath", BUILD_DIR, |
53 | 57 "-exportOptionsPlist", build_type + "ExportOptions.plis t"]) |
pavel
2016/02/01 10:18:15
Oh wow. Seeing that -exportOptionsPlist doc was wo
| |
54 subprocess.check_call(["xcrun", "-sdk", "iphoneos", | 58 os.rename(os.path.join(BUILD_DIR, "AdblockPlusSafari.ipa"), |
55 "PackageApplication", "-v", | 59 os.path.join(BUILD_DIR, build_name + ".ipa")) |
56 os.path.join(BUILD_DIR, "AdblockPlusSafari.app"), | |
57 "-o", os.path.join(BUILD_DIR, package_name), | |
58 "-s", "iPhone Distribution: Eyeo GmbH"]) | |
59 | 60 |
60 if __name__ == "__main__": | 61 if __name__ == "__main__": |
61 if len(sys.argv) < 2: | 62 if len(sys.argv) < 2: |
62 print_usage() | 63 print_usage() |
63 sys.exit(1) | 64 sys.exit(1) |
64 | 65 |
65 build_type = sys.argv[1] | 66 build_type = sys.argv[1] |
66 if build_type not in ["devbuild", "release"]: | 67 if build_type not in ["devbuild", "release"]: |
67 print_usage() | 68 print_usage() |
68 sys.exit(2) | 69 sys.exit(2) |
69 | 70 |
70 shutil.rmtree(BUILD_DIR, ignore_errors=True) | 71 shutil.rmtree(BUILD_DIR, ignore_errors=True) |
71 build_dependencies() | 72 build_dependencies() |
72 build_apps(build_type) | 73 build_name = "adblockplussafariios-%s-%s" % (build_type, BUILD_NUMBER) |
73 package(build_type) | 74 archive_path = build_app(build_type, build_name) |
75 package_app(archive_path, build_type, build_name) | |
LEFT | RIGHT |