mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +00:00
[tools.darkcult] fix help message.
This commit is contained in:
parent
429aab2ac2
commit
6a58eade0e
3 changed files with 84 additions and 87 deletions
|
@ -29,7 +29,6 @@ compile() {
|
||||||
${5}/${1}-${2}/bin/${1/%cc}++ -Wall -pedantic -std=c++11 -o ${stagedir}/test_${1}${2//.} ${4} ${3}
|
${5}/${1}-${2}/bin/${1/%cc}++ -Wall -pedantic -std=c++11 -o ${stagedir}/test_${1}${2//.} ${4} ${3}
|
||||||
results[${1}-${2}]=$?
|
results[${1}-${2}]=$?
|
||||||
}
|
}
|
||||||
|
|
||||||
execute() {
|
execute() {
|
||||||
if [ ${results[${1}-${2}]} -eq 0 ]; then
|
if [ ${results[${1}-${2}]} -eq 0 ]; then
|
||||||
echo "${1}-${2} compile succeeded."
|
echo "${1}-${2} compile succeeded."
|
||||||
|
@ -99,14 +98,17 @@ echo " gcc-version = (${gcc_version})"
|
||||||
echo " clang-version = (${clang_version})"
|
echo " clang-version = (${clang_version})"
|
||||||
echo " gcc-root = '${gcc_root}'"
|
echo " gcc-root = '${gcc_root}'"
|
||||||
echo " clang-root = '${clang_root}'"
|
echo " clang-root = '${clang_root}'"
|
||||||
if [ ${#user_macros[*]} -gt 0 ]; then
|
echo " user-macros = (${user_macros[*]})"
|
||||||
echo " user-macros = (${user_macros[*]})"
|
echo " include-paths = (${include_paths[*]})"
|
||||||
fi
|
|
||||||
if [ ${#include_paths[*]} -gt 0 ]; then
|
|
||||||
echo " include-paths = (${include_paths[*]})"
|
|
||||||
fi
|
|
||||||
echo " force = ${force}"
|
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 [ -d "${stagedir}" ]; then
|
||||||
if [ ${force} -eq 0 ]; then
|
if [ ${force} -eq 0 ]; then
|
||||||
echo >&2 "error: stagedir(${stagedir}) already exists."
|
echo >&2 "error: stagedir(${stagedir}) already exists."
|
||||||
|
@ -118,18 +120,9 @@ else
|
||||||
mkdir -p ${stagedir}
|
mkdir -p ${stagedir}
|
||||||
fi
|
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
|
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}
|
compile gcc ${version} $(cd $(dirname $0); pwd)/sprout.cpp "${define_options} ${include_options} ${version_specific_options[gcc-${version}]}" ${gcc_root}
|
||||||
done
|
done
|
||||||
|
|
||||||
for version in ${clang_version}; do
|
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}
|
compile clang ${version} $(cd $(dirname $0); pwd)/sprout.cpp "${define_options} ${include_options} ${version_specific_options[clang-${version}]}" ${clang_root}
|
||||||
done
|
done
|
||||||
|
@ -137,7 +130,6 @@ done
|
||||||
for version in ${gcc_version}; do
|
for version in ${gcc_version}; do
|
||||||
execute gcc ${version}
|
execute gcc ${version}
|
||||||
done
|
done
|
||||||
|
|
||||||
for version in ${clang_version}; do
|
for version in ${clang_version}; do
|
||||||
execute clang ${version}
|
execute clang ${version}
|
||||||
done
|
done
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
#!/usr/bin/env python
|
#!/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 sys
|
||||||
import os
|
import optparse
|
||||||
import subprocess
|
import subprocess
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
|
||||||
|
@ -10,45 +16,50 @@ def compile(command):
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
return subprocess.call(command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
return subprocess.call(command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||||
|
|
||||||
if __name__=="__main__":
|
def main():
|
||||||
argv = sys.argv
|
parser = optparse.OptionParser(description='darkcult.py')
|
||||||
argc = len(argv)
|
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]
|
pool = multiprocessing.Pool(opts.max_procs if opts.max_procs != 0 else None)
|
||||||
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])
|
|
||||||
|
|
||||||
commands = []
|
def format_command(x, y):
|
||||||
for y in range(0, height, tile_height):
|
bin = "%s/%d/%d.out" % (opts.stagedir, y, x)
|
||||||
for x in range(0, width, tile_width):
|
out = "%s/%d/%d.ppm" % (opts.stagedir, y, x)
|
||||||
bin = "%s/%d/%d.out" % (stagedir, y, x)
|
return "%s -o %s" \
|
||||||
out = "%s/%d/%d.ppm" % (stagedir, y, x)
|
" %s" \
|
||||||
command = "%s -o %s" \
|
" -DDARKROOM_SOURCE=\'\"%s\"\'" \
|
||||||
" %s" \
|
" -DDARKROOM_TOTAL_WIDTH=%d -DDARKROOM_TOTAL_HEIGHT=%d" \
|
||||||
" -DDARKROOM_SOURCE=\'\"%s\"\'" \
|
" -DDARKROOM_TILE_WIDTH=%d -DDARKROOM_TILE_HEIGHT=%d" \
|
||||||
" -DDARKROOM_TOTAL_WIDTH=%d -DDARKROOM_TOTAL_HEIGHT=%d" \
|
" -DDARKROOM_OFFSET_X=%d -DDARKROOM_OFFSET_Y=%d" \
|
||||||
" -DDARKROOM_TILE_WIDTH=%d -DDARKROOM_TILE_HEIGHT=%d" \
|
" %s" \
|
||||||
" -DDARKROOM_OFFSET_X=%d -DDARKROOM_OFFSET_Y=%d" \
|
" && %s > %s" \
|
||||||
" %s" \
|
% (opts.compiler, bin,
|
||||||
" && %s > %s" \
|
opts.compile_options,
|
||||||
% (compiler, bin,
|
opts.src,
|
||||||
compile_options,
|
opts.width, opts.height,
|
||||||
src,
|
opts.tile_width, opts.tile_height,
|
||||||
width, height,
|
x, y,
|
||||||
tile_width, tile_height,
|
opts.darkcult_cpp,
|
||||||
x, y,
|
bin, out
|
||||||
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)
|
if __name__=="__main__":
|
||||||
sys.exit(any(pool.map(compile, commands)))
|
sys.exit(main())
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
#
|
#
|
||||||
# requires: Netpbm (http://netpbm.sourceforge.net/)
|
# requires: Netpbm (http://netpbm.sourceforge.net/)
|
||||||
|
# requires: Python (http://www.python.org/) if parallel mode
|
||||||
#
|
#
|
||||||
src="../../example/darkroom/two_spheres.hpp"
|
src="../../example/darkroom/two_spheres.hpp"
|
||||||
stagedir="darkroom"
|
stagedir="darkroom"
|
||||||
|
@ -85,6 +86,8 @@ if [ ${use_help} -ne 0 ]; then
|
||||||
echo " -I, --include=<dir> Add system include path."
|
echo " -I, --include=<dir> Add system include path."
|
||||||
echo ""
|
echo ""
|
||||||
echo " -P, --max-procs=<value> The maximum number of process use."
|
echo " -P, --max-procs=<value> The maximum number of process use."
|
||||||
|
echo " If other than 1, processing in parallel mode."
|
||||||
|
echo " If 0, using the number of CPUs in the system."
|
||||||
echo " Default; 1"
|
echo " Default; 1"
|
||||||
echo ""
|
echo ""
|
||||||
echo " -f, --force Allow overwrite of <stagedir>."
|
echo " -f, --force Allow overwrite of <stagedir>."
|
||||||
|
@ -102,12 +105,8 @@ echo " width = ${width}"
|
||||||
echo " height = ${height}"
|
echo " height = ${height}"
|
||||||
echo " tile-width = ${tile_width}"
|
echo " tile-width = ${tile_width}"
|
||||||
echo " tile-height = ${tile_height}"
|
echo " tile-height = ${tile_height}"
|
||||||
if [ ${#user_macros[*]} -gt 0 ]; then
|
echo " user-macros = (${user_macros[*]})"
|
||||||
echo " user-macros = (${user_macros[*]})"
|
echo " include-paths = (${include_paths[*]})"
|
||||||
fi
|
|
||||||
if [ ${#include_paths[*]} -gt 0 ]; then
|
|
||||||
echo " include-paths = (${include_paths[*]})"
|
|
||||||
fi
|
|
||||||
echo " max-procs = ${max_procs}"
|
echo " max-procs = ${max_procs}"
|
||||||
echo " force = ${force}"
|
echo " force = ${force}"
|
||||||
|
|
||||||
|
@ -116,6 +115,14 @@ if [ ! -f "${src}" -a ! -f "$(cd $(dirname $0); pwd)/${src}" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
||||||
|
compile_options="-std=c++11 ${define_options} ${include_options}"
|
||||||
|
|
||||||
if [ -d "${stagedir}" ]; then
|
if [ -d "${stagedir}" ]; then
|
||||||
if [ ${force} -eq 0 ]; then
|
if [ ${force} -eq 0 ]; then
|
||||||
echo >&2 "error: stagedir(${stagedir}) already exists."
|
echo >&2 "error: stagedir(${stagedir}) already exists."
|
||||||
|
@ -126,21 +133,10 @@ if [ -d "${stagedir}" ]; then
|
||||||
else
|
else
|
||||||
mkdir -p ${stagedir}
|
mkdir -p ${stagedir}
|
||||||
fi
|
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 ((y=0; y<height; y+=tile_height)); do
|
for ((y=0; y<height; y+=tile_height)); do
|
||||||
mkdir -p ${stagedir}/${y}/
|
mkdir -p ${stagedir}/${y}/
|
||||||
done
|
done
|
||||||
|
|
||||||
compile_options="-std=c++11 ${define_options} ${include_options}"
|
|
||||||
|
|
||||||
echo "rendering:"
|
echo "rendering:"
|
||||||
start=${SECONDS}
|
start=${SECONDS}
|
||||||
|
|
||||||
|
@ -151,22 +147,22 @@ if [ ${max_procs} -eq 1 ]; then
|
||||||
|
|
||||||
echo -n " x = "
|
echo -n " x = "
|
||||||
for ((x=0; x<width; x+=tile_width)); do
|
for ((x=0; x<width; x+=tile_width)); do
|
||||||
echo -n "(${x}/${height})..."
|
echo -n "(${x}/${height})."
|
||||||
binname=${y}/${x}.out
|
bin=${stagedir}/${y}/${x}.out
|
||||||
bin=${stagedir}/${binname}
|
out=${stagedir}/${y}/${x}.ppm
|
||||||
${compiler} -o ${bin} \
|
${compiler} -o ${bin} \
|
||||||
${compile_options} \
|
${compile_options} \
|
||||||
-DDARKROOM_SOURCE="\"${src}\"" \
|
-DDARKROOM_SOURCE="\"${src}\"" \
|
||||||
-DDARKROOM_TOTAL_WIDTH=${width} -DDARKROOM_TOTAL_HEIGHT=${height} \
|
-DDARKROOM_TOTAL_WIDTH=${width} -DDARKROOM_TOTAL_HEIGHT=${height} \
|
||||||
-DDARKROOM_TILE_WIDTH=${tile_width} -DDARKROOM_TILE_HEIGHT=${tile_height} \
|
-DDARKROOM_TILE_WIDTH=${tile_width} -DDARKROOM_TILE_HEIGHT=${tile_height} \
|
||||||
-DDARKROOM_OFFSET_X=${x} -DDARKROOM_OFFSET_Y=${y} \
|
-DDARKROOM_OFFSET_X=${x} -DDARKROOM_OFFSET_Y=${y} \
|
||||||
${darkcult_cpp}
|
${darkcult_cpp} \
|
||||||
|
&& ${bin} > ${out}
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo ""
|
echo ""
|
||||||
echo >&2 "error: compile(${binname}) failed."
|
echo >&2 "error: compile(${y}/${x}) failed."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
${bin} > ${stagedir}/${y}/${x}.ppm
|
|
||||||
done
|
done
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
@ -177,11 +173,11 @@ else
|
||||||
echo " processing in parallel mode."
|
echo " processing in parallel mode."
|
||||||
echo -n " "
|
echo -n " "
|
||||||
python "${darkcult_py}" \
|
python "${darkcult_py}" \
|
||||||
"${src}" "${stagedir}" "${output}" "${compiler}" \
|
"--src=${src}" "--stagedir=${stagedir}" "--output=${output}" "--compiler=${compiler}" \
|
||||||
"${width}" "${height}" \
|
"--width=${width}" "--height=${height}" \
|
||||||
"${tile_width}" "${tile_height}" \
|
"--tile_width=${tile_width}" "--tile_height=${tile_height}"" "\
|
||||||
"${compile_options}" "${darkcult_cpp}" \
|
"--compile_options=${compile_options}" "--darkcult_cpp=${darkcult_cpp}" \
|
||||||
"${max_procs}"
|
"--max_procs=${max_procs}"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo ""
|
echo ""
|
||||||
echo >&2 "error: compile failed."
|
echo >&2 "error: compile failed."
|
||||||
|
@ -195,12 +191,10 @@ echo " elapsed(total) = ${elapsed}s"
|
||||||
|
|
||||||
for ((y=0; y<height; y+=tile_height)); do
|
for ((y=0; y<height; y+=tile_height)); do
|
||||||
pushd ${stagedir}/${y}/ > /dev/null
|
pushd ${stagedir}/${y}/ > /dev/null
|
||||||
# convert +append $(ls *.ppm | sort -n) ../${y}.ppm
|
|
||||||
pnmcat -lr $(ls *.ppm | sort -n) > ../${y}.ppm
|
pnmcat -lr $(ls *.ppm | sort -n) > ../${y}.ppm
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
done
|
done
|
||||||
pushd ${stagedir} > /dev/null
|
pushd ${stagedir} > /dev/null
|
||||||
#convert -append $(ls *.ppm | sort -n) ${output}
|
|
||||||
pnmcat -tb $(ls *.ppm | sort -n) > ${output}
|
pnmcat -tb $(ls *.ppm | sort -n) > ${output}
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue