diff --git a/testspr/test.sh b/testspr/test.sh index 4b7d85ed..3d3661f6 100755 --- a/testspr/test.sh +++ b/testspr/test.sh @@ -29,7 +29,6 @@ compile() { ${5}/${1}-${2}/bin/${1/%cc}++ -Wall -pedantic -std=c++11 -o ${stagedir}/test_${1}${2//.} ${4} ${3} results[${1}-${2}]=$? } - execute() { if [ ${results[${1}-${2}]} -eq 0 ]; then echo "${1}-${2} compile succeeded." @@ -99,14 +98,17 @@ echo " gcc-version = (${gcc_version})" echo " clang-version = (${clang_version})" echo " gcc-root = '${gcc_root}'" echo " clang-root = '${clang_root}'" -if [ ${#user_macros[*]} -gt 0 ]; then - echo " user-macros = (${user_macros[*]})" -fi -if [ ${#include_paths[*]} -gt 0 ]; then - echo " include-paths = (${include_paths[*]})" -fi +echo " user-macros = (${user_macros[*]})" +echo " include-paths = (${include_paths[*]})" echo " force = ${force}" +for user_macro in ${user_macros}; do + define_options="${define_options} -D${user_macro}" +done +for include_path in ${include_paths}; do + include_options="${include_options} -I${include_path}" +done + if [ -d "${stagedir}" ]; then if [ ${force} -eq 0 ]; then echo >&2 "error: stagedir(${stagedir}) already exists." @@ -118,18 +120,9 @@ else mkdir -p ${stagedir} fi -for user_macro in ${user_macros}; do - define_options="${define_options} -D${user_macro}" -done - -for include_path in ${include_paths}; do - include_options="${include_options} -I${include_path}" -done - for version in ${gcc_version}; do compile gcc ${version} $(cd $(dirname $0); pwd)/sprout.cpp "${define_options} ${include_options} ${version_specific_options[gcc-${version}]}" ${gcc_root} done - for version in ${clang_version}; do compile clang ${version} $(cd $(dirname $0); pwd)/sprout.cpp "${define_options} ${include_options} ${version_specific_options[clang-${version}]}" ${clang_root} done @@ -137,7 +130,6 @@ done for version in ${gcc_version}; do execute gcc ${version} done - for version in ${clang_version}; do execute clang ${version} done diff --git a/tools/darkroom/darkcult.py b/tools/darkroom/darkcult.py index 5948856d..29004fa0 100755 --- a/tools/darkroom/darkcult.py +++ b/tools/darkroom/darkcult.py @@ -1,7 +1,13 @@ #!/usr/bin/env python - +# ============================================================================= +# Copyright (c) 2011-2013 Bolero MURAKAMI +# 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 os +import optparse import subprocess import multiprocessing @@ -10,45 +16,50 @@ def compile(command): sys.stdout.flush() return subprocess.call(command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE) -if __name__=="__main__": - argv = sys.argv - argc = len(argv) +def main(): + parser = optparse.OptionParser(description='darkcult.py') + parser.add_option('--src', type='string') + parser.add_option('--stagedir', type='string') + parser.add_option('--output', type='string') + parser.add_option('--compiler', type='string') + parser.add_option('--width', type='int') + parser.add_option('--height', type='int') + parser.add_option('--tile_width', type='int') + parser.add_option('--tile_height', type='int') + parser.add_option('--compile_options', type='string') + parser.add_option('--darkcult_cpp', type='string') + parser.add_option('--max_procs', type='int') + (opts, args) = parser.parse_args() - src = argv[1] - stagedir = argv[2] - output = argv[3] - compiler = argv[4] - width = int(argv[5]) - height = int(argv[6]) - tile_width = int(argv[7]) - tile_height = int(argv[8]) - compile_options = argv[9] - darkcult_cpp = argv[10] - max_procs = int(argv[11]) + pool = multiprocessing.Pool(opts.max_procs if opts.max_procs != 0 else None) - commands = [] - for y in range(0, height, tile_height): - for x in range(0, width, tile_width): - bin = "%s/%d/%d.out" % (stagedir, y, x) - out = "%s/%d/%d.ppm" % (stagedir, y, x) - command = "%s -o %s" \ - " %s" \ - " -DDARKROOM_SOURCE=\'\"%s\"\'" \ - " -DDARKROOM_TOTAL_WIDTH=%d -DDARKROOM_TOTAL_HEIGHT=%d" \ - " -DDARKROOM_TILE_WIDTH=%d -DDARKROOM_TILE_HEIGHT=%d" \ - " -DDARKROOM_OFFSET_X=%d -DDARKROOM_OFFSET_Y=%d" \ - " %s" \ - " && %s > %s" \ - % (compiler, bin, - compile_options, - src, - width, height, - tile_width, tile_height, - x, y, - darkcult_cpp, - bin, out + def format_command(x, y): + bin = "%s/%d/%d.out" % (opts.stagedir, y, x) + out = "%s/%d/%d.ppm" % (opts.stagedir, y, x) + return "%s -o %s" \ + " %s" \ + " -DDARKROOM_SOURCE=\'\"%s\"\'" \ + " -DDARKROOM_TOTAL_WIDTH=%d -DDARKROOM_TOTAL_HEIGHT=%d" \ + " -DDARKROOM_TILE_WIDTH=%d -DDARKROOM_TILE_HEIGHT=%d" \ + " -DDARKROOM_OFFSET_X=%d -DDARKROOM_OFFSET_Y=%d" \ + " %s" \ + " && %s > %s" \ + % (opts.compiler, bin, + opts.compile_options, + opts.src, + opts.width, opts.height, + opts.tile_width, opts.tile_height, + x, y, + opts.darkcult_cpp, + bin, out ) - commands.append(command); + return any(pool.map( + compile, + [format_command(x, y) + for x in range(0, opts.width, opts.tile_width) + for y in range(0, opts.height, opts.tile_height) + ] + )) - pool = multiprocessing.Pool(max_procs) - sys.exit(any(pool.map(compile, commands))) +if __name__=="__main__": + sys.exit(main()) diff --git a/tools/darkroom/darkcult.sh b/tools/darkroom/darkcult.sh index 1912ed26..19f01a16 100755 --- a/tools/darkroom/darkcult.sh +++ b/tools/darkroom/darkcult.sh @@ -8,6 +8,7 @@ # ============================================================================= # # requires: Netpbm (http://netpbm.sourceforge.net/) +# requires: Python (http://www.python.org/) if parallel mode # src="../../example/darkroom/two_spheres.hpp" stagedir="darkroom" @@ -85,6 +86,8 @@ if [ ${use_help} -ne 0 ]; then echo " -I, --include=