57 lines
1.3 KiB
Perl
Executable File
57 lines
1.3 KiB
Perl
Executable File
#!/usr/bin/perl
|
|
#
|
|
# Update the list of debug channels of a given spec file
|
|
#
|
|
# Copyright 2000 Alexandre Julliard
|
|
#
|
|
# Usage: make_debug spec_file [source_files...]
|
|
#
|
|
|
|
die "Usage: make_debug spec_file [source]\n" unless @ARGV;
|
|
|
|
$SPEC = shift @ARGV;
|
|
|
|
# read in all the source files
|
|
if (@ARGV)
|
|
{
|
|
while (<>)
|
|
{
|
|
if (/DECLARE_DEBUG_CHANNEL\s*\(\s*([A-Za-z0-9_]+)\s*\)/) { $channels{$1} = 1; }
|
|
if (/DEFAULT_DEBUG_CHANNEL\s*\(\s*([A-Za-z0-9_]+)\s*\)/) { $channels{$1} = 1; }
|
|
}
|
|
}
|
|
@dbg_channels = sort keys %channels;
|
|
|
|
# read the whole spec file
|
|
undef $/;
|
|
open SPEC or die "Cannot open $SPEC\n";
|
|
$spec = <SPEC>;
|
|
close SPEC;
|
|
|
|
# build the new channel list
|
|
$channel_str = "debug_channels (";
|
|
$pos = length($channel_str);
|
|
for ($i = 0; $i <= $#dbg_channels; $i++)
|
|
{
|
|
$channel_str .= $dbg_channels[$i];
|
|
$pos += length($dbg_channels[$i]);
|
|
if ($i < $#dbg_channels)
|
|
{
|
|
if ($pos >= 75) { $pos = 16; $channel_str .= "\n" . (" " x $pos); }
|
|
else { $channel_str .= " "; $pos++; }
|
|
}
|
|
}
|
|
$channel_str .= ")";
|
|
|
|
# replace the list in the spec file
|
|
if (!($spec =~ s/debug_channels\s*\(([^)]*)\)/$channel_str/))
|
|
{
|
|
die "Could not replace debug_channels\n" if @dbg_channels;
|
|
exit 0;
|
|
}
|
|
|
|
# output the modified spec file
|
|
open OUTPUT, ">$SPEC" or die "Cannot modify $SPEC\n";
|
|
print OUTPUT $spec;
|
|
close OUTPUT;
|