rev 10329 - scripts

Modestas Vainius modax-guest at alioth.debian.org
Mon Apr 28 10:51:25 UTC 2008


Author: modax-guest
Date: 2008-04-28 10:51:24 +0000 (Mon, 28 Apr 2008)
New Revision: 10329

Modified:
   scripts/autofixtll
Log:
* v0.4
- Does not hang loading QtGui
- Executes build commands in the source dir.
- Faster search (using hashes)
- Added @LIBS:
	solid
	QtGui

Modified: scripts/autofixtll
===================================================================
--- scripts/autofixtll	2008-04-28 10:45:35 UTC (rev 10328)
+++ scripts/autofixtll	2008-04-28 10:51:24 UTC (rev 10329)
@@ -60,6 +60,11 @@
 specific, `debian/rules build' will be executed from the B<source tree>.
 However, if you specify the command, it will be from the B<build tree>.
 
+=item B<-i>, B<--exec-in-build-dir>
+
+Run build command in the build directory. Default is to run in the source
+directory.
+
 =item B<-p>, B<--patch-name>=I<name>
 
 The name of the quilt patch in which all changes made by the script will be
@@ -111,8 +116,11 @@
     new Library('QtNetwork', '${QT_QTNETWORK_LIBRARY}'),
     new Library('QtXml', '${QT_QTXML_LIBRARY}'),
     new Library('QtSvg', '${QT_QTSVG_LIBRARY}'),
+    new Library('QtGui', '${QT_QTGUI_LIBRARY}'),
+#    new Library('pthread', '${CMAKE_THREAD_LIBS_INIT}', '/lib/libpthread.so.0'),
     new Library('X11', '${X11_X11_LIB}'),
     new Library('z', '${ZLIB_LIBRARY}'),
+    new Library('solid', '${KDE4_SOLID_LIBS}'),
 );
 
 #### Some defaults
@@ -132,6 +140,7 @@
 sub Library::load {
     my $self = shift;
     my @symbols;
+    my %symbhash;
     my @cpp_symbols;
     if (-r $self->{path}) {
         open(OBJDUMP, "objdump -T '$self->{path}' |") or die "Unable to run objdump";
@@ -143,8 +152,8 @@
                     # It is C++ symbol. Needs demangling.
                     push @cpp_symbols, $symbol;
                 } else {
-                    # FIXME: use hashes?
                     push @symbols, $symbol;
+                    $symbhash{$symbol} = 1;
                 }
             }
         }
@@ -152,28 +161,33 @@
     }
     if (@cpp_symbols) {
         open2(*OUT, *IN, "c++filt") or die "Unable to run c++filt";
+        my $count = 0;
         for (@cpp_symbols) {
             print IN "$_\n";
-        }
-        close(IN);
-        my $count = 0;
-        while(<OUT>) {
+            $_ = <OUT>;
             chomp;
-            # Don't care about everything after `('
+            # Don't care about anything after `('
             s/\(.*$//;
             s/^non-virtual thunk to\s+//;
             push @symbols, $_;
+            $symbhash{$_} = 1;
             $count++;
         }
+        close(IN);
+#        while(<OUT>) {
+#            chomp;
+#        }
         close(OUT);
         print(STDERR "Lost a few C++ symbols (", (scalar(@cpp_symbols) - $count), 
                      ") while demangling ", $self->to_string(), "\n") unless ($count == scalar(@cpp_symbols));
     }
     if (@symbols) {
         $self->{symbols} = \@symbols;
+        $self->{symbhash} = \%symbhash;
         return scalar(@symbols);
     } else {
         $self->{symbols} = [];
+        $self->{symbhash} = {};
         return 0;
     }
 }
@@ -186,10 +200,18 @@
             return 1;
         }
     }
-
     return 0;
 }
 
