gov.llnl.babel.backend

Class MakefileGenerator

Implemented Interfaces:
BuildGenerator, ContextAware, FileListener

public class MakefileGenerator
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

MakefileGenerator()

Method Summary

void
createAll()
Create all Makefiles in all the directories registered with the FileManager.
void
createMakefileInDirectory(String makefilename, String dirname)
Create a single makefile in a specific directory.
protected String
defaultFilename()
Return the default file name.
void
excludeGroup(String groupname)
Add a file group to be excluded from generation.
Set
getLanguages()
void
newFile(SymbolID id, int type, String role, String dir, String name)
This method is called for each file created by the FileManager.
void
readmitExcludedGroup(String groupname)
Remove a group name from those excluded from generation;
void
setContext(Context context)
protected void
writeMakefile(PrintWriter pw, Map role2files)
Generate the actual make file.

Constructor Details

MakefileGenerator

public MakefileGenerator()

Method Details

createAll

public void createAll()
            throws IOException
Create all Makefiles in all the directories registered with the FileManager.
Specified by:
createAll in interface BuildGenerator
See Also:
FileManager

createMakefileInDirectory

public void createMakefileInDirectory(String makefilename,
                                      String dirname)
            throws 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:
makefilename - set makefile name, if null or "", defaults to <make-prefix> + "babel.make"
dirname - directory to look for

defaultFilename

protected 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

excludeGroup

public void excludeGroup(String groupname)
Add a file group to be excluded from generation. By default no group is excluded when the MakefileGenerator is constructed.
Parameters:
groupname - string name of a file group

getLanguages

public Set getLanguages()
Specified by:
getLanguages in interface BuildGenerator

newFile

public void newFile(SymbolID id,
                    int type,
                    String role,
                    String dir,
                    String name)
This method is called for each file created by the FileManager.
Specified by:
newFile in interface FileListener

readmitExcludedGroup

public void readmitExcludedGroup(String groupname)
Remove a group name from those excluded from generation;
Parameters:
groupname - string name of a file group

setContext

public void setContext(Context context)
Specified by:
setContext in interface ContextAware

writeMakefile

protected void writeMakefile(PrintWriter pw,
                             Map role2files)
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.