X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/27f7006d3136f93a67086f125afca174554c3f5e..d011cb8a5566e78daba9b90c6a370dca07b74c5a:/src/simgrid/sg_config.cpp diff --git a/src/simgrid/sg_config.cpp b/src/simgrid/sg_config.cpp index 19e7b14506..11bd7dd3bb 100644 --- a/src/simgrid/sg_config.cpp +++ b/src/simgrid/sg_config.cpp @@ -1,99 +1,106 @@ -/* Copyright (c) 2009-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ /* sg_config: configuration infrastructure for the simulation world */ -#include "simgrid/sg_config.h" -#include "instr/instr_interface.h" -#include "mc/mc.h" +#include "simgrid/sg_config.hpp" #include "simgrid/instr.h" -#include "simgrid/simix.h" -#include "simgrid_config.h" /* what was compiled in? */ +#include "simgrid/version.h" +#include "src/instr/instr_private.hpp" +#include "src/internal_config.h" #include "src/kernel/lmm/maxmin.hpp" +#include "src/mc/mc_config.hpp" #include "src/mc/mc_replay.hpp" #include "src/surf/surf_interface.hpp" #include "surf/surf.hpp" -#include "xbt/config.h" #include "xbt/config.hpp" -#include "xbt/log.h" -#include "xbt/mallocator.h" -#include "xbt/misc.h" -#include "xbt/sysdep.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_config, surf, "About the configuration of SimGrid"); +static simgrid::config::Flag cfg_continue_after_help + {"help-nostop", "Do not stop the execution when --help is found", false}; -/* 0: beginning of time (config cannot be changed yet); - * 1: initialized: cfg_set created (config can now be changed); +/** @brief Allow other libraries to react to the --help flag, too + * + * When finding --help on the command line, simgrid usually stops right after displaying its help message. + * If you are writing a library using simgrid, you may want to display your own help message before everything stops. + * If so, just call this function before having simgrid parsing the command line, and you will be given the control + * even if the user is asking for help. + */ +void sg_config_continue_after_help() +{ + cfg_continue_after_help = true; +} + +/* 0: beginning of time (config cannot be changed yet) + * 1: initialized: cfg_set created (config can now be changed) * 2: configured: command line parsed and config part of platform file was * integrated also, platform construction ongoing or done. * (Config cannot be changed anymore!) */ int _sg_cfg_init_status = 0; -/* instruct the upper layer (simix or simdag) to exit as soon as possible */ -int _sg_cfg_exit_asap = 0; - -#define sg_cfg_exit_early() do { _sg_cfg_exit_asap = 1; return; } while (0) - /* Parse the command line, looking for options */ static void sg_config_cmd_line(int *argc, char **argv) { - int shall_exit = 0; + bool shall_exit = false; int i; int j; + bool parse_args = true; // Stop parsing the parameters once we found '--' for (j = i = 1; i < *argc; i++) { - if (not strncmp(argv[i], "--cfg=", strlen("--cfg="))) { + if (not strcmp("--", argv[i])) { + parse_args = false; + // Remove that '--' from the arguments + } else if (parse_args && not strncmp(argv[i], "--cfg=", strlen("--cfg="))) { char *opt = strchr(argv[i], '='); opt++; - xbt_cfg_set_parse(opt); + simgrid::config::set_parse(opt); XBT_DEBUG("Did apply '%s' as config setting", opt); - } else if (not strcmp(argv[i], "--version")) { - printf("%s\n", SIMGRID_VERSION_STRING); - shall_exit = 1; - } else if (not strcmp(argv[i], "--cfg-help") || not strcmp(argv[i], "--help")) { - printf("Description of the configuration accepted by this simulator:\n"); - xbt_cfg_help(); - printf( - "\n" - "Each of these configurations can be used by adding\n" - " --cfg=