1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-02-25 21:43:57 +00:00

fix bashscript: output message

This commit is contained in:
bolero-MURAKAMI 2013-09-23 20:53:01 +09:00
parent 940d0f97c8
commit 6d5bc5762c
2 changed files with 21 additions and 10 deletions

View file

@ -63,7 +63,7 @@ if [ ${use_help} -ne 0 ]; then
echo "help:" echo "help:"
echo "" echo ""
echo " -S, --stagedir=<directory> Output files here." echo " -S, --stagedir=<directory> Output files here."
echo " Default; testspr" echo " Default; 'testspr'"
echo "" echo ""
echo " --gcc-version=<value> Indicates gcc version." echo " --gcc-version=<value> Indicates gcc version."
echo " Default; 4.7.0 4.7.1 4.7.2 4.7.3 4.8.0 4.8.1" echo " Default; 4.7.0 4.7.1 4.7.2 4.7.3 4.8.0 4.8.1"

View file

@ -11,6 +11,7 @@
# #
src="../../example/darkroom/two_spheres.hpp" src="../../example/darkroom/two_spheres.hpp"
stagedir="darkroom" stagedir="darkroom"
output="out.ppm"
width=16 width=16
height=16 height=16
tile_width=16 tile_width=16
@ -22,7 +23,7 @@ include_paths=()
force=0 force=0
use_help=0 use_help=0
args=`getopt -o s:S:w:h:W:H:D:I:f -l source:,stagedir:,width:,height:,tile-width:,tile-height:,define:,include:,force,help -- "$@"` args=`getopt -o s:S:o:w:h:W:H:D:I:f -l source:,stagedir:,output:,width:,height:,tile-width:,tile-height:,define:,include:,force,help -- "$@"`
if [ "$?" -ne 0 ]; then if [ "$?" -ne 0 ]; then
echo >&2 "error: options parse error. see 'darkcult.sh --help'" echo >&2 "error: options parse error. see 'darkcult.sh --help'"
exit 1 exit 1
@ -32,6 +33,7 @@ while [ -n "$1" ]; do
case $1 in case $1 in
-s|--source) src=$2; shift 2;; -s|--source) src=$2; shift 2;;
-S|--stagedir) stagedir=$2; shift 2;; -S|--stagedir) stagedir=$2; shift 2;;
-o|--output) output=$2; shift 2;;
-w|--width) width=$2; shift 2;; -w|--width) width=$2; shift 2;;
-h|--height) height=$2; shift 2;; -h|--height) height=$2; shift 2;;
-W|--tile-width) tile_width=$2; shift 2;; -W|--tile-width) tile_width=$2; shift 2;;
@ -49,9 +51,13 @@ if [ ${use_help} -ne 0 ]; then
echo "help:" echo "help:"
echo "" echo ""
echo " -s, --source=<file> Indicates the source file." echo " -s, --source=<file> Indicates the source file."
echo " Default; '../../example/darkroom/two_spheres.hpp'"
echo "" echo ""
echo " -S, --stagedir=<directory> Output files here." echo " -S, --stagedir=<directory> Output files here."
echo " Default; darkroom" echo " Default; 'darkroom'"
echo ""
echo " -o, --output=<file> Output file of the result."
echo " Default; 'out.ppm'"
echo "" echo ""
echo " -w, --width=<value> Output width of rendering." echo " -w, --width=<value> Output width of rendering."
echo " Default; 16" echo " Default; 16"
@ -78,6 +84,7 @@ fi
echo "settings:" echo "settings:"
echo " source = \"${src}\"" echo " source = \"${src}\""
echo " stagedir = \"${stagedir}\"" echo " stagedir = \"${stagedir}\""
echo " output = \"${output}\""
echo " width = ${width}" echo " width = ${width}"
echo " height = ${height}" echo " height = ${height}"
echo " tile-width = ${tile_width}" echo " tile-width = ${tile_width}"
@ -114,15 +121,17 @@ for include_path in ${include_paths}; do
include_options="${include_options} -I${include_path}" include_options="${include_options} -I${include_path}"
done done
echo "start." echo "rendering:"
start=${SECONDS} start=${SECONDS}
for ((y=0; y<height; y+=tile_height)); do for ((y=0; y<height; y+=tile_height)); do
echo "rendering(${y}/${height})..." echo " y = (${y}/${height})..."
y_start=${SECONDS} y_start=${SECONDS}
mkdir -p ${stagedir}/${y}/
echo -n " x = "
for ((x=0; x<width; x+=tile_width)); do for ((x=0; x<width; x+=tile_width)); do
mkdir -p ${stagedir}/${y}/ echo -n "(${x}/${height})..."
binname=${stagedir}/${y}/${x}.out binname=${stagedir}/${y}/${x}.out
g++ -o ${binname} -std=c++11 \ g++ -o ${binname} -std=c++11 \
${define_options} ${include_options} \ ${define_options} ${include_options} \
@ -135,19 +144,21 @@ for ((y=0; y<height; y+=tile_height)); do
-DDARKROOM_OFFSET_Y=${y} \ -DDARKROOM_OFFSET_Y=${y} \
$(cd $(dirname $0); pwd)/darkcult.cpp && ${binname} > ${stagedir}/${y}/${x}.ppm $(cd $(dirname $0); pwd)/darkcult.cpp && ${binname} > ${stagedir}/${y}/${x}.ppm
done done
echo ""
pushd ${stagedir}/${y}/ > /dev/null pushd ${stagedir}/${y}/ > /dev/null
# convert +append $(ls *.ppm | sort -n) ../${y}.ppm # 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
let "y_elapsed=${SECONDS}-${y_start}" let "y_elapsed=${SECONDS}-${y_start}"
echo " elapsed = ${y_elapsed}s" echo " elapsed = ${y_elapsed}s"
done done
pushd ${stagedir} > /dev/null pushd ${stagedir} > /dev/null
#convert -append $(ls *.ppm | sort -n) out.ppm #convert -append $(ls *.ppm | sort -n) ${output}
pnmcat -tb $(ls *.ppm | sort -n) > out.ppm pnmcat -tb $(ls *.ppm | sort -n) > ${output}
popd > /dev/null popd > /dev/null
let "elapsed=${SECONDS}-${start}" let "elapsed=${SECONDS}-${start}"
echo "elapsed(total) = ${elapsed}s" echo " elapsed(total) = ${elapsed}s"
echo "finished." echo "finished."