1#!/usr/bin/python 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 4# found in the LICENSE file. 5 6""" 7cr_cronet.py - cr - like helper tool for cronet developers 8""" 9 10import argparse 11import os 12import sys 13 14def run(command): 15 print command 16 return os.system(command) 17 18def main(): 19 parser = argparse.ArgumentParser() 20 parser.add_argument('command', 21 choices=['gyp', 22 'sync', 23 'build', 24 'install', 25 'proguard', 26 'test', 27 'debug']) 28 parser.add_argument('-r', '--release', action='store_true', 29 help='use release configuration') 30 31 options = parser.parse_args() 32 print options 33 gyp_defines = 'GYP_DEFINES="OS=android enable_websockets=0 '+ \ 34 'disable_file_support=1 disable_ftp_support=1 '+ \ 35 'use_icu_alternatives_on_android=1" ' 36 out_dir = 'out/Debug' 37 release_arg = '' 38 if options.release: 39 out_dir = 'out/Release' 40 release_arg = ' --release' 41 42 if (options.command=='gyp'): 43 return run (gyp_defines + ' gclient runhooks') 44 if (options.command=='sync'): 45 return run ('git pull --rebase && ' + gyp_defines + ' gclient sync') 46 if (options.command=='build'): 47 return run ('ninja -C ' + out_dir + ' cronet_test_instrumentation_apk') 48 if (options.command=='install'): 49 return run ('build/android/adb_install_apk.py ' + release_arg + \ 50 ' --apk=CronetTest.apk') 51 if (options.command=='proguard'): 52 return run ('ninja -C ' + out_dir + ' cronet_sample_proguard_apk') 53 if (options.command=='test'): 54 return run ('build/android/test_runner.py instrumentation '+ \ 55 release_arg + ' --test-apk=CronetTestInstrumentation') 56 57 parser.print_help() 58 return 1 59 60 61if __name__ == '__main__': 62 sys.exit(main()) 63