blob: b1274c901a20102a161199a5134f3727cd8ec805 [file] [log] [blame]
Shubham Ajmerae381ffe2017-03-08 11:03:22 -08001#!/usr/bin/env python
2#
3# Copyright 2017, The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
Shubham Ajmera9c4b4f82017-03-09 10:15:49 -080017"""Build and run go/ab/git_master-art-host target
18
Igor Murashkin6228e9d2017-03-21 11:36:09 -070019This script is executed by the android build server and must not be moved,
20or changed in an otherwise backwards-incompatible manner.
21
Shubham Ajmera9c4b4f82017-03-09 10:15:49 -080022Provided with a target name, the script setup the environment for
23building the test target by taking config information from
24from target_config.py.
25
Igor Murashkin6228e9d2017-03-21 11:36:09 -070026See target_config.py for the configuration syntax.
Shubham Ajmera9c4b4f82017-03-09 10:15:49 -080027"""
28
Shubham Ajmerae381ffe2017-03-08 11:03:22 -080029import argparse
30import os
31import subprocess
Shubham Ajmera9c4b4f82017-03-09 10:15:49 -080032import sys
Shubham Ajmerae381ffe2017-03-08 11:03:22 -080033
34from target_config import target_config
35import env
36
37parser = argparse.ArgumentParser()
Shubham Ajmerae381ffe2017-03-08 11:03:22 -080038parser.add_argument('-j', default='1', dest='n_threads')
Igor Murashkin6228e9d2017-03-21 11:36:09 -070039# either -l/--list OR build-target is required (but not both).
40group = parser.add_mutually_exclusive_group(required=True)
41group.add_argument('build_target', nargs='?')
42group.add_argument('-l', '--list', action='store_true', help='List all possible run-build targets.')
Shubham Ajmerae381ffe2017-03-08 11:03:22 -080043options = parser.parse_args()
44
Igor Murashkin6228e9d2017-03-21 11:36:09 -070045##########
46
47if options.list:
48 print "List of all known build_target: "
49 for k in sorted(target_config.iterkeys()):
50 print " * " + k
51 # TODO: would be nice if this was the same order as the target config file.
52 sys.exit(1)
53
54if not target_config.get(options.build_target):
55 sys.stderr.write("error: invalid build_target, see -l/--list.\n")
56 sys.exit(1)
57
Shubham Ajmerae381ffe2017-03-08 11:03:22 -080058target = target_config[options.build_target]
59n_threads = options.n_threads
60custom_env = target.get('env', {})
61custom_env['SOONG_ALLOW_MISSING_DEPENDENCIES'] = 'true'
62print custom_env
63os.environ.update(custom_env)
64
Igor Murashkin01079c42017-04-21 13:04:27 -070065if target.has_key('make'):
Shubham Ajmerae381ffe2017-03-08 11:03:22 -080066 build_command = 'make'
67 build_command += ' -j' + str(n_threads)
68 build_command += ' -C ' + env.ANDROID_BUILD_TOP
Igor Murashkin6228e9d2017-03-21 11:36:09 -070069 build_command += ' ' + target.get('make')
Nicolas Geoffrayc4614762017-03-27 10:06:14 +010070 # Add 'dist' to avoid Jack issues b/36169180.
71 build_command += ' dist'
Igor Murashkin6228e9d2017-03-21 11:36:09 -070072 sys.stdout.write(str(build_command) + '\n')
Shubham Ajmera3092c6e2017-03-24 16:19:48 -070073 sys.stdout.flush()
Shubham Ajmerae381ffe2017-03-08 11:03:22 -080074 if subprocess.call(build_command.split()):
75 sys.exit(1)
76
Igor Murashkin01079c42017-04-21 13:04:27 -070077if target.has_key('golem'):
Igor Murashkin6228e9d2017-03-21 11:36:09 -070078 machine_type = target.get('golem')
79 # use art-opt-cc by default since it mimics the default preopt config.
80 default_golem_config = 'art-opt-cc'
81
82 os.chdir(env.ANDROID_BUILD_TOP)
83 cmd = ['art/tools/golem/build-target.sh']
84 cmd += ['-j' + str(n_threads)]
85 cmd += ['--showcommands']
86 cmd += ['--machine-type=%s' %(machine_type)]
87 cmd += ['--golem=%s' %(default_golem_config)]
88 cmd += ['--tarball']
89 sys.stdout.write(str(cmd) + '\n')
90 sys.stdout.flush()
91
92 if subprocess.call(cmd):
93 sys.exit(1)
94
Igor Murashkin01079c42017-04-21 13:04:27 -070095if target.has_key('run-test'):
Shubham Ajmerae381ffe2017-03-08 11:03:22 -080096 run_test_command = [os.path.join(env.ANDROID_BUILD_TOP,
97 'art/test/testrunner/testrunner.py')]
Igor Murashkin6228e9d2017-03-21 11:36:09 -070098 run_test_command += target.get('run-test', [])
Shubham Ajmerae381ffe2017-03-08 11:03:22 -080099 run_test_command += ['-j', str(n_threads)]
100 run_test_command += ['-b']
Shubham Ajmera9c4b4f82017-03-09 10:15:49 -0800101 run_test_command += ['--host']
Shubham Ajmerae381ffe2017-03-08 11:03:22 -0800102 run_test_command += ['--verbose']
103
Igor Murashkin6228e9d2017-03-21 11:36:09 -0700104 sys.stdout.write(str(run_test_command) + '\n')
Shubham Ajmera3092c6e2017-03-24 16:19:48 -0700105 sys.stdout.flush()
Shubham Ajmerae381ffe2017-03-08 11:03:22 -0800106 if subprocess.call(run_test_command):
107 sys.exit(1)
108
109sys.exit(0)