@@ -580,9 +580,9 @@ private boolean isIncludePathDuplicated(String pathToCheck)
580580 {
581581 // path operations failed, just returning false
582582 }
583-
583+
584584 return false ;
585- }
585+ }
586586
587587 public static void printHelp ()
588588 {
@@ -783,9 +783,20 @@ private Project parseIDL(
783783 for (Map .Entry <String , String > entry : m_customStgOutput .entrySet ())
784784 {
785785 System .out .println ("Loading custom template " + entry .getKey () + "..." );
786- Path path = Paths .get (entry .getKey ());
787- String templateName = path .getFileName ().toString ().substring (0 , path .getFileName ().toString ().lastIndexOf ('.' ));
788- tmanager .addGroup (templateName );
786+ loadAndAddTemplate (entry .getKey (), tmanager );
787+ }
788+ }
789+ else
790+ {
791+ // Check if there is a '@' in the output_file_name
792+ for (Map .Entry <String , String > entry : m_customStgOutput .entrySet ())
793+ {
794+ if (entry .getValue ().contains ("@" ))
795+ {
796+ System .out .println ("Loading custom template " +
797+ entry .getKey () + " for included IDL file " + idlFilename + "..." );
798+ loadAndAddTemplate (entry .getKey (), tmanager );
799+ }
789800 }
790801 }
791802
@@ -828,25 +839,27 @@ private Project parseIDL(
828839 {
829840 for (Map .Entry <String , String > entry : m_customStgOutput .entrySet ())
830841 {
831- Path path = Paths .get (entry .getKey ());
832- String templateName = path .getFileName ().toString ().substring (0 , path .getFileName ().toString ().lastIndexOf ('.' ));
833- System .out .println ("Generating from custom " + templateName + " to " + entry .getValue ());
834-
835- if (returnedValue = Utils .writeFile (m_outputDir + entry .getValue (), maintemplates .getTemplate (templateName ), m_replace ))
842+ if (! (returnedValue = createOutputCustomTemplate (
843+ entry , idlFilename , m_outputDir , ctx .getFilename (),
844+ maintemplates , m_replace , project )))
836845 {
837- // Try to determine if the file is a header file.
838- if (entry .getValue ().contains (".hpp" ) || entry .getValue ().contains (".h" ))
839- {
840- project .addCommonIncludeFile (entry .getValue ());
841- }
842- else
843- {
844- project .addCommonSrcFile (ctx .getFilename () + entry .getValue ());
845- }
846+ break ;
846847 }
847- else
848+ }
849+ }
850+ else
851+ {
852+ // Check if there is a '$' in the output_file_name
853+ for (Map .Entry <String , String > entry : m_customStgOutput .entrySet ())
854+ {
855+ if (entry .getValue ().contains ("@" ))
848856 {
849- break ;
857+ if (! (returnedValue = createOutputCustomTemplate (
858+ entry , idlFilename , m_outputDir , ctx .getFilename (),
859+ maintemplates , m_replace , project )))
860+ {
861+ break ;
862+ }
850863 }
851864 }
852865 }
@@ -1048,6 +1061,46 @@ private Project parseIDL(
10481061 return returnedValue ? project : null ;
10491062 }
10501063
1064+ private void loadAndAddTemplate (
1065+ String templatePath ,
1066+ TemplateManager tmanager )
1067+ {
1068+ Path path = Paths .get (templatePath );
1069+ String templateName = path .getFileName ().toString ();
1070+ templateName = templateName .substring (0 , templateName .lastIndexOf ('.' ));
1071+ tmanager .addGroup (templateName );
1072+ }
1073+
1074+ private boolean createOutputCustomTemplate (
1075+ Map .Entry <String , String > entry ,
1076+ String idlFilename ,
1077+ String outputDir ,
1078+ String contextFilename ,
1079+ TemplateGroup maintemplates ,
1080+ boolean replace ,
1081+ Project project )
1082+ {
1083+ Path path = Paths .get (entry .getKey ());
1084+ String templateName = path .getFileName ().toString ();
1085+ templateName = templateName .substring (0 , templateName .lastIndexOf ('.' ));
1086+ String outputName = entry .getValue ().replace ("@" , idlFilename .substring (0 , idlFilename .lastIndexOf ('.' )));
1087+ System .out .println ("Generating from custom " + templateName + " to " + outputName );
1088+
1089+ boolean ret_val = Utils .writeFile (outputDir + outputName , maintemplates .getTemplate (templateName ), replace );
1090+ if (ret_val )
1091+ {
1092+ if (outputName .contains (".hpp" ) || outputName .contains (".h" ))
1093+ {
1094+ project .addCommonIncludeFile (outputName );
1095+ }
1096+ else
1097+ {
1098+ project .addCommonSrcFile (contextFilename + outputName );
1099+ }
1100+ }
1101+ return ret_val ;
1102+ }
1103+
10511104 private boolean genSolution (
10521105 Solution solution )
10531106 {
0 commit comments