changeset 2947:11f8d72f366f

Lua 5.3.5
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 29 Nov 2018 18:40:51 +0100
parents 2e751f615e03
children d2e548e643af
files NEWS Resources/CMake/LuaConfiguration.cmake Resources/Samples/Lua/CallWebService.lua UnitTestsSources/LuaTests.cpp UnitTestsSources/VersionsTests.cpp
diffstat 5 files changed, 59 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Thu Nov 29 17:15:29 2018 +0100
+++ b/NEWS	Thu Nov 29 18:40:51 2018 +0100
@@ -40,6 +40,7 @@
 * Fix issue 114 (Boost 1.68 doesn't support SHA-1 anymore)
 * Upgraded dependencies for static and Windows builds:
   - boost 1.68.0
+  - lua 5.3.5
 
 
 Version 1.4.2 (2018-09-20)
--- a/Resources/CMake/LuaConfiguration.cmake	Thu Nov 29 17:15:29 2018 +0100
+++ b/Resources/CMake/LuaConfiguration.cmake	Thu Nov 29 18:40:51 2018 +0100
@@ -1,7 +1,7 @@
 if (STATIC_BUILD OR NOT USE_SYSTEM_LUA)
-  SET(LUA_SOURCES_DIR ${CMAKE_BINARY_DIR}/lua-5.1.5)
-  SET(LUA_MD5 "2e115fe26e435e33b0d5c022e4490567")
-  SET(LUA_URL "http://www.orthanc-server.com/downloads/third-party/lua-5.1.5.tar.gz")
+  SET(LUA_SOURCES_DIR ${CMAKE_BINARY_DIR}/lua-5.3.5)
+  SET(LUA_MD5 "4f4b4f323fd3514a68e0ab3da8ce3455")
+  SET(LUA_URL "http://www.orthanc-server.com/downloads/third-party/lua-5.3.5.tar.gz")
 
   DownloadPackage(${LUA_MD5} ${LUA_URL} "${LUA_SOURCES_DIR}")
 
@@ -18,53 +18,83 @@
       # shared libraries can call them
       set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--export-dynamic")
 
+      if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR
+          ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD")
+        add_definitions(-DLUA_USE_LINUX=1)
+      elseif (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
+        add_definitions(
+          -DLUA_USE_LINUX=1
+          -DLUA_USE_READLINE=1
+          )
+      elseif (${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
+        add_definitions(-DLUA_USE_POSIX=1)
+      endif()
+
     elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
-      add_definitions(-DLUA_DL_DLL=1)       # Enable loading of shared libraries (for Microsoft Windows)
+      add_definitions(
+        -DLUA_DL_DLL=1       # Enable loading of shared libraries (for Microsoft Windows)
+        )
       
     elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
-      add_definitions(-LUA_DL_DYLD=1)       # Enable loading of shared libraries (for Apple OS X)
+      add_definitions(
+        -DLUA_USE_MACOSX=1
+        -DLUA_DL_DYLD=1       # Enable loading of shared libraries (for Apple OS X)
+        )
       
     else()
       message(FATAL_ERROR "Support your platform here")
     endif()
   endif()
 
+  add_definitions(
+    -DLUA_COMPAT_5_2=1
+    )
+
   include_directories(
     ${LUA_SOURCES_DIR}/src
     )
 
   set(LUA_SOURCES
+    # Don't compile the Lua command-line
+    #${LUA_SOURCES_DIR}/src/lua.c
+    #${LUA_SOURCES_DIR}/src/luac.c
+
     # Core Lua
     ${LUA_SOURCES_DIR}/src/lapi.c
-    ${LUA_SOURCES_DIR}/src/lcode.c 
-    ${LUA_SOURCES_DIR}/src/ldebug.c 
-    ${LUA_SOURCES_DIR}/src/ldo.c 
-    ${LUA_SOURCES_DIR}/src/ldump.c 
-    ${LUA_SOURCES_DIR}/src/lfunc.c 
+    ${LUA_SOURCES_DIR}/src/lcode.c
+    ${LUA_SOURCES_DIR}/src/lctype.c
+    ${LUA_SOURCES_DIR}/src/ldebug.c
+    ${LUA_SOURCES_DIR}/src/ldo.c
+    ${LUA_SOURCES_DIR}/src/ldump.c
+    ${LUA_SOURCES_DIR}/src/lfunc.c
     ${LUA_SOURCES_DIR}/src/lgc.c
     ${LUA_SOURCES_DIR}/src/llex.c
-    ${LUA_SOURCES_DIR}/src/lmem.c 
-    ${LUA_SOURCES_DIR}/src/lobject.c 
-    ${LUA_SOURCES_DIR}/src/lopcodes.c 
+    ${LUA_SOURCES_DIR}/src/lmem.c
+    ${LUA_SOURCES_DIR}/src/lobject.c
+    ${LUA_SOURCES_DIR}/src/lopcodes.c
     ${LUA_SOURCES_DIR}/src/lparser.c
-    ${LUA_SOURCES_DIR}/src/lstate.c 
+    ${LUA_SOURCES_DIR}/src/lstate.c
     ${LUA_SOURCES_DIR}/src/lstring.c
     ${LUA_SOURCES_DIR}/src/ltable.c
     ${LUA_SOURCES_DIR}/src/ltm.c
-    ${LUA_SOURCES_DIR}/src/lundump.c 
-    ${LUA_SOURCES_DIR}/src/lvm.c 
+    ${LUA_SOURCES_DIR}/src/lundump.c
+    ${LUA_SOURCES_DIR}/src/lvm.c
     ${LUA_SOURCES_DIR}/src/lzio.c
 
     # Base Lua modules
     ${LUA_SOURCES_DIR}/src/lauxlib.c
     ${LUA_SOURCES_DIR}/src/lbaselib.c
+    ${LUA_SOURCES_DIR}/src/lbitlib.c
+    ${LUA_SOURCES_DIR}/src/lcorolib.c
     ${LUA_SOURCES_DIR}/src/ldblib.c
     ${LUA_SOURCES_DIR}/src/liolib.c
     ${LUA_SOURCES_DIR}/src/lmathlib.c
+    ${LUA_SOURCES_DIR}/src/loadlib.c
     ${LUA_SOURCES_DIR}/src/loslib.c
+    ${LUA_SOURCES_DIR}/src/lstrlib.c
     ${LUA_SOURCES_DIR}/src/ltablib.c
-    ${LUA_SOURCES_DIR}/src/lstrlib.c
-    ${LUA_SOURCES_DIR}/src/loadlib.c
+    ${LUA_SOURCES_DIR}/src/lutf8lib.c
+
     ${LUA_SOURCES_DIR}/src/linit.c
     )
 
--- a/Resources/Samples/Lua/CallWebService.lua	Thu Nov 29 17:15:29 2018 +0100
+++ b/Resources/Samples/Lua/CallWebService.lua	Thu Nov 29 18:40:51 2018 +0100
@@ -5,7 +5,9 @@
 
 -- Download and install the JSON module for Lua by Jeffrey Friedl
 -- http://regex.info/blog/lua/json
-JSON = (loadstring(HttpGet('http://regex.info/code/JSON.lua'))) ()
+
+-- NOTE : Replace "load" by "loadstring" for Lua <= 5.1
+JSON = (load(HttpGet('http://regex.info/code/JSON.lua'))) ()
 
 SetHttpCredentials('alice', 'alicePassword')
 
--- a/UnitTestsSources/LuaTests.cpp	Thu Nov 29 17:15:29 2018 +0100
+++ b/UnitTestsSources/LuaTests.cpp	Thu Nov 29 18:40:51 2018 +0100
@@ -293,7 +293,13 @@
   // OpenSSL/HTTPS support is disabled in curl
   const std::string BASE = "http://www.orthanc-server.com/downloads/third-party/";
 
+#if LUA_VERSION_NUM >= 502
+  // Since Lua >= 5.2.0, the function "loadstring" has been replaced by "load"
+  lua.Execute("JSON = load(HttpGet('" + BASE + "JSON.lua')) ()");
+#else
   lua.Execute("JSON = loadstring(HttpGet('" + BASE + "JSON.lua')) ()");
+#endif
+
   const std::string url(BASE + "Product.json");
 #endif
 
--- a/UnitTestsSources/VersionsTests.cpp	Thu Nov 29 17:15:29 2018 +0100
+++ b/UnitTestsSources/VersionsTests.cpp	Thu Nov 29 18:40:51 2018 +0100
@@ -141,7 +141,7 @@
 
 TEST(Version, LuaStatic)
 {
-  ASSERT_STREQ("Lua 5.1.5", LUA_RELEASE);
+  ASSERT_STREQ("Lua 5.3.5", LUA_RELEASE);
 }
 
 TEST(Version, LibIconvStatic)