Showing the changes to src/scripts/compressSndFile.pl (1 of 158 files). Show all
Unified · Split
| @@ -0,0 +1,104 @@ | ||
| 1 | +use Data::Dumper; | |
| 2 | +my %seen; | |
| 3 | +my @source; | |
| 4 | + | |
| 5 | +my $output = $ARGV[0]; | |
| 6 | + | |
| 7 | +my @fileList = `ls *.c *.h`; | |
| 8 | +foreach $_ (@fileList) | |
| 9 | +{ | |
| 10 | + chomp; | |
| 11 | + if( $_ =~ /$output/ || $_ =~ /test/ ) {} | |
| 12 | + elsif( $_ =~ /\.h/ ) { $seen{$_} = 0; } | |
| 13 | + elsif( $_ =~ /\.c/ ) { push @source, $_ } | |
| 14 | +} | |
| 15 | + | |
| 16 | +close DOTH; | |
| 17 | +close DOTC; | |
| 18 | +open DOTH, ">" . $output . ".h" or die; | |
| 19 | +open DOTC, ">" . $output . ".c" or die; | |
| 20 | +my @list; | |
| 21 | +$seen{'config.h'} = 1; | |
| 22 | +push @list, "config.h"; | |
| 23 | +$seen{'sndfile.h'} = 1; | |
| 24 | +push @list, "sndfile.h"; | |
| 25 | +$seen{'common.h'} = 1; | |
| 26 | +push @list, "common.h"; | |
| 27 | +$seen{'G72x.h'} = 1; | |
| 28 | +push @list, "G72x.h"; | |
| 29 | + | |
| 30 | +sub depend | |
| 31 | +{ | |
| 32 | + my $file = shift; | |
| 33 | + my $handle; | |
| 34 | + open $handle, "<$file"; | |
| 35 | + while(<$handle>) | |
| 36 | + { | |
| 37 | + if( my $include = /#include[ \t]*[<"]([\w\d]+\.h)[>"]/ ) | |
| 38 | + { | |
| 39 | + if( defined( $seen{$include} && $seen{$include} == 0 ) ) | |
| 40 | + { | |
| 41 | + depend( $include ); | |
| 42 | + } | |
| 43 | + } | |
| 44 | + } | |
| 45 | + close $handle; | |
| 46 | + $seen{$file} = 1; | |
| 47 | + push @list, $file; | |
| 48 | +} | |
| 49 | + | |
| 50 | +foreach my $key ( keys %seen ) | |
| 51 | +{ | |
| 52 | + if( $seen{$key} == 0 ) { depend($key); } | |
| 53 | +} | |
| 54 | + | |
| 55 | +print DOTH '#include <stdio.h>' . "\n\n"; | |
| 56 | +print DOTH '#include <stdlib.h>' . "\n\n"; | |
| 57 | +foreach my $file (@list) | |
| 58 | +{ | |
| 59 | + open F, "<$file"; | |
| 60 | + while(<F>) | |
| 61 | + { | |
| 62 | + if( $_ !~ /#include[ \t]*[<"](\w+\.h)[>"]/ ) | |
| 63 | + { | |
| 64 | + print DOTH $_; | |
| 65 | + } | |
| 66 | + } | |
| 67 | + close F; | |
| 68 | +} | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | +close FILE; | |
| 75 | + | |
| 76 | +print DOTC '#include ' . "\"$output.h\"\n"; | |
| 77 | +print DOTC '#include <stdio.h>' . "\n\n"; | |
| 78 | +print DOTC '#include <stdlib.h>' . "\n\n"; | |
| 79 | +foreach my $file (@source) | |
| 80 | +{ | |
| 81 | + open FILE, $file; | |
| 82 | + $file =~ s/\.[ch]//g; | |
| 83 | + while( my $line = <FILE> ) | |
| 84 | + { | |
| 85 | + if( $line !~ /#include[ \t]*("[\w\d]+\.[ch]")|<CoreServices.h>/ ) | |
| 86 | + { | |
| 87 | + $line =~ s/(f2d_array)/$file$1/g; | |
| 88 | + $line =~ s/(d2f_array)/$file$1/g; | |
| 89 | + $line =~ s/(_\w+tab)/$file$1/g; | |
| 90 | + $line =~ s/(STEP)/$file$1/g; | |
| 91 | + $line =~ s/(HAVE_[^D]\w+)/$file$1/g; | |
| 92 | + print DOTC $line; | |
| 93 | + } | |
| 94 | + } | |
| 95 | + close FILE; | |
| 96 | +} | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | +close DOTH; | |
| 101 | +close DOTC; | |
| 102 | + | |
| 103 | + | |
| 104 | + | |