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

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: Make it syncable 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'
21 out_dir_suffix = '-iphonesimulator'
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') 36 ' --apk=CronetTest.apk')
29 37
30 38
31 def test(release_arg, extra_options): 39 def test(release_arg, extra_options):
32 return run('build/android/test_runner.py instrumentation '+ \ 40 return run('build/android/test_runner.py instrumentation '+ \
33 release_arg + ' --test-apk=CronetTestInstrumentation' + \ 41 release_arg + ' --test-apk=CronetTestInstrumentation' + \
34 ' --fast-local-dev', 42 ' --fast-local-dev',
35 extra_options) 43 extra_options)
36 44
45 def test_ios(out_dir, extra_options):
46 return run(out_dir + '/iossim ' + out_dir + '/cronet_test.app', extra_options)
37 47
38 def debug(extra_options): 48 def debug(extra_options):
39 return run('build/android/adb_gdb --start ' + \ 49 return run('build/android/adb_gdb --start ' + \
40 '--activity=.CronetTestActivity ' + \ 50 '--activity=.CronetTestActivity ' + \
41 '--program-name=CronetTest ' + \ 51 '--program-name=CronetTest ' + \
42 '--package-name=org.chromium.net', 52 '--package-name=org.chromium.net',
43 extra_options) 53 extra_options)
44 54
45 55
46 def stack(out_dir): 56 def stack(out_dir):
(...skipping 22 matching lines...) Expand all
69 print options 79 print options
70 print extra_options_list 80 print extra_options_list
71 gyp_defines = 'GYP_DEFINES="OS=android enable_websockets=0 '+ \ 81 gyp_defines = 'GYP_DEFINES="OS=android enable_websockets=0 '+ \
72 'disable_file_support=1 disable_ftp_support=1 '+ \ 82 'disable_file_support=1 disable_ftp_support=1 '+ \
73 'enable_errorprone=1 use_platform_icu_alternatives=1 ' + \ 83 'enable_errorprone=1 use_platform_icu_alternatives=1 ' + \
74 'disable_brotli_filter=1"' 84 'disable_brotli_filter=1"'
75 gn_args = 'target_os="android" enable_websockets=false '+ \ 85 gn_args = 'target_os="android" enable_websockets=false '+ \
76 'disable_file_support=true disable_ftp_support=true '+ \ 86 'disable_file_support=true disable_ftp_support=true '+ \
77 'use_errorprone_java_compiler=true use_platform_icu_alternatives=true '+ \ 87 'use_errorprone_java_compiler=true use_platform_icu_alternatives=true '+ \
78 'disable_brotli_filter=true' 88 'disable_brotli_filter=true'
79 out_dir = 'out/Debug' 89 out_dir = 'out/Debug' + out_dir_suffix
80 release_arg = '' 90 release_arg = ''
81 extra_options = ' '.join(extra_options_list) 91 extra_options = ' '.join(extra_options_list)
82 if options.release: 92 if options.release:
83 out_dir = 'out/Release' 93 out_dir = 'out/Release'
84 release_arg = ' --release' 94 release_arg = ' --release'
85 gn_args += ' is_debug=false ' 95 gn_args += ' is_debug=false '
86 96
87 if (options.command=='gyp'): 97 if (options.command=='gyp'):
88 return run (gyp_defines + ' gclient runhooks') 98 return run (gyp_defines + ' gclient runhooks')
89 if (options.command=='gn'): 99 if (options.command=='gn'):
90 return run ('gn gen ' + out_dir + ' --args=\'' + gn_args + '\'') 100 return run ('gn gen ' + out_dir + ' --args=\'' + gn_args + '\'')
91 if (options.command=='sync'): 101 if (options.command=='sync'):
92 return run ('git pull --rebase && ' + gyp_defines + ' gclient sync') 102 return run ('git pull --rebase && ' + gyp_defines + ' gclient sync')
93 if (options.command=='build'): 103 if (options.command=='build'):
94 return build(out_dir, extra_options) 104 return build(out_dir, extra_options)
95 if (options.command=='install'): 105 if (options.command=='install'):
96 return install(release_arg) 106 return install(release_arg)
97 if (options.command=='proguard'): 107 if (options.command=='proguard'):
98 return run ('ninja -C ' + out_dir + ' cronet_sample_proguard_apk') 108 return run ('ninja -C ' + out_dir + ' cronet_sample_proguard_apk')
99 if (options.command=='test'): 109 if (options.command=='test' and target_os == 'android'):
100 return install(release_arg) or test(release_arg, extra_options) 110 return install(release_arg) or test(release_arg, extra_options)
111 if (options.command=='test' and target_os == 'ios'):
112 return test_ios(out_dir, extra_options)
101 if (options.command=='build-test'): 113 if (options.command=='build-test'):
102 return build(out_dir) or install(release_arg) or \ 114 return build(out_dir) or install(release_arg) or \
103 test(release_arg, extra_options) 115 test(release_arg, extra_options)
104 if (options.command=='stack'): 116 if (options.command=='stack'):
105 return stack(out_dir) 117 return stack(out_dir)
106 if (options.command=='debug'): 118 if (options.command=='debug'):
107 return install(release_arg) or debug(extra_options) 119 return install(release_arg) or debug(extra_options)
108 if (options.command=='build-debug'): 120 if (options.command=='build-debug'):
109 return build(out_dir) or install(release_arg) or debug(extra_options) 121 return build(out_dir) or install(release_arg) or debug(extra_options)
110 122
111 parser.print_help() 123 parser.print_help()
112 return 1 124 return 1
113 125
114 126
115 if __name__ == '__main__': 127 if __name__ == '__main__':
116 sys.exit(main()) 128 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698