# HG changeset patch # User anatofuz # Date 1573638023 -32400 # Node ID 3ef66c1568be422c1a427ed91890749eef8884dc # Parent bce3183c2e355297b5118e6ec9bed7730d038c3a impl overrrite mode at update_context.pl diff -r bce3183c2e35 -r 3ef66c1568be src/parallel_execution/update_context.pl --- 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; +}