gov.llnl.babel.backend
Class DependenciesGenerator

java.lang.Object
  extended by gov.llnl.babel.backend.DependenciesGenerator
All Implemented Interfaces:
BuildGenerator, ContextAware, FileListener

public class DependenciesGenerator
extends java.lang.Object
implements FileListener, BuildGenerator, ContextAware

This class is used to generate makefiles but may be amenable to extension to other types of build files. gets the database of generated files from the FileManager. It then create makefiles

See Also:
FileManager

Constructor Summary
DependenciesGenerator()
           
 
Method Summary
 void createAll()
          Create all Makefiles in all the directories registered with the FileManager.
 void createMakefileInDirectory(java.lang.String dependfilename, java.lang.String dirname)
          Create a single makefile in a specific directory.
protected  java.lang.String defaultDependencyFilename()
          Return the default file name.
protected  java.lang.String defaultFilename()
          Return the default file name.
protected  java.lang.String defaultPackageDependencyFilename()
           
 java.util.Set getLanguages()
          Return the set of languages that this build generator serves.
 void newFile(SymbolID id, int type, java.lang.String role, java.lang.String dir, java.lang.String name)
          This method is called for each file created by the FileManager.
 void setContext(Context context)
          Routine to notify extensions of the context.
protected  void writeMakefile(java.io.PrintWriter pw, java.util.Map role2files, java.util.HashMap fileData)
          Generate the actual make file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DependenciesGenerator

public DependenciesGenerator()
Method Detail

newFile

public void newFile(SymbolID id,
                    int type,
                    java.lang.String role,
                    java.lang.String dir,
                    java.lang.String name)
This method is called for each file created by the FileManager.

Specified by:
newFile in interface FileListener
Parameters:
id - the file is related to this symbol id.
type - this indicates the type of the symbol. A constant from Type.
role - this describes the role the file plays. For example, the file could be a STUBSRCS file or a IMPLSRCS file. The role strings used are determined by the backend.
dir - the path (relative or absolute) of the directory where the file will be created.
name - the name of the file not including any directory information. The complete name of the file should be dir + name.

createAll

public void createAll()
               throws java.io.IOException
Create all Makefiles in all the directories registered with the FileManager.

Specified by:
createAll in interface BuildGenerator
Throws:
java.io.IOException - the message contained is the concatenation of all IOExceptions thrown by createMakefileInDirectory
See Also:
FileManager

createMakefileInDirectory

public void createMakefileInDirectory(java.lang.String dependfilename,
                                      java.lang.String dirname)
                               throws java.io.IOException
Create a single makefile in a specific directory. This will do nothing if there are no files defined in that directory according to the FileManager class.

Parameters:
dependfilename - set makefile name, if null or "", defaults to <make-prefix> + "babel.make"
dirname - directory to look for
Throws:
java.io.IOException - if problems are encountered with the file system.
See Also:
FileManager

writeMakefile

protected void writeMakefile(java.io.PrintWriter pw,
                             java.util.Map role2files,
                             java.util.HashMap fileData)
Generate the actual make file. This method can be overridden for tools other than make provided that whatever files are generated exist in the same directory as the sourcecode.

Parameters:
fileData: - keyed by filename(leaf) and valued by prerequisite filenames in a List.

defaultFilename

protected java.lang.String defaultFilename()
Return the default file name. This method can be overridden in derived classes if a different default name is preferred.

Returns:
value of the make file name

defaultDependencyFilename

protected java.lang.String defaultDependencyFilename()
Return the default file name. This method can be overridden in derived classes if a different default name is preferred.

Returns:
value of the make file name

defaultPackageDependencyFilename

protected java.lang.String defaultPackageDependencyFilename()

getLanguages

public java.util.Set getLanguages()
Description copied from interface: BuildGenerator
Return the set of languages that this build generator serves. Each build generator serves a Set of languages.

Specified by:
getLanguages in interface BuildGenerator
Returns:
a Set of strings. Each string in the set represents a language supported by the build generator.

setContext

public void setContext(Context context)
Description copied from interface: ContextAware
Routine to notify extensions of the context.

Specified by:
setContext in interface ContextAware