@@ -580,9 +580,50 @@ private boolean isIncludePathDuplicated(String pathToCheck)
580
580
{
581
581
// path operations failed, just returning false
582
582
}
583
+ <<<<<<< HEAD
583
584
584
585
return false ;
585
586
}
587
+ =======
588
+ return false ;
589
+ }
590
+
591
+ /*
592
+ * ----------------------------------------------------------------------------------------
593
+ * Arguments
594
+ */
595
+ private static final String case_sensitive_arg = "-cs" ;
596
+ private static final String output_path_arg = "-d" ;
597
+ private static final String default_container_prealloc_size = "-default-container-prealloc-size" ;
598
+ private static final String default_extensibility_arg = "-default_extensibility" ;
599
+ private static final String default_extensibility_short_arg = "-de" ;
600
+ private static final String specific_platform_arg = "-example" ;
601
+ private static final String extra_template_arg = "-extrastg" ;
602
+ private static final String flat_output_directory_arg = "-flat-output-dir" ;
603
+ private static final String fusion_arg = "-fusion" ;
604
+ private static final String help_arg = "-help" ;
605
+ private static final String include_path_arg = "-I" ;
606
+ private static final String language_arg = "-language" ;
607
+ private static final String no_typesupport_arg = "-no-typesupport" ;
608
+ private static final String no_typeobjectsupport_arg = "-no-typeobjectsupport" ;
609
+ private static final String no_dependencies_arg = "-no-dependencies" ;
610
+ private static final String package_arg = "-package" ;
611
+ private static final String disable_preprocessor_arg = "-ppDisable" ;
612
+ private static final String preprocessor_path_arg = "-ppPath" ;
613
+ private static final String python_bindings_arg = "-python" ;
614
+ private static final String replace_arg = "-replace" ;
615
+ private static final String temp_dir_arg = "-t" ;
616
+ private static final String ros2_names_arg = "-typeros2" ;
617
+ private static final String cnames_arg = "-typesc" ;
618
+ private static final String version_arg = "-version" ;
619
+
620
+ /*
621
+ * ----------------------------------------------------------------------------------------
622
+ * Developer Arguments
623
+ */
624
+ private static final String generate_api_arg = "-genapi" ;
625
+ private static final String execute_test_arg = "-test" ;
626
+ >>>>>>> fbb0672 (Apply user template to included IDL files (#472 ) (#474 ))
586
627
587
628
public static void printHelp ()
588
629
{
@@ -783,9 +824,26 @@ private Project parseIDL(
783
824
for (Map .Entry <String , String > entry : m_customStgOutput .entrySet ())
784
825
{
785
826
System .out .println ("Loading custom template " + entry .getKey () + "..." );
827
+ <<<<<<< HEAD
786
828
Path path = Paths .get (entry .getKey ());
787
829
String templateName = path .getFileName ().toString ().substring (0 , path .getFileName ().toString ().lastIndexOf ('.' ));
788
830
tmanager .addGroup (templateName );
831
+ =======
832
+ loadAndAddTemplate (entry .getKey (), tmanager );
833
+ }
834
+ }
835
+ else
836
+ {
837
+ // Check if there is a '@' in the output_file_name
838
+ for (Map .Entry <String , String > entry : m_customStgOutput .entrySet ())
839
+ {
840
+ if (entry .getValue ().contains ("@" ))
841
+ {
842
+ System .out .println ("Loading custom template " +
843
+ entry .getKey () + " for included IDL file " + idlFilename + "..." );
844
+ loadAndAddTemplate (entry .getKey (), tmanager );
845
+ }
846
+ >>>>>>> fbb0672 (Apply user template to included IDL files (#472 ) (#474 ))
789
847
}
790
848
}
791
849
@@ -828,6 +886,7 @@ private Project parseIDL(
828
886
{
829
887
for (Map .Entry <String , String > entry : m_customStgOutput .entrySet ())
830
888
{
889
+ <<<<<<< HEAD
831
890
Path path = Paths .get (entry .getKey ());
832
891
String templateName = path .getFileName ().toString ().substring (0 , path .getFileName ().toString ().lastIndexOf ('.' ));
833
892
System .out .println ("Generating from custom " + templateName + " to " + entry .getValue ());
@@ -845,11 +904,32 @@ private Project parseIDL(
845
904
}
846
905
}
847
906
else
907
+ =======
908
+ if (! (returnedValue = createOutputCustomTemplate (
909
+ entry , idlFilename , output_dir , relative_dir , ctx .getFilename (),
910
+ maintemplates , m_replace , project )))
911
+ >>>>>>> fbb0672 (Apply user template to included IDL files (#472 ) (#474 ))
848
912
{
849
913
break ;
850
914
}
851
915
}
852
916
}
917
+ else
918
+ {
919
+ // Check if there is a '$' in the output_file_name
920
+ for (Map .Entry <String , String > entry : m_customStgOutput .entrySet ())
921
+ {
922
+ if (entry .getValue ().contains ("@" ))
923
+ {
924
+ if (! (returnedValue = createOutputCustomTemplate (
925
+ entry , idlFilename , output_dir , relative_dir , ctx .getFilename (),
926
+ maintemplates , m_replace , project )))
927
+ {
928
+ break ;
929
+ }
930
+ }
931
+ }
932
+ }
853
933
854
934
System .out .println ("Generating Type definition files..." );
855
935
if ((returnedValue ) && (returnedValue =
@@ -1048,6 +1128,55 @@ private Project parseIDL(
1048
1128
return returnedValue ? project : null ;
1049
1129
}
1050
1130
1131
+ private void loadAndAddTemplate (
1132
+ String templatePath ,
1133
+ TemplateManager tmanager )
1134
+ {
1135
+ try
1136
+ {
1137
+ Path path = Paths .get (templatePath );
1138
+ String templateName = path .getFileName ().toString ();
1139
+ templateName = templateName .substring (0 , templateName .lastIndexOf ('.' ));
1140
+ String content = new String (Files .readAllBytes (path ));
1141
+ tmanager .addGroupFromString (templateName , content );
1142
+ }
1143
+ catch (IOException e )
1144
+ {
1145
+ System .out .println (ColorMessage .error ("IOException" ) + "Cannot read content from " + templatePath );
1146
+ }
1147
+ }
1148
+
1149
+ private boolean createOutputCustomTemplate (
1150
+ Map .Entry <String , String > entry ,
1151
+ String idlFilename ,
1152
+ String outputDir ,
1153
+ String relativeDir ,
1154
+ String contextFilename ,
1155
+ TemplateGroup maintemplates ,
1156
+ boolean replace ,
1157
+ Project project )
1158
+ {
1159
+ Path path = Paths .get (entry .getKey ());
1160
+ String templateName = path .getFileName ().toString ();
1161
+ templateName = templateName .substring (0 , templateName .lastIndexOf ('.' ));
1162
+ String outputName = entry .getValue ().replace ("@" , idlFilename .substring (0 , idlFilename .lastIndexOf ('.' )));
1163
+ System .out .println ("Generating from custom " + templateName + " to " + outputName );
1164
+
1165
+ boolean ret_val = Utils .writeFile (outputDir + outputName , maintemplates .getTemplate (templateName ), replace );
1166
+ if (ret_val )
1167
+ {
1168
+ if (outputName .contains (".hpp" ) || outputName .contains (".h" ))
1169
+ {
1170
+ project .addCommonIncludeFile (relativeDir + outputName );
1171
+ }
1172
+ else
1173
+ {
1174
+ project .addCommonSrcFile (relativeDir + contextFilename + outputName );
1175
+ }
1176
+ }
1177
+ return ret_val ;
1178
+ }
1179
+
1051
1180
private boolean genSolution (
1052
1181
Solution solution )
1053
1182
{
0 commit comments