Repository: lucy-clownfish
Updated Branches:
  refs/heads/master 94a0410a0 -> 6a69caef1


Allow multiple modules to be passed to cf_linker_flags


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/5fbb175a
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/5fbb175a
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/5fbb175a

Branch: refs/heads/master
Commit: 5fbb175ae086fa7f445270c2d9003717f176d080
Parents: 94a0410
Author: Nick Wellnhofer <[email protected]>
Authored: Thu Jul 31 22:54:40 2014 +0200
Committer: Nick Wellnhofer <[email protected]>
Committed: Thu Jul 31 22:54:40 2014 +0200

----------------------------------------------------------------------
 compiler/perl/lib/Clownfish/CFC/Perl/Build.pm | 47 ++++++++++++++--------
 1 file changed, 31 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5fbb175a/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
----------------------------------------------------------------------
diff --git a/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm 
b/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
index dc1d285..cd3f3a7 100644
--- a/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
+++ b/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
@@ -132,26 +132,41 @@ sub cf_system_include_dirs {
 }
 
 sub cf_linker_flags {
-    my ( $self_or_class, $module_name ) = @_;
+    my $self_or_class = shift;
 
     my $dlext = $Config{dlext};
     # Only needed on Windows
     return () if $dlext ne 'dll';
 
-    # Find library to link against
-    my @module_parts = split( '::', $module_name );
-    my $class_name   = $module_parts[-1];
     # Link against import library on MSVC
-    my $ext          = $Config{cc} =~ /^cl\b/ ? 'lib' : $dlext;
+    my $ext = $Config{cc} =~ /^cl\b/ ? 'lib' : $dlext;
 
-    for my $dir (@INC) {
-        my $lib_file = catfile(
-            $dir, 'auto', @module_parts, "$class_name.$ext",
-        );
-        return ( $lib_file ) if -f $lib_file;
+    my @linker_flags;
+
+    for my $module_name (@_) {
+        # Find library to link against
+        my @module_parts = split( '::', $module_name );
+        my $class_name   = $module_parts[-1];
+        my $lib_file;
+        my $found;
+
+        for my $dir (@INC) {
+            $lib_file = catfile(
+                $dir, 'auto', @module_parts, "$class_name.$ext",
+            );
+            if ( -f $lib_file ) {
+                $found = 1;
+                last;
+            }
+        }
+
+        die("No Clownfish library file found for module $module_name")
+            if !$found;
+
+        push( @linker_flags, $lib_file );
     }
 
-    die("No Clownfish library file found for module $module_name");
+    return @linker_flags;
 }
 
 sub _cfh_filepaths {
@@ -684,13 +699,13 @@ Currently either C<()> or C<('..')>.
 Returns a list of Clownfish include directories of system-wide installations
 of Clownfish modules.
 
-=head2 cf_linker_flags(module_name)
+=head2 cf_linker_flags( I<[module_names]> )
 
-    my @flags = Clownfish::CFC::Perl::Build->cf_linker_flags($module_name);
+    my @flags = Clownfish::CFC::Perl::Build->cf_linker_flags(@module_names);
 
-Returns the linker flags needed to link against Clownfish module named
-C<$module_name>. Should be added to C<extra_linker_flags> for all module
-dependencies.
+Returns the linker flags needed to link against all Clownfish modules in
+C<@module_names>. Should be added to C<extra_linker_flags> for all module
+dependencies. Only needed on Windows.
 
 =head1 METHODS
 

Reply via email to