Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Document last change
[simgrid.git] / src / surf / xml / surfxml_parseplatf.cpp
index 460bba8..19f1909 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2018. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-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. */
@@ -60,25 +60,24 @@ void sg_platf_trace_connect(simgrid::kernel::routing::TraceConnectCreationArgs*
 }
 
 /* This function acts as a main in the parsing area. */
-void parse_platform_file(const char *file)
+void parse_platform_file(std::string file)
 {
-#if SIMGRID_HAVE_LUA
-  int len    = (file == nullptr ? 0 : strlen(file));
-  int is_lua = (file != nullptr && len > 3 && file[len - 3] == 'l' && file[len - 2] == 'u' && file[len - 1] == 'a');
-#endif
+  const char* cfile = file.c_str();
+  int len           = strlen(cfile);
+  int is_lua        = len > 3 && file[len - 3] == 'l' && file[len - 2] == 'u' && file[len - 1] == 'a';
 
   sg_platf_init();
 
-#if SIMGRID_HAVE_LUA
   /* Check if file extension is "lua". If so, we will use
    * the lua bindings to parse the platform file (since it is
    * written in lua). If not, we will use the (old?) XML parser
    */
   if (is_lua) {
+#if SIMGRID_HAVE_LUA
     lua_State* L = luaL_newstate();
     luaL_openlibs(L);
 
-    luaL_loadfile(L, file); // This loads the file without executing it.
+    luaL_loadfile(L, cfile); // This loads the file without executing it.
 
     /* Run the script */
     if (lua_pcall(L, 0, 0, 0)) {
@@ -87,8 +86,10 @@ void parse_platform_file(const char *file)
     }
     lua_close(L);
     return;
-  }
+#else
+    XBT_WARN("This looks like a lua platform file, but your SimGrid was not compiled with lua. Loading it as XML.");
 #endif
+  }
 
   // Use XML parser
 
@@ -109,7 +110,7 @@ void parse_platform_file(const char *file)
     xbt_assert(host, "Host %s undefined", elm.second.c_str());
     simgrid::surf::Cpu* cpu = host->pimpl_cpu;
 
-    cpu->setStateTrace(trace);
+    cpu->set_state_trace(trace);
   }
 
   for (auto const& elm : trace_connect_list_host_speed) {