diff --git a/src/util/command_line_handling.cpp b/src/util/command_line_handling.cpp index 4033b94ce018..a9e6257c43f1 100644 --- a/src/util/command_line_handling.cpp +++ b/src/util/command_line_handling.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -1250,6 +1251,19 @@ namespace hpx { namespace util return options; } + /////////////////////////////////////////////////////////////////////////// + std::vector prepend_options( + std::vector&& args, std::string&& options) + { + using tokenizer = boost::tokenizer>; + boost::escaped_list_separator sep('\\', ' ', '\"'); + tokenizer tok(options, sep); + + std::vector result(tok.begin(), tok.end()); + std::move(args.begin(), args.end(), std::back_inserter(result)); + return result; + } + /////////////////////////////////////////////////////////////////////////// int command_line_handling::call( boost::program_options::options_description const& desc_cmdline, @@ -1274,6 +1288,14 @@ namespace hpx { namespace util error_mode |= util::rethrow_on_error; } + // The cfg registry may hold command line options to prepend to the + // real command line. + std::string prepend_command_line = + rtcfg_.get_entry("hpx.commandline.prepend_options"); + + args = + prepend_options(std::move(args), std::move(prepend_command_line)); + // Initial analysis of the command line options. This is // preliminary as it will not take into account any aliases as // defined in any of the runtime configuration files. diff --git a/src/util/runtime_configuration.cpp b/src/util/runtime_configuration.cpp index 86ebb0fae1fb..65fc8ef6cb2f 100644 --- a/src/util/runtime_configuration.cpp +++ b/src/util/runtime_configuration.cpp @@ -270,6 +270,10 @@ namespace hpx { namespace util // allow for unknown options to be passed through "allow_unknown = ${HPX_COMMANDLINE_ALLOW_UNKNOWN:0}", + // allow for command line options to to be passed through the + // environment + "prepend_options = ${HPX_COMMANDLINE_OPTIONS}", + // predefine command line aliases "[hpx.commandline.aliases]", "-a = --hpx:agas",