瀏覽代碼

HPCC-9704 Add libarchive support to WIN32

Fixed Bundle.rst install location
Added USE_GIT (Hooks) option (no Win32 support yet)

Fixes HPCC-9704

Signed-off-by: Godon Smith <gordon.smith@lexisnexis.com>
Godon Smith 12 年之前
父節點
當前提交
e3507a14b4

+ 1 - 1
cmake_modules/FindLIBARCHIVE.cmake

@@ -23,7 +23,7 @@
 
 IF (NOT LIBARCHIVE_FOUND)
   IF (WIN32)
-    SET (libarchive_lib "libarchive")
+    SET (libarchive_lib "archive_static")
   ELSE()
     SET (libarchive_lib "archive")
   ENDIF()

+ 14 - 2
cmake_modules/commonSetup.cmake

@@ -53,10 +53,11 @@ IF ("${COMMONSETUP_DONE}" STREQUAL "")
   option(USE_OPENSSL "Configure use of OpenSSL" ON)
   option(USE_ZLIB "Configure use of zlib" ON)
   if (WIN32)
-    option(USE_LIBARCHIVE "Configure use of libarchive" OFF)   # libarchive rather less standard on windows systems
+    option(USE_GIT "Configure use of GIT (Hooks)" OFF)
   else()
-    option(USE_LIBARCHIVE "Configure use of libarchive" ON)
+    option(USE_GIT "Configure use of GIT (Hooks)" ON)
   endif()
+  option(USE_LIBARCHIVE "Configure use of libarchive" ON)
   option(USE_URIPARSER "Configure use of uriparser" OFF)
   option(USE_NATIVE_LIBRARIES "Search standard OS locations for thirdparty libraries" ON)
   option(USE_GIT_DESCRIBE "Use git describe to generate build tag" ON)
@@ -539,6 +540,17 @@ IF ("${COMMONSETUP_DONE}" STREQUAL "")
       endif(USE_ZLIB)
 
       if(USE_LIBARCHIVE)
+        if (WIN32)
+          if(NOT USE_ZLIB)
+            message(FATAL ERROR "LIBARCHIVE requires ZLIB")
+          endif(NOT USE_ZLIB)
+          find_package(BZip2)
+          if (BZIP2_FOUND)
+            add_definitions (-D_USE_BZIP2)
+          else()
+            message(FATAL_ERROR "LIBARCHIVE requires BZIP2 but package not found")
+          endif()
+        endif (WIN32)
         find_package(LIBARCHIVE)
         if (LIBARCHIVE_FOUND)
           add_definitions (-D_USE_LIBARCHIVE)

+ 1 - 1
common/remote/CMakeLists.txt

@@ -24,7 +24,7 @@
 
 project( remote ) 
 
-HPCC_ADD_SUBDIRECTORY(hooks "PLATFORM")
+HPCC_ADD_SUBDIRECTORY(hooks)
 
 set (    SRCS 
          rmtfile.cpp 

+ 3 - 1
common/remote/hooks/CMakeLists.txt

@@ -24,7 +24,9 @@
 
 project( hooks )
 
-add_subdirectory(git)
+IF (USE_GIT)
+  add_subdirectory(git)
+ENDIF()
 IF (USE_LIBARCHIVE)
   add_subdirectory(libarchive)
 ENDIF()

+ 12 - 2
common/remote/hooks/libarchive/CMakeLists.txt

@@ -37,11 +37,21 @@ include_directories (
 include_directories ( ${LIBARCHIVE_INCLUDE_DIR} )
 
 ADD_DEFINITIONS( -D_USRDLL -DARCHIVEFILE_EXPORTS )
+if ( WIN32 )
+  ADD_DEFINITIONS( -DLIBARCHIVE_STATIC )
+endif ( WIN32 )
 
 HPCC_ADD_LIBRARY( archivefile SHARED ${SRCS}  )
-install ( TARGETS archivefile DESTINATION filehooks )
+install ( TARGETS archivefile RUNTIME DESTINATION filehooks LIBRARY DESTINATION filehooks )
 
 target_link_libraries ( archivefile
     jlib
-    archive
+    ${LIBARCHIVE_LIBRARIES}
     )
+
+if (WIN32)
+target_link_libraries ( archivefile
+    ${ZLIB_LIBRARIES}
+    ${BZIP2_LIBRARIES}
+    )
+endif (WIN32)

+ 19 - 0
common/remote/hooks/libarchive/archive.cpp

@@ -17,6 +17,10 @@
 
 #include "platform.h"
 
+#ifdef _WIN32
+#define S_ISDIR(m) (((m)&_S_IFDIR)!=0)
+#endif
+
 #include "jlib.hpp"
 #include "jio.hpp"
 
@@ -174,8 +178,14 @@ public:
         curBuffSize = 0;
         curBuff = NULL;
         archive = archive_read_new();
+#ifdef _WIN32
+        archive_read_support_format_zip(archive);
+        archive_read_support_format_tar(archive);
+        archive_read_support_compression_bzip2(archive);
+#else
         archive_read_support_format_all(archive);
         archive_read_support_compression_all(archive);
+#endif
         int retcode = archive_read_open_filename(archive, container, 10240);
         if (retcode == ARCHIVE_OK)
         {
@@ -265,6 +275,9 @@ protected:
 #if ARCHIVE_VERSION_NUMBER < 3000000
     off_t curPos;
 #else
+#if defined(_WIN32)
+#define	int64_t	__int64
+#endif
     int64_t curPos;
 #endif
     offset_t lastPos;
@@ -467,8 +480,14 @@ public:
         entries.kill();
         curIndex = 0;
         struct archive *archive = archive_read_new();
+#ifdef _WIN32
+        archive_read_support_format_zip(archive);
+        archive_read_support_format_tar(archive);
+        archive_read_support_compression_bzip2(archive);
+#else
         archive_read_support_format_all(archive);
         archive_read_support_compression_all(archive);
+#endif
         int retcode = archive_read_open_filename(archive, container, 10240);
         if (retcode == ARCHIVE_OK)
         {

+ 1 - 1
ecl/ecl-bundle/CMakeLists.txt

@@ -68,4 +68,4 @@ if ( UNIX )
     install ( PROGRAMS ecl-bundle.uninstall DESTINATION etc/init.d/uninstall COMPONENT Runtime )
 endif ( UNIX )
 # Put the bundle-writers guide into the bundles directory - makes sure it's not empty
-install ( FILES BUNDLES.rst DESTINATION ${INSTALL_DIR}/share/bundles COMPONENT Runtime )
+install ( FILES BUNDLES.rst DESTINATION share/bundles COMPONENT Runtime )