Mercurial > hg > Members > menikon > CbC_xv6
changeset 111:239bd73abac6
add gen context.h at generate_context.pl
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 28 Nov 2019 12:17:05 +0900 |
parents | 8c7c1ea49f21 |
children | b9df8ea87b42 |
files | src/CMakeLists.txt src/file.cbc src/gearsTools/generate_context.pl src/gearsTools/lib/Gears/Context.pm src/usr/CMakeLists.txt |
diffstat | 5 files changed, 35 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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}")
--- 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) {
--- 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/);
--- 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;
--- 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)