-- $Id$
-- Helper methods for generating build.xml files.
library BuildFileHelpers;
helper context String def : configString(ignore : Sequence(String)) : String =
'-- code generation configuration\n' +
'library config;\n\n' +
'helper context String def : path() : String =\n' +
' \'' + self.targetPath() + '/\' + self;\n\n' +
'helper context String def : ignore() : Boolean =\n' +
ignore->iterate(e; acc : String = ' false'|
acc + ' or self.startsWith(\'' + e + '\')') + ';\n';
helper context String def : header() : String =
'\n' +
'\n' +
' \n' +
' \n\n' +
' \n' +
' \n' +
' \n' +
' \n' +
' \n\n' +
' \n' +
' \n';
helper context String def : targetPath() : String =
DSL!CodeGenerator.allInstances()->collect(e|e.targetPath)->first();
helper context String def : footer() : String =
' \n' +
' \n\n' +
' \n' +
'';
helper context DSL!RefinementConfiguration def : body(input : String) : String =
self.first.toString(input);
helper context String def : comment() : String =
' \n';
helper context String def : argLine() : String =
' \n';
helper context String def : argTrans() : String =
'--trans ${transf.uri}' + self + '.asm';
helper context String def : argInUML() : String =
'--in IN=' + self + '.ecore UML=${mmodel.uml} EMF';
helper context String def : argMergeUML() : String =
'--in MERGE=' + self + '.ecore UML=${mmodel.uml} EMF';
helper context String def : argOutUML() : String =
'--out OUT=' + self + '.ecore UML=${mmodel.uml} EMF';
helper context String def : atlMergeCommand(trans : String, input : String, merge : String, output : String, useJavaLib : Boolean) : String =
self.comment() +
trans.argTrans().argLine() +
input.argInUML().argLine() +
merge.argMergeUML().argLine() +
output.argOutUML().argLine() +
'--lib MergeHelpers=${lib.merge}'.argLine() +
if useJavaLib then '--lib Java=${lib.java}'.argLine() else '' endif +
'--next'.argLine();
helper context String def : atlCommand(trans : String, input : String, output : String, useJavaLib : Boolean) : String =
self.comment() +
trans.argTrans().argLine() +
input.argInUML().argLine() +
output.argOutUML().argLine() +
if useJavaLib then '--lib Java=${lib.java}'.argLine() else '' endif +
'--next'.argLine();
helper context String def : atlGeneratorCommand(trans : String, input : String) : String =
self.comment() +
trans.argTrans().argLine() +
input.argInUML().argLine() +
'--lib Java=${lib.config}'.argLine();
helper context String def : atlRefineMergeCommand(input : String, merge : String) : String =
('refine ' + self).atlMergeCommand(self, input, merge, input + 'r', true);
helper context String def : atlRefineCommand(input : String) : String =
('refine ' + self).atlCommand(self, input, input + 'r', true);
helper context DSL!AssociationAttributes def : toString(input : String) : String =
'AssociationAttributes'.atlRefineMergeCommand(input, '${rmodel.ocltypes}') +
self.next.toString(input + 'r');
helper context DSL!Java2AssociationAttributes def : toString(input : String) : String =
'Java2AssociationAttributes'.atlRefineMergeCommand(input, '${rmodel.ocltypes}') +
self.next.toString(input + 'r');
helper context DSL!Accessors def : toString(input : String) : String =
'Accessors'.atlRefineMergeCommand(input, '${rmodel.ocltypes}') +
self.next.toString(input + 'r');
helper context DSL!Java2Accessors def : toString(input : String) : String =
'Java2Accessors'.atlRefineMergeCommand(input, '${rmodel.ocltypes}') +
self.next.toString(input + 'r');
helper context DSL!Observer def : toString(input : String) : String =
'Observer'.atlRefineMergeCommand(input, '${rmodel.observer}') +
self.next.toString(input + 'r');
helper context DSL!JavaObserver def : toString(input : String) : String =
'JavaObserver'.atlRefineMergeCommand(input, '${rmodel.javatypes}') +
self.next.toString(input + 'r');
helper context DSL!Singleton def : toString(input : String) : String =
'Singleton'.atlRefineCommand(input) +
self.next.toString(input + 'r');
helper context DSL!Applet def : toString(input : String) : String =
'Applet'.atlRefineMergeCommand(input, '${rmodel.applet}') +
self.next.toString(input + 'r');
helper context DSL!MIDlet def : toString(input : String) : String =
'MIDlet'.atlRefineMergeCommand(input, '${rmodel.midlet}') +
self.next.toString(input + 'r');
helper context DSL!AsyncMethods def : toString(input : String) : String =
'AsyncMethods'.atlRefineCommand(input) +
self.next.toString(input + 'r');
helper context DSL!DataTypes def : toString(input : String) : String =
'DataTypes'.atlRefineMergeCommand(input, '${rmodel.javatypes}') +
self.next.toString(input + 'r');
helper context DSL!Java2DataTypes def : toString(input : String) : String =
'Java2DataTypes'.atlRefineMergeCommand(input, '${rmodel.javatypes}') +
self.next.toString(input + 'r');
helper context DSL!UMLtoJava def : toString(input : String) : String =
'generate Java code'.atlGeneratorCommand('UMLtoJava', input);