@@ -589,7 +589,7 @@ private boolean isIncludePathDuplicated(String pathToCheck) {
589
589
}
590
590
return false ;
591
591
}
592
-
592
+
593
593
/*
594
594
* ----------------------------------------------------------------------------------------
595
595
* Arguments
@@ -875,14 +875,19 @@ private Project parseIDL(
875
875
for (Map .Entry <String , String > entry : m_customStgOutput .entrySet ())
876
876
{
877
877
System .out .println ("Loading custom template " + entry .getKey () + "..." );
878
- Path path = Paths .get (entry .getKey ());
879
- String templateName = path .getFileName ().toString ().substring (0 , path .getFileName ().toString ().lastIndexOf ('.' ));
880
- try {
881
- String content = new String (Files .readAllBytes (path ));
882
- tmanager .addGroupFromString (templateName , content );
883
- } catch (IOException e ){
884
- System .out .println (ColorMessage .error (
885
- "IOException" ) + "Cannot read content from " + path .toString ());
878
+ loadAndAddTemplate (entry .getKey (), tmanager );
879
+ }
880
+ }
881
+ else
882
+ {
883
+ // Check if there is a '@' in the output_file_name
884
+ for (Map .Entry <String , String > entry : m_customStgOutput .entrySet ())
885
+ {
886
+ if (entry .getValue ().contains ("@" ))
887
+ {
888
+ System .out .println ("Loading custom template " +
889
+ entry .getKey () + " for included IDL file " + idlFilename + "..." );
890
+ loadAndAddTemplate (entry .getKey (), tmanager );
886
891
}
887
892
}
888
893
}
@@ -925,25 +930,27 @@ private Project parseIDL(
925
930
{
926
931
for (Map .Entry <String , String > entry : m_customStgOutput .entrySet ())
927
932
{
928
- Path path = Paths .get (entry .getKey ());
929
- String templateName = path .getFileName ().toString ().substring (0 , path .getFileName ().toString ().lastIndexOf ('.' ));
930
- System .out .println ("Generating from custom " + templateName + " to " + entry .getValue ());
931
-
932
- if (returnedValue = Utils .writeFile (output_dir + entry .getValue (), maintemplates .getTemplate (templateName ), m_replace ))
933
+ if (! (returnedValue = createOutputCustomTemplate (
934
+ entry , idlFilename , output_dir , relative_dir , ctx .getFilename (),
935
+ maintemplates , m_replace , project )))
933
936
{
934
- // Try to determine if the file is a header file.
935
- if (entry .getValue ().contains (".hpp" ) || entry .getValue ().contains (".h" ))
936
- {
937
- project .addCommonIncludeFile (relative_dir + entry .getValue ());
938
- }
939
- else
940
- {
941
- project .addCommonSrcFile (relative_dir + ctx .getFilename () + entry .getValue ());
942
- }
937
+ break ;
943
938
}
944
- else
939
+ }
940
+ }
941
+ else
942
+ {
943
+ // Check if there is a '$' in the output_file_name
944
+ for (Map .Entry <String , String > entry : m_customStgOutput .entrySet ())
945
+ {
946
+ if (entry .getValue ().contains ("@" ))
945
947
{
946
- break ;
948
+ if (! (returnedValue = createOutputCustomTemplate (
949
+ entry , idlFilename , output_dir , relative_dir , ctx .getFilename (),
950
+ maintemplates , m_replace , project )))
951
+ {
952
+ break ;
953
+ }
947
954
}
948
955
}
949
956
}
@@ -1226,6 +1233,55 @@ private Project parseIDL(
1226
1233
return returnedValue ? project : null ;
1227
1234
}
1228
1235
1236
+ private void loadAndAddTemplate (
1237
+ String templatePath ,
1238
+ TemplateManager tmanager )
1239
+ {
1240
+ try
1241
+ {
1242
+ Path path = Paths .get (templatePath );
1243
+ String templateName = path .getFileName ().toString ();
1244
+ templateName = templateName .substring (0 , templateName .lastIndexOf ('.' ));
1245
+ String content = new String (Files .readAllBytes (path ));
1246
+ tmanager .addGroupFromString (templateName , content );
1247
+ }
1248
+ catch (IOException e )
1249
+ {
1250
+ System .out .println (ColorMessage .error ("IOException" ) + "Cannot read content from " + templatePath );
1251
+ }
1252
+ }
1253
+
1254
+ private boolean createOutputCustomTemplate (
1255
+ Map .Entry <String , String > entry ,
1256
+ String idlFilename ,
1257
+ String outputDir ,
1258
+ String relativeDir ,
1259
+ String contextFilename ,
1260
+ TemplateGroup maintemplates ,
1261
+ boolean replace ,
1262
+ Project project )
1263
+ {
1264
+ Path path = Paths .get (entry .getKey ());
1265
+ String templateName = path .getFileName ().toString ();
1266
+ templateName = templateName .substring (0 , templateName .lastIndexOf ('.' ));
1267
+ String outputName = entry .getValue ().replace ("@" , idlFilename .substring (0 , idlFilename .lastIndexOf ('.' )));
1268
+ System .out .println ("Generating from custom " + templateName + " to " + outputName );
1269
+
1270
+ boolean ret_val = Utils .writeFile (outputDir + outputName , maintemplates .getTemplate (templateName ), replace );
1271
+ if (ret_val )
1272
+ {
1273
+ if (outputName .contains (".hpp" ) || outputName .contains (".h" ))
1274
+ {
1275
+ project .addCommonIncludeFile (relativeDir + outputName );
1276
+ }
1277
+ else
1278
+ {
1279
+ project .addCommonSrcFile (relativeDir + contextFilename + outputName );
1280
+ }
1281
+ }
1282
+ return ret_val ;
1283
+ }
1284
+
1229
1285
private boolean genSolution (
1230
1286
Solution solution )
1231
1287
{
0 commit comments