Repaired shared PE data sections.
[wine/multimedia.git] / tools / make_debug
blob7916f8ec5290adb3fa0735a923e62d01289870fb
1 #!/usr/bin/perl
3 # Update the list of debug channels of a given spec file
5 # Copyright 2000 Alexandre Julliard
7 # Usage: make_debug spec_file [source_files...]
10 die "Usage: make_debug spec_file [source]\n" unless @ARGV;
12 $SPEC = shift @ARGV;
14 # read in all the source files
15 if (@ARGV)
17 while (<>)
19 if (/DECLARE_DEBUG_CHANNEL\s*\(\s*([A-Za-z0-9_]+)\s*\)/) { $channels{$1} = 1; }
20 if (/DEFAULT_DEBUG_CHANNEL\s*\(\s*([A-Za-z0-9_]+)\s*\)/) { $channels{$1} = 1; }
23 @dbg_channels = sort keys %channels;
25 # read the whole spec file
26 undef $/;
27 open SPEC or die "Cannot open $SPEC\n";
28 $spec = <SPEC>;
29 close SPEC;
31 # build the new channel list
32 $channel_str = "debug_channels (";
33 $pos = length($channel_str);
34 for ($i = 0; $i <= $#dbg_channels; $i++)
36 $channel_str .= $dbg_channels[$i];
37 $pos += length($dbg_channels[$i]);
38 if ($i < $#dbg_channels)
40 if ($pos >= 75) { $pos = 16; $channel_str .= "\n" . (" " x $pos); }
41 else { $channel_str .= " "; $pos++; }
44 $channel_str .= ")";
46 # replace the list in the spec file
47 if (!($spec =~ s/debug_channels\s*\(([^)]*)\)/$channel_str/))
49 die "Could not replace debug_channels\n" if @dbg_channels;
50 exit 0;
53 # output the modified spec file
54 open OUTPUT, ">$SPEC" or die "Cannot modify $SPEC\n";
55 print OUTPUT $spec;
56 close OUTPUT;