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

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

Issue 1858483002: Cronet for iOS with C API for GRPC support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@small
Patch Set: Strip debug symbols from libcronet_standalone library. Created 4 years, 8 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 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 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 cr_cronet.py - cr - like helper tool for cronet developers 7 cr_cronet.py - cr - like helper tool for cronet developers
8 """ 8 """
9 9
10 import argparse 10 import argparse
11 import os 11 import os
12 import sys 12 import sys
13 13
14 target_os = 'android'
15 test_target = 'cronet_test_instrumentation_apk'
16 out_dir_suffix = ''
17
18 if (sys.platform == 'darwin'):
19 target_os = 'ios'
20 test_target = 'cronet_test'
kapishnikov 2016/04/08 23:54:18 It is better if the name stays the same (see the c
mef 2016/04/09 00:52:29 Yes, although its execution is different anyway.
21 out_dir_suffix = '-iphonesimulator'
kapishnikov 2016/04/08 23:54:18 Should we add the ability to build for an iOS phis
mef 2016/04/09 00:52:29 Done.
14 22
15 def run(command, extra_options=''): 23 def run(command, extra_options=''):
16 command = command + ' ' + extra_options 24 command = command + ' ' + extra_options
17 print command 25 print command
18 return os.system(command) 26 return os.system(command)
19 27
20 28
21 def build(out_dir, extra_options=''): 29 def build(out_dir, extra_options=''):
22 return run('ninja -C ' + out_dir + ' cronet_test_instrumentation_apk', 30 return run('ninja -C ' + out_dir + ' ' + test_target,
23 extra_options) 31 extra_options)
24 32
25 33
26 def install(release_arg): 34 def install(release_arg):
27 return run('build/android/adb_install_apk.py ' + release_arg + \ 35 return run('build/android/adb_install_apk.py ' + release_arg + \
28 ' --apk=CronetTest.apk') or \ 36 ' --apk=CronetTest.apk') or \
29 run('build/android/adb_install_apk.py ' + release_arg + \ 37 run('build/android/adb_install_apk.py ' + release_arg + \
30 ' --apk=ChromiumNetTestSupport.apk') 38 ' --apk=ChromiumNetTestSupport.apk')
31 39
32 40
33 def test(release_arg, extra_options): 41 def test(release_arg, extra_options):
34 return run('build/android/test_runner.py instrumentation '+ \ 42 return run('build/android/test_runner.py instrumentation '+ \
35 release_arg + ' --test-apk=CronetTestInstrumentation' + \ 43 release_arg + ' --test-apk=CronetTestInstrumentation' + \
36 ' --fast-local-dev', 44 ' --fast-local-dev',
37 extra_options) 45 extra_options)
38 46
47 def test_ios(out_dir, extra_options):
48 return run(out_dir + '/iossim ' + out_dir + '/cronet_test.app', extra_options)
39 49
40 def debug(extra_options): 50 def debug(extra_options):
41 return run('build/android/adb_gdb --start ' + \ 51 return run('build/android/adb_gdb --start ' + \
42 '--activity=.CronetTestActivity ' + \ 52 '--activity=.CronetTestActivity ' + \
43 '--program-name=CronetTest ' + \ 53 '--program-name=CronetTest ' + \
44 '--package-name=org.chromium.net', 54 '--package-name=org.chromium.net',
45 extra_options) 55 extra_options)
46 56
47 57
48 def stack(out_dir): 58 def stack(out_dir):
(...skipping 14 matching lines...) Expand all
63 'build-test', 73 'build-test',
64 'stack', 74 'stack',
65 'debug', 75 'debug',
66 'build-debug']) 76 'build-debug'])
67 parser.add_argument('-r', '--release', action='store_true', 77 parser.add_argument('-r', '--release', action='store_true',
68 help='use release configuration') 78 help='use release configuration')
69 79
70 options, extra_options_list = parser.parse_known_args() 80 options, extra_options_list = parser.parse_known_args()
71 print options 81 print options
72 print extra_options_list 82 print extra_options_list
73 gyp_defines = 'GYP_DEFINES="OS=android enable_websockets=0 '+ \ 83 gyp_defines = 'GYP_DEFINES="OS=' + target_os + ' enable_websockets=0 '+ \
74 'disable_file_support=1 disable_ftp_support=1 '+ \ 84 'disable_file_support=1 disable_ftp_support=1 '+ \
75 'enable_errorprone=1 use_platform_icu_alternatives=1 ' + \ 85 'enable_errorprone=1 use_platform_icu_alternatives=1 ' + \
76 'disable_brotli_filter=1"' 86 'disable_brotli_filter=1 use_openssl=1"'
77 gn_args = 'target_os="android" enable_websockets=false '+ \ 87 gn_args = 'target_os="' + target_os + '" enable_websockets=false '+ \
78 'disable_file_support=true disable_ftp_support=true '+ \ 88 'disable_file_support=true disable_ftp_support=true '+ \
79 'use_errorprone_java_compiler=true use_platform_icu_alternatives=true '+ \ 89 'use_errorprone_java_compiler=true use_platform_icu_alternatives=true '+ \
80 'disable_brotli_filter=true' 90 'disable_brotli_filter=true'
81 out_dir = 'out/Debug' 91 out_dir = 'out/Debug' + out_dir_suffix
82 release_arg = '' 92 release_arg = ''
83 extra_options = ' '.join(extra_options_list) 93 extra_options = ' '.join(extra_options_list)
84 if options.release: 94 if options.release:
85 out_dir = 'out/Release' 95 out_dir = 'out/Release'
86 release_arg = ' --release' 96 release_arg = ' --release'
87 gn_args += ' is_debug=false ' 97 gn_args += ' is_debug=false '
88 98
89 if (options.command=='gyp'): 99 if (options.command=='gyp'):
90 return run (gyp_defines + ' gclient runhooks') 100 return run (gyp_defines + ' gclient runhooks')
91 if (options.command=='gn'): 101 if (options.command=='gn'):
92 return run ('gn gen ' + out_dir + ' --args=\'' + gn_args + '\'') 102 return run ('gn gen ' + out_dir + ' --args=\'' + gn_args + '\'')
93 if (options.command=='sync'): 103 if (options.command=='sync'):
94 return run ('git pull --rebase && ' + gyp_defines + ' gclient sync') 104 return run ('git pull --rebase && ' + gyp_defines + ' gclient sync')
95 if (options.command=='build'): 105 if (options.command=='build'):
96 return build(out_dir, extra_options) 106 return build(out_dir, extra_options)
97 if (options.command=='install'): 107 if (options.command=='install'):
98 return install(release_arg) 108 return install(release_arg)
99 if (options.command=='proguard'): 109 if (options.command=='proguard'):
100 return run ('ninja -C ' + out_dir + ' cronet_sample_proguard_apk') 110 return run ('ninja -C ' + out_dir + ' cronet_sample_proguard_apk')
101 if (options.command=='test'): 111 if (options.command=='test' and target_os == 'android'):
102 return install(release_arg) or test(release_arg, extra_options) 112 return install(release_arg) or test(release_arg, extra_options)
113 if (options.command=='test' and target_os == 'ios'):
114 return test_ios(out_dir, extra_options)
103 if (options.command=='build-test'): 115 if (options.command=='build-test'):
kapishnikov 2016/04/08 23:54:18 Should we add 'build-test' for iOS?
mef 2016/04/09 00:52:29 Done.
104 return build(out_dir) or install(release_arg) or \ 116 return build(out_dir) or install(release_arg) or \
105 test(release_arg, extra_options) 117 test(release_arg, extra_options)
106 if (options.command=='stack'): 118 if (options.command=='stack'):
107 return stack(out_dir) 119 return stack(out_dir)
108 if (options.command=='debug'): 120 if (options.command=='debug'):
109 return install(release_arg) or debug(extra_options) 121 return install(release_arg) or debug(extra_options)
110 if (options.command=='build-debug'): 122 if (options.command=='build-debug'):
111 return build(out_dir) or install(release_arg) or debug(extra_options) 123 return build(out_dir) or install(release_arg) or debug(extra_options)
112 124
113 parser.print_help() 125 parser.print_help()
114 return 1 126 return 1
115 127
116 128
117 if __name__ == '__main__': 129 if __name__ == '__main__':
118 sys.exit(main()) 130 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698