org.eclipse.cdt.managedbuilder.makegen.gnu
Class GnuMakefileGenerator

java.lang.Object
  extended by org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator
All Implemented Interfaces:
IManagedBuilderMakefileGenerator, IManagedBuilderMakefileGenerator2

public class GnuMakefileGenerator
extends java.lang.Object
implements IManagedBuilderMakefileGenerator2

This is a specialized makefile generator that takes advantage of the extensions present in Gnu Make.

Since:
1.2

Nested Class Summary
 class GnuMakefileGenerator.ResourceDeltaVisitor
          This class walks the delta supplied by the build system to determine what resources have been changed.
 
Field Summary
static int ABSOLUTE
           
static java.lang.String ECHO_BLANK_LINE
           
static int PROJECT_RELATIVE
           
static int PROJECT_SUBDIR_RELATIVE
           
 
Fields inherited from interface org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator
AT, COLON, COLS_PER_LINE, COMMENT_SYMBOL, DASH, DEP_EXT, DEPFILE_NAME, DOLLAR_SYMBOL, DOT, ECHO, IN_MACRO, LINEBREAK, LOGICAL_AND, MAKE, MAKEFILE_DEFS, MAKEFILE_INIT, MAKEFILE_NAME, MAKEFILE_TARGETS, MODFILE_NAME, NEWLINE, NO_PRINT_DIR, NO_SOURCE_FOLDERS, OBJECTS_MAKFILE, OUT_MACRO, ROOT, SEPARATOR, SINGLE_QUOTE, SPACES_IN_PATH, SRCSFILE_NAME, TAB, WHITESPACE, WILDCARD
 
Constructor Summary
GnuMakefileGenerator()
           
 
Method Summary
 void addMacroAdditionFiles(java.util.HashMap map, java.lang.String macroName, java.util.Vector filenames)
           
static boolean containsSpecialCharacters(java.lang.String path)
           
 java.lang.String ensurePathIsGNUMakeTargetRuleCompatibleSyntax(java.lang.String path)
          Process a String denoting a filepath in a way compatible for GNU Make rules, handling windows drive letters and whitespace appropriately.
static java.lang.String ensureUnquoted(java.lang.String path)
          Strips outermost quotes of Strings of the form "a" and 'a' or returns the original string if the input is not of this form.
static java.lang.String escapedEcho(java.lang.String string)
          prepend all instanced of '\' or '"' with a backslash
static java.lang.String escapeWhitespaces(java.lang.String path)
           
 void generateDependencies()
           
 org.eclipse.core.runtime.MultiStatus generateMakefiles(org.eclipse.core.resources.IResourceDelta delta)
          Clients call this method when an incremental rebuild is required.
 java.util.HashMap getBuildOutputVars()
           
 java.util.List getBuildVariableList(org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator.ToolInfoHolder h, java.lang.String variable, int locationType, org.eclipse.core.runtime.IPath directory, boolean getAll)
           
 org.eclipse.core.runtime.IPath getBuildWorkingDir()
          Answers the path of the top directory generated for the build output, or null if none has been generated.
 java.lang.StringBuffer getDepMacroName(java.lang.String extensionName)
           
 java.lang.String getMakefileName()
          Answers the name of the top-level makefile generated by the receiver.
 java.util.Set getOutputExtensions(org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator.ToolInfoHolder h)
           
 java.lang.StringBuffer getSourceMacroName(java.lang.String extensionName)
          M A K E F I L E G E N E R A T I O N C O M M O N M E T H O D S
 org.eclipse.core.runtime.IPath getTopBuildDir()
          Return the configuration's top build directory as an absolute path
 java.util.LinkedHashMap getTopBuildOutputVars()
           
 java.util.List getTopBuildVariableList(java.lang.String variable)
           
 void initialize(int buildKind, IConfiguration cfg, IBuilder builder, org.eclipse.core.runtime.IProgressMonitor monitor)
           
 void initialize(org.eclipse.core.resources.IProject project, IManagedBuildInfo info, org.eclipse.core.runtime.IProgressMonitor monitor)
          IManagedBuilderMakefileGenerator M E T H O D S
 boolean isGeneratedResource(org.eclipse.core.resources.IResource resource)
          Answers true if the argument is a resource created by the generator
static boolean populateDummyTargets(IConfiguration cfg, org.eclipse.core.resources.IFile makefile, boolean force)
          This method postprocesses a .d file created by a build.
static boolean populateDummyTargets(IResourceInfo rcInfo, org.eclipse.core.resources.IFile makefile, boolean force)
           
 void regenerateDependencies(boolean force)
           
 org.eclipse.core.runtime.MultiStatus regenerateMakefiles()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROJECT_RELATIVE

public static final int PROJECT_RELATIVE
See Also:
Constant Field Values

PROJECT_SUBDIR_RELATIVE

public static final int PROJECT_SUBDIR_RELATIVE
See Also:
Constant Field Values

ABSOLUTE

public static final int ABSOLUTE
See Also:
Constant Field Values

ECHO_BLANK_LINE

public static java.lang.String ECHO_BLANK_LINE
Constructor Detail

GnuMakefileGenerator

public GnuMakefileGenerator()
Method Detail

initialize

public void initialize(org.eclipse.core.resources.IProject project,
                       IManagedBuildInfo info,
                       org.eclipse.core.runtime.IProgressMonitor monitor)
IManagedBuilderMakefileGenerator M E T H O D S

Specified by:
initialize in interface IManagedBuilderMakefileGenerator

generateDependencies

public void generateDependencies()
                          throws org.eclipse.core.runtime.CoreException
Specified by:
generateDependencies in interface IManagedBuilderMakefileGenerator
Throws:
org.eclipse.core.runtime.CoreException

generateMakefiles

