Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix conflict - Adrien
authorAd(rien) L <adrien.lebre@inria.fr>
Tue, 20 Oct 2015 12:51:28 +0000 (14:51 +0200)
committerAd(rien) L <adrien.lebre@inria.fr>
Tue, 20 Oct 2015 12:51:28 +0000 (14:51 +0200)
14 files changed:
.travis.yml
appveyor.yml
buildtools/Cmake/Modules/FindLua.cmake [deleted file]
doc/doxygen/internals.doc
doc/webcruft/DiscoveringSimgrid.gif [new file with mode: 0644]
examples/lua/CMakeLists.txt
include/xbt/log.h
src/msg/msg_vm.c
src/surf/plugins/energy.cpp
tools/cmake/CompleteInFiles.cmake
tools/cmake/DefinePackages.cmake
tools/cmake/MakeLib.cmake
tools/cmake/Modules/FindLua51Simgrid.cmake [deleted file]
tools/cmake/Modules/FindLuaSimgrid.cmake [new file with mode: 0644]

index dcc5b7c..3bcaa99 100644 (file)
@@ -13,6 +13,7 @@ compiler:
 #              reference to non-static member function must be called
 #                        std::uninitialized_fill( buffer_, buffer_ + size, init_value );
 #                                                                    ^~~~
+#
 addons:
   apt: # Get recent versions of the compiler, even on Ubuntu Precise
       sources:
@@ -29,8 +30,14 @@ before_install:
    - if [ ${TRAVIS_OS_NAME} = 'linux' ] ; then sudo apt-get install -y cmake valgrind default-jdk gfortran liblua5.1-dev lua5.1 libboost-chrono1.48-dev ; fi
    - if [ ${TRAVIS_OS_NAME} = 'linux' ] ; then sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 50 ; fi
    - if [ ${TRAVIS_OS_NAME} = 'linux' ] ; then sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.7 50 ; fi
+   - curl http://www.lua.org/ftp/lua-5.3.1.tar.gz | tar xz
+   - cd lua-5.3.1 
+   -   if [ ${TRAVIS_OS_NAME} = 'linux' ] ; then make linux ; else make macosx ; fi
+   -   make INSTALL_TOP=$TRAVIS_BUILD_DIR/LuaInstall install
+   - cd ..
+   - ls -lR $TRAVIS_BUILD_DIR/LuaInstall
 script:
-   - cmake -Denable_documentation=OFF -Denable_coverage=OFF -Denable_java=ON -Denable_model-checking=OFF -Denable_lua=ON -Denable_compile_optimizations=ON -Denable_smpi=ON -Denable_smpi_MPICH3_testsuite=OFF -Denable_compile_warnings=ON . && make VERBOSE=1 && ctest --output-on-failure --timeout 100
+   - LUA_HINT=$TRAVIS_BUILD_DIR/LuaInstall cmake -Denable_documentation=OFF -Denable_coverage=OFF -Denable_java=ON -Denable_model-checking=OFF -Denable_lua=ON -Denable_compile_optimizations=ON -Denable_smpi=ON -Denable_smpi_MPICH3_testsuite=OFF -Denable_compile_warnings=ON . && make VERBOSE=1 && ctest --output-on-failure --timeout 100
 branches:
   only:
      - master
index 8817dd1..c404bf1 100644 (file)
@@ -8,7 +8,6 @@ clone_depth: 1
 # scripts that are called at very beginning, before repo cloning
 init:
 - cmake --version
-- msbuild /version
 - git config --global core.longpaths true
 - git config --global core.autocrlf input
 
@@ -35,6 +34,9 @@ install:
 - if [%COMPILER%]==[MinGW-w64] rename "C:\Program Files (x86)\Git\bin\sh.exe" "sh2.exe"
 - if [%COMPILER%]==[MinGW-w64] appveyor DownloadFile "https://raw.githubusercontent.com/symengine/dependencies/5cff7d1736877336cf9fb58267111beea4fa152f/x86_64-4.9.1-release-posix-seh-rt_v3-rev1.7z" -FileName mw64.7z || appveyor DownloadFile "https://raw.githubusercontent.com/symengine/dependencies/5cff7d1736877336cf9fb58267111beea4fa152f/x86_64-4.9.1-release-posix-seh-rt_v3-rev1.7z" -FileName mw64.7z
 - if [%COMPILER%]==[MinGW-w64] 7z x -oC:\ mw64.7z > NUL
