Parcourir la source

Use Readline library when it is found for Lua and isql.

Yao Wei Tjong 姚伟忠 il y a 10 ans
Parent
commit
105aa2699e

+ 41 - 0
CMake/Modules/FindReadline.cmake

@@ -0,0 +1,41 @@
+#
+# Copyright (c) 2008-2015 the Urho3D project.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+
+# Find Readline development library
+#
+#  READLINE_FOUND
+#  READLINE_INCLUDE_DIRS
+#  READLINE_LIBRARIES
+#
+
+if (APPLE AND NOT READLINE_INCLUDE_DIRS AND NOT READLINE_LIBRARIES)
+    # Assuming GNU Readline development library is installed using Homebrew (keg-only)
+    execute_process (COMMAND find /usr/local/Cellar/readline -type d -name include OUTPUT_VARIABLE INC_HINTS ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
+    execute_process (COMMAND find /usr/local/Cellar/readline -type d -name lib OUTPUT_VARIABLE LIB_HINTS ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
+endif ()
+find_path (READLINE_INCLUDE_DIRS NAMES readline.h HINTS ${INC_HINTS} PATH_SUFFIXES readline DOC "Readline include directory")
+find_library (READLINE_LIBRARIES NAMES readline HINTS ${LIB_HINTS} DOC "Readline library")
+
+include (FindPackageHandleStandardArgs)
+find_package_handle_standard_args (READLINE REQUIRED_VARS READLINE_LIBRARIES READLINE_INCLUDE_DIRS FAIL_MESSAGE "Could NOT find Readline development library")
+
+mark_as_advanced (READLINE_INCLUDE_DIRS READLINE_LIBRARIES)

+ 5 - 2
CMake/Modules/Urho3D-CMake-common.cmake

@@ -483,9 +483,9 @@ if (URHO3D_DATABASE_SQLITE OR URHO3D_DATABASE_ODBC)
     add_definitions (-DURHO3D_DATABASE)
 endif ()
 
-# Find Direct3D include & library directories in MS Windows SDK or DirectX SDK. They may also be required by SDL
-# even if using OpenGL instead of Direct3D, but do not make Direct3D REQUIRED in that case
 if (WIN32)
+    # Find Direct3D include & library directories in MS Windows SDK or DirectX SDK. They may also be required by SDL
+    # even if using OpenGL instead of Direct3D, but do not make Direct3D REQUIRED in that case
     if (NOT URHO3D_OPENGL)
         find_package (Direct3D REQUIRED)
     else ()
@@ -494,6 +494,9 @@ if (WIN32)
     if (DIRECT3D_INCLUDE_DIRS)
         include_directories (${DIRECT3D_INCLUDE_DIRS})
     endif ()
+else ()
+    # Find GNU Readline development library for Lua interpreter and SQLite's isql
+    find_package (Readline)
 endif ()
 
 # Platform and compiler specific options

+ 3 - 2
Rakefile

@@ -211,6 +211,7 @@ task :ci_push_bindings do
   system "rm -rf fastcomp-clang && git config user.name $GIT_NAME && git config user.email $GIT_EMAIL && git remote set-url --push origin https://[email protected]/$TRAVIS_REPO_SLUG.git && git add -A Source/Urho3D && if git commit -qm 'Result of AutoBinder tool. [ci skip]'; then git push -q origin HEAD:#{ENV['TRAVIS_BRANCH']} >/dev/null 2>&1; fi" or abort "Failed to push #{ENV['TRAVIS_BRANCH']} branch"
 end
 
+# Always call this function last in the multiple conditional check so that the checkpoint message does not being echoed unnecessarily
 def timeup
   unless $start_time
     puts; $stdout.flush
@@ -263,7 +264,7 @@ task :ci do
     next
   end
   system "bash -c 'rake make'" or abort 'Failed to build Urho3D library'
-  if !timeup && ENV['URHO3D_TESTING']
+  if ENV['URHO3D_TESTING'] && !timeup
     # Multi-config CMake generators use different test target name than single-config ones for no good reason
     test = "rake make target=#{ENV['OS'] || ENV['XCODE'] ? 'RUN_TESTS' : 'test'}"
     system "bash -c '#{test}'" or abort 'Failed to test Urho3D library'
@@ -272,7 +273,7 @@ task :ci do
     test = ''
   end
   # Skip scaffolding test when time up or packaging for iOS and Web platform
-  unless timeup || ENV['XCODE_64BIT_ONLY'] || ENV['CI'] && (ENV['IOS'] || ENV['WEB']) && ENV['PACKAGE_UPLOAD']
+  unless ENV['CI'] && (ENV['IOS'] || ENV['WEB']) && ENV['PACKAGE_UPLOAD'] || ENV['XCODE_64BIT_ONLY'] || timeup
     # Staged-install Urho3D SDK when on Travis-CI; normal install when on AppVeyor
     ENV['DESTDIR'] = ENV['HOME'] || Dir.home unless ENV['APPVEYOR']
     puts "Installing Urho3D SDK to #{ENV['DESTDIR'] ? "#{ENV['DESTDIR']}/usr/local" : 'default system-wide location'}..."; $stdout.flush

+ 7 - 0
Source/ThirdParty/Lua/CMakeLists.txt

@@ -26,6 +26,13 @@ set (TARGET_NAME Lua)
 # Define source files
 define_source_files (GLOB_CPP_PATTERNS src/*.c GLOB_H_PATTERNS src/*.h EXCLUDE_PATTERNS src/lua.c src/luac.c)
 
+# Define dependency libs
+if (READLINE_FOUND)
+    add_definitions (-DLUA_USE_READLINE)
+    list (APPEND INCLUDE_DIRS ${READLINE_INCLUDE_DIR})
+    list (APPEND LIBS ${READLINE_LIBRARIES})
+endif ()
+
 # Setup target
 setup_library ()
 

+ 5 - 0
Source/ThirdParty/SQLite/CMakeLists.txt

@@ -51,6 +51,11 @@ if (NOT IOS AND NOT WEB)
     if (NOT WIN32)
         set (LIBS dl)
     endif ()
+    if (READLINE_FOUND)
+        add_definitions (-DHAVE_READLINE)
+        list (APPEND INCLUDE_DIRS ${READLINE_INCLUDE_DIR})
+        list (APPEND LIBS ${READLINE_LIBRARIES})
+    endif ()
 
     # Setup target
     setup_executable (NODEPS)