private void writeLinkOptions ( final Writer writer , final boolean isDebug , final List < DependencyDef > dependencies , final String basePath , final TargetInfo linkTarget , final Map < String , TargetInfo > targets ) throws IOException { final StringBuffer baseOptions = new StringBuffer ( 100 ) ; final StringBuffer options = new StringBuffer ( 100 ) ; baseOptions . append ( "# ADD BASE LINK32" ) ; options . append ( "# ADD LINK32" ) ; final ProcessorConfiguration config = linkTarget . getConfiguration ( ) ; if ( config instanceof CommandLineLinkerConfiguration ) { final CommandLineLinkerConfiguration linkConfig = ( CommandLineLinkerConfiguration ) config ; final File [ ] linkSources = linkTarget . getAllSources ( ) ; for ( final File linkSource : linkSources ) { // // if file was not compiled or otherwise generated // if ( targets . get ( linkSource . getName ( ) ) == null ) { // // if source appears to be a system library or object file // just output the name of the file (advapi.lib for example) // otherwise construct a relative path. // String relPath = linkSource . getName ( ) ; // // check if file comes from a project dependency // if it does it should not be explicitly linked boolean fromDependency = false ; if ( relPath . indexOf ( "." ) > 0 ) { final String baseName = relPath . substring ( 0 , relPath . indexOf ( "." ) ) ; for ( final DependencyDef depend : dependencies ) { if ( baseName . compareToIgnoreCase ( depend . getName ( ) ) == 0 ) { fromDependency = true ; } } } if ( ! fromDependency ) { if ( ! CUtil . isSystemPath ( linkSource ) ) { relPath = CUtil . getRelativePath ( basePath , linkSource ) ; } // // if path has an embedded space then // must quote if ( relPath . indexOf ( ' ' ) > 0 ) { options . append ( " \"" ) ; options . append ( CUtil . toWindowsPath ( relPath ) ) ; options . append ( "\"" ) ; } else { options . append ( ' ' ) ; options . append ( CUtil . toWindowsPath ( relPath ) ) ; } } } } final String [ ] preArgs = linkConfig . getPreArguments ( ) ; for ( final String preArg : preArgs ) { if ( isDebug || ! preArg . equals ( "/DEBUG" ) ) { options . append ( ' ' ) ; options . append ( preArg ) ; baseOptions . append ( ' ' ) ; baseOptions . append ( preArg ) ; } } final String [ ] endArgs = linkConfig . getEndArguments ( ) ; for ( final String endArg : endArgs ) { options . append ( ' ' ) ; options . append ( endArg ) ; baseOptions . append ( ' ' ) ; baseOptions . append ( endArg ) ; } } baseOptions . append ( "\r\n" ) ; options . append ( "\r\n" ) ; writer . write ( baseOptions . toString ( ) ) ; writer . write ( options . toString ( ) ) ; }
Writes link options .