# HG changeset patch # User anatofuz # Date 1574911025 -32400 # Node ID 239bd73abac64ef44e2fa956e8b30f674391edb9 # Parent 8c7c1ea49f21eae82c0bcfe8fee8c991d98fb33b add gen context.h at generate_context.pl diff -r 8c7c1ea49f21 -r 239bd73abac6 src/CMakeLists.txt --- a/src/CMakeLists.txt Wed Nov 27 21:21:42 2019 +0900 +++ b/src/CMakeLists.txt Thu Nov 28 12:17:05 2019 +0900 @@ -98,7 +98,7 @@ add_custom_command ( OUTPUT ${CMAKE_KERNEL_DIR_C}/c/${_Gears_TARGET}-context.c DEPENDS ${_Gears_CBC_SOURCES} fs.img initcode - COMMAND "cd" "CMakeFiles/kernel.dir" ";" "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_context.pl" "-o" ${_Gears_TARGET} ${_Gears_CBC_SOURCES} + COMMAND "cd" "CMakeFiles/kernel.dir" ";" "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_context.pl" "-o" ${_Gears_TARGET} "-w" ${_Gears_CBC_SOURCES} ) # add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} ${CMAKE_KERNEL_DIR}/c/${_Gears_TARGET}-context.c ) file(COPY "${CMAKE_SOURCE_DIR}/device" DESTINATION "${CMAKE_KERNEL_DIR_C}") diff -r 8c7c1ea49f21 -r 239bd73abac6 src/file.cbc --- a/src/file.cbc Wed Nov 27 21:21:42 2019 +0900 +++ b/src/file.cbc Thu Nov 28 12:17:05 2019 +0900 @@ -128,6 +128,7 @@ } +// Skip: generate_context __code cbc_fileread(struct file *f, char *addr, int n, __code next(int ret, ...)) { if (f->readable == 0) { diff -r 8c7c1ea49f21 -r 239bd73abac6 src/gearsTools/generate_context.pl --- a/src/gearsTools/generate_context.pl Wed Nov 27 21:21:42 2019 +0900 +++ b/src/gearsTools/generate_context.pl Thu Nov 28 12:17:05 2019 +0900 @@ -43,8 +43,8 @@ my $ddir = "c"; -our($opt_o,$opt_d,$opt_h); -getopts('o:d:h'); +our($opt_o,$opt_d,$opt_h,$opt_w); +getopts('o:d:hw'); my $name = $opt_o?$opt_o:"gears"; @@ -65,6 +65,30 @@ my %dataGear; my %constructor; +{ + use FindBin; + use lib "$FindBin::Bin/lib"; + + use File::Spec; + use Cwd 'getcwd'; + + use Gears::Context; + use Getopt::Std; + + my $output = $opt_w ? "context.h" : "stdout"; + + my @cbc_files; + map { push(@cbc_files,File::Spec->rel2abs($_)); } @ARGV; + my $gears = Gears::Context->new(compile_sources => \@cbc_files, find_root => "$FindBin::Bin/../", output => $output); + my $data_gears = $gears->extraction_dg_compile_sources(); + my $g = $gears->set_data_gear_header_path(); + + #use DDP {deparse =>1}; + my $dg2path = $gears->update_dg_each_header_path($data_gears,$g); + my $tree = $gears->createImplTree_from_header($dg2path); + $gears->tree2create_context_h($tree); +} + # gather module Information for code table initialization for (@ARGV) { next if (/context.c/); diff -r 8c7c1ea49f21 -r 239bd73abac6 src/gearsTools/lib/Gears/Context.pm --- a/src/gearsTools/lib/Gears/Context.pm Wed Nov 27 21:21:42 2019 +0900 +++ b/src/gearsTools/lib/Gears/Context.pm Thu Nov 28 12:17:05 2019 +0900 @@ -36,6 +36,11 @@ next; } + if ($line =~ m|//\s*Skip:\s*generate_context|) { + $line = <$fh>; + next; + } + if ($line =~ /^(\w+)(\*)+ *create(\w+)\(([^]]*)\)/) { my $interface = $1; my $implementation = $3; @@ -164,9 +169,8 @@ my $impls = $dg2path->{impl}; use Data::Dumper; - use DDP {deparse => 1}; print Dumper $dg2path; - p $self; + print Dumper $self; map { $dg_str{$_}->{elem} = Gears::Util->parse_interface($inters->{$_}) } keys %$inters; diff -r 8c7c1ea49f21 -r 239bd73abac6 src/usr/CMakeLists.txt --- a/src/usr/CMakeLists.txt Wed Nov 27 21:21:42 2019 +0900 +++ b/src/usr/CMakeLists.txt Thu Nov 28 12:17:05 2019 +0900 @@ -65,7 +65,7 @@ add_custom_command ( OUTPUT ${_Gears_TARGET}.dir/c/${_Gears_TARGET}-context.c DEPENDS ${_Gears_CBC_SOURCES} - COMMAND "cd" "${_Gears_TARGET}.dir" ";" "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_context.pl" "-o" ${_Gears_TARGET} ${CMAKE_SOURCE_DIR}/usr/${_Gears_CSOURCES} + COMMAND "cd" "${_Gears_TARGET}.dir" ";" "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_context.pl" "-o" ${_Gears_TARGET} "-w" ${CMAKE_SOURCE_DIR}/usr/${_Gears_CSOURCES} ) add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} ${_Gears_TARGET}.dir/c/${_Gears_TARGET}-context.c ) target_link_libraries(${_Gears_TARGET} ulib)