Skip to content

Commit

Permalink
darkcult: add --runtime mode
Browse files Browse the repository at this point in the history
  • Loading branch information
bolero-MURAKAMI committed Feb 20, 2014
1 parent bf0f36d commit 06bd554
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
8 changes: 4 additions & 4 deletions example/inv_fizzbuzz/main.cpp
Expand Up @@ -14,7 +14,7 @@
#include <sprout/range/algorithm.hpp>
#include <sprout/range/adaptor.hpp>

static constexpr auto token_table = sprout::to_string_array<sprout::string<8> >(
static constexpr auto token_table = sprout::make_array<sprout::string<8> >(
"Fizz", "Buzz", "Fizz", "Fizz", "Buzz", "Fizz", "FizzBuzz",
"Fizz", "Buzz", "Fizz", "Fizz", "Buzz", "Fizz"
);
Expand Down Expand Up @@ -65,7 +65,7 @@ void print(ForwardRange const& input, Pair const& answer) {

int main() {
{
constexpr auto input = sprout::to_string_array<sprout::string<8> >(
constexpr auto input = sprout::make_array<sprout::string<8> >(
"Fizz", "FizzBuzz", "Fizz", "Buzz"
);
constexpr auto answer = inv_fizzbuzz(input);
Expand All @@ -74,7 +74,7 @@ int main() {
print(input, answer);
}
{
constexpr auto input = sprout::to_string_array<sprout::string<8> >(
constexpr auto input = sprout::make_array<sprout::string<8> >(
"FizzBuzz", "Fizz", "Buzz", "Fizz", "Fizz", "Buzz", "Fizz",
"FizzBuzz", "Fizz", "Buzz", "Fizz", "Fizz", "Buzz", "Fizz",
"FizzBuzz", "Fizz", "Buzz"
Expand All @@ -85,7 +85,7 @@ int main() {
print(input, answer);
}
{
constexpr auto input = sprout::to_string_array<sprout::string<8> >(
constexpr auto input = sprout::make_array<sprout::string<8> >(
"Fizz", "FizzBuzz", "Buzz"
);
constexpr auto answer = inv_fizzbuzz(input);
Expand Down
11 changes: 10 additions & 1 deletion tools/darkroom/darkcult.cpp
Expand Up @@ -47,6 +47,15 @@
# define DARKROOM_OFFSET_Y 0
#endif

//
// DARKROOM_RUNTIME/DARKROOM_VARIABLE
//
#ifndef DARKROOM_RUNTIME
# define DARKROOM_VARIABLE SPROUT_STATIC_CONSTEXPR
#else
# define DARKROOM_VARIABLE
#endif

#include <cstddef>
#include <iostream>
#include <sprout/darkroom.hpp>
Expand All @@ -64,7 +73,7 @@ int main() {
using namespace sprout::darkroom;

typedef pixels::color_pixels<darkcult::tile_width, darkcult::tile_height>::type image_type;
SPROUT_STATIC_CONSTEXPR auto image = pixels::generate<image_type>(
DARKROOM_VARIABLE auto image = pixels::generate<image_type>(
darkcult::raytracer, darkcult::renderer, darkcult::camera,
darkcult::object, darkcult::light,
darkcult::offset_x, darkcult::offset_y,
Expand Down
10 changes: 9 additions & 1 deletion tools/darkroom/darkcult.sh
Expand Up @@ -28,11 +28,12 @@ declare -a include_paths=()
max_procs=
force=0
continuable=0
runtime=0
use_help=0
darkcult_cpp=$(cd $(dirname $0); pwd)/darkcult.cpp
darkcult_py=$(cd $(dirname $0); pwd)/darkcult.py

args=`getopt -o s:S:o:C:w:h:W:H:l:t:r:b:O:D:I:P:fc -l source:,stagedir:,output:,compiler:,width:,height:,tile-width:,tile-height:,left:,top:,right:,bottom:,option:,define:,include:,max-procs:,force,continuable,help -- "$@"`
args=`getopt -o s:S:o:C:w:h:W:H:l:t:r:b:O:D:I:P:fc -l source:,stagedir:,output:,compiler:,width:,height:,tile-width:,tile-height:,left:,top:,right:,bottom:,option:,define:,include:,max-procs:,force,continuable,runtime,help -- "$@"`
if [ "$?" -ne 0 ]; then
echo >&2 "error: options parse error. See 'darkcult.sh --help'"
exit 1
Expand All @@ -58,6 +59,7 @@ while [ -n "$1" ]; do
-P|--max-procs) max_procs=$2; shift 2;;
-f|--force) force=1; shift;;
-c|--continuable) continuable=1; shift;;
--runtime) runtime=1; shift;;
--help) use_help=1; shift;;
--) shift; break;;
*) echo >&2 "error: unknown option($1) used."; exit 1;;
Expand Down Expand Up @@ -121,6 +123,8 @@ if [ ${use_help} -ne 0 ]; then
echo " Press <Enter>; check finished."
echo " Press 'q' ; terminate compile."
echo ""
echo " --runtime Enable runtime mode."
echo ""
echo " --help This message."
exit 0
fi
Expand All @@ -143,6 +147,7 @@ echo " include-paths = (${include_paths[*]})"
echo " max-procs = ${max_procs}"
echo " force = ${force}"
echo " continuable = ${continuable}"
echo " runtime = ${runtime}"

if [ ! -f "${src}" -a ! -f "$(cd $(dirname $0); pwd)/${src}" ]; then
echo >&2 "error: source(${src}) not exists."
Expand All @@ -156,6 +161,9 @@ for include_path in ${include_paths}; do
include_options="${include_options} -I${include_path}"
done
compile_options="-std=c++11 ${define_options} ${include_options} ${common_options[*]}"
if [ ${runtime} -ne 0 ]; then
compile_options="${compile_options} -DDARKROOM_RUNTIME"
fi

if [ -d "${stagedir}" ]; then
if [ ${force} -eq 0 ]; then
Expand Down

0 comments on commit 06bd554

Please sign in to comment.