From ceda292193213fb19870115ef402296670885fe5 Mon Sep 17 00:00:00 2001 From: xiaozhuai <798047000@qq.com> Date: Mon, 31 Jul 2023 17:54:11 +0800 Subject: [PATCH 1/2] [avro-cpp] Fix windows static build --- ports/avro-cpp/fix-cmake.patch | 99 ++++++++++++++++++++++++++++ ports/avro-cpp/install.patch | 116 --------------------------------- ports/avro-cpp/portfile.cmake | 30 +++++++-- ports/avro-cpp/usage | 11 +--- ports/avro-cpp/vcpkg.json | 16 ++--- scripts/ci.baseline.txt | 3 - 6 files changed, 130 insertions(+), 145 deletions(-) create mode 100644 ports/avro-cpp/fix-cmake.patch delete mode 100644 ports/avro-cpp/install.patch diff --git a/ports/avro-cpp/fix-cmake.patch b/ports/avro-cpp/fix-cmake.patch new file mode 100644 index 00000000000000..1030b37778210b --- /dev/null +++ b/ports/avro-cpp/fix-cmake.patch @@ -0,0 +1,99 @@ +diff --git a/lang/c++/CMakeLists.txt b/lang/c++/CMakeLists.txt +index 472684f4c..edde09e40 100644 +--- a/lang/c++/CMakeLists.txt ++++ b/lang/c++/CMakeLists.txt +@@ -51,20 +51,16 @@ list(GET AVRO_VERSION 2 AVRO_VERSION_PATCH) + project (Avro-cpp) + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}) + ++find_package(ZLIB REQUIRED) ++ + if (WIN32 AND NOT CYGWIN AND NOT MSYS) + add_definitions (/EHa) +- add_definitions ( +- -DNOMINMAX +- -DBOOST_REGEX_DYN_LINK +- -DBOOST_FILESYSTEM_DYN_LINK +- -DBOOST_SYSTEM_DYN_LINK +- -DBOOST_IOSTREAMS_DYN_LINK +- -DBOOST_PROGRAM_OPTIONS_DYN_LINK +- -DBOOST_ALL_NO_LIB) ++ add_definitions (-DNOMINMAX) + endif() + + if (CMAKE_COMPILER_IS_GNUCXX) +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror") ++ # Remove " -Werror" because of warning from boost-math (will require C++ 14 soon) ++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic") + if (AVRO_ADD_PROTECTOR_FLAGS) + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstack-protector-all -D_GLIBCXX_DEBUG") + # Unset _GLIBCXX_DEBUG for avrogencpp.cc because using Boost Program Options +@@ -114,7 +110,7 @@ set (AVRO_SOURCE_FILES + impl/CustomAttributes.cc + ) + +-add_library (avrocpp SHARED ${AVRO_SOURCE_FILES}) ++add_library (avrocpp ${AVRO_SOURCE_FILES}) + + set_property (TARGET avrocpp + APPEND PROPERTY COMPILE_DEFINITIONS AVRO_DYN_LINK) +@@ -131,12 +127,12 @@ set_target_properties (avrocpp PROPERTIES + set_target_properties (avrocpp_s PROPERTIES + VERSION ${AVRO_VERSION_MAJOR}.${AVRO_VERSION_MINOR}.${AVRO_VERSION_PATCH}) + +-target_link_libraries (avrocpp ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES}) ++target_link_libraries (avrocpp ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES} ZLIB::ZLIB) + target_include_directories(avrocpp PRIVATE ${SNAPPY_INCLUDE_DIR}) + + add_executable (precompile test/precompile.cc) + +-target_link_libraries (precompile avrocpp_s ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES}) ++target_link_libraries (precompile avrocpp_s ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES} ZLIB::ZLIB) + + macro (gen file ns) + add_custom_command (OUTPUT ${file}.hh +@@ -166,13 +162,14 @@ gen (primitivetypes pt) + gen (cpp_reserved_words cppres) + + add_executable (avrogencpp impl/avrogencpp.cc) +-target_link_libraries (avrogencpp avrocpp_s ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES}) ++target_link_libraries (avrogencpp avrocpp_s ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES} ZLIB::ZLIB) + ++if(BUILD_TESTING) + enable_testing() + + macro (unittest name) +- add_executable (${name} test/${name}.cc) +- target_link_libraries (${name} avrocpp ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES}) ++ add_executable (${name} test/${name}.cc impl/json/JsonIO.cc impl/json/JsonDom.cc) ++ target_link_libraries (${name} avrocpp ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES} ZLIB::ZLIB) + add_test (NAME ${name} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${name}) + endmacro (unittest) +@@ -197,6 +194,7 @@ add_dependencies (AvrogencppTests bigrecord_hh bigrecord_r_hh bigrecord2_hh + union_array_union_hh union_map_union_hh union_conflict_hh + recursive_hh reuse_hh circulardep_hh tree1_hh tree2_hh crossref_hh + primitivetypes_hh empty_record_hh) ++endif() + + include (InstallRequiredSystemLibraries) + +@@ -204,10 +202,14 @@ set (CPACK_PACKAGE_FILE_NAME "avrocpp-${AVRO_VERSION_MAJOR}") + + include (CPack) + +-install (TARGETS avrocpp avrocpp_s +- LIBRARY DESTINATION lib +- ARCHIVE DESTINATION lib +- RUNTIME DESTINATION lib) ++install(TARGETS avrocpp EXPORT unofficial-avro-cpp) ++ ++install( ++ EXPORT unofficial-avro-cpp ++ FILE unofficial-avro-cpp-config.cmake ++ DESTINATION share/unofficial-avro-cpp ++ NAMESPACE unofficial::avro-cpp:: ++) + + install (TARGETS avrogencpp RUNTIME DESTINATION bin) + diff --git a/ports/avro-cpp/install.patch b/ports/avro-cpp/install.patch deleted file mode 100644 index 7f4c4eb5f7bc2e..00000000000000 --- a/ports/avro-cpp/install.patch +++ /dev/null @@ -1,116 +0,0 @@ -diff --git "a/lang/c++/CMakeLists.txt" "b/lang/c++/CMakeLists.txt" -index 52d6ac8a..39d59cd8 100644 ---- "a/lang/c++/CMakeLists.txt" -+++ "b/lang/c++/CMakeLists.txt" -@@ -51,6 +51,8 @@ list(GET AVRO_VERSION 2 AVRO_VERSION_PATCH) - project (Avro-cpp) - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}) - -+find_package(ZLIB REQUIRED) -+ - if (WIN32 AND NOT CYGWIN AND NOT MSYS) - add_definitions (/EHa) - add_definitions ( -@@ -64,7 +66,8 @@ if (WIN32 AND NOT CYGWIN AND NOT MSYS) - endif() - - if (CMAKE_COMPILER_IS_GNUCXX) -- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror") -+ # Remove " -Werror" because of warning from boost-math (will require C++ 14 soon) -+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic") - if (AVRO_ADD_PROTECTOR_FLAGS) - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstack-protector-all -D_GLIBCXX_DEBUG") - # Unset _GLIBCXX_DEBUG for avrogencpp.cc because using Boost Program Options -@@ -131,12 +134,12 @@ set_target_properties (avrocpp PROPERTIES - set_target_properties (avrocpp_s PROPERTIES - VERSION ${AVRO_VERSION_MAJOR}.${AVRO_VERSION_MINOR}.${AVRO_VERSION_PATCH}) - --target_link_libraries (avrocpp ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES}) -+target_link_libraries (avrocpp ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES} ZLIB::ZLIB) - target_include_directories(avrocpp PRIVATE ${SNAPPY_INCLUDE_DIR}) - - add_executable (precompile test/precompile.cc) - --target_link_libraries (precompile avrocpp_s ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES}) -+target_link_libraries (precompile avrocpp_s ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES} ZLIB::ZLIB) - - macro (gen file ns) - add_custom_command (OUTPUT ${file}.hh -@@ -166,37 +169,41 @@ gen (primitivetypes pt) - gen (cpp_reserved_words cppres) - - add_executable (avrogencpp impl/avrogencpp.cc) --target_link_libraries (avrogencpp avrocpp_s ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES}) -+target_link_libraries (avrogencpp avrocpp_s ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES} ZLIB::ZLIB) - --enable_testing() -+if(BUILD_TESTING) -+ enable_testing() -+endif() - - macro (unittest name) -- add_executable (${name} test/${name}.cc) -- target_link_libraries (${name} avrocpp ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES}) -+ add_executable (${name} test/${name}.cc impl/json/JsonIO.cc impl/json/JsonDom.cc) -+ target_link_libraries (${name} avrocpp ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES} ZLIB::ZLIB) - add_test (NAME ${name} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${name}) - endmacro (unittest) - --unittest (buffertest) --unittest (unittest) --unittest (SchemaTests) --unittest (LargeSchemaTests) --unittest (CodecTests) --unittest (StreamTests) --unittest (SpecificTests) --unittest (DataFileTests) --unittest (JsonTests) --unittest (AvrogencppTests) --unittest (CompilerTests) --unittest (AvrogencppTestReservedWords) -- --add_dependencies (AvrogencppTestReservedWords cpp_reserved_words_hh) -- --add_dependencies (AvrogencppTests bigrecord_hh bigrecord_r_hh bigrecord2_hh -- tweet_hh -- union_array_union_hh union_map_union_hh union_conflict_hh -- recursive_hh reuse_hh circulardep_hh tree1_hh tree2_hh crossref_hh -- primitivetypes_hh empty_record_hh) -+if(BUILD_TESTING) -+ unittest (buffertest) -+ unittest (unittest) -+ unittest (SchemaTests) -+ unittest (LargeSchemaTests) -+ unittest (CodecTests) -+ unittest (StreamTests) -+ unittest (SpecificTests) -+ unittest (DataFileTests) -+ unittest (JsonTests) -+ unittest (AvrogencppTests) -+ unittest (CompilerTests) -+ unittest (AvrogencppTestReservedWords) -+ -+ add_dependencies (AvrogencppTestReservedWords cpp_reserved_words_hh) -+ -+ add_dependencies (AvrogencppTests bigrecord_hh bigrecord_r_hh bigrecord2_hh -+ tweet_hh -+ union_array_union_hh union_map_union_hh union_conflict_hh -+ recursive_hh reuse_hh circulardep_hh tree1_hh tree2_hh crossref_hh -+ primitivetypes_hh empty_record_hh) -+endif() - - include (InstallRequiredSystemLibraries) - -@@ -207,9 +214,9 @@ include (CPack) - install (TARGETS avrocpp avrocpp_s - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib -- RUNTIME DESTINATION lib) -+ RUNTIME DESTINATION bin) - --install (TARGETS avrogencpp RUNTIME DESTINATION bin) -+install (TARGETS avrogencpp RUNTIME DESTINATION tools/bin) - - install (DIRECTORY api/ DESTINATION include/avro - FILES_MATCHING PATTERN *.hh) diff --git a/ports/avro-cpp/portfile.cmake b/ports/avro-cpp/portfile.cmake index 6e2ee4923c3d6f..d6c5e7f36c5bfa 100644 --- a/ports/avro-cpp/portfile.cmake +++ b/ports/avro-cpp/portfile.cmake @@ -1,5 +1,3 @@ -vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY) - vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO apache/avro @@ -7,12 +5,10 @@ vcpkg_from_github( SHA512 932f642f272997b5c0be467d3a3ccc354c6edf425c36b33aa7e61984f67312c712bb1d74cb1a5fd8066169104851e73830f0ed3fdb450e005a5c5bef33c34f20 HEAD_REF master PATCHES - install.patch + fix-cmake.patch ) vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS - FEATURES - test BUILD_TESTING INVERTED_FEATURES snappy CMAKE_DISABLE_FIND_PACKAGE_Snappy ) @@ -20,14 +16,34 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}/lang/c++" OPTIONS + -DBUILD_TESTING=OFF ${FEATURE_OPTIONS} ) -vcpkg_cmake_install(ADD_BIN_TO_PATH) +vcpkg_cmake_install() +vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-${PORT}) + +file(READ "${CURRENT_PACKAGES_DIR}/share/unofficial-avro-cpp/unofficial-avro-cpp-config.cmake" cmake_config) +if("snappy" IN_LIST FEATURES) + file(WRITE "${CURRENT_PACKAGES_DIR}/share/unofficial-avro-cpp/unofficial-avro-cpp-config.cmake" +"include(CMakeFindDependencyMacro) +find_dependency(ZLIB) +find_dependency(Snappy) +${cmake_config} +") +else() + file(WRITE "${CURRENT_PACKAGES_DIR}/share/unofficial-avro-cpp/unofficial-avro-cpp-config.cmake" +"include(CMakeFindDependencyMacro) +find_dependency(ZLIB) +${cmake_config} +") +endif() vcpkg_copy_pdbs() +vcpkg_copy_tools(TOOL_NAMES avrogencpp AUTO_CLEAN) file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") -file(INSTALL "${SOURCE_PATH}/lang/c++/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/lang/c++/LICENSE") file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") diff --git a/ports/avro-cpp/usage b/ports/avro-cpp/usage index f59a204cb77ae5..243b52d86c7778 100644 --- a/ports/avro-cpp/usage +++ b/ports/avro-cpp/usage @@ -1,9 +1,4 @@ -The package avro-cpp can be used from CMake via: +avro-cpp provides CMake targets: - find_path(AVROCPP_INCLUDE_DIR avro/Encoder.hh) - find_library(AVROCPP_LIBRARY_DEBUG avrocpp PATH_SUFFIXES "debug/lib" REQUIRED) - get_filename_component(AVROCPP_ROOT_FIND_DIR ${AVROCPP_INCLUDE_DIR} DIRECTORY) - find_library(AVROCPP_LIBRARY_RELEASE avrocpp PATHS "${AVROCPP_ROOT_FIND_DIR}/lib/" REQUIRED NO_DEFAULT_PATH) - - target_include_directories(main PRIVATE "${AVROCPP_INCLUDE_DIR}") - target_link_libraries(main PRIVATE optimized "${AVROCPP_LIBRARY_RELEASE}" debug "${AVROCPP_LIBRARY_DEBUG}") + find_package(unofficial-avro-cpp CONFIG REQUIRED) + target_link_libraries(main PRIVATE unofficial::avro-cpp::avrocpp) diff --git a/ports/avro-cpp/vcpkg.json b/ports/avro-cpp/vcpkg.json index 735fdac645164a..a1817d9f8b3f2d 100644 --- a/ports/avro-cpp/vcpkg.json +++ b/ports/avro-cpp/vcpkg.json @@ -1,10 +1,10 @@ { "name": "avro-cpp", "version-date": "2022-11-07", + "port-version": 1, "description": "Apache Avro is a data serialization system", "homepage": "https://github.com/apache/avro", "license": "Apache-2.0", - "supports": "!(windows & static)", "dependencies": [ "boost-algorithm", "boost-any", @@ -21,6 +21,10 @@ "name": "vcpkg-cmake", "host": true }, + { + "name": "vcpkg-cmake-config", + "host": true + }, "zlib" ], "features": { @@ -29,16 +33,6 @@ "dependencies": [ "snappy" ] - }, - "test": { - "description": "Build tests", - "dependencies": [ - "boost-asio", - "boost-bind", - "boost-smart-ptr", - "boost-test", - "boost-thread" - ] } } } diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index 059db7f97854a6..71cf471d9710ce 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -62,9 +62,6 @@ assimp:arm-neon-android=fail avro-c:arm-neon-android=fail avro-c:arm64-android=fail avro-c:x64-android=fail -avro-cpp:arm-neon-android=fail -avro-cpp:arm64-android=fail -avro-cpp:x64-android=fail azure-identity-cpp:arm-neon-android=fail azure-identity-cpp:arm64-android=fail azure-identity-cpp:x64-android=fail From 77d9fb29df5e66924f052689bfb07de11e4eb298 Mon Sep 17 00:00:00 2001 From: xiaozhuai <798047000@qq.com> Date: Tue, 1 Aug 2023 17:02:19 +0800 Subject: [PATCH 2/2] update version database --- versions/a-/avro-cpp.json | 5 +++++ versions/baseline.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/versions/a-/avro-cpp.json b/versions/a-/avro-cpp.json index 2475b975d81a76..b88e06893cfb1f 100644 --- a/versions/a-/avro-cpp.json +++ b/versions/a-/avro-cpp.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "0f04b2076c299b830bfdd3a698db754f4f8cf269", + "version-date": "2022-11-07", + "port-version": 1 + }, { "git-tree": "08f82323ee0bb00a297cc1318c04dd3bce5d963e", "version-date": "2022-11-07", diff --git a/versions/baseline.json b/versions/baseline.json index c0a53b306d0f1a..bb34318143cf9c 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -338,7 +338,7 @@ }, "avro-cpp": { "baseline": "2022-11-07", - "port-version": 0 + "port-version": 1 }, "aws-c-auth": { "baseline": "0.6.22",