Home | History | Annotate | Download | only in clients
      1 #!/usr/bin/python
      2 #
      3 # Copyright 2011 Google Inc. All Rights Reserved.
      4 """Client for Android nightly jobs.
      5 
      6 Does the following jobs:
      7   1. Checkout android toolchain sources
      8   2. Build Android toolchain
      9   3. Build Android tree
     10   4. Checkout/build/run Android benchmarks (TODO)
     11   5. Generate size/performance dashboard ? (TODO)
     12 """
     13 
     14 __author__ = 'jingyu (at] google.com (Jing Yu)'
     15 
     16 import optparse
     17 import pickle
     18 import sys
     19 import xmlrpclib
     20 
     21 from automation.clients.helper import android
     22 from automation.common import job_group
     23 from automation.common import logger
     24 
     25 
     26 class AndroidToolchainNightlyClient(object):
     27   VALID_GCC_VERSIONS = ['4.4.3', '4.6', 'google_main', 'fsf_trunk']
     28 
     29   def __init__(self, gcc_version, is_release):
     30     assert gcc_version in self.VALID_GCC_VERSIONS
     31     self.gcc_version = gcc_version
     32     if is_release:
     33       self.build_type = 'RELEASE'
     34     else:
     35       self.build_type = 'DEVELOPMENT'
     36 
     37   def Run(self):
     38     server = xmlrpclib.Server('http://localhost:8000')
     39     server.ExecuteJobGroup(pickle.dumps(self.CreateJobGroup()))
     40 
     41   def CreateJobGroup(self):
     42     factory = android.JobsFactory(self.gcc_version, self.build_type)
     43 
     44     p4_androidtc_job, checkout_dir_dep = factory.CheckoutAndroidToolchain()
     45 
     46     tc_build_job, tc_prefix_dep = factory.BuildAndroidToolchain(
     47         checkout_dir_dep)
     48 
     49     tree_build_job = factory.BuildAndroidImage(tc_prefix_dep)
     50 
     51     benchmark_job = factory.Benchmark(tc_prefix_dep)
     52 
     53     all_jobs = [p4_androidtc_job, tc_build_job, tree_build_job, benchmark_job]
     54 
     55     return job_group.JobGroup('androidtoolchain_nightly', all_jobs, True, False)
     56 
     57 
     58 @logger.HandleUncaughtExceptions
     59 def Main(argv):
     60   valid_gcc_versions_string = ', '.join(
     61       AndroidToolchainNightlyClient.VALID_GCC_VERSIONS)
     62 
     63   parser = optparse.OptionParser()
     64   parser.add_option('--with-gcc-version',
     65                     dest='gcc_version',
     66                     default='4.6',
     67                     action='store',
     68                     choices=AndroidToolchainNightlyClient.VALID_GCC_VERSIONS,
     69                     help='gcc version: %s.' % valid_gcc_versions_string)
     70   parser.add_option('-r',
     71                     '--release',
     72                     dest='is_release',
     73                     default=False,
     74                     action='store_true',
     75                     help='Build a release toolchain?')
     76   options, _ = parser.parse_args(argv)
     77 
     78   option_list = [opt.dest for opt in parser.option_list if opt.dest]
     79 
     80   kwargs = dict((option, getattr(options, option)) for option in option_list)
     81 
     82   client = AndroidToolchainNightlyClient(**kwargs)
     83   client.Run()
     84 
     85 
     86 if __name__ == '__main__':
     87   Main(sys.argv)
     88