+sub Library::has_symbol_fast {
+    my ($self, $symbol) = @_;
+
+    # Don't care about anything after `('
+    $symbol =~ s/\(.*$//;
+
+    return (exists $self->{symbhash}{$symbol});
+}
+
 sub Library::to_string() {
     my ($self) = @_;
     return $self->{name} . " ( " . $self->{path} . " )";
@@ -240,10 +262,24 @@
     my ($alllibs, $undefrefs) = @_;
     my @_libs;
     my @libs = ();
+    my @notfound;
 
+    # Try fast search first
     for my $ref (@$undefrefs) {
         my $lib;
         for my $lib (@$alllibs) {
+            if ($lib->has_symbol_fast($ref)) {
+                push @_libs, $lib;
+                next;
+            }
+        }
+        push @notfound, $ref;
+    }
+
+    # Then try slow one
+    for my $ref (@notfound) {
+        my $lib;
+        for my $lib (@$alllibs) {
             if ($lib->has_symbol($ref)) {
                 push @_libs, $lib;
                 next;
@@ -314,7 +350,7 @@
             $found = ${ignored[0]}->{found};
             my $newline = ${ignored[0]}->{newline};
             $contents[$found-1] = $newline;
-        } else {
+        } elsif (!$found && @ignored > 1) {
             print "$MSG_PREFIX More (", scalar(@ignored), ") than 1 target_link_libraries() found in the IF/WHILE etc. blocks\n";
         }
 
@@ -342,7 +378,7 @@
 }
 
 sub build_and_fix {
-    my ($sourcedir, $builddir, $buildcmd, $do_backups, $invoke_edit) = @_;
+    my ($sourcedir, $builddir, $buildcmd, $exec_in_build_dir, $do_backups, $invoke_edit) = @_;
 
     my $bdir;
     my $btarget;
@@ -350,14 +386,14 @@
     my @undefrefs;
     my $link_cmd = 0;
 
-    if (defined $buildcmd) {
+    if ($exec_in_build_dir) {
         chdir $builddir;
-        open(MAKE, "$buildcmd 2>&1 |") or die "Unable to run `$buildcmd' in $builddir";
     } else {
         chdir $sourcedir;
-        open(MAKE, "debian/rules build 2>&1 |") or die "Unable to run `$buildcmd' in $builddir";
     }
 
+    open(MAKE, "$buildcmd 2>&1 |") or die "Unable to run `$buildcmd' in $builddir";
+
     while (<MAKE>) {
         # [ 39%] Building CXX object kwin/kcmkwin/kwindecoration/CMakeFiles
         print $_;
@@ -406,7 +442,7 @@
             print "$MSG_PREFIX Target: $btarget; CMakeLists.txt: $cmakelists", "\n";
             my $quilt_cmd = "$QUILT edit $cmakelists";
             if ($invoke_edit) {
-                print "$MSG_PREFIX Press any key to edit '$cmakelists' or ^C to cancel ...";
+                print "$MSG_PREFIX Press ENTER to edit '$cmakelists' or ^C to cancel ...";
                 <>;
                 system($quilt_cmd);
             } else {
@@ -463,11 +499,12 @@
 
 ############## Main loop ##############################
 
-$main::VERSION = "0.3";
+$main::VERSION = "0.4";
 
 my $sourcedir = Cwd::getcwd();
 my $builddir = "obj-" . get_gnu_build_type();
-my $buildcmd = undef;
+my $exec_in_build_dir = 0;
+my $buildcmd = "debian/rules build";
 my $patchname = "97_fix_target_link_libraries.diff";
 my $do_backups = 0;
 my $show_help = 0;
@@ -477,9 +514,10 @@
         "help|h|?" => \$show_help,
         "build-dir|b=s" => \$builddir,
         "build-command|c=s" => \$buildcmd,
+        "invoke-edit|edit|e!" => \$invoke_edit,
+        "exec-in-build-dir|i!" => \$exec_in_build_dir,
         "patch-name|p=s" => \$patchname,
         "do-backups|backup!" => \$do_backups,
-        "invoke-edit|edit|e!" => \$invoke_edit,
     )) {
 
     pod2usage(-exitval => 1, -verbose => 2, -noperldoc => 1) if ($show_help);
@@ -492,7 +530,7 @@
     }
 
     my $ret;
-    while (!($ret = build_and_fix($sourcedir, $builddir, $buildcmd, $do_backups, $invoke_edit))) {
+    while (!($ret = build_and_fix($sourcedir, $builddir, $buildcmd, $exec_in_build_dir, $do_backups, $invoke_edit))) {
         print "$MSG_PREFIX Linkage problem fixed, rebuilding again\n";
     }
 




More information about the pkg-kde-commits mailing list