changeset 552:3ef66c1568be

impl overrrite mode at update_context.pl
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Wed, 13 Nov 2019 18:40:23 +0900
parents bce3183c2e35
children e9b1f533e587
files src/parallel_execution/update_context.pl
diffstat 1 files changed, 23 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/update_context.pl	Wed Nov 13 18:13:57 2019 +0900
+++ b/src/parallel_execution/update_context.pl	Wed Nov 13 18:40:23 2019 +0900
@@ -1,15 +1,21 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
+use Getopt::Std;
 
 my $interface_file = shift or die "require itnerface file";
 my $h2context = parse_interface($interface_file);
 my $context = dump_h2context($h2context);
 my ($first,$last) = slup_context_h($h2context->{name});
-print "@{$first}";
-print "$context";
-print "@{$last}";
+
+my %opt;
+getopts("w" => \%opt);
 
+if ($opt{w}) {
+  context_write(@{$first},$context,@{$last});
+} else {
+  context_dump(@{$first},$context,@{$last});
+}
 
 
 sub slup_context_h {
@@ -90,3 +96,17 @@
   $context .= "${space}} $h2context->{name};\n";
   return $context;
 }
+
+sub context_dump {
+  for my $line (@_) {
+    print "$line";
+  }
+}
+
+sub context_write {
+  open my $fh, '>', "context.h";
+  for my $line (@_) {
+    print $fh "$line";
+  }
+  close $fh;
+}