[MediaWiki-commits] [Gerrit] Link the c++ lua library if building for HHVM - change (mediawiki...luasandbox)
Giuseppe Lavagetto has uploaded a new change for review. https://gerrit.wikimedia.org/r/149001 Change subject: Link the c++ lua library if building for HHVM .. Link the c++ lua library if building for HHVM Change-Id: I2ee5ee8b7ebd6607665e24771035f0a6fde9ff36 Signed-off-by: Giuseppe Lavagetto glavage...@wikimedia.org --- A FindLua51cpp.cmake M config.cmake M debian/rules 3 files changed, 101 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/php/luasandbox refs/changes/01/149001/1 diff --git a/FindLua51cpp.cmake b/FindLua51cpp.cmake new file mode 100644 index 000..cefbf5e --- /dev/null +++ b/FindLua51cpp.cmake @@ -0,0 +1,79 @@ +# Locate Lua library +# This module defines +# LUA51_FOUND, if false, do not try to link to Lua +# LUA_LIBRARIES +# LUA_INCLUDE_DIR, where to find lua.h +# LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8) +# +# 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/ + +#= +# Copyright 2007-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the License); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#= + +find_path(LUA_INCLUDE_DIR lua.h + HINTS +ENV LUA_DIR + PATH_SUFFIXES include/lua51 include/lua5.1 include/lua-5.1 include/lua include + PATHS + ~/Library/Frameworks + /Library/Frameworks + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt +) + +find_library(LUA_LIBRARY + NAMES lua5.1-c++ + HINTS +ENV LUA_DIR + PATH_SUFFIXES lib + PATHS + ~/Library/Frameworks + /Library/Frameworks + /sw + /opt/local + /opt/csw + /opt +) + +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} CACHE STRING Lua Libraries) + # For Windows and Mac, don't need to explicitly include the math library + else() +set( LUA_LIBRARIES ${LUA_LIBRARY} CACHE STRING Lua Libraries) + endif() +endif() + +if(LUA_INCLUDE_DIR AND EXISTS ${LUA_INCLUDE_DIR}/lua.h) + file(STRINGS ${LUA_INCLUDE_DIR}/lua.h lua_version_str REGEX ^#define[ \t]+LUA_RELEASE[ \t]+\Lua .+\) + + string(REGEX REPLACE ^#define[ \t]+LUA_RELEASE[ \t]+\Lua ([^\]+)\.* \\1 LUA_VERSION_STRING ${lua_version_str}) + unset(lua_version_str) +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(Lua51 + REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR + VERSION_VAR LUA_VERSION_STRING) + +mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY) + diff --git a/config.cmake b/config.cmake index 894001a..3dc4884 100644 --- a/config.cmake +++ b/config.cmake @@ -1,6 +1,18 @@ -INCLUDE(FindLua51) +# HHVM needs to link luasandbox to the c++ version of liblua +if (LUA_USE_CPLUSPLUS) + INCLUDE(FindLua51cpp.cmake) +else(!LUA_USE_CPLUSPLUS) + INCLUDE(FindLua51) +endif(LUA_USE_CPLUSPLUS) + + if (!LUA51_FOUND) - message(FATAL_ERROR unable to find Lua 5.1) + message(FATAL_ERROR unable to find Lua 5.1) +endif() + +# HHVM needs to link luasandbox to the c++ version of liblua +if (ENV{USE_CPLUSPLUS_LUA}) + SET(LUA_LIBRARIES /usr/lib/x86_64-linux-gnu/liblua5.1-c++.so.0) endif() # Parse version string from debian/changelog and use it to generate luasandbox_version.h @@ -9,12 +21,12 @@ file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/luasandbox_version.h \#define LUASANDBOX_VERSION \${LUASANDBOX_VERSION}\\n) HHVM_COMPAT_EXTENSION(luasandbox - alloc.c - data_conversion.c - library.c - luasandbox.c - timer.c - luasandbox_lstrlib.c) + alloc.c + data_conversion.c + library.c + luasandbox.c + timer.c + luasandbox_lstrlib.c) HHVM_ADD_INCLUDES(luasandbox ${LUA_INCLUDE_DIR}) HHVM_LINK_LIBRARIES(luasandbox ${LUA_LIBRARIES}) diff --git a/debian/rules b/debian/rules index c247faf..92c8667 100755 --- a/debian/rules +++ b/debian/rules @@ -17,7 +17,8 @@ cd debian/build-hhvm cmake . \ -DCMAKE_INSTALL_PREFIX=/usr \ -DCMAKE_VERBOSE_MAKEFILE=ON \ - -DCMAKE_BUILD_TYPE=None + -DCMAKE_BUILD_TYPE=None \ + -DLUA_USE_CPLUSPLUS=1 cd debian/build-hhvm dh_auto_configure override_dh_auto_build: -- To view, visit
[MediaWiki-commits] [Gerrit] Link the c++ lua library if building for HHVM - change (mediawiki...luasandbox)
Giuseppe Lavagetto has submitted this change and it was merged. Change subject: Link the c++ lua library if building for HHVM .. Link the c++ lua library if building for HHVM Change-Id: I2ee5ee8b7ebd6607665e24771035f0a6fde9ff36 Signed-off-by: Giuseppe Lavagetto glavage...@wikimedia.org --- A FindLua51cpp.cmake M config.cmake M debian/rules 3 files changed, 96 insertions(+), 9 deletions(-) Approvals: Giuseppe Lavagetto: Looks good to me, approved jenkins-bot: Verified diff --git a/FindLua51cpp.cmake b/FindLua51cpp.cmake new file mode 100644 index 000..cefbf5e --- /dev/null +++ b/FindLua51cpp.cmake @@ -0,0 +1,79 @@ +# Locate Lua library +# This module defines +# LUA51_FOUND, if false, do not try to link to Lua +# LUA_LIBRARIES +# LUA_INCLUDE_DIR, where to find lua.h +# LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8) +# +# 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/ + +#= +# Copyright 2007-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the License); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#= + +find_path(LUA_INCLUDE_DIR lua.h + HINTS +ENV LUA_DIR + PATH_SUFFIXES include/lua51 include/lua5.1 include/lua-5.1 include/lua include + PATHS + ~/Library/Frameworks + /Library/Frameworks + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt +) + +find_library(LUA_LIBRARY + NAMES lua5.1-c++ + HINTS +ENV LUA_DIR + PATH_SUFFIXES lib + PATHS + ~/Library/Frameworks + /Library/Frameworks + /sw + /opt/local + /opt/csw + /opt +) + +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} CACHE STRING Lua Libraries) + # For Windows and Mac, don't need to explicitly include the math library + else() +set( LUA_LIBRARIES ${LUA_LIBRARY} CACHE STRING Lua Libraries) + endif() +endif() + +if(LUA_INCLUDE_DIR AND EXISTS ${LUA_INCLUDE_DIR}/lua.h) + file(STRINGS ${LUA_INCLUDE_DIR}/lua.h lua_version_str REGEX ^#define[ \t]+LUA_RELEASE[ \t]+\Lua .+\) + + string(REGEX REPLACE ^#define[ \t]+LUA_RELEASE[ \t]+\Lua ([^\]+)\.* \\1 LUA_VERSION_STRING ${lua_version_str}) + unset(lua_version_str) +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(Lua51 + REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR + VERSION_VAR LUA_VERSION_STRING) + +mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY) + diff --git a/config.cmake b/config.cmake index 894001a..ec50358 100644 --- a/config.cmake +++ b/config.cmake @@ -1,6 +1,12 @@ -INCLUDE(FindLua51) +# HHVM needs to link luasandbox to the c++ version of liblua +if (LUA_USE_CPP) + INCLUDE(FindLua51cpp.cmake) +else(!LUA_USE_CPP) + INCLUDE(FindLua51) +endif(LUA_USE_CPP) + if (!LUA51_FOUND) - message(FATAL_ERROR unable to find Lua 5.1) + message(FATAL_ERROR unable to find Lua 5.1) endif() # Parse version string from debian/changelog and use it to generate luasandbox_version.h @@ -9,12 +15,12 @@ file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/luasandbox_version.h \#define LUASANDBOX_VERSION \${LUASANDBOX_VERSION}\\n) HHVM_COMPAT_EXTENSION(luasandbox - alloc.c - data_conversion.c - library.c - luasandbox.c - timer.c - luasandbox_lstrlib.c) + alloc.c + data_conversion.c + library.c + luasandbox.c + timer.c + luasandbox_lstrlib.c) HHVM_ADD_INCLUDES(luasandbox ${LUA_INCLUDE_DIR}) HHVM_LINK_LIBRARIES(luasandbox ${LUA_LIBRARIES}) diff --git a/debian/rules b/debian/rules index c247faf..93fe08a 100755 --- a/debian/rules +++ b/debian/rules @@ -14,10 +14,12 @@ | tar -xf - -C debian/build-hhvm cd debian/build-hhvm /usr/bin/hphpize # workaround cmake .. bug in HHVM's CMake extension code + # Also, link to lua-c++ cd debian/build-hhvm cmake . \ -DCMAKE_INSTALL_PREFIX=/usr \ -DCMAKE_VERBOSE_MAKEFILE=ON \ - -DCMAKE_BUILD_TYPE=None + -DCMAKE_BUILD_TYPE=None \ + -DLUA_USE_CPP=1 cd debian/build-hhvm dh_auto_configure override_dh_auto_build: -- To view, visit https://gerrit.wikimedia.org/r/149001 To