rev 10348 - scripts
Modestas Vainius
modax-guest at alioth.debian.org
Mon Apr 28 22:01:15 UTC 2008
Author: modax-guest
Date: 2008-04-28 22:01:14 +0000 (Mon, 28 Apr 2008)
New Revision: 10348
Modified:
scripts/autofixtll
Log:
v0.5
* Support conditional linking
* Performance improvements
Modified: scripts/autofixtll
===================================================================
--- scripts/autofixtll 2008-04-28 21:30:12 UTC (rev 10347)
+++ scripts/autofixtll 2008-04-28 22:01:14 UTC (rev 10348)
@@ -109,7 +109,7 @@
use IPC::Open2;
#### Please add predefined libraries to load dynamic symbol from here.
-# new Library(name, cmake_target, [path]). If path is not specified,
+# new Library(name, cmake_target, condition => 'condition', [path]). If path is not specified,
# it's /usr/lib/$name.so. Use '' quotes to avoid escaping $.
my @LIBS = (
new Library('QtDBus', '${QT_QTDBUS_LIBRARY}'),
@@ -118,7 +118,8 @@
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('X11', '${X11_X11_LIB}', condition => 'X11_FOUND'),
+ new Library('Xext', '${X11_Xext_LIB}', condition => 'X11_Xext_FOUND'),
new Library('z', '${ZLIB_LIBRARY}'),
new Library('solid', '${KDE4_SOLID_LIBS}'),
);
@@ -130,11 +131,13 @@
############### Implementation ###############################
sub Library::new {
- my ($cls, $name, $cmake_target, $path) = @_;
+ my ($cls, $name, $cmake_target, %other) = @_;
+ my $path = $other{path};
+ my $condition = $other{condition};
if (!defined $path) {
$path = "/usr/lib/lib$name.so";
}
- return bless( { name => $name, path => $path, cmake_target => $cmake_target }, $cls);
+ return bless( { name => $name, path => $path, cmake_target => $cmake_target, condition => $condition }, $cls);
}
sub Library::load {
@@ -262,24 +265,26 @@
my @notfound;
# Try fast search first
+ nextfastref:
for my $ref (@$undefrefs) {
my $lib;
for my $lib (@$alllibs) {
if ($lib->has_symbol_fast($ref)) {
push @_libs, $lib;
- next;
+ next nextfastref;
}
}
push @notfound, $ref;
}
# Then try slow one
+ nextslowref:
for my $ref (@notfound) {
my $lib;
for my $lib (@$alllibs) {
if ($lib->has_symbol($ref)) {
push @_libs, $lib;
- next;
+ next nextslowref;
}
}
}
@@ -299,8 +304,20 @@
sub write_target_link_libs {
my ($dir, $target, $libs, $do_backups) = @_;
my $cmakelists = File::Spec->catfile($dir, "CMakeLists.txt");
- my $strlibs = join(" ", map($_->{cmake_target}, @$libs));
+
+ my $strlibs = ""; # Unconditional libs
+ my $condlibs = ""; # Conditional linking
+ for (@$libs) {
+ if (exists $_->{condition}) {
+ $condlibs .= sprintf("if (%s)\n target_link_libraries($target %s)\nendif (%s)\n",
+ $_->{condition}, $_->{cmake_target}, $_->{condition});
+ } else {
+ $strlibs .= " " if ($strlibs);
+ $strlibs .= $_->{cmake_target};
+ }
+ }
+
if (-r $cmakelists) {
my @contents;
my @ignored;
@@ -314,14 +331,20 @@
if (!$found && !$ignstack->process_line($_) &&
m/^\s*(target_link_libraries\s*\(\s*$target\s+)(.*?)(\s*\).*)?$/i) {
- # Fix it
- my $newline = $1;
- my $end = $3;
- $newline .= $2 if ($2);
- $newline .= " " if ($newline !~ m/\s+$/);
- $newline .= $strlibs;
- $newline .= $end if ($end);
- $newline .= "\n";
+ my $newline;
+ if ($strlibs) {
+ # Fix it
+ $newline = $1;
+ my $end = $3;
+ $newline .= $2 if ($2);
+ $newline .= " " if ($newline !~ m/\s+$/);
+ $newline .= $strlibs;
+ $newline .= $end if ($end);
+ $newline .= "\n";
+ } else {
+ $newline = $_;
+ }
+ $newline .= "\n" . $condlibs . "\n" if ($condlibs);
if ($ignstack->is_empty()) {
push @contents, $newline;
@@ -507,7 +530,7 @@
############## Main loop ##############################
-$main::VERSION = "0.4.1";
+$main::VERSION = "0.5.0";
my $sourcedir = Cwd::getcwd();
my $builddir = "obj-" . get_gnu_build_type();
More information about the pkg-kde-commits
mailing list