Update Android's test configuration for new APIs.

The upstream test runner has changed enough that the way Android was
shimmed into it was no longer compatible. This adapts our test runner
to the new APIs for cross-compiling and remote execution.

There's probably a fair amount of dead code in the Android test
runners now (or at least some code that should be made dead). I'll
clean it up in a later patch, but want to get us up and running for
now.

The NDK test runner will need to be updated as well. There aren't any
continuous runs for that, so that will be fixed in a follow up as
well.

Change-Id: I1756f538aa6c7136ebd26d1e81c8299b87f0c6b2
This commit is contained in:
Dan Albert
2015-03-04 16:03:43 -08:00
parent 490d4a2aa6
commit 5d8e4e3581
4 changed files with 173 additions and 107 deletions

View File

@@ -0,0 +1,75 @@
import os
import re
import shlex
import subprocess
import libcxx.compiler
class AndroidCXXCompiler(libcxx.compiler.CXXCompiler):
def __init__(self, cxx_under_test, cxx_template, link_template):
super(AndroidCXXCompiler, self).__init__(cxx_under_test)
self.cxx_template = cxx_template
self.link_template = link_template
self.build_top = os.getenv('ANDROID_BUILD_TOP')
def get_triple(self):
if 'clang' in self.path:
return self.get_clang_triple()
else:
return self.get_gcc_triple()
raise RuntimeError('Could not determine target triple.')
def get_clang_triple(self):
match = re.search(r'-target\s+(\S+)', self.cxx_template)
if match:
return match.group(1)
return None
def get_gcc_triple(self):
proc = subprocess.Popen([self.path, '-v'],
stderr=subprocess.PIPE)
_, stderr = proc.communicate()
for line in stderr.split('\n'):
print 'Checking {}'.format(line)
match = re.search(r'^Target: (.+)$', line)
if match:
return match.group(1)
return None
def compile(self, source_files, out=None, flags=None, env=None, cwd=None):
flags = [] if flags is None else flags
return super(AndroidCXXCompiler, self).compile(source_files, out, flags,
env, self.build_top)
def link(self, source_files, out=None, flags=None, env=None, cwd=None):
flags = [] if flags is None else flags
return super(AndroidCXXCompiler, self).link(source_files, out, flags,
env, self.build_top)
def compileCmd(self, source_files, out=None, flags=None):
if out is None:
raise RuntimeError('The Android compiler requires an out path.')
if isinstance(source_files, str):
source_files = [source_files]
cxx_args = self.cxx_template.replace('%OUT%', out)
cxx_args = cxx_args.replace('%SOURCE%', ' '.join(source_files))
return [self.path] + shlex.split(cxx_args)
def linkCmd(self, source_files, out=None, flags=None):
if out is None:
raise RuntimeError('The Android compiler requires an out path.')
if isinstance(source_files, str):
source_files = [source_files]
link_args = self.link_template.replace('%OUT%', out)
link_args = link_args.replace('%SOURCE%', ' '.join(source_files))
return [self.path] + shlex.split(link_args)
def _basicCmd(self, source_files, out, is_link=False, input_is_cxx=False):
raise NotImplementedError()
def _initTypeAndVersion(self):
pass