Kaydet (Commit) 82cdcc2b authored tarafından Michael Meeks's avatar Michael Meeks

cleanup macro.pl - re-build if your config changes

üst 6ef9e5bd
...@@ -25,9 +25,11 @@ ...@@ -25,9 +25,11 @@
# #
#************************************************************************* #*************************************************************************
my $outfile;
my $destfile;
my $config_stamp;
my $lastcompletelangiso_var;
my $completelangiso_var = $ENV{COMPLETELANGISO_VAR}; my $completelangiso_var = $ENV{COMPLETELANGISO_VAR};
my $lastcompletelangiso_var;;
my $outfile = "";
if ( !defined $completelangiso_var) { if ( !defined $completelangiso_var) {
print STDERR "ERROR: No language defined!\n"; print STDERR "ERROR: No language defined!\n";
...@@ -42,11 +44,11 @@ foreach $lang (split (/ /, $poorhelplocalizations_var)) { ...@@ -42,11 +44,11 @@ foreach $lang (split (/ /, $poorhelplocalizations_var)) {
$poorhelplocalizations{$lang}++; $poorhelplocalizations{$lang}++;
} }
startup_check(); if (!args_require_build()) {
if ( "$completelangiso_var" eq "$lastcompletelangiso_var" ) { print STDERR "No new languages, or config. Keeping old file\n";
print STDERR "No new languages. Keeping old file\n";
exit 0; exit 0;
} }
print STDERR "re-building macros\n";
my @completelangiso = split " +", $completelangiso_var; my @completelangiso = split " +", $completelangiso_var;
...@@ -75,6 +77,7 @@ write_FILE_ALL_LANG_LETTER(); ...@@ -75,6 +77,7 @@ write_FILE_ALL_LANG_LETTER();
close OUTFILE; close OUTFILE;
rename $outfile, $destfile;
sub write_ALL_LANG sub write_ALL_LANG
{ {
...@@ -256,25 +259,26 @@ sub write_FILE_ALL_LANG_LETTER ...@@ -256,25 +259,26 @@ sub write_FILE_ALL_LANG_LETTER
print OUTFILE "\n\n"; print OUTFILE "\n\n";
} }
sub startup_check sub args_require_build
{ {
my $i; while (@ARGV) {
for ( $i=0; $i <= $#ARGV; $i++) { $opt = shift @ARGV;
if ( "$ARGV[$i]" eq "-o" ) { $destfile = shift @ARGV if ($opt eq '-o');
if ( defined $ARGV[ $i + 1] ) { $config_stamp = shift @ARGV if ($opt eq '-c');
$outfile = $ARGV[ $i + 1];
} else {
usage();
}
}
} }
usage() if $i<2; usage() if (!defined ($destfile) || !defined ($config_stamp));
usage() if "$outfile" eq ""; $outfile = "$destfile.tmp";
if ( -f "$outfile" ) {
# changed script - run allways if ( -f "$destfile" ) {
return if (stat($0))[9] > (stat("$outfile"))[9] ; # changed script - run always
return 1 if (stat($0))[9] > (stat("$destfile"))[9] ;
open OLDFILE, "$outfile" or die "$0 - ERROR: $outfile exists but isn't readable.\n"; # changed set_soenv.stamp - run always
if (-f "$config_stamp") {
return 1 if (stat($config_stamp))[9] > (stat($destfile))[9];
}
open OLDFILE, "$destfile" or die "$0 - ERROR: $outfile exists but isn't readable.\n";
while ( $line = <OLDFILE> ) { while ( $line = <OLDFILE> ) {
if ( $line =~ /^\/\/.*completelangiso:/ ) { if ( $line =~ /^\/\/.*completelangiso:/ ) {
$lastcompletelangiso_var = $line; $lastcompletelangiso_var = $line;
...@@ -285,12 +289,15 @@ sub startup_check ...@@ -285,12 +289,15 @@ sub startup_check
} }
close OLDFILE; close OLDFILE;
return 0 if ( "$completelangiso_var" eq "$lastcompletelangiso_var" );
} }
return 1;
} }
sub usage sub usage
{ {
print STDERR "Generate language dependend macros use in *.scp files\n"; print STDERR "Generate language dependend macros use in *.scp files\n";
print STDERR "perl $0 -o outputfile\n"; print STDERR "perl $0 -o <outputfile> -c <config_stamp_file>\n";
exit 1; exit 1;
} }
...@@ -45,5 +45,4 @@ ALLTAR : $(INCCOM)$/langmacros.inc ...@@ -45,5 +45,4 @@ ALLTAR : $(INCCOM)$/langmacros.inc
.PHONY $(INCCOM)$/langmacros.inc: .PHONY $(INCCOM)$/langmacros.inc:
@echo ------------------------------ @echo ------------------------------
@echo Making: $@ @echo Making: $@
@@-$(RENAME) $@ $@.tmp $(COMMAND_ECHO)$(PERL) macro.pl $(VERBOSITY) -o $@ -c $(SOLARSRC)/set_soenv.stamp
$(COMMAND_ECHO)$(PERL) macro.pl $(VERBOSITY) -o $@.tmp && $(RENAME:s/+//) $@.tmp $@
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment