Mercurial > hg > GearsTemplate
view src/auto_generate_context.pl @ 590:9146d6017f18 default tip
hg mv parallel_execution/* ..
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 16 Jan 2020 15:12:06 +0900 |
parents | src/parallel_execution/auto_generate_context.pl@f78ad1f89524 |
children |
line wrap: on
line source
#!/usr/bin/env perl use strict; use warnings; use FindBin; use lib "$FindBin::Bin/lib"; use Gears::Context; use Getopt::Std; my %opt; getopts("w" => \%opt); my $h = find_target_from_camke_list(); my $target = shift; unless (exists $h->{$target}) { map { print "$_\n" } keys %$h; print "invalid target name\n"; exit 0; } my @cbc_files; for my $file_name (split / /, $h->{$target}) { if ($file_name =~ /^\s*$/) { next; } chomp $file_name; push(@cbc_files,$file_name); } my $output = $opt{w} ? "$FindBin::Bin/context.h" : "stdout"; 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(); my $dg2path = $gears->update_dg_each_header_path($data_gears,$g); my $tree = $gears->createImplTree_from_header($dg2path); $gears->tree2create_context_h($tree); sub find_target_from_camke_list { open my $fh, '<', "CMakeLists.txt"; my $in_gears = 0; my $target; my %res; while (my $line = <$fh>) { if ($in_gears == 1) { $in_gears++; next; } if ($in_gears == 2) { $line =~ s/\s*(\w+)\s*/$1/g; $target = $line; chomp $target; $in_gears++; next; } if ($in_gears == 3) { $in_gears++; next; } if ($in_gears == 4) { $res{$target} = $line; chomp $res{$target}; $in_gears = 0; next; } if ($line =~ /^GearsCommand\(/) { $in_gears++; } } return \%res; } #GearsCommand( # TARGET # rbtree # SOURCES # SingleLinkedQueue.cbc test/rbTree_test.cbc RedBlackTree.cbc SingleLinkedStack.cbc compare.c #)