diff src/gearsTools/generate_context.pl @ 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 435bfab09924
children f9df567f7f2d
line wrap: on
line diff
--- 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/);