Mercurial > hg > Gears > Gears
changeset 663:24571f9c6187
...
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 18 Aug 2020 19:07:42 +0900 |
parents | 7bb657ce6399 |
children | 4fdacdac4b38 |
files | src/parallel_execution/generate_stub.pl src/parallel_execution/lib/Gears/Util.pm |
diffstat | 2 files changed, 34 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/generate_stub.pl Tue Aug 18 18:55:16 2020 +0900 +++ b/src/parallel_execution/generate_stub.pl Tue Aug 18 19:07:42 2020 +0900 @@ -3,6 +3,10 @@ use strict; use Getopt::Long; use File::Path qw(make_path); +use File::Basename qw/basename/; +use File::Basename; +use File::Spec qw/rel2abs/; + use FindBin; use lib "$FindBin::Bin/lib"; @@ -51,6 +55,9 @@ $context_name = $projects{$opt_project}->{context}; } +my $interface_name_to_header_path = create_interface_name_to_header_path($FindBin::Bin); +my $cbc_name_to_source_path = create_cbc_name_to_source_path($FindBin::Bin); + for my $fn (@ARGV) { @@ -72,7 +79,6 @@ my $implementation; my $interface; my %call_interfaces; -my $interface_name_to_header_paths = create_interface_name_to_header_path(); # interface definision # @@ -147,9 +153,9 @@ $interfaceHeader =~ m|(\w+)\.\w+$|; #remove filename extention my $interfaceName = $1; $call_interfaces{$filename}->{$interfaceName} = 1; - if (exists $interface_name_to_header_paths->{$interfaceName}) { - &getDataGear($interface_name_to_header_paths->{$interfaceName}); - &getCodeGear($interface_name_to_header_paths->{$interfaceName}); + if (exists $interface_name_to_header_path->{$interfaceName}) { + &getDataGear($interface_name_to_header_path->{$interfaceName}); + &getCodeGear($interface_name_to_header_path->{$interfaceName}); } } elsif (/^\_\_code (\w+)\((.*)\)(.*)/) { my $codeGearName = $1; @@ -727,7 +733,8 @@ } sub create_interface_name_to_header_path { - my $files = Gears::Util->find_headers_from_path("$FindBin::Bin"); + my $search_root = shift; + my $files = Gears::Util->find_headers_from_path($search_root); my $interface_name2headerpath = {}; for my $file (@{$files}) { @@ -740,8 +747,16 @@ return $interface_name2headerpath; } - - +sub create_cbc_name_to_source_path { + my $search_root = shift; + my $files = Gears::Util->find_cbc_sources_from_path($search_root); -# end + my $cbc_name2_source_path = {}; + for my $file (@{$files}) { + my $cbc_name = basename $file; + $cbc_name =~ s/\.cbc//; + push(@{$cbc_name2_source_path->{$cbc_name}},$file); + } + return $cbc_name2_source_path; +}
--- a/src/parallel_execution/lib/Gears/Util.pm Tue Aug 18 18:55:16 2020 +0900 +++ b/src/parallel_execution/lib/Gears/Util.pm Tue Aug 18 19:07:42 2020 +0900 @@ -14,7 +14,7 @@ sub parse_interface { my ($class, $file_name) = @_; my $ir = _parse_base($file_name); - + unless ($ir->{name}) { croak "invalid struct name $file_name"; } @@ -154,6 +154,16 @@ } +sub find_cbc_sources_from_path { + my $class = shift; + my $find_path = shift // "."; + + my @files; + find( { wanted => sub { push @files, $_ if /\.cbc/ }, no_chdir => 1 }, $find_path); + + return \@files; +} + sub find_headers_from_path { my $class = shift; my $find_path = shift // ".";