+- if [%COMPILER%]==[MinGW-w64] appveyor DownloadFile "http://www.lua.org/ftp/lua-5.3.1.tar.gz" -FileName lua-5.3.1.tar.gz || appveyor DownloadFile "http://www.lua.org/ftp/lua-5.3.1.tar.gz" -FileName lua-5.3.1.tar.gz
+- if [%COMPILER%]==[MinGW-w64] tar xfz lua-5.3.1.tar.gz 
+- if [%COMPILER%]==[MinGW-w64] cd lua-5.3.1 && mingw32-make mingw && mingw32-make INSTALL_TOP=C:/mingw64 install && cd ..
 - if [%COMPILER%]==[MSYS2]     set PATH=C:\msys64\bin,%PATH%
 
 build_script:
diff --git a/buildtools/Cmake/Modules/FindLua.cmake b/buildtools/Cmake/Modules/FindLua.cmake
deleted file mode 100644 (file)
index 22b6fb4..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-# Locate Lua library
-# This module defines
-#  LUA_FOUND          - if false, do not try to link to Lua
-#  LUA_LIBRARIES      - both lua and lualib
-#  LUA_INCLUDE_DIR    - where to find lua.h
-#  LUA_VERSION_STRING - the version of Lua found
-#  LUA_VERSION_MAJOR  - the major version of Lua
-#  LUA_VERSION_MINOR  - the minor version of Lua
-#  LUA_VERSION_PATCH  - the patch version of Lua
-#
-# Note that the expected include convention is
-#  #include "lua.h"
-# and not
-#  #include <lua/lua.h>
-# This is because, the lua location is not standardized and may exist
-# in locations other than lua/
-
-#=============================================================================
-# CMake - Cross Platform Makefile Generator
-# Copyright 2000-2014 Kitware, Inc.
-# Copyright 2000-2011 Insight Software Consortium
-# All rights reserved.
-# 
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 
-# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# 
-# * Neither the names of Kitware, Inc., the Insight Software Consortium,
-# nor the names of their contributors may be used to endorse or promote
-# products derived from this software without specific prior written
-# permission.
-# 
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#=============================================================================
-# See the copyright notice: http://www.cmake.org/licensing/
-
-unset(_lua_include_subdirs)
-unset(_lua_library_names)
-
-# this is a function only to have all the variables inside go away automatically
-function(set_lua_version_vars)
-    set(LUA_VERSIONS5 5.3 5.2 5.1 5.0)
-
-    if (Lua_FIND_VERSION_EXACT)
-        if (Lua_FIND_VERSION_COUNT GREATER 1)
-            set(lua_append_versions ${Lua_FIND_VERSION_MAJOR} ${Lua_FIND_VERSION_MINOR})
-        endif ()
-    elseif (Lua_FIND_VERSION)
-        # once there is a different major version supported this should become a loop
-        if (NOT Lua_FIND_VERSION_MAJOR GREATER 5)
-            if (Lua_FIND_VERSION_COUNT EQUAL 1)
-                set(lua_append_versions ${LUA_VERSIONS5})
-            else ()
-                foreach (subver IN LISTS LUA_VERSIONS5)
-                    if (NOT subver VERSION_LESS ${Lua_FIND_VERSION})
-                        list(APPEND lua_append_versions ${subver})
-                    endif ()
-                endforeach ()
-            endif ()
-        endif ()
-    else ()
-        # once there is a different major version supported this should become a loop
-        set(lua_append_versions ${LUA_VERSIONS5})
-    endif ()
-
-    foreach (ver IN LISTS lua_append_versions)
-        string(REGEX MATCH "^([0-9]+)\\.([0-9]+)$" _ver "${ver}")
-        list(APPEND _lua_include_subdirs
-             include/lua${CMAKE_MATCH_1}${CMAKE_MATCH_2}
-             include/lua${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
-             include/lua-${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
-        )
-        list(APPEND _lua_library_names
-             lua${CMAKE_MATCH_1}${CMAKE_MATCH_2}
-             lua${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
-             lua-${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
-        )
-    endforeach ()
-
-    set(_lua_include_subdirs "${_lua_include_subdirs}" PARENT_SCOPE)
-    set(_lua_library_names "${_lua_library_names}" PARENT_SCOPE)
-endfunction(set_lua_version_vars)
-
-set_lua_version_vars()
-
-find_path(LUA_INCLUDE_DIR lua.h
-  HINTS
-    ENV LUA_DIR
-  PATH_SUFFIXES ${_lua_include_subdirs} include/lua include
-  PATHS
-  ~/Library/Frameworks
-  /Library/Frameworks
-  /sw # Fink
-  /opt/local # DarwinPorts
-  /opt/csw # Blastwave
-  /opt
-)
-unset(_lua_include_subdirs)
-
-find_library(LUA_LIBRARY
-  NAMES ${_lua_library_names} lua
-  HINTS
-    ENV LUA_DIR
-  ""PATH_SUFFIXES lib
-  PATHS
-  ~/Library/Frameworks
-  /Library/Frameworks
-  /sw
-  /opt/local
-  /opt/csw
-  /opt
-)
-unset(_lua_library_names)
-
-if (LUA_LIBRARY)
-    # include the math library for Unix
-    if (UNIX AND NOT APPLE AND NOT BEOS)
-        find_library(LUA_MATH_LIBRARY m)
-        set(LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}")
-    # For Windows and Mac, don't need to explicitly include the math library
-    else ()
-        set(LUA_LIBRARIES "${LUA_LIBRARY}")
-    endif ()
-endif ()
-
-if (LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
-    # At least 5.[012] have different ways to express the version
-    # so all of them need to be tested. Lua 5.2 defines LUA_VERSION
-    # and LUA_RELEASE as joined by the C preprocessor, so avoid those.
-    file(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_strings
-         REGEX "^#define[ \t]+LUA_(RELEASE[ \t]+\"Lua [0-9]|VERSION([ \t]+\"Lua [0-9]|_[MR])).*")
-
-    string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_MAJOR[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_MAJOR ";${lua_version_strings};")
-    if (LUA_VERSION_MAJOR MATCHES "^[0-9]+$")
-        string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_MINOR[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_MINOR ";${lua_version_strings};")
-        string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_RELEASE[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_PATCH ";${lua_version_strings};")
-        set(LUA_VERSION_STRING "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}.${LUA_VERSION_PATCH}")
-    else ()
-        string(REGEX REPLACE ".*;#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([0-9.]+)\"[ \t]*;.*" "\\1" LUA_VERSION_STRING ";${lua_version_strings};")
-        if (NOT LUA_VERSION_STRING MATCHES "^[0-9.]+$")
-            string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION[ \t]+\"Lua ([0-9.]+)\"[ \t]*;.*" "\\1" LUA_VERSION_STRING ";${lua_version_strings};")
-        endif ()
-        string(REGEX REPLACE "^([0-9]+)\\.[0-9.]*$" "\\1" LUA_VERSION_MAJOR "${LUA_VERSION_STRING}")
-        string(REGEX REPLACE "^[0-9]+\\.([0-9]+)[0-9.]*$" "\\1" LUA_VERSION_MINOR "${LUA_VERSION_STRING}")
-        string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]).*" "\\1" LUA_VERSION_PATCH "${LUA_VERSION_STRING}")
-    endif ()
-
-    unset(lua_version_strings)
-endif()
-
-include(FindPackageHandleStandardArgs)
-# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
-# all listed variables are TRUE
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua
-                                  REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
-                                  VERSION_VAR LUA_VERSION_STRING)
-
-
-mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARY LUA_MATH_LIBRARY)
index 30e96a8..e3ecacd 100644 (file)
@@ -3,6 +3,11 @@
 This page does not exist yet, sorry. We are currently refurbishing the
 user documentation -- the internal documentation will follow (FIXME).
 
