2004-01-12 10:21:20 +03:00
|
|
|
//
|
|
|
|
// $HEADER$
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <iostream>
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "ompi_config.h"
|
|
|
|
#include "tools/wrappers/ompi_wrap.h"
|
2004-01-12 10:21:20 +03:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
///
|
|
|
|
/// Back-end entry point for the wrapper compiler functionality. All
|
|
|
|
/// three wrapper compilers invoke this function.
|
|
|
|
///
|
|
|
|
/// \param argc Number of command line arguments
|
|
|
|
/// \param argv Vector containing command line arguments
|
|
|
|
/// \param env_vars Environment variables
|
|
|
|
/// \param default_compiler The default backend compiler
|
|
|
|
/// \param want_cxx_libs Whether C++ libraries should be linked in
|
|
|
|
/// \param want_f77_includes Whether F77 include path should be added
|
|
|
|
/// \param extra_args Extra arguments which need to be added
|
|
|
|
///
|
|
|
|
int
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_wrap_engine(int argc, char* argv[],
|
|
|
|
const ompi_sv_t& env_vars, const string& default_compiler,
|
2004-01-12 10:21:20 +03:00
|
|
|
bool want_cxx_libs, bool want_f77_includes,
|
|
|
|
const string& extra_args)
|
|
|
|
{
|
|
|
|
int ret(0);
|
|
|
|
|
|
|
|
bool want_flags;
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_sv_t str_vec;
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_sv_t compiler;
|
|
|
|
ompi_sv_t cflags;
|
|
|
|
ompi_sv_t user_args;
|
|
|
|
ompi_sv_t ldflags;
|
|
|
|
ompi_sv_t libs;
|
|
|
|
ompi_sv_t extra_flags;
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_sv_t cmd_line;
|
2004-01-12 10:21:20 +03:00
|
|
|
|
|
|
|
// Parse command line
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_wrap_parse_args(argc, argv, want_flags);
|
2004-01-12 10:21:20 +03:00
|
|
|
|
|
|
|
// Get the compiler
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_wrap_get_compiler(env_vars, default_compiler, compiler);
|
2004-01-12 10:21:20 +03:00
|
|
|
|
|
|
|
// Build the CFLAGS
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_wrap_build_cflags(want_f77_includes, cflags);
|
2004-01-12 10:21:20 +03:00
|
|
|
|
|
|
|
// Build the user arguments
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_wrap_build_user_args(argc, argv, user_args);
|
2004-01-12 10:21:20 +03:00
|
|
|
|
|
|
|
// Build the LDFLAGS
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_wrap_build_ldflags(ldflags);
|
2004-01-12 10:21:20 +03:00
|
|
|
|
|
|
|
// Build the LIBS
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_wrap_build_libs(want_cxx_libs, libs);
|
2004-01-12 10:21:20 +03:00
|
|
|
|
|
|
|
// Build any extra arguments
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_wrap_build_extra_flags(extra_args, extra_flags);
|
2004-01-12 10:21:20 +03:00
|
|
|
|
|
|
|
// Now assemble the command line
|
|
|
|
|
|
|
|
cmd_line.clear();
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_wrap_append_sv(compiler, cmd_line);
|
2004-01-12 10:21:20 +03:00
|
|
|
if (want_flags) {
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_wrap_append_sv(cflags, cmd_line);
|
|
|
|
ompi_wrap_append_sv(extra_flags, cmd_line);
|
2004-01-12 10:21:20 +03:00
|
|
|
}
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_wrap_append_sv(user_args, cmd_line);
|
2004-01-12 10:21:20 +03:00
|
|
|
if (want_flags) {
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_wrap_append_sv(ldflags, cmd_line);
|
|
|
|
ompi_wrap_append_sv(libs, cmd_line);
|
2004-01-12 10:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Display or execute?
|
|
|
|
|
|
|
|
if (showme_cmd)
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_wrap_print_sv(compiler);
|
2004-01-12 10:21:20 +03:00
|
|
|
if (showme_cmd || showme_compile) {
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_wrap_print_sv(cflags);
|
|
|
|
ompi_wrap_print_sv(extra_flags);
|
2004-01-12 10:21:20 +03:00
|
|
|
}
|
|
|
|
if (showme_cmd || showme_compile || showme_link)
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_wrap_print_sv(user_args);
|
2004-01-12 10:21:20 +03:00
|
|
|
if (showme_cmd || showme_link) {
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_wrap_print_sv(ldflags);
|
|
|
|
ompi_wrap_print_sv(libs);
|
2004-01-12 10:21:20 +03:00
|
|
|
}
|
|
|
|
if (showme_cmd || showme_compile || showme_link)
|
|
|
|
cout << endl;
|
|
|
|
else
|
2004-06-07 19:33:53 +04:00
|
|
|
ret = ompi_wrap_exec_sv(cmd_line);
|
2004-01-12 10:21:20 +03:00
|
|
|
|
|
|
|
// That's all she wrote
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|