diff --git a/src/main/java/com/eprosima/fastdds/fastddsgen.java b/src/main/java/com/eprosima/fastdds/fastddsgen.java index 718f6c91..39bebd51 100644 --- a/src/main/java/com/eprosima/fastdds/fastddsgen.java +++ b/src/main/java/com/eprosima/fastdds/fastddsgen.java @@ -40,8 +40,14 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.IOError; import java.io.InputStreamReader; import java.io.OutputStream; +<<<<<<< HEAD +======= +import java.nio.file.InvalidPathException; +import java.nio.file.Files; +>>>>>>> 5f95b79 (Avoid inclussion of duplicate included paths (#429)) import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; @@ -174,7 +180,54 @@ else if (arg.equals("-example")) throw new BadArgumentException("No architecture speficied after -example argument"); } } +<<<<<<< HEAD else if (arg.equals("-language")) +======= + else if (arg.equals(extra_template_arg)) + { + if (count + 1 < args.length) + { + m_customStgOutput.put(args[count++], args[count++]); + } + else + { + throw new BadArgumentException("Missing arguments for " + extra_template_arg); + } + } + else if (arg.equals(flat_output_directory_arg)) + { + m_flat_output_dir = true; + } + else if (arg.equals(generate_api_arg)) + { + gen_api_ = true; + } + else if (arg.equals(help_arg)) + { + printHelp(); + System.exit(0); + } + else if (arg.equals("-help+")) + { + printEnhacedHelp(); + System.exit(0); + } + else if (arg.equals(include_path_arg)) + { + if (count < args.length) + { + String pathStr = args[count++]; + if (!isIncludePathDuplicated(pathStr)) { + m_includePaths.add(include_path_arg.concat(pathStr)); + } + } + else + { + throw new BadArgumentException("No include directory specified after " + include_path_arg + " argument"); + } + } + else if (arg.equals(language_arg)) +>>>>>>> 5f95b79 (Avoid inclussion of duplicate included paths (#429)) { if (count < args.length) { @@ -542,6 +595,70 @@ private void showVersion() System.out.println(m_appName + " version " + version); } +<<<<<<< HEAD +======= + private boolean isIncludePathDuplicated(String pathToCheck) { + try { + Path path = Paths.get(pathToCheck); + String absPath = path.toAbsolutePath().toString(); + boolean isDuplicateFound = false; + for (String includePath : m_includePaths) { + // include paths are prefixed with "-I" + if (includePath.length() <= 2) { + continue; + } + String absIncludePath = Paths.get(includePath.substring(2)).toAbsolutePath().toString(); + if (absPath.toLowerCase().equals(absIncludePath.toLowerCase())) { + isDuplicateFound = true; + break; + } + } + if (isDuplicateFound) { + return true; + } + } catch (InvalidPathException | IOError | SecurityException ex) { + // path operations failed, just returning false + } + return false; + } + + /* + * ---------------------------------------------------------------------------------------- + * Arguments + */ + private static final String case_sensitive_arg = "-cs"; + private static final String output_path_arg = "-d"; + private static final String default_container_prealloc_size = "-default-container-prealloc-size"; + private static final String default_extensibility_arg = "-default_extensibility"; + private static final String default_extensibility_short_arg = "-de"; + private static final String specific_platform_arg = "-example"; + private static final String extra_template_arg = "-extrastg"; + private static final String flat_output_directory_arg = "-flat-output-dir"; + private static final String fusion_arg = "-fusion"; + private static final String help_arg = "-help"; + private static final String include_path_arg = "-I"; + private static final String language_arg = "-language"; + private static final String no_typesupport_arg = "-no-typesupport"; + private static final String no_typeobjectsupport_arg = "-no-typeobjectsupport"; + private static final String no_dependencies_arg = "-no-dependencies"; + private static final String package_arg = "-package"; + private static final String disable_preprocessor_arg = "-ppDisable"; + private static final String preprocessor_path_arg = "-ppPath"; + private static final String python_bindings_arg = "-python"; + private static final String replace_arg = "-replace"; + private static final String temp_dir_arg = "-t"; + private static final String ros2_names_arg = "-typeros2"; + private static final String cnames_arg = "-typesc"; + private static final String version_arg = "-version"; + + /* + * ---------------------------------------------------------------------------------------- + * Developer Arguments + */ + private static final String generate_api_arg = "-genapi"; + private static final String execute_test_arg = "-test"; + +>>>>>>> 5f95b79 (Avoid inclussion of duplicate included paths (#429)) public static void printHelp() { System.out.println(m_appName + " usage:");