changeset 577:f78ad1f89524

add static genmode
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Mon, 25 Nov 2019 19:37:17 +0900
parents c86da02a73bf
children d6718b5ad312
files src/parallel_execution/auto_generate_context.pl
diffstat 1 files changed, 65 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/auto_generate_context.pl	Mon Nov 25 17:06:09 2019 +0900
+++ b/src/parallel_execution/auto_generate_context.pl	Mon Nov 25 19:37:17 2019 +0900
@@ -8,9 +8,25 @@
 use Getopt::Std;
 my %opt;
 getopts("w" => \%opt);
-my @cbc_files = <DATA>;
-chomp @cbc_files;
+
+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);
@@ -22,14 +38,50 @@
 my $tree = $gears->createImplTree_from_header($dg2path);
 $gears->tree2create_context_h($tree);
 
-#
-__DATA__
-/Users/anatofuz/src/firefly/hg/Gears/src/parallel_execution/examples/calc/calc.cbc
-/Users/anatofuz/src/firefly/hg/Gears/src/parallel_execution/examples/calc/add.cbc
-/Users/anatofuz/src/firefly/hg/Gears/src/parallel_execution/examples/calc/mult.cbc
-/Users/anatofuz/src/firefly/hg/Gears/src/parallel_execution/examples/calc/initIntegerDataGears.cbc
-/Users/anatofuz/src/firefly/hg/Gears/src/parallel_execution/CPUWorker.cbc
-/Users/anatofuz/src/firefly/hg/Gears/src/parallel_execution/TaskManagerImpl.cbc
-/Users/anatofuz/src/firefly/hg/Gears/src/parallel_execution/SingleLinkedQueue.cbc
-/Users/anatofuz/src/firefly/hg/Gears/src/parallel_execution/SynchronizedQueue.cbc
-/Users/anatofuz/src/firefly/hg/Gears/src/parallel_execution/AtomicReference.cbc
+
+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
+#)