[avro-c] Update to 1.11.0 and also support osx (#21036)

* [avro-c] Update to 1.11.0

* Fix linux

* Update patch

* Update patch and support osx

* Small changes in patch
This commit is contained in:
NancyLi1013 2021-11-06 07:12:19 +08:00 committed by GitHub
parent 41d944f701
commit 23157c1545
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 103 additions and 161 deletions

View File

@ -1,92 +1,94 @@
diff --git a/lang/c/CMakeLists.txt b/lang/c/CMakeLists.txt
index 11cbf01..620490d 100644
index aa923e1..9ee7937 100644
--- a/lang/c/CMakeLists.txt
+++ b/lang/c/CMakeLists.txt
@@ -149,7 +149,10 @@ else (ZLIB_FOUND)
@@ -22,6 +22,9 @@ enable_testing()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR})
+option(BUILD_EXAMPLES "Build examples." OFF)
+option(BUILD_TESTS "Build tests." OFF)
+option(BUILD_DOCS "Build docs." OFF)
# Eliminates warning about linker paths when linking both zlib and
# liblzma.
cmake_policy(SET CMP0003 NEW)
@@ -149,50 +152,60 @@ else (ZLIB_FOUND)
message("Disabled deflate codec. zlib not found.")
endif (ZLIB_FOUND)
-find_package(Snappy)
+find_library(SNAPPY_LIBRARY_RELEASE NAMES snappy PATH_SUFFIXES lib)
+find_library(SNAPPY_LIBRARY_DEBUG NAMES snappyd PATH_SUFFIXES debug/lib)
+find_path(SNAPPY_INCLUDE_DIR snappy-c.h)
+select_library_configurations(SNAPPY)
if (SNAPPY_FOUND AND ZLIB_FOUND) # Snappy borrows crc32 from zlib
-if (SNAPPY_FOUND AND ZLIB_FOUND) # Snappy borrows crc32 from zlib
+find_package(Snappy CONFIG REQUIRED)
+if (Snappy_FOUND AND ZLIB_FOUND) # Snappy borrows crc32 from zlib
set(SNAPPY_PKG libsnappy)
add_definitions(-DSNAPPY_CODEC)
@@ -161,32 +164,36 @@ else (SNAPPY_FOUND AND ZLIB_FOUND)
+ set(SNAPPY_LIBRARIES Snappy::snappy)
+ if (UNIX)
+ set(SNAPPY_LIBRARIES ${SNAPPY_LIBRARIES} -lstdc++)
+ endif ()
include_directories(${SNAPPY_INCLUDE_DIRS})
message("Enabled snappy codec")
-else (SNAPPY_FOUND AND ZLIB_FOUND)
+else (Snappy_FOUND AND ZLIB_FOUND)
set(SNAPPY_PKG "")
set(SNAPPY_LIBRARIES "")
message("Disabled snappy codec. libsnappy not found or zlib not found.")
endif (SNAPPY_FOUND AND ZLIB_FOUND)
-endif (SNAPPY_FOUND AND ZLIB_FOUND)
+endif (Snappy_FOUND AND ZLIB_FOUND)
-find_package(PkgConfig)
-pkg_check_modules(LZMA liblzma)
-if (LZMA_FOUND)
+find_package(LibLZMA)
+find_package(LibLZMA REQUIRED)
+if (LibLZMA_FOUND)
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ set(SNAPPY_LIBRARIES ${SNAPPY_LIBRARIES} -lstdc++)
+ endif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(LZMA_PKG liblzma)
add_definitions(-DLZMA_CODEC)
- include_directories(${LZMA_INCLUDE_DIRS})
- link_directories(${LZMA_LIBRARY_DIRS})
+ include_directories(${LibLZMA_INCLUDE_DIRS})
+ link_directories(${LibLZMA_LIBRARY_DIRS})
+ set(LZMA_LIBRARIES LibLZMA::LibLZMA)
include_directories(${LZMA_INCLUDE_DIRS})
link_directories(${LZMA_LIBRARY_DIRS})
message("Enabled lzma codec")
-else (LZMA_FOUND)
+else (LibLZMA_FOUND)
set(LZMA_PKG "")
- set(LZMA_LIBRARIES "")
+ set(LibLZMA_LIBRARIES "")
set(LZMA_LIBRARIES "")
message("Disabled lzma codec. liblzma not found.")
-endif (LZMA_FOUND)
+endif (LIBLZMA_FOUND)
+endif (LibLZMA_FOUND)
-set(CODEC_LIBRARIES ${ZLIB_LIBRARIES} ${LZMA_LIBRARIES} ${SNAPPY_LIBRARIES})
+set(CODEC_LIBRARIES ${ZLIB_LIBRARIES} ${LibLZMA_LIBRARIES} ${SNAPPY_LIBRARIES})
set(CODEC_LIBRARIES ${ZLIB_LIBRARIES} ${LZMA_LIBRARIES} ${SNAPPY_LIBRARIES})
set(CODEC_PKG "@ZLIB_PKG@ @LZMA_PKG@ @SNAPPY_PKG@")
# Jansson JSON library
-pkg_check_modules(JANSSON jansson>=2.3)
-if (JANSSON_FOUND)
+find_path(JANSSON_INCLUDE_DIR NAMES jansson.h)
+find_library(JANSSON_LIBRARY NAMES jansson)
+if (JANSSON_LIBRARY)
+find_package(jansson CONFIG REQUIRED)
+if (jansson_FOUND)
set(JANSSON_PKG libjansson)
+ set(JANSSON_LIBRARIES ${JANSSON_LIBRARY})
+ set(JANSSON_LIBRARIES jansson::jansson)
include_directories(${JANSSON_INCLUDE_DIRS})
link_directories(${JANSSON_LIBRARY_DIRS})
-else (JANSSON_FOUND)
+else (JANSSON_LIBRARY)
+else (jansson_FOUND)
message(FATAL_ERROR "libjansson >=2.3 not found")
-endif (JANSSON_FOUND)
+endif (JANSSON_LIBRARY)
+endif (jansson_FOUND)
add_subdirectory(src)
diff --git a/lang/c/examples/quickstop.c b/lang/c/examples/quickstop.c
index f18225b..78e2b1b 100644
--- a/lang/c/examples/quickstop.c
+++ b/lang/c/examples/quickstop.c
@@ -16,6 +16,7 @@
*/
#include <avro.h>
+#include <avro/platform.h>
#include <stdio.h>
#include <stdlib.h>
@@ -102,7 +103,7 @@ int print_person(avro_file_reader_t db, avro_schema_t reader_schema)
if (avro_record_get(person, "ID", &id_datum) == 0) {
avro_int64_get(id_datum, &i64);
- fprintf(stdout, "%"PRId64" | ", i64);
+ fprintf(stdout, "%" PRId64 " | ", i64);
}
if (avro_record_get(person, "First", &first_datum) == 0) {
avro_string_get(first_datum, &p);
+if(BUILD_EXAMPLES)
add_subdirectory(examples)
+endif()
+if(BUILD_TESTS)
add_subdirectory(tests)
+endif()
+if(BUILD_DOCS)
add_subdirectory(docs)
-
+endif()
add_custom_target(pretty
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake_pretty.cmake")
diff --git a/lang/c/src/avro/msinttypes.h b/lang/c/src/avro/msinttypes.h
index 29be14b..7efc702 100644
index 29be14b..020346d 100644
--- a/lang/c/src/avro/msinttypes.h
+++ b/lang/c/src/avro/msinttypes.h
@@ -54,6 +54,10 @@
@ -145,7 +147,7 @@ index 9293055..edfe1e0 100644
#define PRIsz "zu"
#endif
diff --git a/lang/c/src/avro_private.h b/lang/c/src/avro_private.h
index f97ef6b..6b29104 100644
index f97ef6b..9c47d26 100644
--- a/lang/c/src/avro_private.h
+++ b/lang/c/src/avro_private.h
@@ -34,7 +34,7 @@ extern "C" {
@ -153,7 +155,7 @@ index f97ef6b..6b29104 100644
#ifdef _WIN32
-#define snprintf _snprintf
+ // #define snprintf _snprintf
+// #define snprintf _snprintf
#endif
/* Note that AVRO_PLATFORM_IS_BIG_ENDIAN is *always* defined. It is
@ -171,10 +173,10 @@ index 7243c60..39656ff 100644
#include "avro.h"
diff --git a/lang/c/src/codec.c b/lang/c/src/codec.c
index 5b55b35..49789f2 100644
index 613a914..8092326 100644
--- a/lang/c/src/codec.c
+++ b/lang/c/src/codec.c
@@ -269,7 +269,7 @@ static int encode_deflate(avro_codec_t c, void * data, int64_t len)
@@ -272,7 +272,7 @@ static int encode_deflate(avro_codec_t c, void * data, int64_t len)
s->next_in = (Bytef*)data;
s->avail_in = (uInt)len;
@ -183,7 +185,7 @@ index 5b55b35..49789f2 100644
s->avail_out = (uInt)c->block_size;
s->total_out = 0;
@@ -313,10 +313,10 @@ static int decode_deflate(avro_codec_t c, void * data, int64_t len)
@@ -316,10 +316,10 @@ static int decode_deflate(avro_codec_t c, void * data, int64_t len)
c->used_size = 0;
@ -196,7 +198,7 @@ index 5b55b35..49789f2 100644
s->avail_out = c->block_size;
s->total_out = 0;
@@ -337,7 +337,7 @@ static int decode_deflate(avro_codec_t c, void * data, int64_t len)
@@ -340,7 +340,7 @@ static int decode_deflate(avro_codec_t c, void * data, int64_t len)
if (err == Z_BUF_ERROR)
{
c->block_data = avro_realloc(c->block_data, c->block_size, c->block_size * 2);
@ -205,7 +207,7 @@ index 5b55b35..49789f2 100644
s->avail_out += c->block_size;
c->block_size = c->block_size * 2;
}
@@ -440,7 +440,7 @@ static int encode_lzma(avro_codec_t codec, void * data, int64_t len)
@@ -443,7 +443,7 @@ static int encode_lzma(avro_codec_t codec, void * data, int64_t len)
return 1;
}
@ -214,7 +216,7 @@ index 5b55b35..49789f2 100644
codec->used_size = written;
@@ -471,8 +471,8 @@ static int decode_lzma(avro_codec_t codec, void * data, int64_t len)
@@ -474,8 +474,8 @@ static int decode_lzma(avro_codec_t codec, void * data, int64_t len)
do
{
@ -226,7 +228,7 @@ index 5b55b35..49789f2 100644
codec->used_size = write_pos;
diff --git a/lang/c/src/schema.c b/lang/c/src/schema.c
index 7b38900..50fa0db 100644
index 7b38900..e3794d5 100644
--- a/lang/c/src/schema.c
+++ b/lang/c/src/schema.c
@@ -74,7 +74,7 @@ static int is_avro_id(const char *name)
@ -384,27 +386,3 @@ index 7b38900..50fa0db 100644
check(rval, avro_write_str(out, "."));
}
check(rval, avro_write_str(out, avro_schema_name(link->to)));
diff --git a/lang/c/tests/test_avro_data.c b/lang/c/tests/test_avro_data.c
index 1da09e6..714d5d8 100644
--- a/lang/c/tests/test_avro_data.c
+++ b/lang/c/tests/test_avro_data.c
@@ -28,6 +28,10 @@ avro_writer_t writer;
typedef int (*avro_test) (void);
+#ifdef _WIN32
+# define strcasecmp stricmp
+#endif
+
/*
* Use a custom allocator that verifies that the size that we use to
* free an object matches the size that we use to allocate it.
@@ -112,7 +116,7 @@ write_read_check(avro_schema_t writers_schema, avro_datum_t datum,
if (size != avro_writer_tell(writer)) {
fprintf(stderr,
"Unable to calculate size %s validate=%d "
- "(%"PRId64" != %"PRId64")\n %s\n",
+ "(%" PRId64 " != %" PRId64 ")\n %s\n",
type, validate, size, avro_writer_tell(writer),
avro_strerror());
exit(EXIT_FAILURE);

View File

@ -1,29 +1,41 @@
vcpkg_buildpath_length_warning(37)
vcpkg_fail_port_install(ON_TARGET "uwp" "osx")
vcpkg_fail_port_install(ON_TARGET "uwp")
if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
endif()
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO apache/avro
REF release-1.9.2
SHA512 6a6980901eea964c050eb3d61fadf28712e2f02c36985bf8e5176b668bba48985f6a666554a1964435448de29b18d790ab86b787d0288a22fd9cba00746a7846
HEAD_REF master
PATCHES
OUT_SOURCE_PATH SOURCE_PATH
REPO apache/avro
REF 4e1fefca493029ace961b7ef8889a3722458565a #release-1.11.0
SHA512 6e787983d68bc6ecffd14ca585917f695bc1ae554de9146a436d342f32321c3e7878cdfa32989742e682ac12a6eb914b3e3b515ca3164f386c0281c8b50b53ad
HEAD_REF master
PATCHES
avro.patch # Private vcpkg build fixes
snappy-pr-793.patch # Snappy build fixes for Windows (PR-793)
)
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}/lang/c
PREFER_NINJA
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}/lang/c"
OPTIONS
-DBUILD_EXAMPLES=OFF
-DBUILD_TESTS=OFF
-DBUILD_DOCS=OFF
)
vcpkg_install_cmake()
vcpkg_cmake_install()
vcpkg_copy_pdbs()
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/bin)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(INSTALL ${SOURCE_PATH}/lang/c/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
vcpkg_copy_tools(TOOL_NAMES avroappend avrocat AUTO_CLEAN)
if(NOT VCPKG_TARGET_IS_WINDOWS)
vcpkg_copy_tools(TOOL_NAMES avropipe avromod AUTO_CLEAN)
endif()
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static" AND NOT VCPKG_TARGET_IS_WINDOWS)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
endif()
file(INSTALL "${SOURCE_PATH}/lang/c/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

View File

@ -1,56 +0,0 @@
diff -ru b/c/src/codec.c a/lang/c/src/codec.c
--- b/lang/c/src/codec.c 2020-01-23 16:18:15.119970300 +0200
+++ a/lang/c/src/codec.c 2020-01-23 19:31:41.679834300 +0200
@@ -24,6 +24,9 @@
# elif defined(__FreeBSD__)
# include <sys/endian.h>
# define __bswap_32 bswap32
+# elif defined(_WIN32)
+# include <stdlib.h>
+# define __bswap_32 _byteswap_ulong
# else
# include <byteswap.h>
# endif
@@ -115,14 +118,14 @@
return 1;
}
- if (snappy_compress(data, len, c->block_data, &outlen) != SNAPPY_OK)
+ if (snappy_compress((const char *)data, len, (char*)c->block_data, &outlen) != SNAPPY_OK)
{
avro_set_error("Error compressing block with Snappy");
return 1;
}
- crc = __bswap_32(crc32(0, data, len));
- memcpy(c->block_data+outlen, &crc, 4);
+ crc = __bswap_32(crc32(0, (const Bytef *)data, len));
+ memcpy((char*)c->block_data+outlen, &crc, 4);
c->used_size = outlen+4;
return 0;
@@ -133,7 +136,7 @@
uint32_t crc;
size_t outlen;
- if (snappy_uncompressed_length(data, len-4, &outlen) != SNAPPY_OK) {
+ if (snappy_uncompressed_length((const char*)data, len-4, &outlen) != SNAPPY_OK) {
avro_set_error("Uncompressed length error in snappy");
return 1;
}
@@ -152,13 +155,13 @@
return 1;
}
- if (snappy_uncompress(data, len-4, c->block_data, &outlen) != SNAPPY_OK)
+ if (snappy_uncompress((const char*)data, len-4, (char*)c->block_data, &outlen) != SNAPPY_OK)
{
avro_set_error("Error uncompressing block with Snappy");
return 1;
}
- crc = __bswap_32(crc32(0, c->block_data, outlen));
+ crc = __bswap_32(crc32(0, (const Bytef *)c->block_data, outlen));
if (memcmp(&crc, (char*)data+len-4, 4))
{
avro_set_error("CRC32 check failure uncompressing block with Snappy");

View File

@ -1,14 +1,17 @@
{
"name": "avro-c",
"version-string": "1.9.2",
"port-version": 2,
"version": "1.11.0",
"description": "Apache Avro is a data serialization system",
"homepage": "https://github.com/apache/avro",
"supports": "!(uwp | osx)",
"supports": "!uwp",
"dependencies": [
"jansson",
"liblzma",
"snappy",
{
"name": "vcpkg-cmake",
"host": true
},
"zlib"
]
}

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "0b07ed910d3ad0ec9a5be71e1b37f0593ab540c9",
"version": "1.11.0",
"port-version": 0
},
{
"git-tree": "0828484bab48f23c09e440f9df3d9d99dd3caaa0",
"version-string": "1.9.2",

View File

@ -249,8 +249,8 @@
"port-version": 1
},
"avro-c": {
"baseline": "1.9.2",
"port-version": 2
"baseline": "1.11.0",
"port-version": 0
},
"avro-cpp": {
"baseline": "2021-06-01",