@@ -561,19 +561,8 @@ private Options.ExplicitOptions GenerateOptions(Project.Configuration conf, File
561561 // OutputFile
562562 options [ "OutputFile" ] = conf . TargetFileFullNameWithExtension . Replace ( " " , @"\ " ) ;
563563
564- // DependenciesLibraryFiles
565- var dependenciesLibraryFiles = new OrderableStrings ( conf . DependenciesLibraryFiles ) ;
566- FixupLibraryNames ( dependenciesLibraryFiles ) ;
567- dependenciesLibraryFiles . InsertPrefix ( "-l:" ) ;
568- dependenciesLibraryFiles . Sort ( ) ;
569- options [ "DependenciesLibraryFiles" ] = dependenciesLibraryFiles . JoinStrings ( " " ) ;
570-
571564 // LibraryFiles
572- OrderableStrings libraryFiles = new OrderableStrings ( conf . LibraryFiles ) ;
573- FixupLibraryNames ( libraryFiles ) ;
574- libraryFiles . InsertPrefix ( "-l:" ) ;
575- libraryFiles . Sort ( ) ;
576- options [ "LibraryFiles" ] = libraryFiles . JoinStrings ( " " ) ;
565+ options [ "LibraryFiles" ] = GenerateLibraryReferences ( conf . LibraryFiles , conf ) ;
577566
578567 // LibraryPaths
579568 OrderableStrings libraryPaths = new OrderableStrings ( ) ;
@@ -608,6 +597,10 @@ private Options.ExplicitOptions GenerateOptions(Project.Configuration conf, File
608597 depsRelative . Sort ( ) ;
609598 options [ "LDDEPS" ] = depsRelative . JoinStrings ( " " ) ;
610599
600+ // DependenciesLibraryFiles
601+ options [ "DependenciesLibraryFiles" ] = GenerateLibraryReferences ( conf . DependenciesOtherLibraryFiles , conf , depsRelative ) ;
602+
603+
611604 // LinkCommand
612605 if ( conf . Output == Project . Configuration . OutputType . Lib )
613606 {
@@ -697,20 +690,41 @@ private string GetOutputDirectory(Project.Configuration conf, FileInfo projectFi
697690 return Util . PathGetRelative ( projectFileInfo . DirectoryName , conf . TargetPath ) ;
698691 }
699692
700- private static void FixupLibraryNames ( IList < string > paths )
693+ private static string GenerateLibraryReferences ( OrderableStrings paths , Project . Configuration conf , OrderableStrings pathsToMerge = null )
701694 {
702695 for ( int i = 0 ; i < paths . Count ; ++ i )
703696 {
704697 string libraryName = PathMakeUnix ( paths [ i ] ) ;
705- // We've got two kinds of way of listing a library:
706- // - With a filename without extension we must add the potential prefix and potential extension.
707- // - With a filename with a static or shared lib extension (eg. .a/.so), we shouldn't touch it as it's already set by the script.
708- string extension = Path . GetExtension ( libraryName ) . ToLowerInvariant ( ) ;
709- if ( extension != ".a" && extension != ".so" )
710- paths [ i ] = "lib" + libraryName + ".a" ;
698+ if ( File . Exists ( libraryName ) )
699+ {
700+ // If this is a full path to an existing file then do nothing, the linker can accept
701+ // it as a direct argument instead of having to go through -l
702+ }
703+ else if ( conf . Platform . IsMac ( ) )
704+ {
705+ // Mac ld only supports -l<name
706+ paths [ i ] = "-l" + libraryName ;
707+ }
711708 else
712- paths [ i ] = libraryName ;
709+ {
710+ // We've got two kinds of way of listing a library:
711+ // - With a filename without extension we must add the potential prefix and potential extension.
712+ // - With a filename with a static or shared lib extension (eg. .a/.so), we shouldn't touch it as it's already set by the script.
713+ string extension = Path . GetExtension ( libraryName ) . ToLowerInvariant ( ) ;
714+ if ( extension != ".a" && extension != ".so" )
715+ paths [ i ] = "-l:lib" + libraryName + ".a" ;
716+ else
717+ paths [ i ] = "-l:" + libraryName ;
718+ }
713719 }
720+
721+ if ( pathsToMerge != null )
722+ {
723+ paths . AddRange ( pathsToMerge ) ;
724+ }
725+
726+ paths . Sort ( ) ;
727+ return paths . JoinStrings ( " " ) ;
714728 }
715729
716730 #endregion
0 commit comments