2013-09-26 13:43:57 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# =============================================================================
|
2014-01-11 14:23:00 +00:00
|
|
|
# Copyright (c) 2011-2014 Bolero MURAKAMI
|
2013-09-26 13:43:57 +00:00
|
|
|
# https://github.com/bolero-MURAKAMI/Sprout
|
|
|
|
#
|
|
|
|
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
# =============================================================================
|
|
|
|
import sys
|
|
|
|
import optparse
|
|
|
|
import subprocess
|
|
|
|
import multiprocessing
|
|
|
|
|
2013-09-29 05:47:04 +00:00
|
|
|
def build(command):
|
2013-09-26 13:43:57 +00:00
|
|
|
sys.stdout.write(".")
|
|
|
|
sys.stdout.flush()
|
|
|
|
return subprocess.call(command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
|
|
|
|
|
|
|
def main():
|
|
|
|
parser = optparse.OptionParser(description='test.py')
|
2013-09-29 05:47:04 +00:00
|
|
|
parser.add_option('--stagedir', type='string', default='testspr')
|
|
|
|
parser.add_option('--gcc_version', type='string', default='.')
|
|
|
|
parser.add_option('--clang_version', type='string', default='.')
|
|
|
|
parser.add_option('--gcc_root', type='string', default='/usr/local')
|
|
|
|
parser.add_option('--clang_root', type='string', default='/usr/local')
|
2014-01-11 11:27:55 +00:00
|
|
|
parser.add_option('--all_options', type='string', default='')
|
2013-09-26 13:43:57 +00:00
|
|
|
parser.add_option('--test_cpp', type='string')
|
2013-10-08 16:03:36 +00:00
|
|
|
parser.add_option('--serialized_std_options', type='string', default='{}')
|
2014-01-11 11:27:55 +00:00
|
|
|
parser.add_option('--serialized_compiler_specific_options', type='string', default='{}')
|
2013-09-29 05:47:04 +00:00
|
|
|
parser.add_option('--serialized_version_specific_options', type='string', default='{}')
|
|
|
|
parser.add_option('--max_procs', type='int', default=0)
|
2013-09-26 13:43:57 +00:00
|
|
|
(opts, args) = parser.parse_args()
|
|
|
|
|
2013-10-09 07:14:41 +00:00
|
|
|
std_options = eval(opts.serialized_std_options)
|
|
|
|
version_specific_options = eval(opts.serialized_version_specific_options)
|
2014-01-11 11:27:55 +00:00
|
|
|
compiler_specific_options = eval(opts.serialized_compiler_specific_options)
|
2013-10-09 07:14:41 +00:00
|
|
|
|
2013-09-26 13:43:57 +00:00
|
|
|
def format_command(name, version, root):
|
|
|
|
base = "%s-%s" % (name, version) if version != "." else name
|
|
|
|
bin = "%s/test.%s.out" % (opts.stagedir, base.replace('.', ''))
|
|
|
|
compile_log = "%s/test.%s.compile.log" % (opts.stagedir, base.replace('.', ''))
|
|
|
|
execute_log = "%s/test.%s.execute.log" % (opts.stagedir, base.replace('.', ''))
|
|
|
|
compiler = "%s/%s/bin/%s++" % (root, base, name.rstrip('c')) if version != "." else "%s++" % name.rstrip('c')
|
|
|
|
return "%s -o %s" \
|
2014-01-11 11:27:55 +00:00
|
|
|
" %s %s" \
|
|
|
|
" %s %s" \
|
2013-09-26 13:43:57 +00:00
|
|
|
" %s > %s 2>&1" \
|
|
|
|
" && %s > %s 2>&1" \
|
|
|
|
% (compiler, bin,
|
2014-01-11 11:27:55 +00:00
|
|
|
std_options.get(base, ''), opts.all_options,
|
|
|
|
compiler_specific_options.get(name, ''), version_specific_options.get(base, ''),
|
2013-09-26 13:43:57 +00:00
|
|
|
opts.test_cpp, compile_log,
|
|
|
|
bin, execute_log
|
|
|
|
)
|
2013-09-29 05:47:04 +00:00
|
|
|
|
|
|
|
pool = multiprocessing.Pool(opts.max_procs if opts.max_procs != 0 else None)
|
2013-09-26 13:43:57 +00:00
|
|
|
return sum(result != 0 for result in pool.map(
|
2013-09-29 05:47:04 +00:00
|
|
|
build,
|
2014-01-14 03:39:07 +00:00
|
|
|
([format_command('gcc', version, opts.gcc_root)
|
2013-09-26 13:43:57 +00:00
|
|
|
for version in opts.gcc_version.split(' ')
|
2014-01-11 11:27:55 +00:00
|
|
|
] if opts.gcc_version != ' '
|
|
|
|
else []
|
2014-01-14 03:39:07 +00:00
|
|
|
)
|
2013-09-26 13:43:57 +00:00
|
|
|
+
|
2014-01-14 03:39:07 +00:00
|
|
|
([format_command('clang', version, opts.clang_root)
|
2013-09-26 13:43:57 +00:00
|
|
|
for version in opts.clang_version.split(' ')
|
2014-01-11 11:27:55 +00:00
|
|
|
] if opts.clang_version != ' '
|
|
|
|
else []
|
2014-01-14 03:39:07 +00:00
|
|
|
)
|
2013-09-26 13:43:57 +00:00
|
|
|
))
|
|
|
|
|
2013-09-30 00:36:56 +00:00
|
|
|
if __name__ == "__main__":
|
2013-09-26 13:43:57 +00:00
|
|
|
sys.exit(main())
|