void BE_post_init(char*[], long) { std::ostringstream version; version << "-D__OPENDDS_IDL=0x" << std::setw(2) << std::setfill('0') << DDS_MAJOR_VERSION << std::setw(2) << std::setfill('0') << DDS_MINOR_VERSION << std::setw(2) << std::setfill('0') << DDS_MICRO_VERSION; DRV_cpp_putarg(version.str().c_str()); #ifdef ACE_HAS_CDR_FIXED DRV_cpp_putarg("-D__OPENDDS_IDL_HAS_FIXED"); #endif const char* env = ACE_OS::getenv("DDS_ROOT"); if (env && env[0]) { std::string dds_root = env; if (dds_root.find(' ') != std::string::npos && dds_root[0] != '"') { dds_root.insert(dds_root.begin(), '"'); dds_root.insert(dds_root.end(), '"'); } be_global->add_inc_path(dds_root.c_str()); ACE_CString included; DRV_add_include_path(included, dds_root.c_str(), 0, true); } }
// Prepare a CPP argument static void DRV_prep_cpp_arg (char *s) { std::string instr (s); std::string newarg; newarg.reserve (512); for (std::string::size_type pos = instr.find_first_of (','); pos != std::string::npos; instr = instr.substr (pos + 1), pos = instr.find_first_of (',')) { newarg.append (instr.substr (0, pos)); } DRV_cpp_putarg (newarg.c_str ()); }
// Parse arguments on command line void DRV_parse_args (long ac, char **av) { ACE_CString buffer; char *s = 0; long i; bool has_space = false; FE_store_env_include_paths (); DRV_cpp_init (); idl_global->set_prog_name (av[0]); for (i = 1; i < ac; i++) { if (av[i][0] == '-') { idl_global->append_idl_flag (av[i]); switch (av[i][1]) { case 0: // One or more letters expected after the dash. ACE_ERROR (( LM_ERROR, ACE_TEXT ("IDL: Space between dash and option ") ACE_TEXT ("letters not allowed\n") )); ++i; idl_global->set_err_count (idl_global->err_count () + 1); break; case 'A': if (av[i][2] == '\0') { if (i < ac - 1) { s = av[i + 1]; ++i; } else { ACE_ERROR (( LM_ERROR, ACE_TEXT ("IDL: incorrect use of ") ACE_TEXT ("the -A option\n") )); idl_global->set_compile_flags ( idl_global->compile_flags () | IDL_CF_ONLY_USAGE ); break; } } else { s = av[i] + 2; } ACE_OS::strcat (idl_global->local_escapes (), s); ACE_OS::strcat (idl_global->local_escapes (), " "); break; case 'a': if (av[i][2] == 'e') { idl_global->anon_type_diagnostic ( IDL_GlobalData::ANON_TYPE_ERROR); } else if (av[i][2] == 'w') { idl_global->anon_type_diagnostic ( IDL_GlobalData::ANON_TYPE_WARNING); } else if (av[i][2] == 's') { idl_global->anon_type_diagnostic ( IDL_GlobalData::ANON_TYPE_SILENT); } else { ACE_ERROR (( LM_ERROR, ACE_TEXT ("IDL: I don't understand") ACE_TEXT (" the '%s' option\n"), ACE_TEXT_CHAR_TO_TCHAR (av[i]) )); } break; // Temp directory for the IDL compiler to keep its files. case 't': if ((av[i][2] == '\0') && (i < ac - 1)) { idl_global->append_idl_flag (av[i + 1]); idl_global->temp_dir (av[i + 1]); ++i; } else { ACE_ERROR (( LM_ERROR, ACE_TEXT ("IDL: I don't understand") ACE_TEXT (" the '%s' option\n"), ACE_TEXT_CHAR_TO_TCHAR (av[i]) )); idl_global->set_compile_flags ( idl_global->compile_flags () | IDL_CF_ONLY_USAGE ); } break; case 'D': case 'U': case 'I': if (av[i][2] == '\0') { if (i < ac - 1) { idl_global->append_idl_flag (av[i + 1]); has_space = FE_Utils::hasspace (av[i + 1]); // If the include path has a space, we need to // add literal "s. ACE_CString arg = av[i]; arg += (has_space ? "\"" : ""); arg += av[i + 1]; arg += (has_space ? "\"" : ""); DRV_cpp_putarg (arg.c_str ()); idl_global->add_include_path (arg.substr (2).c_str (), false); ++i; } else { ACE_ERROR (( LM_ERROR, ACE_TEXT ("IDL: I don't understand") ACE_TEXT (" the '%s' option\n"), ACE_TEXT_CHAR_TO_TCHAR (av[i]) )); idl_global->set_compile_flags ( idl_global->compile_flags () | IDL_CF_ONLY_USAGE ); break; } } else { has_space = FE_Utils::hasspace (av[i]); // If the include path has a space, we need to // add literal "s. ACE_CString arg (av[i], 2); arg += (has_space ? "\"" : ""); arg += av[i] + 2; arg += (has_space? "\"" : ""); idl_global->add_include_path (arg.substr (2).c_str (), false); DRV_cpp_putarg (arg.c_str ()); } break; case 'E': idl_global->set_compile_flags (idl_global->compile_flags () | IDL_CF_ONLY_PREPROC); break; case 'V': idl_global->set_compile_flags (idl_global->compile_flags () | IDL_CF_VERSION); break; case 'W': if (av[i][2] == '\0') { if (i < ac - 1) { s = av[i + 1]; ++i; } else { ACE_ERROR (( LM_ERROR, ACE_TEXT ("IDL: I don't understand") ACE_TEXT (" the '%s' option\n"), ACE_TEXT_CHAR_TO_TCHAR (av[i]) )); idl_global->set_compile_flags ( idl_global->compile_flags () | IDL_CF_ONLY_USAGE ); break; } } else { s = av[i] + 2; } switch (*s) { default: ACE_ERROR (( LM_ERROR, ACE_TEXT ("IDL: Incorrect use of -W option\n") )); idl_global->set_compile_flags ( idl_global->compile_flags () | IDL_CF_ONLY_USAGE ); break; case 'p': if (*(s + 1) == ',') { DRV_prep_cpp_arg (s + 2); } break; case 'b': if (*(s + 1) == ',') { be_util::prep_be_arg (s + 2); } break; } break; case 'Y': if (av[i][2] == '\0') { if (i < ac - 1) { s = av[i + 1]; ++i; } else { ACE_ERROR (( LM_ERROR, ACE_TEXT ("IDL: I don't understand") ACE_TEXT (" the '%s' option\n"), ACE_TEXT_CHAR_TO_TCHAR (av[i]) )); idl_global->set_compile_flags ( idl_global->compile_flags () | IDL_CF_ONLY_USAGE ); break; } } else { s = av[i] + 2; } switch (*s) { case 'p': if (*(s + 1) == ',') { idl_global->set_cpp_location (s + 2); DRV_cpp_new_location (s + 2); } else { ACE_ERROR (( LM_ERROR, ACE_TEXT ("IDL: I don't understand") ACE_TEXT (" the '-Y' option\n") )); idl_global->set_compile_flags ( idl_global->compile_flags () | IDL_CF_ONLY_USAGE ); } break; default: ACE_ERROR (( LM_ERROR, ACE_TEXT ("IDL: I dont' understand the use of") ACE_TEXT (" %s with the '-Y' option\n"), ACE_TEXT_CHAR_TO_TCHAR (s) )); idl_global->set_compile_flags ( idl_global->compile_flags () | IDL_CF_ONLY_USAGE ); break; } break; case 'd': idl_global->set_compile_flags (idl_global->compile_flags () | IDL_CF_DUMP_AST); break; case 'u': idl_global->set_compile_flags (idl_global->compile_flags () | IDL_CF_ONLY_USAGE); break; case 'v': idl_global->set_compile_flags (idl_global->compile_flags () | IDL_CF_INFORMATIVE); break; case 'w': idl_global->set_compile_flags (idl_global->compile_flags () | IDL_CF_NOWARNINGS); break; case 'C': // If identifiers in the same scope differ only by case... if (av[i][2] == 'e') { // ...report an error. idl_global->case_diff_error (true); } else if (av[i][2] == 'w') { // ...report a warning (default for now) idl_global->case_diff_error (false); } else { ACE_ERROR (( LM_ERROR, ACE_TEXT ("IDL: I don't understand the '%s' option\n"), ACE_TEXT_CHAR_TO_TCHAR (av[i]) )); idl_global->set_compile_flags ( idl_global->compile_flags () | IDL_CF_ONLY_USAGE ); } break; default: be_global->parse_args (i, av); break; } // End of switch (av[i][1]) } // End of IF (av[i][0] == '-') else { DRV_push_file (av[i]); } } // End of FOR (i = 1; i < ac; i++) be_util::arg_post_proc (); // Make sure the output directory is valid. if (idl_global->temp_dir () == 0) { ACE_TCHAR tmpdir[MAXPATHLEN + 1]; if (ACE::get_temp_dir (tmpdir, MAXPATHLEN) == -1) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Temporary path too long, ") ACE_TEXT ("defaulting to current directory\n"))); ACE_OS::strcpy (tmpdir, ACE_TEXT (".")); } #if defined(ACE_MVS) if (ACE_OS::access (tmpdir, F_OK) == -1 || ACE_OS::access (tmpdir, R_OK) == -1 || ACE_OS::access (tmpdir, W_OK) == -1) #else if (ACE_OS::access (tmpdir, F_OK | R_OK | W_OK) == -1) #endif /* ACE_MVS */ { ACE_ERROR (( LM_ERROR, ACE_TEXT ("Can't access temporary directory (%s),") ACE_TEXT (" using current directory for temp files.\n"), tmpdir )); ACE_OS::strcpy (tmpdir, ACE_TEXT (".")); #if defined(ACE_MVS) if (ACE_OS::access (tmpdir, F_OK) == -1 || ACE_OS::access (tmpdir, R_OK) == -1 || ACE_OS::access (tmpdir, W_OK) == -1) #else if (ACE_OS::access (tmpdir, F_OK | R_OK | W_OK) == -1) #endif /* ACE_MVS */ { ACE_ERROR ((LM_ERROR, "Error: Can't access temporary directory %s\n", tmpdir)); throw Bailout (); } } idl_global->temp_dir (ACE_TEXT_ALWAYS_CHAR (tmpdir)); } DRV_cpp_post_init (); }