# HG changeset patch # User mir3636 # Date 1485509055 -32400 # Node ID 79bbe2c63fb0217c9c6441ea291b8b15e009ddf3 # Parent edb3aff688d0047dee8f1e02f905e094fc8943b9 cmake generate c from cbc diff -r edb3aff688d0 -r 79bbe2c63fb0 src/parallel_execution/CMakeLists.txt --- a/src/parallel_execution/CMakeLists.txt Fri Jan 27 10:10:09 2017 +0900 +++ b/src/parallel_execution/CMakeLists.txt Fri Jan 27 18:24:15 2017 +0900 @@ -11,11 +11,19 @@ set( _ONE_VALUE_ARGS TARGET ) set( _MULTI_VALUE_ARGS SOURCES ) cmake_parse_arguments( _Gears "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) + + set(_Gear_CSOURCES string(REGEX REPLACE "([^ ]*)\\.cbc" "c/\\1.c" ${_Gears_SOURCES})) + add_custom_command ( OUTPUT c/${_Gears_TARGET}-context.c - COMMAND "perl" "generate_context.pl" "-o" ${_Gears_TARGET} ${_Gears_SOURCES} + COMMAND "perl" "generate_context.pl" "-o" ${_Gears_TARGET} ${_Gears_CSOURCES} ) - add_executable(${_Gears_TARGET} ${_Gears_SOURCES} c/${_Gears_TARGET}-context.c) + add_custom_command ( + DEPENDS ${_Gears_SOURCES} + OUTPUT ${_Gears_CSOURCES} + COMMAND "perl" "generate_stub.pl" "-d" "-c" ${_Gears_SOURCES} + ) + add_executable(${_Gears_TARGET} ${_Gears_CSOURCES} c/${_Gears_TARGET}-context.c) endmacro() @@ -39,3 +47,11 @@ SOURCES origin_cs.c test/queue_test.c queue.c ) + +GearsCommand( + TARGET + cbc_stack_test + SOURCES + origin_cs.c test/stack_test.c SingleLinkedStack.cbc +) + diff -r edb3aff688d0 -r 79bbe2c63fb0 src/parallel_execution/generate_stub.pl --- a/src/parallel_execution/generate_stub.pl Fri Jan 27 10:10:09 2017 +0900 +++ b/src/parallel_execution/generate_stub.pl Fri Jan 27 18:24:15 2017 +0900 @@ -14,10 +14,19 @@ # struct Queue* tasks; # } Worker; -our($opt_o,$opt_h); -getopts('o:h'); +our($opt_o,$opt_d,$opt_h); +getopts('o:d:h'); + +my $dir = "."; +if ($opt_d) { + $dir = $opt_d; + if (! -d $dir) { + mkdir $dir; + } +} for my $fn (@ARGV) { + next if ($fn !~ /\.cbc$/); &getDataGear($fn); &generateDataGear($fn); } @@ -113,9 +122,9 @@ my $fn1 = $filename; $fn1 =~ s/\.cbc/.c/; my $i = 1; - $fn = $fn1; + $fn = "$dir/$fn1"; while ( -f $fn) { - $fn = "$fn1.$i"; + $fn = "$dir/$fn1.$i"; $i++; } } @@ -175,6 +184,11 @@ my $typeField = lcfirst($typeName); $newArgs .= $&; &generateStubArgs($codeGearName, $varName, $typeName, $typeField, $interface); + } elsif ($args =~ s/(.*,)//) { + $newArgs .= $1; + } else { + $newArgs .= $args; + last; } } $dataGearName{$codeGearName} .= "\tgoto $codeGearName(context";