mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-25 21:35:41 +00:00
darkcult: add --runtime mode
This commit is contained in:
parent
bf0f36d5a9
commit
06bd554967
3 changed files with 23 additions and 6 deletions
|
@ -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"
|
||||
);
|
||||
|
@ -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);
|
||||
|
@ -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"
|
||||
|
@ -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);
|
||||
|
|
|
@ -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>
|
||||
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
@ -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;;
|
||||
|
@ -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
|
||||
|
@ -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."
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue