public void compareWithMakefileList ( File makefileSourceList ) throws ProblemException { // If we are building on win32 using for example cygwin the paths in the // makefile source list // might be /cygdrive/c/.... which does not match c:\.... // We need to adjust our calculated sources to be identical, if // necessary. boolean mightNeedRewriting = File . pathSeparatorChar == ' ' ; if ( makefileSourceList == null ) return ; Set < String > calculatedSources = new HashSet <> ( ) ; Set < String > listedSources = new HashSet <> ( ) ; // Create a set of filenames with full paths. for ( Source s : now . sources ( ) . values ( ) ) { // Don't include link only sources when comparing sources to compile if ( ! s . isLinkedOnly ( ) ) { String path = s . file ( ) . getPath ( ) ; if ( mightNeedRewriting ) path = Util . normalizeDriveLetter ( path ) ; calculatedSources . add ( path ) ; } } // Read in the file and create another set of filenames with full paths. try ( BufferedReader in = new BufferedReader ( new FileReader ( makefileSourceList ) ) ) { for ( ; ; ) { String l = in . readLine ( ) ; if ( l == null ) break ; l = l . trim ( ) ; if ( mightNeedRewriting ) { if ( l . indexOf ( ":" ) == 1 && l . indexOf ( "\\" ) == 2 ) { // Everything a-ok, the format is already C:\foo\bar } else if ( l . indexOf ( ":" ) == 1 && l . indexOf ( "/" ) == 2 ) { // The format is C:/foo/bar, rewrite into the above format. l = l . replaceAll ( "/" , "\\\\" ) ; } else if ( l . charAt ( 0 ) == ' ' && l . indexOf ( "/" , 1 ) != - 1 ) { // The format might be: /cygdrive/c/foo/bar, rewrite into the above format. // Do not hardcode the name cygdrive here. int slash = l . indexOf ( "/" , 1 ) ; l = l . replaceAll ( "/" , "\\\\" ) ; l = "" + l . charAt ( slash + 1 ) + ":" + l . substring ( slash + 2 ) ; } if ( Character . isLowerCase ( l . charAt ( 0 ) ) ) { l = Character . toUpperCase ( l . charAt ( 0 ) ) + l . substring ( 1 ) ; } } listedSources . add ( l ) ; } } catch ( FileNotFoundException | NoSuchFileException e ) { throw new ProblemException ( "Could not open " + makefileSourceList . getPath ( ) + " since it does not exist!" ) ; } catch ( IOException e ) { throw new ProblemException ( "Could not read " + makefileSourceList . getPath ( ) ) ; } for ( String s : listedSources ) { if ( ! calculatedSources . contains ( s ) ) { throw new ProblemException ( "The makefile listed source " + s + " was not calculated by the smart javac wrapper!" ) ; } } for ( String s : calculatedSources ) { if ( ! listedSources . contains ( s ) ) { throw new ProblemException ( "The smart javac wrapper calculated source " + s + " was not listed by the makefiles!" ) ; } } }
Compare the calculate source list with an explicit list usually supplied from the makefile . Used to detect bugs where the makefile and sjavac have different opinions on which files should be compiled .