From: SUTER Frederic Date: Thu, 6 Jan 2022 10:57:26 +0000 (+0100) Subject: drop the old Lua bindings for programmatic platform creation X-Git-Tag: v3.30~126 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a4bb00c8480e534de5fdf1b16dccbda13421a9fa drop the old Lua bindings for programmatic platform creation --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 31b507b82a..6943264653 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,14 +217,10 @@ include(CheckLibraryExists) include(CheckSymbolExists) set(HAVE_GRAPHVIZ 0) -set(SIMGRID_HAVE_LUA 0) if(minimal-bindings) - message(STATUS "Don't even look for graphviz nor lua, as we build minimal binding libraries.") + message(STATUS "Don't even look for graphviz, as we build minimal binding libraries.") else() include(FindGraphviz) - if(enable_lua) - include(FindLuaSimgrid) - endif() endif() set(SIMGRID_HAVE_NS3 0) @@ -950,7 +946,6 @@ if(pybind11_FOUND) else() message(" Compile Python bindings .....: OFF (disabled, or pybind11 not found)") endif() -message(" Compile Lua .................: ${SIMGRID_HAVE_LUA}") message(" Compile Smpi ................: ${HAVE_SMPI}") message(" Smpi fortran ..............: ${SMPI_FORTRAN}") message(" MPICH3 testsuite ..........: ${enable_smpi_MPICH3_testsuite}") diff --git a/ChangeLog b/ChangeLog index 27bb59cd7c..a68f0ad7b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,7 +12,10 @@ Main user-visible changes: of examples. - The removal of SimDag led us to also remove the export to Jedule files that was tightly coupled to SimDag. The instrumentation of DAG simulation is still - possible through the regular instrumentation API based on the Paje format. + possible through the regular instrumentation API based on the Paje format. + - We also dropped the old and clumsy Lua bindings to create platforms in a + programmatic way. It can be done in C++ in a much cleaner way now, which + motivates this suppression. S4U: - Introduce on_X_cb() functions for all signals, to attach a new diff --git a/MANIFEST.in b/MANIFEST.in index 583e1ab64b..c5fd86b08e 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1962,7 +1962,6 @@ include examples/platforms/cluster_dragonfly.xml include examples/platforms/cluster_fat_tree.svg include examples/platforms/cluster_fat_tree.xml include examples/platforms/cluster_multi.xml -include examples/platforms/cluster_prototype.lua include examples/platforms/cluster_torus.svg include examples/platforms/cluster_torus.xml include examples/platforms/config.xml @@ -2000,11 +1999,9 @@ include examples/platforms/profiles/trace_B.txt include examples/platforms/prop.xml include examples/platforms/ptask_L07.xml include examples/platforms/routing_cluster.cpp -include examples/platforms/routing_cluster.lua include examples/platforms/routing_cluster.xml include examples/platforms/routing_none.xml include examples/platforms/simulacrum_7_hosts.xml -include examples/platforms/small_platform.lua include examples/platforms/small_platform.xml include examples/platforms/small_platform_constant.xml include examples/platforms/small_platform_failures.xml @@ -2199,13 +2196,6 @@ include src/bindings/java/org/simgrid/msg/TimeoutException.java include src/bindings/java/org/simgrid/msg/TransferFailureException.java include src/bindings/java/org/simgrid/msg/VM.java include src/bindings/java/org/simgrid/trace/Trace.java -include src/bindings/lua/lua_host.cpp -include src/bindings/lua/lua_platf.cpp -include src/bindings/lua/lua_private.hpp -include src/bindings/lua/lua_utils.cpp -include src/bindings/lua/lua_utils.hpp -include src/bindings/lua/simgrid_lua.cpp -include src/bindings/lua/simgrid_lua.hpp include src/bindings/python/simgrid_python.cpp include src/dag/dax.dtd include src/dag/dax_dtd.c @@ -2740,8 +2730,6 @@ include src/xbt/xbt_str_test.cpp include src/xbt/xbt_virtu.cpp include teshsuite/java/CMakeLists.txt include teshsuite/kernel/CMakeLists.txt -include teshsuite/lua/CMakeLists.txt -include teshsuite/lua/lua_platforms.tesh include teshsuite/mc/CMakeLists.txt include teshsuite/models/CMakeLists.txt include teshsuite/msg/CMakeLists.txt @@ -2800,7 +2788,6 @@ include tools/cmake/Modules/FindLibdw.cmake include tools/cmake/Modules/FindLibelf.cmake include tools/cmake/Modules/FindLibevent.cmake include tools/cmake/Modules/FindLibunwind.cmake -include tools/cmake/Modules/FindLuaSimgrid.cmake include tools/cmake/Modules/FindNS3.cmake include tools/cmake/Modules/FindPAPI.cmake include tools/cmake/Modules/FindValgrind.cmake @@ -2818,7 +2805,6 @@ include tools/cmake/test_prog/prog_stacksetup.c include tools/cmake/test_prog/prog_tsan.cpp include tools/doxygen/list_routing_models_examples.sh include tools/graphicator/CMakeLists.txt -include tools/lualib.patch include tools/smpi/generate_smpi_defines.pl include tools/stack-cleaner/README include tools/stack-cleaner/as diff --git a/docs/source/Installing_SimGrid.rst b/docs/source/Installing_SimGrid.rst index 8b02627e8e..16b420502f 100644 --- a/docs/source/Installing_SimGrid.rst +++ b/docs/source/Installing_SimGrid.rst @@ -127,16 +127,6 @@ Java (optional): - Debian / Ubuntu: ``apt install default-jdk libgcj18-dev`` (or any version of libgcj) - macOS or Windows: Grab a `full JDK `_ -Lua (optional -- must be v5.3) - - SimGrid won't work with any other version of Lua. - - Debian / Ubuntu: ``apt install liblua5.3-dev lua5.3`` - - Windows: ``choco install lua53`` - - From the source - - You need to patch the sources to build dynamic libraries. First `download lua 5.3 `_ - - Open the archive: ``tar xvfz lua-5.3.*.tar.gz`` - - Enter the directory: ``cd lua-5.3*`` - - Patch the sources: ``patch -p1 < /path/to/simgrid/...../tools/lualib.patch`` - - Build and install lua: ``make linux && sudo make install`` For platform-specific details, please see below. @@ -261,9 +251,6 @@ enable_java (on/OFF) Generates the java bindings of SimGrid. You must also enable MSG for this to work. -enable_lua (on/OFF) - Generate the lua bindings to the SimGrid internals (requires lua-5.3). - enable_lib_in_jar (ON/off) Embeds the native java bindings into the produced jar file. diff --git a/docs/source/Introduction.rst b/docs/source/Introduction.rst index 4102473b54..572c6675cf 100644 --- a/docs/source/Introduction.rst +++ b/docs/source/Introduction.rst @@ -24,12 +24,12 @@ Any SimGrid study entails the following components: - The **simulated platform**. This is a description of a given distributed system (machines, links, disks, clusters, etc). Most of - the platform files are written in XML although a Lua interface is - under development. SimGrid makes it easy to augment the Simulated - Platform with a Dynamic Scenario where for example the links are - slowed down (because of external usage) or the machines fail. You - even have support to specify the applicative workload that you want - to feed to your application + the platform files are written in XML but a new C++ programmatic + interface has recently been introduced. SimGrid makes it easy to + augment the Simulated Platform with a Dynamic Scenario where for + example the links are slowed down (because of external usage) or the + machines fail. You even have support to specify the applicative + workload that you want to feed to your application :ref:`(more info) `. - The application's **deployment description**. In SimGrid diff --git a/examples/platforms/cluster_prototype.lua b/examples/platforms/cluster_prototype.lua deleted file mode 100644 index 6a852bcf0b..0000000000 --- a/examples/platforms/cluster_prototype.lua +++ /dev/null @@ -1,67 +0,0 @@ --- Copyright (c) 2011-2021. 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. - - require("simgrid") - - function seq(min,max) - L={} - for i=min,max,1 do - table.insert(L,i) - end - return L - end - - function my_cluster(args) - -- args is a table with the following keys - -- - - local required_args = {"id", "prefix", "suffix", "radical", "speed", "bw", "lat" } - for _,val in pairs(required_args) do - if args[val] == nil then simgrid.critical("Must specify '" .. val .. "' attribute. See docs for details.") end - end - if args.sharing_sharing_policy == nil then - args.sharing_sharing_policy = "SHARED" - end - if args.topology ~= "TORUS" and args.topology ~= "FAT_TREE" then - args.topology = "Cluster" - end - - -- Check the mode = Cluster here - return function() - - simgrid.engine.AS_open{id=args.id,mode=args.topology}; - - if args.bb_bw ~= nil and args.bb_lat ~= nil then - simgrid.engine.backbone_new{id=args.id .. "-bb",bandwidth=args.bb_bw,latency=args.bb_lat,sharing_policy=args.bb_sharing_sharing_policy} - end - for _,i in pairs(args.radical) do - local hostname = args.prefix .. i .. args.suffix - local linkname = args.id .."_link_" .. i - simgrid.engine.host_new{id=hostname, speed=args.speed,core=args.core,power_trace=args.availability_file,state_trace=args.state_file}; - simgrid.engine.link_new{id=linkname, bandwidth=args.bw,latency=args.lat, sharing_policy=args.sharing_sharing_policy}; - simgrid.engine.host_link_new{id=hostname,up=linkname.."_UP",down=linkname.."_DOWN"}; - - if args.loopback_bw ~= nil and args.loopback_lat ~= nil then - simgrid.engine.link_new{id=linkname .. "_loopback",bandwidth=args.loopback_bw,latency=args.loopback_lat,sharing_policy="FATPIPE"} - end - end - simgrid.engine.AS_seal() - end - end - - simgrid.engine.open(); - cluster_factory = my_cluster{prefix="node-", suffix=".simgrid.org", radical=seq(0,262144), host_factory = function(hostno) - if hostno % 2 == 0 then return "blabla" end - if hostno % 2 == 1 then return "blublub" end - end, - speed="1Gf", - id="AS0", - bw="125MBps", - lat="50us", - sharing_sharing_policy="SPLITDUPLEX" - }() - --my_cluster{prefix="node2-", suffix=".simgrid.org", radical=seq(0,44) } - - simgrid.engine.close(); diff --git a/examples/platforms/routing_cluster.lua b/examples/platforms/routing_cluster.lua deleted file mode 100644 index 50415aea37..0000000000 --- a/examples/platforms/routing_cluster.lua +++ /dev/null @@ -1,51 +0,0 @@ --- See routing_cluster.xml for description. --- - -require "simgrid" -simgrid.engine.open() -simgrid.engine.AS_open{id="AS0",mode="Full"} - simgrid.engine.AS_open{id="my_cluster1",mode="Cluster"} - simgrid.engine.router_new{id="router1"} - - simgrid.engine.host_new{id="host1",speed="1Gf"}; - simgrid.engine.link_new{id="l1_UP",bandwidth="125MBps",lat="100us"}; - simgrid.engine.link_new{id="l1_DOWN",bandwidth="125MBps",lat="100us"}; - simgrid.engine.host_link_new{id="host1",up="l1_UP",down="l1_DOWN"}; - - simgrid.engine.host_new{id="host2",speed="1Gf"}; - simgrid.engine.link_new{id="l2",bandwidth="125MBps",lat="100us",sharing_policy="SPLITDUPLEX"}; - simgrid.engine.host_link_new{id="host2",up="l2_UP",down="l2_DOWN"}; - - simgrid.engine.host_new{id="host3",speed="1Gf"}; - simgrid.engine.link_new{id="l3",bandwidth="125MBps",lat="100us"}; - simgrid.engine.host_link_new{id="host3",up="l3",down="l3"}; - - simgrid.engine.backbone_new{id="backbone1",bandwidth="2.25GBps",lat="500us"}; - - simgrid.engine.AS_seal() - simgrid.engine.AS_open{id="my_cluster2",mode="Cluster"} - simgrid.engine.router_new{id="router2"} - - simgrid.engine.host_new{id="host4",speed="1Gf"}; - simgrid.engine.link_new{id="l4_UP",bandwidth="125MBps",lat="100us"}; - simgrid.engine.link_new{id="l4_DOWN",bandwidth="125MBps",lat="100us"}; - simgrid.engine.host_link_new{id="host4",up="l4_UP",down="l4_DOWN"}; - - simgrid.engine.host_new{id="host5",speed="1Gf"}; - simgrid.engine.link_new{id="l5",bandwidth="125MBps",lat="100us",sharing_policy="SPLITDUPLEX"}; - simgrid.engine.host_link_new{id="host5",up="l5_UP",down="l5_DOWN"}; - - simgrid.engine.host_new{id="host6",speed="1Gf"}; - simgrid.engine.link_new{id="l6",bandwidth="125MBps",lat="100us"}; - simgrid.engine.host_link_new{id="host6",up="l6",down="l6"}; - - simgrid.engine.backbone_new{id="backbone2",bandwidth="2.25GBps",lat="500us"} - - simgrid.engine.AS_seal() - simgrid.engine.link_new{id="link1-2",bandwidth="2.25GBps",lat="500us"}; - - simgrid.engine.ASroute_new{src="my_cluster1", dst="my_cluster2", - gw_src="router1", gw_dst="router2", links="link1-2"} - -simgrid.engine.AS_seal() -simgrid.engine.close() diff --git a/examples/platforms/small_platform.lua b/examples/platforms/small_platform.lua deleted file mode 100644 index b665996d96..0000000000 --- a/examples/platforms/small_platform.lua +++ /dev/null @@ -1,56 +0,0 @@ --- Copyright (c) 2011-2021. 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. - - - -- This platform.lua file is equivalent to small_platform.xml - -- So don't change anything in here unless you change the xml file too! - -- - require("simgrid") - simgrid.engine.open(); - simgrid.engine.AS_open{id="AS0",mode="Full"}; - - simgrid.engine.host_new{AS="AS0",id="Tremblay",speed=98095000}; - simgrid.engine.host_new{AS="AS0",id="Jupiter",speed=76296000}; - simgrid.engine.host_new{AS="AS0",id="Fafard",speed=76296000}; - simgrid.engine.host_new{AS="AS0",id="Ginette",speed=48492000}; - simgrid.engine.host_new{AS="AS0",id="Bourassa",speed=48492000}; - - -- create Links - simgrid.engine.link_new{AS="AS0",id=0,bandwidth=41279125,lat=0.000059904}; - simgrid.engine.link_new{AS="AS0",id=1,bandwidth=34285625,lat=0.000514433}; - simgrid.engine.link_new{AS="AS0",id=2,bandwidth=118682500,lat=0.000136931}; - simgrid.engine.link_new{AS="AS0",id=3,bandwidth=34285625,lat=0.000514433}; - simgrid.engine.link_new{AS="AS0",id=4,bandwidth=10099625,lat=0.00047978}; - simgrid.engine.link_new{AS="AS0",id=5,bandwidth=27946250,lat=0.000278066}; - simgrid.engine.link_new{AS="AS0",id=6,bandwidth=41279125,lat=0.000059904}; - simgrid.engine.link_new{AS="AS0",id=7,bandwidth=11618875,lat=0.00018998}; - simgrid.engine.link_new{AS="AS0",id=8,bandwidth=8158000,lat=0.000270544}; - simgrid.engine.link_new{AS="AS0",id=9,bandwidth=7209750,lat=0.001461517}; - simgrid.engine.link_new{AS="AS0",id="loopback",bandwidth=498000000,lat=0.000015,sharing_policy="FATPIPE"}; - - -- Register loopback links - for i=1,5,1 do - local hostname = simgrid.host.name(simgrid.host.at(i)) - simgrid.engine.route_new{AS="AS0",src=hostname,dest=hostname,links="loopback"} - end - - simgrid.engine.route_new{AS="AS0",src="Tremblay",dest="Jupiter",links="9"}; - simgrid.engine.route_new{AS="AS0",src="Tremblay",dest="Fafard",links="4,3,2,0,1,8"}; - simgrid.engine.route_new{AS="AS0",src="Tremblay",dest="Ginette",links="4,3,5"}; - simgrid.engine.route_new{AS="AS0",src="Tremblay",dest="Bourassa",links="4,3,2,0,1,6,7"}; - - simgrid.engine.route_new{AS="AS0",src="Jupiter",dest="Fafard",links="9,4,3,2,0,1,8"}; - simgrid.engine.route_new{AS="AS0",src="Jupiter",dest="Ginette",links="9,4,3,5"}; - simgrid.engine.route_new{AS="AS0",src="Jupiter",dest="Bourassa",links="9,4,3,2,0,1,6,7"}; - - simgrid.engine.route_new{AS="AS0",src="Fafard",dest="Ginette",links="8,1,0,2,5"}; - simgrid.engine.route_new{AS="AS0",src="Fafard",dest="Bourassa",links="8,6,7"}; - - simgrid.engine.route_new{AS="AS0",src="Ginette",dest="Bourassa",links="5,2,0,1,6,7"}; - - simgrid.engine.AS_seal(); - - simgrid.engine.close(); diff --git a/include/simgrid/config.h.in b/include/simgrid/config.h.in index 32e11dfd9c..4901cc891f 100644 --- a/include/simgrid/config.h.in +++ b/include/simgrid/config.h.in @@ -11,8 +11,6 @@ /* Was MSG compiled in? */ #cmakedefine01 SIMGRID_HAVE_MSG -/* Was the Lua support compiled in? */ -#cmakedefine01 SIMGRID_HAVE_LUA /* Were mallocators (object pools) compiled in? */ #cmakedefine01 SIMGRID_HAVE_MALLOCATOR /* Was the model-checking compiled in? */ diff --git a/src/bindings/lua/lua_host.cpp b/src/bindings/lua/lua_host.cpp deleted file mode 100644 index cdd2ef4672..0000000000 --- a/src/bindings/lua/lua_host.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/* Copyright (c) 2010-2021. 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. */ - -/* SimGrid Lua bindings */ - -#include "lua_private.hpp" -#include "simgrid/s4u/Engine.hpp" -#include "simgrid/s4u/Host.hpp" -#include "xbt/asserts.h" -#include - -constexpr char HOST_MODULE_NAME[] = "simgrid.host"; -constexpr char HOST_FIELDNAME[] = "__simgrid_host"; - -/* ********************************************************************************* */ -/* simgrid.host API */ -/* ********************************************************************************* */ - -/** @brief Ensures that the pointed stack value is a host userdatum and returns it. - * - * @param L a Lua state - * @param index an index in the Lua stack - * @return the C host corresponding to this Lua host - */ -sg_host_t sglua_check_host(lua_State * L, int index) -{ - luaL_checktype(L, index, LUA_TTABLE); - lua_getfield(L, index, HOST_FIELDNAME); - auto* pi = static_cast(luaL_checkudata(L, lua_gettop(L), HOST_MODULE_NAME)); - lua_pop(L, 1); - xbt_assert(pi != nullptr, "luaL_checkudata() returned nullptr"); - sg_host_t ht = *pi; - if (not ht) - luaL_error(L, "null Host"); - return ht; -} - -/** - * @brief Returns a host given its name. This is a lua function. - * - * @param L a Lua state - * @return number of values returned to Lua - * - * - Argument 1 (string): name of a host - * - Return value (host): the corresponding host will be pushed onto the stack - */ -static int l_host_get_by_name(lua_State * L) -{ - const char *name = luaL_checkstring(L, 1); - lua_remove(L, 1); /* remove the args from the stack */ - - sg_host_t host = sg_host_by_name(name); - lua_ensure(host, "No host name '%s' found.", name); - - lua_newtable(L); /* table */ - auto* lua_host = static_cast(lua_newuserdata(L, sizeof(sg_host_t))); /* table userdatum */ - *lua_host = host; - luaL_getmetatable(L, HOST_MODULE_NAME); /* table userdatum metatable */ - lua_setmetatable(L, -2); /* table userdatum */ - lua_setfield(L, -2, HOST_FIELDNAME); /* table -- put the userdata as field of the table */ - - return 1; -} - -/** - * @brief Returns the name of a host. - * @param L a Lua state - * @return number of values returned to Lua - * - * - Argument 1 (host): a host - * - Return value (string): name of this host - */ -static int l_host_get_name(lua_State * L) -{ - auto const* ht = sglua_check_host(L, 1); - lua_pushstring(L, ht->get_cname()); - return 1; -} - -/** - * @brief Returns the number of existing hosts. - * @param L a Lua state - * @return number of values returned to Lua - * - * - Return value (number): number of hosts - */ -static int l_host_number(lua_State * L) -{ - lua_pushinteger(L, simgrid::s4u::Engine::get_instance()->get_host_count()); - return 1; -} - -/** - * @brief Returns the host given its index. - * @param L a Lua state - * @return number of values returned to Lua - * - * - Argument 1 (number): an index (1 is the first) - * - Return value (host): the host at this index - */ -static int l_host_at(lua_State * L) -{ - lua_Integer index = luaL_checkinteger(L, 1); - std::vector hosts = simgrid::s4u::Engine::get_instance()->get_all_hosts(); - sg_host_t host = hosts[index - 1]; // lua indexing start by 1 (lua[1] <=> C[0]) - lua_newtable(L); /* create a table, put the userdata on top of it */ - auto* lua_host = static_cast(lua_newuserdata(L, sizeof(sg_host_t))); - *lua_host = host; - luaL_getmetatable(L, HOST_MODULE_NAME); - lua_setmetatable(L, -2); - lua_setfield(L, -2, HOST_FIELDNAME); /* put the userdata as field of the table */ - return 1; -} - -/** - * @brief Returns the value of a host property. - * @param L a Lua state - * @return number of values returned to Lua - * - * - Argument 1 (host): a host - * - Argument 2 (string): name of the property to get - * - Return value (string): the value of this property - */ -static int l_host_get_property_value(lua_State * L) -{ - const_sg_host_t ht = sglua_check_host(L, 1); - const char *prop = luaL_checkstring(L, 2); - lua_pushstring(L, sg_host_get_property_value(ht,prop)); - return 1; -} - -/** - * @brief Destroys a host. - * @param L a Lua state - * @return number of values returned to Lua - * - * - Argument 1 (host): the host to destroy - */ -static int l_host_destroy(lua_State *L) -{ - sg_host_t ht = sglua_check_host(L, 1); - ht->destroy(); - return 0; -} - -static const luaL_Reg host_functions[] = { - {"get_by_name", l_host_get_by_name}, - {"name", l_host_get_name}, - {"number", l_host_number}, - {"at", l_host_at}, - {"get_prop_value", l_host_get_property_value}, - {"destroy", l_host_destroy}, - // Bypass XML Methods - {"set_property", console_host_set_property}, - {nullptr, nullptr} -}; - -/** - * @brief Returns a string representation of a host. - * @param L a Lua state - * @return number of values returned to Lua - * - * - Argument 1 (userdata): a host - * - Return value (string): a string describing this host - */ -static int l_host_tostring(lua_State * L) -{ - lua_pushfstring(L, "Host :%p", lua_touserdata(L, 1)); - return 1; -} - -static const luaL_Reg host_meta[] = {{"__tostring", l_host_tostring}, {nullptr, nullptr}}; - -/** - * @brief Registers the host functions into the table simgrid.host. - * - * Also initialize the metatable of the host userdata type. - * - * @param L a lua state - */ -void sglua_register_host_functions(lua_State* L) -{ - /* create a table simgrid.host and fill it with host functions */ - lua_getglobal(L, "simgrid"); /* simgrid */ - luaL_newlib(L, host_functions); /* simgrid simgrid.host */ - lua_setfield(L, -2, "host"); /* simgrid */ - lua_getfield(L, -1, "host"); /* simgrid simgrid.host */ - - /* create the metatable for host, add it to the Lua registry */ - luaL_newmetatable(L, HOST_MODULE_NAME); /* simgrid simgrid.host mt */ - - /* fill the metatable */ - luaL_setfuncs(L, host_meta, 0); /* simgrid simgrid.host mt */ - - /** - * Copy the table and push it onto the stack. - * Required for the lua_setfield call below. - */ - lua_getfield(L, -3, "host"); /* simgrid simgrid.host mt simgrid.host */ - - /* metatable.__index = simgrid.host - * we put the host functions inside the host userdata itself: - * this allows one to write my_host:method(args) for - * simgrid.host.method(my_host, args) */ - lua_setfield(L, -2, "__index"); /* simgrid simgrid.host mt */ - - lua_setmetatable(L, -2); /* simgrid simgrid.host */ - lua_pop(L, 2); /* -- */ -} - diff --git a/src/bindings/lua/lua_platf.cpp b/src/bindings/lua/lua_platf.cpp deleted file mode 100644 index 9465af79a5..0000000000 --- a/src/bindings/lua/lua_platf.cpp +++ /dev/null @@ -1,514 +0,0 @@ -/* Copyright (c) 2010-2021. 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. */ - -/* SimGrid Lua bindings */ - -#include "lua_private.hpp" -#include "simgrid/kernel/routing/NetPoint.hpp" -#include "src/kernel/resource/LinkImpl.hpp" -#include "src/kernel/resource/profile/Profile.hpp" -#include "src/surf/xml/platf.hpp" -#include "src/surf/xml/platf_private.hpp" -#include "xbt/parse_units.hpp" - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua_platf, lua, "Lua bindings (platform module)"); - -constexpr char PLATF_MODULE_NAME[] = "simgrid.engine"; -constexpr char AS_FIELDNAME[] = "__simgrid_as"; - -/* ********************************************************************************* */ -/* simgrid.platf API */ -/* ********************************************************************************* */ - -static const luaL_Reg platf_functions[] = { - {"open", console_open}, - {"close", console_close}, - {"AS_open", console_AS_open}, - {"AS_seal", console_AS_seal}, - {"backbone_new", console_add_backbone}, - {"host_link_new", console_add_host___link}, - {"host_new", console_add_host}, - {"link_new", console_add_link}, - {"router_new", console_add_router}, - {"route_new", console_add_route}, - {"ASroute_new", console_add_ASroute}, - {nullptr, nullptr} -}; - -static simgrid::s4u::Link::SharingPolicy link_policy_get_by_name(const char* policy) -{ - if (policy && not strcmp(policy, "FULLDUPLEX")) { - XBT_WARN("Please update your platform to use SPLITDUPLEX instead of FULLDUPLEX"); - return simgrid::s4u::Link::SharingPolicy::SPLITDUPLEX; - } else if (policy && not strcmp(policy, "SPLITDUPLEX")) { - return simgrid::s4u::Link::SharingPolicy::SPLITDUPLEX; - } else if (policy && not strcmp(policy, "FATPIPE")) { - return simgrid::s4u::Link::SharingPolicy::FATPIPE; - } else { - return simgrid::s4u::Link::SharingPolicy::SHARED; - } -} - -int console_open(lua_State*) -{ - sg_platf_init(); - simgrid::s4u::Engine::on_platform_creation(); - - return 0; -} - -int console_close(lua_State*) -{ - simgrid::s4u::Engine::on_platform_created(); - sg_platf_exit(); - return 0; -} - -int console_add_backbone(lua_State *L) { - auto link = std::make_unique(); - lua_Debug ar; - lua_getstack(L, 1, &ar); - lua_getinfo(L, "Sl", &ar); - - lua_ensure(lua_istable(L, -1),"Bad Arguments to create backbone in Lua. Should be a table with named arguments."); - - lua_pushstring(L, "id"); - int type = lua_gettable(L, -2); - lua_ensure(type == LUA_TSTRING, "Attribute 'id' must be specified for backbone and must be a string."); - link->id = lua_tostring(L, -1); - lua_pop(L, 1); - - lua_pushstring(L, "bandwidth"); - type = lua_gettable(L, -2); - lua_ensure(type == LUA_TSTRING || type == LUA_TNUMBER, - "Attribute 'bandwidth' must be specified for backbone and must either be a string (in the right format; see docs) or a number."); - link->bandwidths.push_back( - xbt_parse_get_bandwidth(ar.short_src, ar.currentline, lua_tostring(L, -1), "bandwidth of backbone " + link->id)); - lua_pop(L, 1); - - lua_pushstring(L, "lat"); - type = lua_gettable(L, -2); - lua_ensure(type == LUA_TSTRING || type == LUA_TNUMBER, - "Attribute 'lat' must be specified for backbone and must either be a string (in the right format; see docs) or a number."); - link->latency = - xbt_parse_get_time(ar.short_src, ar.currentline, lua_tostring(L, -1), "latency of backbone " + link->id); - lua_pop(L, 1); - - lua_pushstring(L, "sharing_policy"); - lua_gettable(L, -2); - const char* policy = lua_tostring(L, -1); - lua_pop(L, 1); - link->policy = link_policy_get_by_name(policy); - - routing_cluster_add_backbone(std::move(link)); - - return 0; -} - -int console_add_host___link(lua_State *L) { - simgrid::kernel::routing::HostLinkCreationArgs hostlink; - int type; - - lua_ensure(lua_istable(L, -1), "Bad Arguments to create host_link in Lua. Should be a table with named arguments."); - - lua_pushstring(L, "id"); - type = lua_gettable(L, -2); - lua_ensure(type == LUA_TSTRING, "Attribute 'id' must be specified for any host_link and must be a string."); - hostlink.id = lua_tostring(L, -1); - lua_pop(L, 1); - - lua_pushstring(L, "up"); - type = lua_gettable(L, -2); - lua_ensure(type == LUA_TSTRING || type == LUA_TNUMBER, - "Attribute 'up' must be specified for host_link and must either be a string or a number."); - hostlink.link_up = lua_tostring(L, -1); - lua_pop(L, 1); - - lua_pushstring(L, "down"); - type = lua_gettable(L, -2); - lua_ensure(type == LUA_TSTRING || type == LUA_TNUMBER, - "Attribute 'down' must be specified for host_link and must either be a string or a number."); - hostlink.link_down = lua_tostring(L, -1); - lua_pop(L, 1); - - XBT_DEBUG("Create a host_link for host %s", hostlink.id.c_str()); - sg_platf_new_hostlink(&hostlink); - - return 0; -} - -int console_add_host(lua_State *L) { - simgrid::kernel::routing::HostCreationArgs host; - int type; - lua_Debug ar; - lua_getstack(L, 1, &ar); - lua_getinfo(L, "Sl", &ar); - - // we get values from the table passed as argument - lua_ensure(lua_istable(L, -1), - "Bad Arguments to create host. Should be a table with named arguments"); - - // get Id Value - lua_pushstring(L, "id"); - type = lua_gettable(L, -2); - lua_ensure(type == LUA_TSTRING, - "Attribute 'id' must be specified for any host and must be a string."); - host.id = lua_tostring(L, -1); - lua_pop(L, 1); - - // get power value - lua_pushstring(L, "speed"); - type = lua_gettable(L, -2); - lua_ensure(type == LUA_TSTRING || type == LUA_TNUMBER, - "Attribute 'speed' must be specified for host and must either be a string (in the correct format; check documentation) or a number."); - if (type == LUA_TNUMBER) - host.speed_per_pstate.push_back(lua_tonumber(L, -1)); - else // LUA_TSTRING - host.speed_per_pstate.push_back( - xbt_parse_get_speed(ar.short_src, ar.currentline, lua_tostring(L, -1), "speed of host " + host.id)); - lua_pop(L, 1); - - // get core - lua_pushstring(L, "core"); - lua_gettable(L, -2); - if (not lua_isnumber(L, -1)) - host.core_amount = 1; // Default value - else - host.core_amount = static_cast(lua_tointeger(L, -1)); - if (host.core_amount == 0) - host.core_amount = 1; - lua_pop(L, 1); - - //get power_trace - lua_pushstring(L, "availability_file"); - lua_gettable(L, -2); - const char *filename = lua_tostring(L, -1); - if (filename) - host.speed_trace = simgrid::kernel::profile::Profile::from_file(filename); - lua_pop(L, 1); - - //get trace state - lua_pushstring(L, "state_file"); - lua_gettable(L, -2); - filename = lua_tostring(L, -1); - if (filename) - host.state_trace = simgrid::kernel::profile::Profile::from_file(filename); - lua_pop(L, 1); - - sg_platf_new_host_begin(&host); - sg_platf_new_host_seal(0); - - return 0; -} - -int console_add_link(lua_State *L) { - simgrid::kernel::routing::LinkCreationArgs link; - lua_Debug ar; - lua_getstack(L, 1, &ar); - lua_getinfo(L, "Sl", &ar); - - const char* policy; - - lua_ensure(lua_istable(L, -1), "Bad Arguments to create link, Should be a table with named arguments"); - - // get Id Value - lua_pushstring(L, "id"); - int type = lua_gettable(L, -2); - lua_ensure(type == LUA_TSTRING || type == LUA_TNUMBER, - "Attribute 'id' must be specified for any link and must be a string."); - link.id = lua_tostring(L, -1); - lua_pop(L, 1); - - // get bandwidth value - lua_pushstring(L, "bandwidth"); - type = lua_gettable(L, -2); - lua_ensure(type == LUA_TSTRING || type == LUA_TNUMBER, - "Attribute 'bandwidth' must be specified for any link and must either be either a string (in the right format; see docs) or a number."); - if (type == LUA_TNUMBER) - link.bandwidths.push_back(lua_tonumber(L, -1)); - else // LUA_TSTRING - link.bandwidths.push_back( - xbt_parse_get_bandwidth(ar.short_src, ar.currentline, lua_tostring(L, -1), "bandwidth of link " + link.id)); - lua_pop(L, 1); - - //get latency value - lua_pushstring(L, "lat"); - type = lua_gettable(L, -2); - lua_ensure(type == LUA_TSTRING || type == LUA_TNUMBER, - "Attribute 'lat' must be specified for any link and must either be a string (in the right format; see docs) or a number."); - if (type == LUA_TNUMBER) - link.latency = lua_tonumber(L, -1); - else // LUA_TSTRING - link.latency = xbt_parse_get_time(ar.short_src, ar.currentline, lua_tostring(L, -1), "latency of link " + link.id); - lua_pop(L, 1); - - /*Optional Arguments */ - - //get bandwidth_trace value - lua_pushstring(L, "bandwidth_file"); - lua_gettable(L, -2); - const char *filename = lua_tostring(L, -1); - if (filename) - link.bandwidth_trace = simgrid::kernel::profile::Profile::from_file(filename); - lua_pop(L, 1); - - //get latency_trace value - lua_pushstring(L, "latency_file"); - lua_gettable(L, -2); - filename = lua_tostring(L, -1); - if (filename) - link.latency_trace = simgrid::kernel::profile::Profile::from_file(filename); - lua_pop(L, 1); - - //get state_trace value - lua_pushstring(L, "state_file"); - lua_gettable(L, -2); - filename = lua_tostring(L, -1); - if (filename) - link.state_trace = simgrid::kernel::profile::Profile::from_file(filename); - lua_pop(L, 1); - - //get policy value - lua_pushstring(L, "sharing_policy"); - lua_gettable(L, -2); - policy = lua_tostring(L, -1); - lua_pop(L, 1); - link.policy = link_policy_get_by_name(policy); - - sg_platf_new_link(&link); - - return 0; -} -/** - * add Router to AS components - */ -int console_add_router(lua_State* L) { - lua_ensure(lua_istable(L, -1), "Bad Arguments to create router, Should be a table with named arguments"); - - lua_pushstring(L, "id"); - int type = lua_gettable(L, -2); - lua_ensure(type == LUA_TSTRING, "Attribute 'id' must be specified for any link and must be a string."); - const char* name = lua_tostring(L, -1); - lua_pop(L,1); - - lua_pushstring(L,"coord"); - lua_gettable(L,-2); - const char* coords = lua_tostring(L, -1); - lua_pop(L,1); - - sg_platf_new_router(name, coords ? coords : ""); - - return 0; -} - -int console_add_route(lua_State *L) { - XBT_DEBUG("Adding route"); - simgrid::kernel::routing::RouteCreationArgs route; - int type; - - lua_ensure(lua_istable(L, -1), "Bad Arguments to add a route. Should be a table with named arguments"); - - lua_pushstring(L,"src"); - type = lua_gettable(L,-2); - lua_ensure(type == LUA_TSTRING, "Attribute 'src' must be specified for any route and must be a string."); - const char *srcName = lua_tostring(L, -1); - route.src = sg_netpoint_by_name_or_null(srcName); - lua_ensure(route.src != nullptr, "Attribute 'src=%s' of route does not name a node.", srcName); - lua_pop(L,1); - - lua_pushstring(L,"dest"); - type = lua_gettable(L,-2); - lua_ensure(type == LUA_TSTRING, "Attribute 'dest' must be specified for any route and must be a string."); - const char *dstName = lua_tostring(L, -1); - route.dst = sg_netpoint_by_name_or_null(dstName); - lua_ensure(route.dst != nullptr, "Attribute 'dst=%s' of route does not name a node.", dstName); - lua_pop(L,1); - - lua_pushstring(L,"links"); - type = lua_gettable(L,-2); - lua_ensure(type == LUA_TSTRING, - "Attribute 'links' must be specified for any route and must be a string (different links separated by commas or single spaces."); - std::vector names; - const char* str = lua_tostring(L, -1); - boost::split(names, str, boost::is_any_of(", \t\r\n")); - if (names.empty()) { - /* unique name */ - route.link_list.emplace_back(simgrid::s4u::Link::by_name(lua_tostring(L, -1))); - } else { - // Several names separated by , \t\r\n - for (auto const& name : names) { - if (name.length() > 0) { - route.link_list.emplace_back(simgrid::s4u::Link::by_name(name)); - } - } - } - lua_pop(L,1); - - /* We are relying on the XML bypassing mechanism since the corresponding sg_platf does not exist yet. - * Et ouais mon pote. That's the way it goes. F34R. - * - * (Note that above this function, there is a #include statement. Is this - * comment related to that statement?) - */ - lua_pushstring(L,"symmetrical"); - lua_gettable(L,-2); - route.symmetrical = (not lua_isstring(L, -1) || strcasecmp("YES", lua_tostring(L, -1)) == 0); - lua_pop(L,1); - - sg_platf_new_route(&route); - - return 0; -} - -int console_add_ASroute(lua_State *L) { - simgrid::kernel::routing::RouteCreationArgs ASroute; - - lua_pushstring(L, "src"); - lua_gettable(L, -2); - const char *srcName = lua_tostring(L, -1); - ASroute.src = sg_netpoint_by_name_or_null(srcName); - lua_ensure(ASroute.src != nullptr, "Attribute 'src=%s' of AS route does not name a node.", srcName); - lua_pop(L, 1); - - lua_pushstring(L, "dst"); - lua_gettable(L, -2); - const char *dstName = lua_tostring(L, -1); - ASroute.dst = sg_netpoint_by_name_or_null(dstName); - lua_ensure(ASroute.dst != nullptr, "Attribute 'dst=%s' of AS route does not name a node.", dstName); - lua_pop(L, 1); - - lua_pushstring(L, "gw_src"); - lua_gettable(L, -2); - const char* pname = lua_tostring(L, -1); - ASroute.gw_src = sg_netpoint_by_name_or_null(pname); - lua_ensure(ASroute.gw_src, "Attribute 'gw_src=%s' of AS route does not name a valid node", pname); - lua_pop(L, 1); - - lua_pushstring(L, "gw_dst"); - lua_gettable(L, -2); - pname = lua_tostring(L, -1); - ASroute.gw_dst = sg_netpoint_by_name_or_null(pname); - lua_ensure(ASroute.gw_dst, "Attribute 'gw_dst=%s' of AS route does not name a valid node", pname); - lua_pop(L, 1); - - lua_pushstring(L,"links"); - lua_gettable(L,-2); - std::vector names; - const char* str = lua_tostring(L, -1); - boost::split(names, str, boost::is_any_of(", \t\r\n")); - if (names.empty()) { - /* unique name with no comma */ - ASroute.link_list.emplace_back(simgrid::s4u::Link::by_name(lua_tostring(L, -1))); - } else { - // Several names separated by , \t\r\n - for (auto const& name : names) { - if (name.length() > 0) { - ASroute.link_list.emplace_back(simgrid::s4u::Link::by_name(name)); - } - } - } - lua_pop(L,1); - - lua_pushstring(L,"symmetrical"); - lua_gettable(L,-2); - ASroute.symmetrical = (not lua_isstring(L, -1) || strcasecmp("YES", lua_tostring(L, -1)) == 0); - lua_pop(L,1); - - sg_platf_new_route(&ASroute); - - return 0; -} - -int console_AS_open(lua_State *L) { - XBT_DEBUG("Opening AS"); - - lua_ensure(lua_istable(L, 1), "Bad Arguments to AS_open, Should be a table with named arguments"); - - lua_pushstring(L, "id"); - int type = lua_gettable(L, -2); - lua_ensure(type == LUA_TSTRING, "Attribute 'id' must be specified for any AS and must be a string."); - const char* id = lua_tostring(L, -1); - lua_pop(L, 1); - - lua_pushstring(L, "mode"); - lua_gettable(L, -2); - const char* mode = lua_tostring(L, -1); - lua_pop(L, 1); - - simgrid::kernel::routing::ZoneCreationArgs AS; - AS.id = id; - AS.routing = mode; - simgrid::kernel::routing::NetZoneImpl* new_as = sg_platf_new_zone_begin(&AS); - - /* Build a Lua representation of the new AS on the stack */ - lua_newtable(L); - auto* lua_as = static_cast( - lua_newuserdata(L, sizeof(simgrid::kernel::routing::NetZoneImpl*))); /* table userdatum */ - *lua_as = new_as; - luaL_getmetatable(L, PLATF_MODULE_NAME); /* table userdatum metatable */ - lua_setmetatable(L, -2); /* table userdatum */ - lua_setfield(L, -2, AS_FIELDNAME); /* table -- put the userdata as field of the table */ - - return 1; -} - -int console_AS_seal(lua_State*) -{ - XBT_DEBUG("Sealing AS"); - sg_platf_new_zone_seal(); - return 0; -} - -int console_host_set_property(lua_State *L) { - lua_ensure(lua_istable(L, -1), "Bad Arguments to create link, Should be a table with named arguments"); - - // get Host id - lua_pushstring(L, "host"); - lua_gettable(L, -2); - const char* name = lua_tostring(L, -1); - lua_pop(L, 1); - - // get prop Name - lua_pushstring(L, "prop"); - lua_gettable(L, -2); - const char* prop_id = lua_tostring(L, -1); - lua_pop(L, 1); - //get args - lua_pushstring(L,"value"); - lua_gettable(L, -2); - const char* prop_value = lua_tostring(L, -1); - lua_pop(L, 1); - - sg_host_t host = sg_host_by_name(name); - lua_ensure(host, "no host '%s' found",name); - host->set_property(prop_id, prop_value); - - return 0; -} - -/** - * @brief Registers the platform functions into the table simgrid.platf. - * @param L a lua state - */ -void sglua_register_platf_functions(lua_State* L) -{ - lua_getglobal(L, "simgrid"); /* simgrid */ - luaL_newlib(L, platf_functions); /* simgrid simgrid.platf */ - lua_setfield(L, -2, "engine"); /* simgrid */ - - lua_pop(L, 1); /* -- */ -} diff --git a/src/bindings/lua/lua_private.hpp b/src/bindings/lua/lua_private.hpp deleted file mode 100644 index 7200558a76..0000000000 --- a/src/bindings/lua/lua_private.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (c) 2010-2021. 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. */ - -/* SimGrid Lua bindings */ - -#ifndef LUA_PRIVATE_HPP -#define LUA_PRIVATE_HPP - -#include "simgrid/host.h" -#include "simgrid_lua.hpp" -#include "xbt/log.h" - -void sglua_register_host_functions(lua_State* L); -sg_host_t sglua_check_host(lua_State* L, int index); - -void sglua_register_platf_functions(lua_State* L); - -#define lua_ensure(...) _XBT_IF_ONE_ARG(_lua_ensure_ARG1, _lua_ensure_ARGN, __VA_ARGS__)(__VA_ARGS__) -#define _lua_ensure_ARG1(cond) _lua_ensure_ARGN((cond), "Assertion " _XBT_STRINGIFY(cond) " failed") -#define _lua_ensure_ARGN(cond, ...) \ - do { \ - if (not(cond)) { \ - luaL_error(L, __VA_ARGS__); \ - return -1; \ - } \ - } while (0) - -#endif diff --git a/src/bindings/lua/lua_utils.cpp b/src/bindings/lua/lua_utils.cpp deleted file mode 100644 index 21bb4b1242..0000000000 --- a/src/bindings/lua/lua_utils.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright (c) 2010-2021. 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. */ - -/* - * This file contains functions that aid users to debug their lua scripts; for instance, - * tables can be easily output and values are represented in a human-readable way. (For instance, - * a nullptr value becomes the string "nil"). - * - */ -/* SimGrid Lua helper functions */ -#include "lua_utils.hpp" -#include -#include -#include - -/** - * @brief Returns a string representation of a value in the Lua stack. - * - * This function is for debugging purposes. - * - * @param L the Lua state - * @param index index in the stack - * @return a string representation of the value at this index - */ -std::string sglua_tostring(lua_State* L, int index) -{ - std::string buff; - - switch (lua_type(L, index)) { - case LUA_TNIL: - buff = "nil"; - break; - - case LUA_TNUMBER: - buff = simgrid::xbt::string_printf("%.3f", lua_tonumber(L, index)); - break; - - case LUA_TBOOLEAN: - buff = lua_toboolean(L, index) ? "true" : "false"; - break; - - case LUA_TSTRING: - buff = simgrid::xbt::string_printf("'%s'", lua_tostring(L, index)); - break; - - case LUA_TFUNCTION: - buff = lua_iscfunction(L, index) ? "C-function" : "function"; - break; - - case LUA_TTABLE: - buff = simgrid::xbt::string_printf("table(%p)", lua_topointer(L, index)); - break; - - case LUA_TLIGHTUSERDATA: - case LUA_TUSERDATA: - buff = simgrid::xbt::string_printf("userdata(%p)", lua_touserdata(L, index)); - break; - - case LUA_TTHREAD: - buff = "thread"; - break; - - default: - buff = simgrid::xbt::string_printf("unknown(%d)", lua_type(L, index)); - break; - } - return buff; -} - -/** - * @brief Returns a string representation of a key-value pair. - * - * @param L the Lua state - * @param key_index index of the key (in the lua stack) - * @param value_index index of the value (in the lua stack) - * @return a string representation of the key-value pair - */ -std::string sglua_keyvalue_tostring(lua_State* L, int key_index, int value_index) -{ - return std::string("[") + sglua_tostring(L, key_index) + "] -> " + sglua_tostring(L, value_index); -} diff --git a/src/bindings/lua/lua_utils.hpp b/src/bindings/lua/lua_utils.hpp deleted file mode 100644 index a42bc901f2..0000000000 --- a/src/bindings/lua/lua_utils.hpp +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright (c) 2010-2021. 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. */ - -/* SimGrid Lua helper functions */ - -#ifndef LUA_UTILS_HPP -#define LUA_UTILS_HPP - -#include -#include - -std::string sglua_tostring(lua_State* L, int index); -std::string sglua_keyvalue_tostring(lua_State* L, int key_index, int value_index); - -#endif diff --git a/src/bindings/lua/simgrid_lua.cpp b/src/bindings/lua/simgrid_lua.cpp deleted file mode 100644 index 26e9078f75..0000000000 --- a/src/bindings/lua/simgrid_lua.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* Copyright (c) 2010-2021. 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. */ - -/* SimGrid Lua bindings */ - -#include "lua_private.hpp" -#include "lua_utils.hpp" -#include "src/surf/xml/platf.hpp" -#include - -XBT_LOG_NEW_DEFAULT_CATEGORY(lua, "Lua Bindings"); - -extern "C" int luaopen_simgrid(lua_State* L); - -/* ********************************************************************************* */ -/* simgrid API */ -/* ********************************************************************************* */ - -/** - * @brief Prints a log string with debug level. - * @param L a Lua state - * @return number of values returned to Lua - * - * - Argument 1 (string): the text to print - */ -static int debug(lua_State* L) -{ - const char* str = luaL_checkstring(L, 1); - XBT_DEBUG("%s", str); - return 0; -} - -/** - * @brief Prints a log string with info level. - * @param L a Lua state - * @return number of values returned to Lua - * - * - Argument 1 (string): the text to print - */ -static int info(lua_State* L) -{ - const char* str = luaL_checkstring(L, 1); - XBT_INFO("%s", str); - return 0; -} - -static int error(lua_State* L) -{ - const char* str = luaL_checkstring(L, 1); - XBT_ERROR("%s", str); - return 0; -} - -static int critical(lua_State* L) -{ - const char* str = luaL_checkstring(L, 1); - XBT_CRITICAL("%s", str); - return 0; -} - -/** - * @brief Dumps a lua table with XBT_DEBUG - * - * This function can be called from within lua via "simgrid.dump(table)". It will - * then dump the table via XBT_DEBUG - */ -static int dump(lua_State* L) -{ - int argc = lua_gettop(L); - - for (int i = 1; i <= argc; i++) { - if (lua_istable(L, i)) { - lua_pushnil(L); /* table nil */ - - //lua_next pops the topmost element from the stack and - //gets the next pair from the table at the specified index - while (lua_next(L, i)) { /* table key val */ - // we need to copy here, as a cast from "Number" to "String" - // could happen in Lua. - // see remark in the lua manual, function "lua_tolstring" - // http://www.lua.org/manual/5.3/manual.html#lua_tolstring - - lua_pushvalue(L, -2); /* table key val key */ - - XBT_DEBUG("%s", sglua_keyvalue_tostring(L, -1, -2).c_str()); - } - - lua_settop(L, argc); // Remove everything except the initial arguments - } - } - - return 0; -} - -static const luaL_Reg simgrid_functions[] = { - {"dump", dump}, - {"debug", debug}, - {"info", info}, - {"critical", critical}, - {"error", error}, - {nullptr, nullptr} -}; - -/* ********************************************************************************* */ -/* module management functions */ -/* ********************************************************************************* */ - -/** - * @brief Makes the core functions available to the Lua world. - * @param L a Lua world - */ -static void sglua_register_core_functions(lua_State *L) -{ - /* register the core C functions to lua */ - luaL_newlib(L, simgrid_functions); /* simgrid */ - lua_pushvalue(L, -1); /* simgrid simgrid */ - lua_setglobal(L, "simgrid"); /* simgrid */ -} - -/** - * @brief Opens the simgrid Lua module. - * - * This function is called automatically by the Lua interpreter when some - * Lua code requires the "simgrid" module. - * - * @param L the Lua state - */ -int luaopen_simgrid(lua_State *L) -{ - XBT_DEBUG("luaopen_simgrid *****"); - - sglua_register_core_functions(L); - sglua_register_host_functions(L); - sglua_register_platf_functions(L); - - return 1; -} diff --git a/src/bindings/lua/simgrid_lua.hpp b/src/bindings/lua/simgrid_lua.hpp deleted file mode 100644 index df129c2a3a..0000000000 --- a/src/bindings/lua/simgrid_lua.hpp +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (c) 2010-2021. 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. */ - -#ifndef SIMGRID_LUA_HPP -#define SIMGRID_LUA_HPP - -#include - -/* ********************************************************************************* */ -/* Platform functions */ -/* ********************************************************************************* */ - -extern "C" { -int console_open(lua_State* L); -int console_close(lua_State* L); - -int console_add_backbone(lua_State*); -int console_add_host___link(lua_State*); -int console_add_host(lua_State*); -int console_add_link(lua_State*); -int console_add_router(lua_State* L); -int console_add_route(lua_State*); -int console_add_ASroute(lua_State*); -int console_AS_open(lua_State*); -int console_AS_seal(lua_State* L); -int console_set_function(lua_State*); -int console_host_set_property(lua_State*); -} -#endif diff --git a/src/simgrid/sg_version.cpp b/src/simgrid/sg_version.cpp index 6c085b2141..7e42e2a5ba 100644 --- a/src/simgrid/sg_version.cpp +++ b/src/simgrid/sg_version.cpp @@ -64,12 +64,6 @@ void sg_version() XBT_HELP(" ns-3 support disabled at compilation."); #endif -#if SIMGRID_HAVE_LUA - XBT_HELP(" Lua support compiled in."); -#else - XBT_HELP(" Lua support disabled at compilation."); -#endif - #if SIMGRID_HAVE_MALLOCATOR XBT_HELP(" Mallocator support compiled in."); #else diff --git a/src/surf/xml/surfxml_parseplatf.cpp b/src/surf/xml/surfxml_parseplatf.cpp index 526815a037..5152815204 100644 --- a/src/surf/xml/surfxml_parseplatf.cpp +++ b/src/surf/xml/surfxml_parseplatf.cpp @@ -13,14 +13,6 @@ #include -#if SIMGRID_HAVE_LUA -#include "src/bindings/lua/simgrid_lua.hpp" - -#include /* Always include this when calling Lua */ -#include /* Always include this when calling Lua */ -#include /* Prototype for luaL_openlibs(), */ -#endif - XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_parse); /* Trace related stuff */ @@ -64,38 +56,9 @@ void parse_platform_file(const std::string& file) { const char* cfile = file.c_str(); size_t len = strlen(cfile); - bool is_lua = len > 3 && file[len - 3] == 'l' && file[len - 2] == 'u' && file[len - 1] == 'a'; sg_platf_init(); - /* 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 - static bool already_warned = false; - if (not already_warned) { // XBT_ATTRIB_DEPRECATED_v332 - XBT_WARN("You are using a lua platform file. This feature is deprecated and will disappear after SimGrid v3.31."); - already_warned = true; - } - lua_State* L = luaL_newstate(); - luaL_openlibs(L); - - luaL_loadfile(L, cfile); // This loads the file without executing it. - - /* Run the script */ - xbt_assert(lua_pcall(L, 0, 0, 0) == 0, "FATAL ERROR:\n %s: %s\n\n", "Lua call failed. Error message:", - lua_tostring(L, -1)); - 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 - /* init the flex parser */ surf_parse_open(file); diff --git a/teshsuite/lua/CMakeLists.txt b/teshsuite/lua/CMakeLists.txt deleted file mode 100644 index 7ee215c5fb..0000000000 --- a/teshsuite/lua/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -IF(SIMGRID_HAVE_LUA) - # Tests testing simulation from C++ but using lua for platform files. - ADD_TESH(lua-platform-masterworker --setenv srcdir=${CMAKE_HOME_DIRECTORY} --setenv bindir=${CMAKE_BINARY_DIR} --cd ${CMAKE_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/teshsuite/lua/lua_platforms.tesh) - SET_TESTS_PROPERTIES(lua-platform-masterworker PROPERTIES ENVIRONMENT "LUA_CPATH=${CMAKE_BINARY_DIR}/lib/lib?.${LIB_EXE}") -ENDIF() diff --git a/teshsuite/lua/lua_platforms.tesh b/teshsuite/lua/lua_platforms.tesh deleted file mode 100644 index 83a675831b..0000000000 --- a/teshsuite/lua/lua_platforms.tesh +++ /dev/null @@ -1,47 +0,0 @@ -$ ${bindir:=.}/examples/cpp/app-masterworkers/s4u-app-masterworkers-fun ${srcdir:=.}/examples/platforms/small_platform.lua ${srcdir:=.}/examples/cpp/app-masterworkers/s4u-app-masterworkers_d.xml --log=no_loc -> [0.000000] [surf_parse/WARNING] You are using a lua platform file. This feature is deprecated and will disappear after SimGrid v3.31. -> [Tremblay:master:(1) 0.000000] [s4u_app_masterworker/INFO] Got 5 workers and 20 tasks to process -> [Tremblay:master:(1) 0.000000] [s4u_app_masterworker/INFO] Sending task 0 of 20 to mailbox 'Tremblay' -> [Tremblay:master:(1) 0.002265] [s4u_app_masterworker/INFO] Sending task 1 of 20 to mailbox 'Jupiter' -> [Tremblay:master:(1) 0.171420] [s4u_app_masterworker/INFO] Sending task 2 of 20 to mailbox 'Fafard' -> [Tremblay:master:(1) 0.329817] [s4u_app_masterworker/INFO] Sending task 3 of 20 to mailbox 'Ginette' -> [Tremblay:master:(1) 0.453549] [s4u_app_masterworker/INFO] Sending task 4 of 20 to mailbox 'Bourassa' -> [Tremblay:master:(1) 0.586168] [s4u_app_masterworker/INFO] Sending task 5 of 20 to mailbox 'Tremblay' -> [Tremblay:master:(1) 0.588433] [s4u_app_masterworker/INFO] Sending task 6 of 20 to mailbox 'Jupiter' -> [Tremblay:master:(1) 0.995917] [s4u_app_masterworker/INFO] Sending task 7 of 20 to mailbox 'Fafard' -> [Tremblay:master:(1) 1.154314] [s4u_app_masterworker/INFO] Sending task 8 of 20 to mailbox 'Ginette' -> [Tremblay:master:(1) 1.608379] [s4u_app_masterworker/INFO] Sending task 9 of 20 to mailbox 'Bourassa' -> [Tremblay:master:(1) 1.749885] [s4u_app_masterworker/INFO] Sending task 10 of 20 to mailbox 'Tremblay' -> [Tremblay:master:(1) 1.752150] [s4u_app_masterworker/INFO] Sending task 11 of 20 to mailbox 'Jupiter' -> [Tremblay:master:(1) 1.921304] [s4u_app_masterworker/INFO] Sending task 12 of 20 to mailbox 'Fafard' -> [Tremblay:master:(1) 2.079701] [s4u_app_masterworker/INFO] Sending task 13 of 20 to mailbox 'Ginette' -> [Tremblay:master:(1) 2.763209] [s4u_app_masterworker/INFO] Sending task 14 of 20 to mailbox 'Bourassa' -> [Tremblay:master:(1) 2.913601] [s4u_app_masterworker/INFO] Sending task 15 of 20 to mailbox 'Tremblay' -> [Tremblay:master:(1) 2.915867] [s4u_app_masterworker/INFO] Sending task 16 of 20 to mailbox 'Jupiter' -> [Tremblay:master:(1) 3.085021] [s4u_app_masterworker/INFO] Sending task 17 of 20 to mailbox 'Fafard' -> [Tremblay:master:(1) 3.243418] [s4u_app_masterworker/INFO] Sending task 18 of 20 to mailbox 'Ginette' -> [Tremblay:master:(1) 3.918038] [s4u_app_masterworker/INFO] Sending task 19 of 20 to mailbox 'Bourassa' -> [Tremblay:master:(1) 4.077318] [s4u_app_masterworker/INFO] All tasks have been dispatched. Request all workers to stop. -> [Tremblay:worker:(2) 4.077513] [s4u_app_masterworker/INFO] Exiting now. -> [Jupiter:worker:(3) 4.096528] [s4u_app_masterworker/INFO] Exiting now. -> [Fafard:worker:(4) 4.122236] [s4u_app_masterworker/INFO] Exiting now. -> [Ginette:worker:(5) 4.965689] [s4u_app_masterworker/INFO] Exiting now. -> [Bourassa:worker:(6) 5.133855] [s4u_app_masterworker/INFO] Exiting now. -> [5.133855] [s4u_app_masterworker/INFO] Simulation is over - -$ ${bindir:=.}/examples/cpp/app-token-ring/s4u-app-token-ring ${srcdir:=.}/examples/platforms/routing_cluster.lua "--log=root.fmt:[%10.6r]%e(%i:%a@%h)%e%m%n" -> [ 0.000000] (0:maestro@) You are using a lua platform file. This feature is deprecated and will disappear after SimGrid v3.31. -> [ 0.000000] (0:maestro@) Number of hosts '6' -> [ 0.000000] (1:0@host1) Host "0" send 'Token' to Host "1" -> [ 0.017354] (2:1@host2) Host "1" received "Token" -> [ 0.017354] (2:1@host2) Host "1" send 'Token' to Host "2" -> [ 0.035121] (3:2@host3) Host "2" received "Token" -> [ 0.035121] (3:2@host3) Host "2" send 'Token' to Host "3" -> [ 0.065898] (4:3@host4) Host "3" received "Token" -> [ 0.065898] (4:3@host4) Host "3" send 'Token' to Host "4" -> [ 0.083252] (5:4@host5) Host "4" received "Token" -> [ 0.083252] (5:4@host5) Host "4" send 'Token' to Host "5" -> [ 0.101019] (6:5@host6) Host "5" received "Token" -> [ 0.101019] (6:5@host6) Host "5" send 'Token' to Host "0" -> [ 0.131796] (1:0@host1) Host "0" received "Token" -> [ 0.131796] (0:maestro@) Simulation time 0.131796 diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index caf746ef18..4f385d9b7d 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -74,8 +74,6 @@ set(EXTRA_DIST src/xbt/mmalloc/mrealloc.c src/xbt/mmalloc/swag.c src/xbt/mmalloc/swag.h - tools/lualib.patch - teshsuite/lua/lua_platforms.tesh examples/smpi/mc/only_send_deterministic.tesh ) @@ -472,12 +470,6 @@ set(DAG_SRC src/dag/loaders.cpp ) -set(BINDINGS_SRC - src/bindings/lua/lua_private.hpp - src/bindings/lua/lua_utils.hpp - src/bindings/lua/simgrid_lua.hpp - ) - set(JMSG_C_SRC src/bindings/java/jmsg.cpp src/bindings/java/jmsg.hpp @@ -533,13 +525,6 @@ set(JTRACE_JAVA_SRC src/bindings/java/org/simgrid/trace/Trace.java) list(APPEND JMSG_C_SRC ${JTRACE_C_SRC}) list(APPEND JMSG_JAVA_SRC ${JTRACE_JAVA_SRC}) -set(LUA_SRC - src/bindings/lua/lua_host.cpp - src/bindings/lua/lua_platf.cpp - src/bindings/lua/lua_utils.cpp - src/bindings/lua/simgrid_lua.cpp - ) - set(TRACING_SRC src/instr/instr_config.cpp src/instr/instr_interface.cpp @@ -789,7 +774,6 @@ set(simgrid_sources ${TRACING_SRC} ${XBT_SRC} ${PLUGINS_SRC} - ${BINDINGS_SRC} ${DAG_SRC} ) @@ -817,12 +801,6 @@ else() set(EXTRA_DIST ${EXTRA_DIST} include/simgrid/plugins/ns3.hpp) endif() -if(SIMGRID_HAVE_LUA) - set(simgrid_sources ${simgrid_sources} ${LUA_SRC}) -else() - set(EXTRA_DIST ${EXTRA_DIST} ${LUA_SRC}) -endif() - set(DOC_SOURCES doc/doxygen/FAQ.doc doc/doxygen/inside.doc @@ -1036,7 +1014,6 @@ set(CMAKEFILES_TXT teshsuite/java/CMakeLists.txt teshsuite/kernel/CMakeLists.txt - teshsuite/lua/CMakeLists.txt teshsuite/mc/CMakeLists.txt teshsuite/models/CMakeLists.txt teshsuite/msg/CMakeLists.txt @@ -1105,7 +1082,6 @@ set(CMAKE_SOURCE_FILES tools/cmake/Modules/FindLibelf.cmake tools/cmake/Modules/FindLibunwind.cmake tools/cmake/Modules/FindLibevent.cmake - tools/cmake/Modules/FindLuaSimgrid.cmake tools/cmake/Modules/FindNS3.cmake tools/cmake/Modules/FindPAPI.cmake tools/cmake/Modules/pybind11Config.cmake @@ -1142,7 +1118,6 @@ set(PLATFORMS_EXAMPLES examples/platforms/cluster_backbone.svg examples/platforms/cluster_multi.xml examples/platforms/cluster_and_one_host.xml - examples/platforms/cluster_prototype.lua examples/platforms/cluster_crossbar.xml examples/platforms/cluster_crossbar.svg examples/platforms/cluster_fat_tree.xml @@ -1186,14 +1161,12 @@ set(PLATFORMS_EXAMPLES examples/platforms/ptask_L07.xml examples/platforms/prop.xml examples/platforms/routing_cluster.xml - examples/platforms/routing_cluster.lua examples/platforms/routing_cluster.cpp examples/platforms/routing_none.xml examples/platforms/simulacrum_7_hosts.xml examples/platforms/storage/content/small_content.txt examples/platforms/storage/content/storage_content.txt examples/platforms/small_platform.xml - examples/platforms/small_platform.lua examples/platforms/small_platform_constant.xml examples/platforms/small_platform_failures.xml examples/platforms/small_platform_fatpipe.xml diff --git a/tools/cmake/Distrib.cmake b/tools/cmake/Distrib.cmake index 4276ff9786..43184e897b 100644 --- a/tools/cmake/Distrib.cmake +++ b/tools/cmake/Distrib.cmake @@ -92,7 +92,6 @@ add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_INSTALL_PREFIX}/doc/simgrid COMMAND ${CMAKE_COMMAND} -E echo "uninstall doc ok" COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_INSTALL_PREFIX}/lib/libsimgrid* - COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_INSTALL_PREFIX}/lib/lua/5.1/simgrid* COMMAND ${CMAKE_COMMAND} -E echo "uninstall lib ok" COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_INSTALL_PREFIX}/bin/smpicc COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_INSTALL_PREFIX}/bin/smpicxx @@ -129,13 +128,6 @@ add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -E echo "uninstall man ok" WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}") -if(SIMGRID_HAVE_LUA) - add_custom_command(TARGET uninstall - COMMAND ${CMAKE_COMMAND} -E echo "uninstall binding lua ok" - COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_INSTALL_PREFIX}/lib/lua/5.1/simgrid.${LIB_EXE} - WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}/") -endif() - ################################################################ ## Build a sain "make dist" target to build a source package ### ## containing only the files that I explicitly state ### @@ -146,10 +138,8 @@ endif() set(source_to_pack ${headers_to_install} ${source_of_generated_headers} - ${BINDINGS_SRC} ${JMSG_C_SRC} ${JMSG_JAVA_SRC} - ${LUA_SRC} ${MC_SRC_BASE} ${MC_SRC} ${MC_SIMGRID_MC_SRC} diff --git a/tools/cmake/MakeLib.cmake b/tools/cmake/MakeLib.cmake index e46a56a1df..b1a72d6fb7 100644 --- a/tools/cmake/MakeLib.cmake +++ b/tools/cmake/MakeLib.cmake @@ -63,13 +63,6 @@ if(CMAKE_USE_PTHREADS_INIT) target_link_libraries(simgrid ${CMAKE_THREAD_LIBS_INIT}) endif() -if(SIMGRID_HAVE_LUA) - ADD_CUSTOM_TARGET(link_simgrid_lua ALL - DEPENDS simgrid - ) - SET(SIMGRID_DEP "${SIMGRID_DEP} ${LUA_LIBRARY}") -endif() - if(HAVE_PAPI) SET(SIMGRID_DEP "${SIMGRID_DEP} -lpapi") endif() diff --git a/tools/cmake/Modules/FindLuaSimgrid.cmake b/tools/cmake/Modules/FindLuaSimgrid.cmake deleted file mode 100644 index 00b9fb801b..0000000000 --- a/tools/cmake/Modules/FindLuaSimgrid.cmake +++ /dev/null @@ -1,68 +0,0 @@ -# Search for the Lua 5.3 include files and libraries -# -# Input variable: -# LUA_HINT: path to Lua installation -- only needed for non-standard installs -# Output variable: -# SIMGRID_HAVE_LUA : if Lua was found -# LUA_LIBRARY : the path to the dynamic library -# LUA_INCLUDE_DIR : where to find lua.h -# LUA_VERSION_MAJOR: First part of the version (often, 5) -# LUA_VERSION_MINOR: Second part of the version (3 when we have 5.3) - -find_path(LUA_INCLUDE_DIR lua.h - HINTS - ENV LUA_HINT - PATH_SUFFIXES include/lua53 include/lua5.3 include/lua-5.3 include/lua include - PATHS - ~/Library/Frameworks - /Library/Frameworks - /sw # Fink - /opt/local # DarwinPorts - /opt/csw # Blastwave - /opt -) - -find_library(LUA_LIBRARY - NAMES # I don't want a lua.a - lua53.so lua5.3.so lua-5.3.so - lua53.dynlib lua5.3.dynlib lua-5.3.dynlib - lua53.dll lua5.3.dll lua-5.3.dll - lua.so lua.dynlib lua.dll - lua53 lua5.3 lua-5.3 lua - HINTS - ENV LUA_HINT - PATH_SUFFIXES lib - PATHS - ~/Library/Frameworks - /Library/Frameworks - /sw - /opt/local - /opt/csw - /opt -) -if (NOT LUA_LIBRARY) - message(FATAL_ERROR "Error: Lua library not found. Please install that package (and set LUA_HINT) or disable Lua.") -endif() -if (NOT LUA_INCLUDE_DIR OR NOT EXISTS "${LUA_INCLUDE_DIR}/lua.h") - message(FATAL_ERROR "Error: Lua header file not found. Please install that package (and set LUA_HINT) or disable Lua.") -endif() - -# Extract the version info out of the header file -file(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_VERSION_MAJOR[ \t]+\"[456]+\"") - string(REGEX REPLACE "^#define[ \t]+LUA_VERSION_MAJOR[ \t]+\"([^\"]+)\"" "\\1" LUA_VERSION_MAJOR "${lua_version_str}") -file(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_VERSION_MINOR[ \t]+\"[0123456789]+\"") - string(REGEX REPLACE "^#define[ \t]+LUA_VERSION_MINOR[ \t]+\"([^\"]+)\"" "\\1" LUA_VERSION_MINOR "${lua_version_str}") -unset(lua_version_str) - -# Check that we have a sufficient version of Lua -if(LUA_VERSION_MAJOR EQUAL 5 AND LUA_VERSION_MINOR EQUAL 3) - set(SIMGRID_HAVE_LUA 1) - include_directories(${LUA_INCLUDE_DIR}) -else() - message(FATAL_ERROR "Error: Lua version 5.3 is required, but version ${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR} found instead.") -endif() - -message(STATUS "Lua version: ${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}") -message(STATUS "Lua library: ${LUA_LIBRARY}") -mark_as_advanced(LUA_INCLUDE_DIR) -mark_as_advanced(LUA_LIBRARY) diff --git a/tools/cmake/Option.cmake b/tools/cmake/Option.cmake index fe18f65c72..2515b91018 100644 --- a/tools/cmake/Option.cmake +++ b/tools/cmake/Option.cmake @@ -32,8 +32,6 @@ if(minimal-bindings) set(enable_lib_in_jar on) endif() -option(enable_lua "Whether the Lua bindings are activated." off) - option(enable_model-checking "Turn this on to experiment with our prototype of model-checker (hinders the simulation's performance even if turned off at runtime)" off) option(enable-model-checking "Please set 'enable_model-checking' instead" off) mark_as_advanced(enable-model-checking) diff --git a/tools/jenkins/DynamicAnalysis.sh b/tools/jenkins/DynamicAnalysis.sh index abe1c1bac5..15c2a37ef0 100755 --- a/tools/jenkins/DynamicAnalysis.sh +++ b/tools/jenkins/DynamicAnalysis.sh @@ -61,7 +61,7 @@ cd "$WORKSPACE"/build ### Proceed with the tests ctest -D ExperimentalStart || true -cmake -Denable_documentation=OFF -Denable_lua=OFF -Denable_python=OFF \ +cmake -Denable_documentation=OFF -Denable_python=OFF \ -Denable_compile_optimizations=OFF -Denable_compile_warnings=ON \ -Denable_mallocators=OFF \ -Denable_smpi=ON -Denable_smpi_MPICH3_testsuite=OFF -Denable_model-checking=OFF \ diff --git a/tools/jenkins/Flags.sh b/tools/jenkins/Flags.sh index aae4c308f9..9358cf6b93 100755 --- a/tools/jenkins/Flags.sh +++ b/tools/jenkins/Flags.sh @@ -86,7 +86,7 @@ then fi echo "Step ${STEP}/${NSTEPS} - Building with java=${buildjava}, debug=${builddebug}, SMPI=${buildsmpi}, MC=${buildmc}, MSG=${buildmsg}" -cmake -Denable_documentation=OFF -Denable_lua=ON -Denable_java=${buildjava} -Denable_msg=${buildmsg} \ +cmake -Denable_documentation=OFF -Denable_java=${buildjava} -Denable_msg=${buildmsg} \ -Denable_compile_optimizations=OFF -Denable_compile_warnings=ON \ -Denable_mallocators=ON -Denable_debug=${builddebug} \ -Denable_smpi=${buildsmpi} -Denable_smpi_MPICH3_testsuite=${buildsmpi} -Denable_model-checking=${buildmc} \ diff --git a/tools/jenkins/build.sh b/tools/jenkins/build.sh index 28ee7c0131..4f2993c0b8 100755 --- a/tools/jenkins/build.sh +++ b/tools/jenkins/build.sh @@ -208,12 +208,11 @@ cmake -G"$GENERATOR" ${INSTALL:+-DCMAKE_INSTALL_PREFIX=$INSTALL} \ -Denable_memcheck=$(onoff test "$build_mode" = "DynamicAnalysis") \ -Denable_compile_warnings=$(onoff test "$GENERATOR" != "MSYS Makefiles") -Denable_smpi=ON \ -Denable_ns3=$(onoff test "$have_NS3" = "yes" -a "$build_mode" = "Debug") \ - -Denable_lua=OFF ${MAY_DISABLE_SOURCE_CHANGE} ${MAY_DISABLE_LTO} \ + ${MAY_DISABLE_SOURCE_CHANGE} ${MAY_DISABLE_LTO} \ -Denable_java=$(onoff test "$build_mode" = "ModelChecker") \ -Denable_msg=$(onoff test "$build_mode" = "ModelChecker") \ -DLTO_EXTRA_FLAG="auto" \ "$SRCFOLDER" -# -Denable_lua=$(onoff test "$build_mode" != "DynamicAnalysis") \ set +x make -j $NUMBER_OF_PROCESSORS VERBOSE=1 tests diff --git a/tools/lualib.patch b/tools/lualib.patch deleted file mode 100644 index b9a8d34121..0000000000 --- a/tools/lualib.patch +++ /dev/null @@ -1,63 +0,0 @@ -This patch is to be applied to the Lua 5.3 source file to get a shared -library. This is because the authors of Lua don't bother distributing -a working build system for their software, so we have to make one... - -As unfortunate as it may be, there is nothing else we can do. - - -- Da SimGrid team. - -diff --git a/Makefile b/Makefile -index 5ee5601..93830a3 100644 ---- a/Makefile -+++ b/Makefile -@@ -52,7 +52,7 @@ R= $V.1 - all: $(PLAT) - - $(PLATS) clean: -- cd src && $(MAKE) $@ -+ cd src && $(MAKE) $@ V=$(V) R=$(R) - - test: dummy - src/lua -v -diff --git a/src/Makefile b/src/Makefile -index d71c75c..64bda79 100644 ---- a/src/Makefile -+++ b/src/Makefile -@@ -7,7 +7,7 @@ - PLAT= none - - CC= gcc -std=gnu99 --CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_2 $(SYSCFLAGS) $(MYCFLAGS) -+CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_2 $(SYSCFLAGS) $(MYCFLAGS) -fPIC - LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS) - LIBS= -lm $(SYSLIBS) $(MYLIBS) - -@@ -29,6 +29,7 @@ MYOBJS= - PLATS= aix bsd c89 freebsd generic linux macosx mingw posix solaris - - LUA_A= liblua.a -+LUA_SO= liblua.so - CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \ - lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \ - ltm.o lundump.o lvm.o lzio.o -@@ -43,7 +44,7 @@ LUAC_T= luac - LUAC_O= luac.o - - ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O) --ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) -+ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) $(LUA_SO) - ALL_A= $(LUA_A) - - # Targets start here. -@@ -59,6 +60,11 @@ $(LUA_A): $(BASE_O) - $(AR) $@ $(BASE_O) - $(RANLIB) $@ - -+$(LUA_SO): $(CORE_O) $(LIB_O) -+ $(CC) -shared -ldl -Wl,-soname,$(LUA_SO).$(V) -o $@.$(R) $? -lm $(MYLDFLAGS) -+ ln -sf $(LUA_SO).$(R) $(LUA_SO).$(V) -+ ln -sf $(LUA_SO).$(R) $(LUA_SO) -+ - $(LUA_T): $(LUA_O) $(LUA_A) - $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS) - diff --git a/tools/simgrid.supp b/tools/simgrid.supp index 5b71741baa..10397ae82f 100644 --- a/tools/simgrid.supp +++ b/tools/simgrid.supp @@ -143,14 +143,6 @@ fun:agconcat } -# We're not interested by memory leaks in the Lua interpreter -{ - Memory leak in lua - Memcheck:Leak - ... - fun:luaD_precall -} - # libunwind seems to be using msync poorly, thus triggering these # https://github.com/JuliaLang/julia/issues/4533 {