public org.eclipse.core.runtime.MultiStatus generateMakefiles(org.eclipse.core.resources.IResourceDelta delta)
                                                       throws org.eclipse.core.runtime.CoreException
Description copied from interface: IManagedBuilderMakefileGenerator
Clients call this method when an incremental rebuild is required. The argument contains a set of resource deltas that will be used to determine which subdirectories need a new makefile and dependency list (if any).

Specified by:
generateMakefiles in interface IManagedBuilderMakefileGenerator
Throws:
org.eclipse.core.runtime.CoreException

getBuildWorkingDir

public org.eclipse.core.runtime.IPath getBuildWorkingDir()
Description copied from interface: IManagedBuilderMakefileGenerator
Answers the path of the top directory generated for the build output, or null if none has been generated.

Specified by:
getBuildWorkingDir in interface IManagedBuilderMakefileGenerator
Returns:
IPath to the working directory of the build

getMakefileName

public java.lang.String getMakefileName()
Description copied from interface: IManagedBuilderMakefileGenerator
Answers the name of the top-level makefile generated by the receiver.

Specified by:
getMakefileName in interface IManagedBuilderMakefileGenerator
Returns:
name of the makefile.

isGeneratedResource

public boolean isGeneratedResource(org.eclipse.core.resources.IResource resource)
Description copied from interface: IManagedBuilderMakefileGenerator
Answers true if the argument is a resource created by the generator

Specified by:
isGeneratedResource in interface IManagedBuilderMakefileGenerator
Returns:

regenerateDependencies

public void regenerateDependencies(boolean force)
                            throws org.eclipse.core.runtime.CoreException
Specified by:
regenerateDependencies in interface IManagedBuilderMakefileGenerator
Throws:
org.eclipse.core.runtime.CoreException

regenerateMakefiles

public org.eclipse.core.runtime.MultiStatus regenerateMakefiles()
                                                         throws org.eclipse.core.runtime.CoreException
Specified by:
regenerateMakefiles in interface IManagedBuilderMakefileGenerator
Throws:
org.eclipse.core.runtime.CoreException

getSourceMacroName

public java.lang.StringBuffer getSourceMacroName(java.lang.String extensionName)
M A K E F I L E G E N E R A T I O N C O M M O N M E T H O D S


getDepMacroName

public java.lang.StringBuffer getDepMacroName(java.lang.String extensionName)

getOutputExtensions

public java.util.Set getOutputExtensions(org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator.ToolInfoHolder h)

populateDummyTargets

public static boolean populateDummyTargets(IConfiguration cfg,
                                           org.eclipse.core.resources.IFile makefile,
                                           boolean force)
                                    throws org.eclipse.core.runtime.CoreException,
                                           java.io.IOException
This method postprocesses a .d file created by a build. It's main job is to add dummy targets for the header files dependencies. This prevents make from aborting the build if the header file does not exist. A secondary job is to work in tandem with the "echo" command that is used by some tool-chains in order to get the "targets" part of the dependency rule correct. This method adds a comment to the beginning of the dependency file which it checks for to determine if this dependency file has already been updated.

Returns:
a true if the dependency file is modified
Throws:
org.eclipse.core.runtime.CoreException
java.io.IOException

populateDummyTargets

public static boolean populateDummyTargets(IResourceInfo rcInfo,
                                           org.eclipse.core.resources.IFile makefile,
                                           boolean force)
                                    throws org.eclipse.core.runtime.CoreException,
                                           java.io.IOException
Throws:
org.eclipse.core.runtime.CoreException
java.io.IOException

escapedEcho

public static java.lang.String escapedEcho(java.lang.String string)
prepend all instanced of '\' or '"' with a backslash

Parameters:
string -
Returns:

containsSpecialCharacters

public static boolean containsSpecialCharacters(java.lang.String path)

escapeWhitespaces

public static java.lang.String escapeWhitespaces(java.lang.String path)

addMacroAdditionFiles

public void addMacroAdditionFiles(java.util.HashMap map,
                                  java.lang.String macroName,
                                  java.util.Vector filenames)

getBuildVariableList

public java.util.List getBuildVariableList(org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator.ToolInfoHolder h,
                                           java.lang.String variable,
                                           int locationType,
                                           org.eclipse.core.runtime.IPath directory,
                                           boolean getAll)

getTopBuildVariableList

public java.util.List getTopBuildVariableList(java.lang.String variable)

getBuildOutputVars

public java.util.HashMap getBuildOutputVars()

getTopBuildOutputVars

public java.util.LinkedHashMap getTopBuildOutputVars()

getTopBuildDir

public org.eclipse.core.runtime.IPath getTopBuildDir()
Return the configuration's top build directory as an absolute path


ensurePathIsGNUMakeTargetRuleCompatibleSyntax

public java.lang.String ensurePathIsGNUMakeTargetRuleCompatibleSyntax(java.lang.String path)
Process a String denoting a filepath in a way compatible for GNU Make rules, handling windows drive letters and whitespace appropriately.

The context these paths appear in is on the right hand side of a rule header. i.e.

target : dep1 dep2 dep3

Parameters:
path - the String denoting the path to process
Returns:
a suitable Make rule compatible path
Throws:
java.lang.NullPointerException - is path is null

ensureUnquoted

public static java.lang.String ensureUnquoted(java.lang.String path)
Strips outermost quotes of Strings of the form "a" and 'a' or returns the original string if the input is not of this form.

Parameters:
path -
Returns:
a String without the outermost quotes (if the input has them)
Throws:
java.lang.NullPointerException - if path is null

initialize

public void initialize(int buildKind,
                       IConfiguration cfg,
                       IBuilder builder,
                       org.eclipse.core.runtime.IProgressMonitor monitor)
Specified by:
initialize in interface IManagedBuilderMakefileGenerator2