Selaa lähdekoodia

HPCC-8030 Java/Python/Javascript language support in ECL

Remove SONAME from these 'module' plugins, so that installers don't complain
about missing dependencies. That way they will be available IFF the
corresponding language they interface to is installed, but not require that it
is for the HPCC-Platform to be installed.

Also clean up the build process to use proper CMake mechanism for finding
includes and libraries, and to add flags to disable building these plugins.

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 12 vuotta sitten
vanhempi
commit
f1ba9b9dbf

+ 41 - 0
cmake_modules/FindV8.cmake

@@ -0,0 +1,41 @@
+################################################################################
+#    HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+################################################################################
+
+# - Try to find the V8 JavaScript library
+# Once done this will define
+#
+#  V8_FOUND - system has the b8 javascript library
+#  V8_INCLUDE_DIR - the V8 include directory
+#  V8_LIBRARIES - The libraries needed to use V8
+
+IF (NOT V8_FOUND)
+  IF (WIN32)
+    SET (v8_lib "libv8")
+  ELSE()
+    SET (v8_lib "v8")
+  ENDIF()
+
+  FIND_PATH (V8_INCLUDE_DIR NAMES v8.h)
+  FIND_LIBRARY (V8_LIBRARIES NAMES ${v8_lib})
+
+  include(FindPackageHandleStandardArgs)
+  find_package_handle_standard_args(v8 DEFAULT_MSG
+    V8_LIBRARIES
+    V8_INCLUDE_DIR
+  )
+
+  MARK_AS_ADVANCED(V8_INCLUDE_DIR V8_LIBRARIES)
+ENDIF()

+ 4 - 0
cmake_modules/commonSetup.cmake

@@ -71,6 +71,10 @@ IF ("${COMMONSETUP_DONE}" STREQUAL "")
   option(USE_RESOURCE "Use resource download in ECLWatch" OFF)
   option(GENERATE_COVERAGE_INFO "Generate coverage info for gcov" OFF)
 
+  option(MAKE_PYEMBED "Make the plugin for Python embedding" ON)
+  option(MAKE_V8EMBED "Make the plugin for V8 JavaScript embedding" ON)
+  option(MAKE_JAVAEMBED "Make the plugin for Java embedding" ON)
+
   if ( USE_XALAN AND USE_LIBXSLT )
       set(USE_XALAN OFF)
   endif()

+ 9 - 3
plugins/CMakeLists.txt

@@ -25,6 +25,12 @@ if ("${BUILD_LEVEL}" STREQUAL "COMMUNITY")
   add_subdirectory (proxies)
 endif ()
 
-add_subdirectory (v8embed)
-add_subdirectory (pyembed)
-add_subdirectory (javaembed)
+if (MAKE_V8EMBED)
+  add_subdirectory (v8embed)
+endif ()
+if (MAKE_PYEMBED)
+  add_subdirectory (pyembed)
+endif ()
+if (MAKE_JAVAEMBED)
+  add_subdirectory (javaembed)
+endif()

+ 9 - 2
plugins/javaembed/CMakeLists.txt

@@ -23,11 +23,12 @@
 #    Cmake Input File for javaembed
 #####################################################
 
-set ( toolsdir "${HPCC_SOURCE_DIR}/tools" )
-
 project( javaembed )
 
 find_package(JNI)
+if (NOT JNI_FOUND)
+  message(FATAL_ERROR "MAKE_JAVAEMBED requested but JNI libraries not found")
+endif()
 
 set (    SRCS
          javaembed.cpp
@@ -44,6 +45,12 @@ include_directories (
 ADD_DEFINITIONS( -D_USRDLL -DJAVAEMBED_EXPORTS )
 
 HPCC_ADD_LIBRARY( javaembed SHARED ${SRCS} )
+if (${CMAKE_VERSION} VERSION_LESS "2.8.9")
+  message("WARNING: Cannot set NO_SONAME. shlibdeps will give warnings when package is installed")
+else()
+  set_target_properties( javaembed PROPERTIES NO_SONAME 1 )
+endif()
+
 install ( TARGETS javaembed DESTINATION plugins )
 
 # We link against jsig so that signals are chained from the jvm

+ 1 - 1
plugins/javaembed/javaembed.cpp

@@ -106,7 +106,7 @@ static JavaGlobalState *queryGlobalState()
 {
     CriticalBlock b(globalStateCrit);
     if (!globalState)
-        globalState = new JavaGlobalState;
+        globalState = new JavaGlobalState;  // Never released. But we don't care - JavaVM does not work if you destroy and try to recreate
     return globalState;
 }
 

+ 14 - 4
plugins/pyembed/CMakeLists.txt

@@ -23,17 +23,21 @@
 #    Cmake Input File for pyembed
 #####################################################
 
-set ( toolsdir "${HPCC_SOURCE_DIR}/tools" )
 set ( debug_python Off )   # A lot slower but can assist in debugging...
 
 project( pyembed )
 
+find_package(PythonLibs)
+if ("${PYTHON_INCLUDE_DIR}" STREQUAL "")
+  message(FATAL_ERROR "MAKE_PYEMBED requested but python libraries not found")
+endif()
+
 set (    SRCS
          pyembed.cpp
     )
 
 include_directories (
-         /usr/include/python2.7
+         "${PYTHON_INCLUDE_DIR}"
          ./../../system/include
          ./../../rtl/eclrtl
          ./../../rtl/include
@@ -46,12 +50,18 @@ if (debug_python)
 endif()
 
 HPCC_ADD_LIBRARY( pyembed SHARED ${SRCS} )
+if (${CMAKE_VERSION} VERSION_LESS "2.8.9")
+  message("WARNING: Cannot set NO_SONAME. shlibdeps will give warnings when package is installed")
+else()
+  set_target_properties( pyembed PROPERTIES NO_SONAME 1 )
+endif()
+
 install ( TARGETS pyembed DESTINATION plugins )
 
 if (debug_python)
-  target_link_libraries ( pyembed python2.7_d )
+  target_link_libraries ( pyembed ${PYTHON_DEBUG_LIBRARY} )
 else()
-  target_link_libraries ( pyembed python2.7 )
+  target_link_libraries ( pyembed ${PYTHON_LIBRARY} )
 endif()
 
 target_link_libraries ( pyembed

+ 14 - 4
plugins/v8embed/CMakeLists.txt

@@ -23,16 +23,20 @@
 #    Cmake Input File for v8embed
 #####################################################
 
-set ( toolsdir "${HPCC_SOURCE_DIR}/tools" )
-
-
 project( v8embed )
 
 set (    SRCS
          v8embed.cpp
     )
 
+find_package(V8)
+if (NOT V8_FOUND)
+  message(FATAL_ERROR "MAKE_V8EMBED requested but v8 not found")
+endif()
+
+
 include_directories (
+         ${V8_INCLUDE_DIR}
          ./../../system/include
          ./../../rtl/eclrtl
          ./../../rtl/include
@@ -42,10 +46,16 @@ include_directories (
 ADD_DEFINITIONS( -D_USRDLL -DV8EMBED_EXPORTS )
 
 HPCC_ADD_LIBRARY( v8embed SHARED ${SRCS} )
+if (${CMAKE_VERSION} VERSION_LESS "2.8.9")
+  message("WARNING: Cannot set NO_SONAME. shlibdeps will give warnings when package is installed")
+else()
+  set_target_properties( v8embed PROPERTIES NO_SONAME 1 )
+endif()
+
 install ( TARGETS v8embed DESTINATION plugins )
 
 target_link_libraries ( v8embed
-    v8
+    ${V8_LIBRARIES}
     eclrtl
     jlib
     )