Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: components/cronet/tools/package_ios.py

Issue 1947903003: Cronet Dynamic Framework for iOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added flag to package_ios.py that prepares Cronet dynamic framework Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright 2016 The Chromium Authors. All rights reserved. 2 # Copyright 2016 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """ 6 """
7 package_ios.py - Build and Package Release and Rebug fat libraries for iOS. 7 package_ios.py - Build and Package Release and Rebug fat libraries for iOS.
8 """ 8 """
9 9
10 import argparse 10 import argparse
11 import os 11 import os
12 import shutil 12 import shutil
13 import sys 13 import sys
14 14
15 def run(command, extra_options=''): 15 def run(command, extra_options=''):
16 command = command + ' ' + extra_options 16 command = command + ' ' + extra_options
17 print command 17 print command
18 return os.system(command) 18 return os.system(command)
19 19
20 def eprint(message):
mef 2016/05/11 12:55:02 only used once, inline?
kapishnikov 2016/05/11 19:48:15 Done.
21 print >>sys.stderr, message
mef 2016/05/11 12:55:02 nit: 2 empty lines between functions. Here and els
kapishnikov 2016/05/11 19:48:15 Done.
22
23 def copy_directory(src, dst):
24 """Copies |src| directory into |dst| directory.
25 """
26 dir_name = os.path.basename(src)
27 os.mkdir(os.path.join(dst, dir_name))
28 for item in os.listdir(src):
mef 2016/05/11 12:55:02 Hrm, I still find it weird that we need a custom f
kapishnikov 2016/05/11 19:48:15 Done.
29 s = os.path.join(src, item)
30 d = os.path.join(dst, dir_name, item)
31 if os.path.isdir(s):
32 shutil.copytree(s, d)
33 else:
34 shutil.copy2(s, d)
20 35
21 def build(out_dir, test_target, extra_options=''): 36 def build(out_dir, test_target, extra_options=''):
22 return run('ninja -C ' + out_dir + ' ' + test_target, 37 return run('ninja -C ' + out_dir + ' ' + test_target,
23 extra_options) 38 extra_options)
24 39
25 40
26 def lipo_libraries(out_dir, input_dirs, out_lib, input_lib): 41 def lipo_libraries(out_dir, input_dirs, out_lib, input_lib):
27 lipo = "lipo -create " 42 lipo = "lipo -create "
28 for input_dir in input_dirs: 43 for input_dir in input_dirs:
29 lipo += input_dir + "/" + input_lib + " " 44 lipo += input_dir + "/" + input_lib + " "
(...skipping 14 matching lines...) Expand all
44 build_target = 'cronet_package' 59 build_target = 'cronet_package'
45 target_dir = out_dir + "/Cronet" 60 target_dir = out_dir + "/Cronet"
46 return build(build_dir_sim, build_target) or \ 61 return build(build_dir_sim, build_target) or \
47 build(build_dir_dev, build_target) or \ 62 build(build_dir_dev, build_target) or \
48 copy_build_dir(target_dir, build_dir_dev + "/cronet") or \ 63 copy_build_dir(target_dir, build_dir_dev + "/cronet") or \
49 lipo_libraries(target_dir, [build_dir_sim, build_dir_dev], \ 64 lipo_libraries(target_dir, [build_dir_sim, build_dir_dev], \
50 "libcronet_" + build_config + ".a", \ 65 "libcronet_" + build_config + ".a", \
51 "cronet/libcronet_standalone.a") 66 "cronet/libcronet_standalone.a")
52 67
53 68
69 def package_ios_framework(out_dir='out/Framework', extra_options=''):
70 print 'Building Cronet Dynamic Framework...'
71
72 # Use Ninja to build all possible combinations.
73 build_dirs = ['Debug-iphonesimulator',
74 'Debug-iphoneos',
75 'Release-iphonesimulator',
76 'Release-iphoneos']
77 for build_dir in build_dirs:
78 print 'Building ' + build_dir
79 build_result = run('ninja -C out/' + build_dir + ' cronet_framework',
80 extra_options)
81 if build_result != 0:
82 return build_result
83
84 # Package all builds in the output directory
85 os.makedirs(out_dir)
86 for build_dir in build_dirs:
87 os.makedirs(os.path.join(out_dir, build_dir))
88 copy_directory(os.path.join('out', build_dir, 'Cronet.framework'),
89 os.path.join(out_dir, build_dir))
90 if 'Release' in build_dir:
91 copy_directory(os.path.join('out', build_dir, 'Cronet.framework.dSYM'),
92 os.path.join(out_dir, build_dir))
93
54 def main(): 94 def main():
55 parser = argparse.ArgumentParser() 95 parser = argparse.ArgumentParser()
56 parser.add_argument('out_dir', nargs=1, help='path to output directory') 96 parser.add_argument('out_dir', nargs=1, help='path to output directory')
57 parser.add_argument('-g', '--skip_gyp', action='store_true', 97 parser.add_argument('-g', '--skip_gyp', action='store_true',
58 help='skip gyp') 98 help='skip gyp')
59 parser.add_argument('-d', '--debug', action='store_true', 99 parser.add_argument('-d', '--debug', action='store_true',
60 help='use release configuration') 100 help='use release configuration')
61 parser.add_argument('-r', '--release', action='store_true', 101 parser.add_argument('-r', '--release', action='store_true',
62 help='use release configuration') 102 help='use release configuration')
103 parser.add_argument('--framework', action='store_true',
104 help='build Cronet dynamic framework')
63 105
64 options, extra_options_list = parser.parse_known_args() 106 options, extra_options_list = parser.parse_known_args()
65 print options 107 print options
66 print extra_options_list 108 print extra_options_list
67 109
110 out_dir = options.out_dir[0]
111
112 # Make sure that the output directory does not exist
113 if os.path.exists(out_dir):
114 eprint('The output directory already exists: ' + out_dir)
115 return 1
116
68 gyp_defines = 'GYP_DEFINES="OS=ios enable_websockets=0 '+ \ 117 gyp_defines = 'GYP_DEFINES="OS=ios enable_websockets=0 '+ \
69 'disable_file_support=1 disable_ftp_support=1 '+ \ 118 'disable_file_support=1 disable_ftp_support=1 '+ \
70 'enable_errorprone=1 use_platform_icu_alternatives=1 ' + \ 119 'enable_errorprone=1 use_platform_icu_alternatives=1 ' + \
71 'disable_brotli_filter=1 target_subarch=both"' 120 'disable_brotli_filter=1 chromium_ios_signing=0 ' + \
121 'target_subarch=both"'
72 if not options.skip_gyp: 122 if not options.skip_gyp:
73 run (gyp_defines + ' gclient runhooks') 123 run (gyp_defines + ' gclient runhooks')
74 124
75 return package_ios(options.out_dir[0], "out/Release", "opt") or \ 125 if options.framework:
76 package_ios(options.out_dir[0], "out/Debug", "dbg") 126 return package_ios_framework(out_dir)
127
128 return package_ios(out_dir, "out/Release", "opt") or \
129 package_ios(out_dir, "out/Debug", "dbg")
77 130
78 131
79 if __name__ == '__main__': 132 if __name__ == '__main__':
80 sys.exit(main()) 133 sys.exit(main())
OLDNEW
« components/cronet/ios/empty.cc ('K') | « components/cronet/ios/empty.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698