+All we can say for now is that once you learn a bit about the SimGrid
+internals, you will probably look a bit like this:
+
+@image html DiscoveringSimgrid.gif Discovering SimGrid's Internals.
+
 There is two main things you want to know about the internals of
 SimGrid. First, you need to understand the component organization, as
 SimGrid is heavily layered, with each level being rather highly
diff --git a/doc/webcruft/DiscoveringSimgrid.gif b/doc/webcruft/DiscoveringSimgrid.gif
new file mode 100644 (file)
index 0000000..9e45ad7
Binary files /dev/null and b/doc/webcruft/DiscoveringSimgrid.gif differ
index 410adaf..8c30ca4 100644 (file)
@@ -36,9 +36,7 @@ set(examples_src
   ${CMAKE_CURRENT_SOURCE_DIR}/kademlia/kademlia.lua
   ${CMAKE_CURRENT_SOURCE_DIR}/kademlia/routing_table.lua
   ${CMAKE_CURRENT_SOURCE_DIR}/kademlia/tools.lua
-  ${CMAKE_CURRENT_SOURCE_DIR}/masterslave/master.lua
   ${CMAKE_CURRENT_SOURCE_DIR}/masterslave/master_slave.lua
-  ${CMAKE_CURRENT_SOURCE_DIR}/masterslave/platform.lua
   ${CMAKE_CURRENT_SOURCE_DIR}/masterslave/slave.lua
   ${CMAKE_CURRENT_SOURCE_DIR}/multi_matrix/mult_matrix.lua
   ${CMAKE_CURRENT_SOURCE_DIR}/multi_matrix/receiver.lua
index b53652e..78a4815 100644 (file)
@@ -455,7 +455,7 @@ extern xbt_log_layout_t xbt_log_default_layout;
 
 /** @ingroup XBT_log
  *  @hideinitializer
- * \param c the category on which to log
+ * \param categ the category on which to log
  * \param ... the format string and its arguments
  *  @brief Log an event at the DEBUG priority on the specified category with these args.
  */
index dfb255c..c4cb96d 100644 (file)
@@ -164,20 +164,25 @@ int MSG_vm_is_restoring(msg_vm_t vm)
 
 /** @brief Create a new VM with specified parameters.
  *  @ingroup msg_VMs*
- *  All parameters are in MBytes
+ *  @param pm        Physical machine that will host the VM
+ *  @param net_cap   Maximal bandwidth that the VM can consume (in MByte/s)
+ *  @param disk_path (unused) Path to the image that boots
+ *  @param disksize  (unused) will represent the size of the VM (will be used during migrations)
+ *  @param mig_netspeed Amount of Mbyte/s allocated to the migration (cannot be larger than net_cap). Use 0 if unsure.
+ *  @param dp_intensity Dirty page percentage according to migNetSpeed, [0-100]. Use 0 if unsure.
  *
  */
-msg_vm_t MSG_vm_create(msg_host_t ind_pm, const char *name,
+msg_vm_t MSG_vm_create(msg_host_t pm, const char *name,
                        int ncpus, int ramsize,
                        int net_cap, char *disk_path, int disksize,
                        int mig_netspeed, int dp_intensity)
 {
   /* For the moment, intensity_rate is the percentage against the migration
    * bandwidth */
-  double host_speed = MSG_get_host_speed(ind_pm);
+  double host_speed = MSG_get_host_speed(pm);
   double update_speed = ((double)dp_intensity/100) * mig_netspeed;
 
-  msg_vm_t vm = MSG_vm_create_core(ind_pm, name);
+  msg_vm_t vm = MSG_vm_create_core(pm, name);
   s_vm_params_t params;
   memset(&params, 0, sizeof(params));
   params.ramsize = (sg_size_t)ramsize * 1024 * 1024;
index 4d44af5..d1d871f 100644 (file)
@@ -56,32 +56,28 @@ static void energyCpuCreatedCallback(Cpu *cpu){
   (*surf_energy)[cpu] = new CpuEnergy(cpu);
 }
 
-static void update_consumption_running(Cpu *cpu, CpuEnergy *cpu_energy) {
+
+/* Computes the consumption so far.  Called lazily on need. */
+static void update_consumption(Cpu *cpu, CpuEnergy *cpu_energy) {
        double cpu_load = lmm_constraint_get_usage(cpu->getConstraint()) / cpu->m_powerPeak;
        double start_time = cpu_energy->last_updated;
        double finish_time = surf_get_clock();
 
        double previous_energy = cpu_energy->total_energy;
-       double energy_this_step = cpu_energy->getCurrentWattsValue(cpu_load)*(finish_time-start_time);
 
-       cpu_energy->total_energy = previous_energy + energy_this_step;
-       cpu_energy->last_updated = finish_time;
-
-       XBT_DEBUG("[cpu_update_energy] period=[%.2f-%.2f]; current power peak=%.0E flop/s; consumption change: %.2f J -> %.2f J",
-                 start_time, finish_time, cpu->m_powerPeak, previous_energy, energy_this_step);
-}
-static void update_consumption_off(Cpu *cpu, CpuEnergy *cpu_energy) {
-       double start_time = cpu_energy->last_updated;
-       double finish_time = surf_get_clock();
+       double instantaneous_consumption;
+       if (cpu->getState() == SURF_RESOURCE_OFF)
+               instantaneous_consumption = cpu_energy->watts_off;
+       else
+               instantaneous_consumption = cpu_energy->getCurrentWattsValue(cpu_load);
 
-       double previous_energy = cpu_energy->total_energy;
-       double energy_this_step = cpu_energy->watts_off*(finish_time-start_time);
+       double energy_this_step = instantaneous_consumption*(finish_time-start_time);
 
        cpu_energy->total_energy = previous_energy + energy_this_step;
        cpu_energy->last_updated = finish_time;
 
-       XBT_DEBUG("[cpu_update_energy] off period=[%.2f-%.2f]; consumption change: %.2f J -> %.2f J",
-                 start_time, finish_time, previous_energy, energy_this_step);
+       XBT_DEBUG("[cpu_update_energy] period=[%.2f-%.2f]; current power peak=%.0E flop/s; consumption change: %.2f J -> %.2f J",
+                 start_time, finish_time, cpu->m_powerPeak, previous_energy, energy_this_step);
 }
 
 static void energyCpuDestructedCallback(Cpu *cpu){
@@ -89,10 +85,7 @@ static void energyCpuDestructedCallback(Cpu *cpu){
   xbt_assert(cpu_energy_it != surf_energy->end(), "The cpu is not in surf_energy.");
 
   CpuEnergy *cpu_energy = cpu_energy_it->second;
-  if (cpu->getState() == SURF_RESOURCE_OFF)
-         update_consumption_off(cpu, cpu_energy);
-  else
-         update_consumption_running(cpu, cpu_energy);
+  update_consumption(cpu, cpu_energy);
 
   // Adrien - October 2015, Changes related to VM energy extensions
   // Only report/delete and erase if the cpu_energy is related to a physical one
@@ -109,20 +102,15 @@ static void energyCpuActionStateChangedCallback(CpuAction *action, e_surf_action
 
   CpuEnergy *cpu_energy = (*surf_energy)[cpu];
 
-  if(cpu_energy->last_updated < surf_get_clock()) {
-         update_consumption_running(cpu, cpu_energy);
-  }
+  if(cpu_energy->last_updated < surf_get_clock())
+         update_consumption(cpu, cpu_energy);
 }
 
 static void energyStateChangedCallback(Cpu *cpu, e_surf_resource_state_t oldState, e_surf_resource_state_t newState){
   CpuEnergy *cpu_energy = (*surf_energy)[cpu];
 
-  if(cpu_energy->last_updated < surf_get_clock()) {
-         if (oldState == SURF_RESOURCE_OFF)
-                 update_consumption_off(cpu, cpu_energy);
-         else
-                 update_consumption_running(cpu, cpu_energy);
-  }
+  if(cpu_energy->last_updated < surf_get_clock())
+         update_consumption(cpu, cpu_energy);
 }
 
 static void sg_energy_plugin_exit()
@@ -218,14 +206,11 @@ double CpuEnergy::getCurrentWattsValue(double cpu_load)
 
 double CpuEnergy::getConsumedEnergy()
 {
-       
-   if(last_updated < surf_get_clock()) {
-               if (cpu->getState() == SURF_RESOURCE_OFF)
-                       update_consumption_off(cpu, this);
-               else
-                       update_consumption_running(cpu, this);
-       }
-  return total_energy;
+
+       if(last_updated < surf_get_clock())
+               update_consumption(cpu, this);
+       return total_energy;
+
 }
 
 xbt_dynar_t CpuEnergy::getWattsRangeList()
index e695dcf..ec65572 100644 (file)
@@ -96,7 +96,7 @@ if(enable_scala)
   set(HAVE_Scala 1)
 endif()
 if(enable_lua)
-  include(FindLua51Simgrid)
+  include(FindLuaSimgrid)
 endif()
 
 set(HAVE_NS3 0)
index e3df7d8..4bcbc4e 100644 (file)
@@ -1222,7 +1222,7 @@ set(CMAKE_SOURCE_FILES
   tools/cmake/Modules/FindLibSigc++.cmake
   tools/cmake/Modules/FindLibdw.cmake
   tools/cmake/Modules/FindLibunwind.cmake
-  tools/cmake/Modules/FindLua51Simgrid.cmake
+  tools/cmake/Modules/FindLuaSimgrid.cmake
   tools/cmake/Modules/FindNS3.cmake
   tools/cmake/Modules/FindRngStream.cmake
   tools/cmake/Modules/FindRubySimgrid.cmake
index 50cdcf4..1786058 100644 (file)
@@ -61,8 +61,7 @@ if(HAVE_LUA)
     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/examples/simdag/
     COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/examples/simdag/simgrid.${LIB_EXE} #for test
     )
-  SET(SIMGRID_DEP "${SIMGRID_DEP} -l${LIB_LUA_NAME}")
-  SET(SIMGRID_DEP "${SIMGRID_DEP} -ldl")
+  SET(SIMGRID_DEP "${SIMGRID_DEP} ${LUA_LIBRARY} -ldl")
 endif()
 
 if(HAVE_GRAPHVIZ)
diff --git a/tools/cmake/Modules/FindLua51Simgrid.cmake b/tools/cmake/Modules/FindLua51Simgrid.cmake
deleted file mode 100644 (file)
index 66aae90..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-include(./FindLua)
-find_program(HAVE_LUA_BIN NAMES lua)
-mark_as_advanced(HAVE_LUA_BIN)
-
-message(STATUS "Looking for lua.h")
-if(LUA_INCLUDE_DIR)
-  message(STATUS "Looking for lua.h - found")
-else()
-  message(STATUS "Looking for lua.h - not found")
-endif()
-
-if(HAVE_LUA_BIN)
-  message(STATUS "Found Lua: ${HAVE_LUA_BIN}")
-endif()
-
-set(LIB_LUA_NAME "")
-
-foreach(lib_path ${LUA_LIBRARIES})
-  if(NOT LIB_LUA_NAME)
-    string(REGEX MATCH "liblua.*$" LIB_LUA_NAME "${lib_path}")
-    string(REPLACE ".${LIB_EXE}" "" LIB_LUA_NAME "${LIB_LUA_NAME}")
-    string(REPLACE "lib" "" LIB_LUA_NAME "${LIB_LUA_NAME}")
-    if(LIB_LUA_NAME)
-      string(REPLACE "/lib${LIB_LUA_NAME}.${LIB_EXE}" "" LUA_LIBRARY_DIR ${lib_path})
-    endif()
-  endif()
-endforeach(lib_path ${LUA_LIBRARIES})
-
-message(STATUS "Looking for lib lua")
-if(LUA_LIBRARY_DIR)
-  message(STATUS "Looking for lib lua - found")
-  message(STATUS "Lua version: ${LUA_VERSION_STRING}")
-  message(STATUS "Lib path   : ${LUA_LIBRARY_DIR}")
-else()
-  message(STATUS "Looking for lib lua - not found")
-endif()
-
-if(LUA_FOUND AND LUA_VERSION_MAJOR EQUAL 5 AND LUA_VERSION_MINOR EQUAL 3)
-  set(HAVE_LUA 1)
-  include_directories(${LUA_INCLUDE_DIR})
-  link_directories(${LUA_LIBRARY_DIR})
-else()
-  message(FATAL_ERROR "Warning: Lua version 5.3 is required, ${LUA_VERSION_STRING} found.")
-endif()
diff --git a/tools/cmake/Modules/FindLuaSimgrid.cmake b/tools/cmake/Modules/FindLuaSimgrid.cmake
new file mode 100644 (file)
index 0000000..b3a4ccd
--- /dev/null
@@ -0,0 +1,67 @@
+# 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:
+#     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(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}")