mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-28 05:21:29 +08:00
add libarchive
This commit is contained in:
parent
b280f57002
commit
f99d143dc3
4
ports/libarchive/CONTROL
Normal file
4
ports/libarchive/CONTROL
Normal file
@ -0,0 +1,4 @@
|
||||
Source: libarchive
|
||||
Version: 3.2.2
|
||||
Description: Library for reading and writing streaming archives
|
||||
Build-Depends: zlib, bzip2, libxml2, libiconv, lz4, liblzma, openssl
|
28
ports/libarchive/auto-define-libarchive-static.patch
Normal file
28
ports/libarchive/auto-define-libarchive-static.patch
Normal file
@ -0,0 +1,28 @@
|
||||
diff --git a/archive.h b/archive.h
|
||||
index ff401e9..602717e 100644
|
||||
--- a/archive.h
|
||||
+++ b/archive.h
|
||||
@@ -106,6 +106,9 @@ typedef ssize_t la_ssize_t;
|
||||
* .lib. The default here assumes you're building a DLL. Only
|
||||
* libarchive source should ever define __LIBARCHIVE_BUILD.
|
||||
*/
|
||||
+
|
||||
+#define LIBARCHIVE_STATIC
|
||||
+
|
||||
#if ((defined __WIN32__) || (defined _WIN32) || defined(__CYGWIN__)) && (!defined LIBARCHIVE_STATIC)
|
||||
# ifdef __LIBARCHIVE_BUILD
|
||||
# ifdef __GNUC__
|
||||
diff --git a/archive_entry.h b/archive_entry.h
|
||||
index 71b1e87..44246b9 100644
|
||||
--- a/archive_entry.h
|
||||
+++ b/archive_entry.h
|
||||
@@ -85,6 +85,9 @@ typedef int64_t la_int64_t;
|
||||
* .lib. The default here assumes you're building a DLL. Only
|
||||
* libarchive source should ever define __LIBARCHIVE_BUILD.
|
||||
*/
|
||||
+
|
||||
+#define LIBARCHIVE_STATIC
|
||||
+
|
||||
#if ((defined __WIN32__) || (defined _WIN32) || defined(__CYGWIN__)) && (!defined LIBARCHIVE_STATIC)
|
||||
# ifdef __LIBARCHIVE_BUILD
|
||||
# ifdef __GNUC__
|
146
ports/libarchive/fix-buildsystem.patch
Normal file
146
ports/libarchive/fix-buildsystem.patch
Normal file
@ -0,0 +1,146 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index a376fce..2d035a1 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -166,7 +166,7 @@ IF (MSVC)
|
||||
# result of an assignment.
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /we4706")
|
||||
# /WX option is the same as gcc's -Werror option.
|
||||
- SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /WX")
|
||||
+ #SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /WX") <- breaks x64-debug
|
||||
# /Oi option enables built-in functions.
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Oi")
|
||||
#################################################################
|
||||
@@ -177,6 +177,7 @@ ENDIF (MSVC)
|
||||
# Enable CTest/CDash support
|
||||
include(CTest)
|
||||
|
||||
+OPTION(ENABLE_LZO2 "Enable use of LZO2 library" ON)
|
||||
OPTION(ENABLE_NETTLE "Enable use of Nettle" ON)
|
||||
OPTION(ENABLE_OPENSSL "Enable use of OpenSSL" ON)
|
||||
OPTION(ENABLE_LZMA "Enable the use of the system found LZMA library if found" ON)
|
||||
@@ -357,7 +358,7 @@ IF(DEFINED __GNUWIN32PATH AND EXISTS "${__GNUWIN32PATH}")
|
||||
# The zlib and the bzip2 Setup program have installed programs and DLLs into
|
||||
# "C:/Program Files/GnuWin32" by default.
|
||||
# This is convenience setting for Windows.
|
||||
- SET(CMAKE_PREFIX_PATH ${__GNUWIN32PATH} $(CMAKE_PREFIX_PATH))
|
||||
+ #SET(CMAKE_PREFIX_PATH ${__GNUWIN32PATH} $(CMAKE_PREFIX_PATH))
|
||||
#
|
||||
# If you didn't use Setup program or installed into nonstandard path,
|
||||
# cmake cannot find out your zlib or bzip2 libraries and include files,
|
||||
@@ -397,11 +398,12 @@ IF(ZLIB_FOUND)
|
||||
#
|
||||
# Test if ZLIB_WINAPI macro is needed to use.
|
||||
#
|
||||
- TRY_MACRO_FOR_LIBRARY(
|
||||
- "${ZLIB_INCLUDE_DIR}" "${ZLIB_LIBRARIES}"
|
||||
- RUNS
|
||||
- "#include <zlib.h>\nint main() {uLong f = zlibCompileFlags(); return (f&(1U<<10))?0:-1; }"
|
||||
- ZLIB_WINAPI)
|
||||
+ SET(ZLIB_WINAPI OFF) # skip following test, it crashes with weird message box
|
||||
+ #TRY_MACRO_FOR_LIBRARY(
|
||||
+ # "${ZLIB_INCLUDE_DIR}" "${ZLIB_LIBRARIES}"
|
||||
+ # RUNS
|
||||
+ # "#include <zlib.h>\nint main() {uLong f = zlibCompileFlags(); return (f&(1U<<10))?0:-1; }"
|
||||
+ # ZLIB_WINAPI)
|
||||
IF(ZLIB_WINAPI)
|
||||
ADD_DEFINITIONS(-DZLIB_WINAPI)
|
||||
ELSE(ZLIB_WINAPI)
|
||||
@@ -483,6 +485,7 @@ ENDIF(LZMA_FOUND)
|
||||
#
|
||||
# Find LZO2
|
||||
#
|
||||
+IF(ENABLE_LZO2)
|
||||
IF (LZO2_INCLUDE_DIR)
|
||||
# Already in cache, be silent
|
||||
SET(LZO2_FIND_QUIETLY TRUE)
|
||||
@@ -504,6 +507,7 @@ IF(LZO2_FOUND)
|
||||
ENDIF(LZO2_FOUND)
|
||||
MARK_AS_ADVANCED(CLEAR LZO2_INCLUDE_DIR)
|
||||
MARK_AS_ADVANCED(CLEAR LZO2_LIBRARY)
|
||||
+ENDIF()
|
||||
#
|
||||
# Find LZ4
|
||||
#
|
||||
@@ -923,7 +927,9 @@ IF(ENABLE_ICONV)
|
||||
CHECK_ICONV("libc" "")
|
||||
|
||||
# If iconv isn't in libc and we have a libiconv, try that.
|
||||
- FIND_LIBRARY(LIBICONV_PATH NAMES iconv libiconv)
|
||||
+ FIND_LIBRARY(LIBICONV_PATH1 NAMES iconv libiconv)
|
||||
+ FIND_LIBRARY(LIBCHARSET_PATH NAMES charset libcharset)
|
||||
+ SET(LIBICONV_PATH ${LIBICONV_PATH1} ${LIBCHARSET_PATH})
|
||||
IF(NOT HAVE_ICONV AND LIBICONV_PATH)
|
||||
LIST(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBICONV_PATH})
|
||||
# Test if a macro is needed for the library.
|
||||
@@ -1307,9 +1313,13 @@ CHECK_C_SOURCE_COMPILES(
|
||||
"#include <sys/sysmacros.h>\nint main() { return major(256); }"
|
||||
MAJOR_IN_SYSMACROS)
|
||||
|
||||
+CMAKE_PUSH_CHECK_STATE()
|
||||
+set(CMAKE_REQUIRED_INCLUDES ${LZMA_INCLUDE_DIR})
|
||||
+set(CMAKE_REQUIRED_LIBRARIES ${LZMA_LIBRARIES})
|
||||
CHECK_C_SOURCE_COMPILES(
|
||||
"#include <lzma.h>\n#if LZMA_VERSION < 50020000\n#error unsupported\n#endif\nint main(void){lzma_stream_encoder_mt(0, 0); return 0;}"
|
||||
HAVE_LZMA_STREAM_ENCODER_MT)
|
||||
+CMAKE_POP_CHECK_STATE()
|
||||
|
||||
IF(HAVE_STRERROR_R)
|
||||
SET(HAVE_DECL_STRERROR_R 1)
|
||||
@@ -1655,12 +1665,12 @@ INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
|
||||
|
||||
# Handle generation of the libarchive.pc file for pkg-config
|
||||
-INCLUDE(CreatePkgConfigFile)
|
||||
+#INCLUDE(CreatePkgConfigFile)
|
||||
|
||||
#
|
||||
# Register installation of PDF documents.
|
||||
#
|
||||
-IF(WIN32 AND NOT CYGWIN)
|
||||
+IF(0 AND WIN32 AND NOT CYGWIN)
|
||||
#
|
||||
# On Windows platform, It's better that we install PDF documents
|
||||
# on one's computer.
|
||||
diff --git a/libarchive/CMakeLists.txt b/libarchive/CMakeLists.txt
|
||||
index 4cc9a2c..ef304c5 100644
|
||||
--- a/libarchive/CMakeLists.txt
|
||||
+++ b/libarchive/CMakeLists.txt
|
||||
@@ -191,28 +191,24 @@ IF(WIN32 AND NOT CYGWIN)
|
||||
ENDIF(WIN32 AND NOT CYGWIN)
|
||||
|
||||
# Libarchive is a shared library
|
||||
-ADD_LIBRARY(archive SHARED ${libarchive_SOURCES} ${include_HEADERS})
|
||||
+ADD_LIBRARY(archive ${libarchive_SOURCES} ${include_HEADERS})
|
||||
TARGET_LINK_LIBRARIES(archive ${ADDITIONAL_LIBS})
|
||||
+IF(BUILD_SHARED_LIBS)
|
||||
SET_TARGET_PROPERTIES(archive PROPERTIES SOVERSION ${SOVERSION})
|
||||
-
|
||||
-# archive_static is a static library
|
||||
-ADD_LIBRARY(archive_static STATIC ${libarchive_SOURCES} ${include_HEADERS})
|
||||
-TARGET_LINK_LIBRARIES(archive_static ${ADDITIONAL_LIBS})
|
||||
-SET_TARGET_PROPERTIES(archive_static PROPERTIES COMPILE_DEFINITIONS
|
||||
- LIBARCHIVE_STATIC)
|
||||
-# On Posix systems, libarchive.so and libarchive.a can co-exist.
|
||||
-IF(NOT WIN32 OR CYGWIN)
|
||||
- SET_TARGET_PROPERTIES(archive_static PROPERTIES OUTPUT_NAME archive)
|
||||
-ENDIF(NOT WIN32 OR CYGWIN)
|
||||
+ELSE()
|
||||
+SET_TARGET_PROPERTIES(archive PROPERTIES COMPILE_DEFINITIONS LIBARCHIVE_STATIC)
|
||||
+ENDIF()
|
||||
|
||||
IF(ENABLE_INSTALL)
|
||||
# How to install the libraries
|
||||
- INSTALL(TARGETS archive archive_static
|
||||
+ INSTALL(TARGETS archive
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib)
|
||||
- INSTALL_MAN(${libarchive_MANS})
|
||||
+ #INSTALL_MAN(${libarchive_MANS})
|
||||
+ IF(NOT ARCHIVE_SKIP_HEADERS)
|
||||
INSTALL(FILES ${include_HEADERS} DESTINATION include)
|
||||
+ ENDIF()
|
||||
ENDIF()
|
||||
|
||||
add_subdirectory(test)
|
50
ports/libarchive/portfile.cmake
Normal file
50
ports/libarchive/portfile.cmake
Normal file
@ -0,0 +1,50 @@
|
||||
# libarchive uses winapi functions not available in WindowsStore
|
||||
if (VCPKG_CMAKE_SYSTEM_NAME STREQUAL WindowsStore)
|
||||
message(FATAL_ERROR "Error: UWP builds are not supported.")
|
||||
endif()
|
||||
|
||||
include(vcpkg_common_functions)
|
||||
set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/libarchive-3.2.2)
|
||||
vcpkg_download_distfile(ARCHIVE
|
||||
URLS "https://github.com/libarchive/libarchive/archive/v3.2.2.zip"
|
||||
FILENAME "libarchive-3.2.2.zip"
|
||||
SHA512 74abe8a66514aa344111f08e08015d2972545f6acf0923ff1ce7267bfc6c195ca562078a11d1c49ca36155c6b782b1f7ad08b71d93cb85fa892373479b0d1182)
|
||||
|
||||
vcpkg_extract_source_archive(${ARCHIVE})
|
||||
|
||||
vcpkg_apply_patches(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
PATCHES
|
||||
${CMAKE_CURRENT_LIST_DIR}/fix-buildsystem.patch
|
||||
${CMAKE_CURRENT_LIST_DIR}/use-memset-not-bzero.patch)
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
OPTIONS
|
||||
-DENABLE_LZO2=OFF
|
||||
-DENABLE_NETTLE=OFF
|
||||
-DENABLE_EXPAT=OFF
|
||||
-DENABLE_LibGCC=OFF
|
||||
-DENABLE_CNG=OFF
|
||||
-DENABLE_TAR=OFF
|
||||
-DENABLE_CPIO=OFF
|
||||
-DENABLE_CAT=OFF
|
||||
-DENABLE_XATTR=OFF
|
||||
-DENABLE_ACL=OFF
|
||||
-DENABLE_TEST=OFF
|
||||
-DPOSIX_REGEX_LIB=NONE
|
||||
OPTIONS_DEBUG
|
||||
-DARCHIVE_SKIP_HEADERS=ON)
|
||||
|
||||
vcpkg_install_cmake()
|
||||
vcpkg_copy_pdbs()
|
||||
|
||||
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
|
||||
vcpkg_apply_patches(
|
||||
SOURCE_PATH ${CURRENT_PACKAGES_DIR}/include
|
||||
PATCHES
|
||||
${CMAKE_CURRENT_LIST_DIR}/auto-define-libarchive-static.patch)
|
||||
endif()
|
||||
|
||||
file(COPY ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/libarchive)
|
||||
file(RENAME ${CURRENT_PACKAGES_DIR}/share/libarchive/COPYING ${CURRENT_PACKAGES_DIR}/share/libarchive/copyright)
|
26
ports/libarchive/use-memset-not-bzero.patch
Normal file
26
ports/libarchive/use-memset-not-bzero.patch
Normal file
@ -0,0 +1,26 @@
|
||||
diff --git a/libarchive/archive_write_add_filter_xz.c b/libarchive/archive_write_add_filter_xz.c
|
||||
index 46a6c38..b0f25a6 100644
|
||||
--- a/libarchive/archive_write_add_filter_xz.c
|
||||
+++ b/libarchive/archive_write_add_filter_xz.c
|
||||
@@ -233,7 +233,7 @@ archive_compressor_xz_init_stream(struct archive_write_filter *f,
|
||||
if (f->code == ARCHIVE_FILTER_XZ) {
|
||||
#ifdef HAVE_LZMA_STREAM_ENCODER_MT
|
||||
if (data->threads != 1) {
|
||||
- bzero(&mt_options, sizeof(mt_options));
|
||||
+ memset(&mt_options, 0, sizeof(mt_options));
|
||||
mt_options.threads = data->threads;
|
||||
mt_options.timeout = 300;
|
||||
mt_options.filters = data->lzmafilters;
|
||||
diff --git a/libarchive/archive_write_set_format_xar.c b/libarchive/archive_write_set_format_xar.c
|
||||
index a2dbc03..15a013c 100644
|
||||
--- a/libarchive/archive_write_set_format_xar.c
|
||||
+++ b/libarchive/archive_write_set_format_xar.c
|
||||
@@ -2913,7 +2913,7 @@ compression_init_encoder_xz(struct archive *a,
|
||||
*strm = lzma_init_data;
|
||||
#ifdef HAVE_LZMA_STREAM_ENCODER_MT
|
||||
if (threads > 1) {
|
||||
- bzero(&mt_options, sizeof(mt_options));
|
||||
+ memset(&mt_options, 0, sizeof(mt_options));
|
||||
mt_options.threads = threads;
|
||||
mt_options.timeout = 300;
|
||||
mt_options.filters = lzmafilters;
|
Loading…
Reference in New Issue
Block a user