1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-08-03 12:49:50 +00:00

[tools.darkcult] add enable break/continue mode option -c|--continuable

This commit is contained in:
bolero-MURAKAMI 2013-09-29 14:47:04 +09:00
parent 4f477dd0dc
commit e56429ad0a
4 changed files with 157 additions and 54 deletions

View file

@ -11,26 +11,24 @@ import optparse
import subprocess
import multiprocessing
def compile(command):
def build(command):
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')
parser.add_option('--stagedir', type='string')
parser.add_option('--gcc_version', type='string')
parser.add_option('--clang_version', type='string')
parser.add_option('--gcc_root', type='string')
parser.add_option('--clang_root', type='string')
parser.add_option('--compile_options', type='string')
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')
parser.add_option('--compile_options', type='string', default='')
parser.add_option('--test_cpp', type='string')
parser.add_option('--serialized_version_specific_options', type='string')
parser.add_option('--max_procs', type='int')
parser.add_option('--serialized_version_specific_options', type='string', default='{}')
parser.add_option('--max_procs', type='int', default=0)
(opts, args) = parser.parse_args()
pool = multiprocessing.Pool(opts.max_procs if opts.max_procs != 0 else None)
def format_command(name, version, root):
base = "%s-%s" % (name, version) if version != "." else name
bin = "%s/test.%s.out" % (opts.stagedir, base.replace('.', ''))
@ -46,8 +44,10 @@ def main():
opts.test_cpp, compile_log,
bin, execute_log
)
pool = multiprocessing.Pool(opts.max_procs if opts.max_procs != 0 else None)
return sum(result != 0 for result in pool.map(
compile,
build,
[format_command('gcc', version, opts.gcc_root)
for version in opts.gcc_version.split(' ')
]

View file

@ -16,7 +16,7 @@ gcc_root="/usr/local"
clang_root="/usr/local"
declare -a user_macros=()
declare -a include_paths=()
max_procs=1
max_procs=
force=0
use_help=0
declare -a common_options=()
@ -27,7 +27,7 @@ declare -A version_specific_options=(
test_cpp=$(cd $(dirname $0); pwd)/test.cpp
test_py=$(cd $(dirname $0); pwd)/test.py
args=`getopt -o S:g:c:O:o:D:I:P:f -l stagedir:,gcc-version:,clang-version:,gcc-root:,clang-root:,option:,version-option:,define:,include:,max-procs:,force,help -- "$@"`
args=`getopt -o S:g:c:O:V:D:I:P:f -l stagedir:,gcc-version:,clang-version:,gcc-root:,clang-root:,option:,version-option:,define:,include:,max-procs:,force,help -- "$@"`
if [ "$?" -ne 0 ]; then
echo >&2 "error: options parse error. See 'test.sh --help'"
exit 1
@ -41,7 +41,7 @@ while [ -n "$1" ]; do
--gcc-root) gcc_root="$2"; shift 2;;
--clang-root) clang_root="$2"; shift 2;;
-O|--option) common_options=(${common_options[@]} "$2"); shift 2;;
-o|--version-option) version_options=(${version_options[@]} "$2"); shift 2;;
-V|--version-option) version_options=(${version_options[@]} "$2"); shift 2;;
-D|--define) user_macros=(${user_macros[@]} "$2"); shift 2;;
-I|--include) include_paths=(${include_paths[@]} "$2"); shift 2;;
-P|--max-procs) max_procs=$2; shift 2;;
@ -74,7 +74,7 @@ if [ ${use_help} -ne 0 ]; then
echo ""
echo " -O, --option=<opt> Add compile option."
echo ""
echo " -o, --version-option=<opt> Add version specific compile option."
echo " -V, --version-option=<opt> Add version specific compile option."
echo " Example; [clang-3.3]='-ftemplate-depth=512'"
echo ""
echo " -D, --define=<identifier> Define macro for preprocessor."
@ -82,9 +82,8 @@ if [ ${use_help} -ne 0 ]; then
echo " -I, --include=<directory> Add system include path."
echo ""
echo " -P, --max-procs=<value> The maximum number of process use."
echo " If other than 1, processing in parallel mode."
echo " If other than null, processing in parallel mode."
echo " If 0, using the number of CPUs in the system."
echo " Default; 1"
echo ""
echo " -f, --force Allow overwrite of <stagedir>."
echo ""
@ -162,7 +161,7 @@ compile() {
fi
return 0
}
if [ ${max_procs} -eq 1 ]; then
if [ -z "${max_procs}" ]; then
fail_count=0
for version in ${gcc_version}; do
compile gcc ${version} ${test_cpp} ${compile_options} ${version_specific_options} ${gcc_root}