Build tsx11 layer as a separate shared library.
[wine] / tools / make_debug
index 2c1d5c6..7916f8e 100755 (executable)
@@ -1,90 +1,56 @@
-#!/bin/bash
+#!/usr/bin/perl
 #
-# This script generates the required files for supporting the debug
-# channels used throught the code.
-# The generated files are 
-#   include/debugdefs.h
-#   include/debug.h
-# The script must be run in the root directory of the project.
+# Update the list of debug channels of a given spec file
 #
-# Dimitrie O. Paun <dimi@cs.toronto.edu>
+# Copyright 2000 Alexandre Julliard
+#
+# Usage: make_debug spec_file [source_files...]
 #
-DEBUG_H="include/debug.h"
-DEBUG_DEFS_H="include/debugdefs.h"
-
-DEBUG_CHANNELS="$( tools/find_debug_channels )"
-DEBUG_CLASSES="fixme err warn trace"
-
-{
-    cat <<EOF
-/* Do not modify this file -- it is automatically generated! */
-
-#ifndef __WINE_DEBUGTOOLS_H
-#include "debugtools.h"
-#endif
-
-EOF
-    echo "/* Definitions for channels identifiers */"
 
-    chno=0
-    for ch in $DEBUG_CHANNELS
-    do
-       echo "#define dbch_${ch} $chno"
-       let chno=$chno+1
-    done
+die "Usage: make_debug spec_file [source]\n" unless @ARGV;
 
-    echo "/* Definitions for classes identifiers */"
-    clno=0
-    for cl in $DEBUG_CLASSES
-    do
-       echo "#define dbcl_${cl} $clno"
-       let clno=$clno+1
-    done
-} > $DEBUG_H
+$SPEC = shift @ARGV;
 
-# Now, on the last step, we proceed to construct
-# the definitions to be used by the main function.
-# These will be stored in include/debugdefs.h
+# read in all the source files
+if (@ARGV)
 {
-    cat <<EOF
-/* Do not modify this file -- it is automatically generated! */
-
-#ifndef __WINE_DEBUGTOOLS_H
-#include "debugtools.h"
-#endif
-
-#define DEBUG_CHANNEL_COUNT $chno
-#ifdef DEBUG_RUNTIME
-short debug_msg_enabled[][DEBUG_CLASS_COUNT] = {
-EOF
-
-    for ch in $DEBUG_CHANNELS
-    do
-       echo "{1, 1, 0, 0},"
-    done
-    echo '};'
-
-    echo 'const char* debug_ch_name[] = {'
-    for ch in $DEBUG_CHANNELS
-    do
-       echo "\"${ch}\","
-    done
-    echo '};'
-    
-    echo 'const char* debug_cl_name[] = {'
-    for ch in $DEBUG_CLASSES
-    do
-       echo "\"${ch}\","
-    done
-    echo '};'
-
-    cat <<EOF
-
-#endif /*DEBUG_RUNTIME*/
-
-/* end of automatically generated debug.h */
-EOF
-
-} > $DEBUG_DEFS_H
-
-
+    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;