@@ -589,7 +589,7 @@ private boolean isIncludePathDuplicated(String pathToCheck) {
589589 }
590590 return false ;
591591 }
592-
592+
593593 /*
594594 * ----------------------------------------------------------------------------------------
595595 * Arguments
@@ -869,14 +869,19 @@ private Project parseIDL(
869869 for (Map .Entry <String , String > entry : m_customStgOutput .entrySet ())
870870 {
871871 System .out .println ("Loading custom template " + entry .getKey () + "..." );
872- Path path = Paths .get (entry .getKey ());
873- String templateName = path .getFileName ().toString ().substring (0 , path .getFileName ().toString ().lastIndexOf ('.' ));
874- try {
875- String content = new String (Files .readAllBytes (path ));
876- tmanager .addGroupFromString (templateName , content );
877- } catch (IOException e ){
878- System .out .println (ColorMessage .error (
879- "IOException" ) + "Cannot read content from " + path .toString ());
872+ loadAndAddTemplate (entry .getKey (), tmanager );
873+ }
874+ }
875+ else
876+ {
877+ // Check if there is a '@' in the output_file_name
878+ for (Map .Entry <String , String > entry : m_customStgOutput .entrySet ())
879+ {
880+ if (entry .getValue ().contains ("@" ))
881+ {
882+ System .out .println ("Loading custom template " +
883+ entry .getKey () + " for included IDL file " + idlFilename + "..." );
884+ loadAndAddTemplate (entry .getKey (), tmanager );
880885 }
881886 }
882887 }
@@ -919,25 +924,27 @@ private Project parseIDL(
919924 {
920925 for (Map .Entry <String , String > entry : m_customStgOutput .entrySet ())
921926 {
922- Path path = Paths .get (entry .getKey ());
923- String templateName = path .getFileName ().toString ().substring (0 , path .getFileName ().toString ().lastIndexOf ('.' ));
924- System .out .println ("Generating from custom " + templateName + " to " + entry .getValue ());
925-
926- if (returnedValue = Utils .writeFile (output_dir + entry .getValue (), maintemplates .getTemplate (templateName ), m_replace ))
927+ if (! (returnedValue = createOutputCustomTemplate (
928+ entry , idlFilename , output_dir , relative_dir , ctx .getFilename (),
929+ maintemplates , m_replace , project )))
927930 {
928- // Try to determine if the file is a header file.
929- if (entry .getValue ().contains (".hpp" ) || entry .getValue ().contains (".h" ))
930- {
931- project .addCommonIncludeFile (relative_dir + entry .getValue ());
932- }
933- else
934- {
935- project .addCommonSrcFile (relative_dir + ctx .getFilename () + entry .getValue ());
936- }
931+ break ;
937932 }
938- else
933+ }
934+ }
935+ else
936+ {
937+ // Check if there is a '$' in the output_file_name
938+ for (Map .Entry <String , String > entry : m_customStgOutput .entrySet ())
939+ {
940+ if (entry .getValue ().contains ("@" ))
939941 {
940- break ;
942+ if (! (returnedValue = createOutputCustomTemplate (
943+ entry , idlFilename , output_dir , relative_dir , ctx .getFilename (),
944+ maintemplates , m_replace , project )))
945+ {
946+ break ;
947+ }
941948 }
942949 }
943950 }
@@ -1176,6 +1183,55 @@ private Project parseIDL(
11761183 return returnedValue ? project : null ;
11771184 }
11781185
1186+ private void loadAndAddTemplate (
1187+ String templatePath ,
1188+ TemplateManager tmanager )
1189+ {
1190+ try
1191+ {
1192+ Path path = Paths .get (templatePath );
1193+ String templateName = path .getFileName ().toString ();
1194+ templateName = templateName .substring (0 , templateName .lastIndexOf ('.' ));
1195+ String content = new String (Files .readAllBytes (path ));
1196+ tmanager .addGroupFromString (templateName , content );
1197+ }
1198+ catch (IOException e )
1199+ {
1200+ System .out .println (ColorMessage .error ("IOException" ) + "Cannot read content from " + templatePath );
1201+ }
1202+ }
1203+
1204+ private boolean createOutputCustomTemplate (
1205+ Map .Entry <String , String > entry ,
1206+ String idlFilename ,
1207+ String outputDir ,
1208+ String relativeDir ,
1209+ String contextFilename ,
1210+ TemplateGroup maintemplates ,
1211+ boolean replace ,
1212+ Project project )
1213+ {
1214+ Path path = Paths .get (entry .getKey ());
1215+ String templateName = path .getFileName ().toString ();
1216+ templateName = templateName .substring (0 , templateName .lastIndexOf ('.' ));
1217+ String outputName = entry .getValue ().replace ("@" , idlFilename .substring (0 , idlFilename .lastIndexOf ('.' )));
1218+ System .out .println ("Generating from custom " + templateName + " to " + outputName );
1219+
1220+ boolean ret_val = Utils .writeFile (outputDir + outputName , maintemplates .getTemplate (templateName ), replace );
1221+ if (ret_val )
1222+ {
1223+ if (outputName .contains (".hpp" ) || outputName .contains (".h" ))
1224+ {
1225+ project .addCommonIncludeFile (relativeDir + outputName );
1226+ }
1227+ else
1228+ {
1229+ project .addCommonSrcFile (relativeDir + contextFilename + outputName );
1230+ }
1231+ }
1232+ return ret_val ;
1233+ }
1234+
11791235 private boolean genSolution (
11801236 Solution solution )
11811237 {
0 commit comments