@@ -580,9 +580,9 @@ private boolean isIncludePathDuplicated(String pathToCheck)
580
580
{
581
581
// path operations failed, just returning false
582
582
}
583
-
583
+
584
584
return false ;
585
- }
585
+ }
586
586
587
587
public static void printHelp ()
588
588
{
@@ -783,9 +783,20 @@ private Project parseIDL(
783
783
for (Map .Entry <String , String > entry : m_customStgOutput .entrySet ())
784
784
{
785
785
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
+ }
789
800
}
790
801
}
791
802
@@ -828,25 +839,27 @@ private Project parseIDL(
828
839
{
829
840
for (Map .Entry <String , String > entry : m_customStgOutput .entrySet ())
830
841
{
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 )))
836
845
{
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 ;
846
847
}
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 ("@" ))
848
856
{
849
- break ;
857
+ if (! (returnedValue = createOutputCustomTemplate (
858
+ entry , idlFilename , m_outputDir , ctx .getFilename (),
859
+ maintemplates , m_replace , project )))
860
+ {
861
+ break ;
862
+ }
850
863
}
851
864
}
852
865
}
@@ -1048,6 +1061,46 @@ private Project parseIDL(
1048
1061
return returnedValue ? project : null ;
1049
1062
}
1050
1063
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
+
1051
1104
private boolean genSolution (
1052
1105
Solution solution )
1053
1106
{
0 commit comments