ptolemy.copernicus.kernel
Class MakefileWriter

java.lang.Object
  extended by soot.Transformer
      extended by soot.SceneTransformer
          extended by ptolemy.copernicus.kernel.MakefileWriter
All Implemented Interfaces:
soot.HasPhaseOptions

public class MakefileWriter
extends soot.SceneTransformer
implements soot.HasPhaseOptions

A transformer that writes a makefile that can be used to run a model that has been code generated.

For a model called Foo, we generate Foo/makefile. in the directory named by the outDir parameter.

Since:
Ptolemy II 2.1
Version:
$Id: MakefileWriter.java,v 1.46 2007/12/06 18:28:59 cxh Exp $
Author:
Christopher Hylands
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (cxh)

Method Summary
static void addMakefileSubstitution(java.lang.String name, java.lang.String value)
          Add a makefile substitution from the given name to the given value.
static java.lang.String codeBase(java.lang.String targetPackage, java.lang.String outputDirectory, java.lang.String ptIIDirectory)
          Convert targetPackage "foo/bar" to codeBase "../../.."
 java.lang.String getDeclaredOptions()
           
 java.lang.String getDefaultOptions()
           
 java.lang.String getPhaseName()
           
protected  void internalTransform(java.lang.String phaseName, java.util.Map options)
          Generate a makefile to that can be used to run the generated code.
static MakefileWriter v(CompositeActor model)
          Return an instance of this transformer that will operate on the given model.
 
Methods inherited from class soot.SceneTransformer
transform, transform, transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

v

public static MakefileWriter v(CompositeActor model)
Return an instance of this transformer that will operate on the given model. The model is assumed to already have been properly initialized so that resolved types and other static properties of the model can be inspected.


getPhaseName

public java.lang.String getPhaseName()
Specified by:
getPhaseName in interface soot.HasPhaseOptions

getDefaultOptions

public java.lang.String getDefaultOptions()
Specified by:
getDefaultOptions in interface soot.HasPhaseOptions

getDeclaredOptions

public java.lang.String getDeclaredOptions()
Specified by:
getDeclaredOptions in interface soot.HasPhaseOptions

addMakefileSubstitution

public static void addMakefileSubstitution(java.lang.String name,
                                           java.lang.String value)
Add a makefile substitution from the given name to the given value.


codeBase

public static java.lang.String codeBase(java.lang.String targetPackage,
                                        java.lang.String outputDirectory,
                                        java.lang.String ptIIDirectory)
Convert targetPackage "foo/bar" to codeBase "../../.."

Parameters:
targetPackage - The package where we are creating the code
outputDirectory - The directory where we are producing code.
ptIIDirectory - The Ptolemy II directory, usually the value of $PTII
Returns:
The codebase. If the codebase is ".", then we may want to copy jar files.

internalTransform

protected void internalTransform(java.lang.String phaseName,
                                 java.util.Map options)
Generate a makefile to that can be used to run the generated code.

For example, if the model is called MyModel, and this phase is called with:

        -p wjtp.makefileWriter targetPackage:foo.bar,outdir:c:/tmp,templateDirectory:bif
  
Then we will create the directory c:/tmp/foo/bar/MyModel, read in $PTII/bif/makefile.in and generate c:/tmp/foo/bar/makefile.

Specified by:
internalTransform in class soot.SceneTransformer
Parameters:
phaseName - The name of the phase, for example wjtp.appletWriter.
options - The options Map. This transformer uses the following options:
_generatorAttributeFileName
The pathname to the GeneratorAttribute that contains the keys and values will we use to update the makefile template with.
outDir
The absolute path to the directory where the generated code will reside, for example: c:/ptII/ptolemy/copernicus/applet/cg/Butterfly
overwrite
Determines whether we overwrite a preexisting makefile. The default is to overwrite. T
targetPackage
The package where the generated code will reside, for example: ptolemy.copernicus.applet.cg.Butterfly
templateDirectory
The directory where we should read the makefile.in file