Mercurial > hg > GearsTemplate
changeset 255:79bbe2c63fb0
cmake generate c from cbc
author | mir3636 |
---|---|
date | Fri, 27 Jan 2017 18:24:15 +0900 |
parents | edb3aff688d0 |
children | d2f5d6fc56fa |
files | src/parallel_execution/CMakeLists.txt src/parallel_execution/generate_stub.pl |
diffstat | 2 files changed, 36 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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 +) +
--- 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";