From 740c7e31b09a7ddceaa730d7a1836531169c9fd6 Mon Sep 17 00:00:00 2001 From: Cheney Wang <38240633+Cheney-W@users.noreply.github.com> Date: Fri, 29 Mar 2024 04:57:12 +0800 Subject: [PATCH] [nanopb] update to 0.4.8 (#37619) --- .../nanopb/fix-cmakelist-and-pb-header.patch | 49 --------------- ports/nanopb/fix-cmakelist.patch | 62 +++++++++++++++++++ ports/nanopb/fix-install-location.patch | 22 ------- ports/nanopb/portfile.cmake | 19 +++--- ports/nanopb/vcpkg.json | 3 +- versions/baseline.json | 4 +- versions/n-/nanopb.json | 5 ++ 7 files changed, 81 insertions(+), 83 deletions(-) delete mode 100644 ports/nanopb/fix-cmakelist-and-pb-header.patch create mode 100644 ports/nanopb/fix-cmakelist.patch delete mode 100644 ports/nanopb/fix-install-location.patch diff --git a/ports/nanopb/fix-cmakelist-and-pb-header.patch b/ports/nanopb/fix-cmakelist-and-pb-header.patch deleted file mode 100644 index 366fa23205..0000000000 --- a/ports/nanopb/fix-cmakelist-and-pb-header.patch +++ /dev/null @@ -1,49 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 8d241c5..4a3d31e 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -14,11 +14,6 @@ option(nanopb_BUILD_RUNTIME "Build the headers and libraries needed at runtime" - option(nanopb_BUILD_GENERATOR "Build the protoc plugin for code generation" ON) - option(nanopb_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON) - --find_program(nanopb_PROTOC_PATH protoc HINTS generator-bin generator) --if(NOT EXISTS ${nanopb_PROTOC_PATH}) -- message(FATAL_ERROR "protoc compiler not found") --endif() -- - if(NOT DEFINED CMAKE_DEBUG_POSTFIX) - set(CMAKE_DEBUG_POSTFIX "d") - endif() -@@ -39,7 +34,6 @@ if(NOT DEFINED CMAKE_INSTALL_CMAKEDIR) - set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/nanopb") - endif() - --find_package(Python REQUIRED COMPONENTS Interpreter) - execute_process( - COMMAND ${Python_EXECUTABLE} -c - "import os.path, sys, sysconfig; print(os.path.relpath(sysconfig.get_path('purelib'), start=sys.prefix))" -@@ -49,7 +43,9 @@ execute_process( - - if(nanopb_BUILD_GENERATOR) - set(generator_protos nanopb) -- -+ if(NOT DEFINED nanopb_PROTOC_PATH) -+ message(FATAL_ERROR "nanopb_PROTOC_PATH not defined") -+ endif() - foreach(generator_proto IN LISTS generator_protos) - string(REGEX REPLACE "([^;]+)" "${PROJECT_SOURCE_DIR}/generator/proto/\\1.proto" generator_proto_file "${generator_proto}") - string(REGEX REPLACE "([^;]+)" "\\1_pb2.py" generator_proto_py_file "${generator_proto}") -diff --git a/pb.h b/pb.h -index 5b3e1ef..693262b 100644 ---- a/pb.h -+++ b/pb.h -@@ -170,6 +170,9 @@ extern "C" { - # if defined(__ICCARM__) - /* IAR has static_assert keyword but no _Static_assert */ - # define PB_STATIC_ASSERT(COND,MSG) static_assert(COND,#MSG); -+# elif defined(_MSC_VER) -+ /* MSVC has static_assert keyword but no _Static_assert */ -+# define PB_STATIC_ASSERT(COND,MSG) static_assert(COND,#MSG); - # elif defined(PB_C99_STATIC_ASSERT) - /* Classic negative-size-array static assert mechanism */ - # define PB_STATIC_ASSERT(COND,MSG) typedef char PB_STATIC_ASSERT_MSG(MSG, __LINE__, __COUNTER__)[(COND)?1:-1]; diff --git a/ports/nanopb/fix-cmakelist.patch b/ports/nanopb/fix-cmakelist.patch new file mode 100644 index 0000000000..9bbb4b8092 --- /dev/null +++ b/ports/nanopb/fix-cmakelist.patch @@ -0,0 +1,62 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 273a841..02fb40c 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -16,11 +16,6 @@ option(nanopb_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON) + + set(nanopb_PYTHON_INSTDIR_OVERRIDE "" CACHE PATH "Override the default python installation directory with the given path") + +-find_program(nanopb_PROTOC_PATH protoc HINTS generator-bin generator) +-if(NOT EXISTS ${nanopb_PROTOC_PATH}) +- message(FATAL_ERROR "protoc compiler not found") +-endif() +- + if(NOT DEFINED CMAKE_DEBUG_POSTFIX) + set(CMAKE_DEBUG_POSTFIX "d") + endif() +@@ -43,7 +38,6 @@ endif() + + # Determine Python module installation path + if (NOT nanopb_PYTHON_INSTDIR_OVERRIDE) +- find_package(Python REQUIRED COMPONENTS Interpreter) + file(TO_CMAKE_PATH "${Python_SITELIB}" PYTHON_INSTDIR) + else() + set(PYTHON_INSTDIR ${nanopb_PYTHON_INSTDIR_OVERRIDE}) +@@ -53,6 +47,10 @@ message(STATUS "Python install dir: ${PYTHON_INSTDIR}") + # Package nanopb generator as Python module 'nanopb' + if(nanopb_BUILD_GENERATOR) + # Copy Python code files related to the generator ++ if(NOT EXISTS ${nanopb_PROTOC_PATH}) ++ message(FATAL_ERROR "protoc compiler not found") ++ endif() ++ + add_custom_target(nanopb_generator ALL + COMMAND ${CMAKE_COMMAND} -E make_directory + ${PROJECT_BINARY_DIR}/nanopb/generator/proto +@@ -82,24 +80,14 @@ if(nanopb_BUILD_GENERATOR) + + # Install Python module files + install( +- DIRECTORY ${PROJECT_BINARY_DIR}/nanopb +- DESTINATION ${PYTHON_INSTDIR} ++ DIRECTORY ${PROJECT_BINARY_DIR}/nanopb/generator ++ DESTINATION ${CMAKE_INSTALL_BINDIR} + FILES_MATCHING + PATTERN *.py + PATTERN *.proto + PATTERN __pycache__ EXCLUDE + ) + +- # Generate a wrapper script that calls nanopb.generator Python module when invoked +- configure_file( +- extra/script_wrappers/nanopb_generator.py.in +- ${PROJECT_BINARY_DIR}/nanopb_generator.py +- ) +- install( +- PROGRAMS ${PROJECT_BINARY_DIR}/nanopb_generator.py +- DESTINATION ${CMAKE_INSTALL_BINDIR} +- ) +- + # Install shell/bat script wrappers for invoking nanopb_generator.py. + # protoc-gen-nanopb is automatically used by protoc when --nanopb_out= option is used. + if(WIN32) diff --git a/ports/nanopb/fix-install-location.patch b/ports/nanopb/fix-install-location.patch deleted file mode 100644 index 9fd1c93c4f..0000000000 --- a/ports/nanopb/fix-install-location.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 4a3d31e..82611ef 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -58,12 +58,15 @@ if(nanopb_BUILD_GENERATOR) - install( - FILES ${PROJECT_BINARY_DIR}/${generator_proto_py_file} - ${generator_proto_file} -- DESTINATION ${PYTHON_INSTDIR}/proto/ -+ DESTINATION ${CMAKE_INSTALL_BINDIR}/proto/ - ) - endforeach() - - install( FILES generator/proto/_utils.py -- DESTINATION ${PYTHON_INSTDIR}/proto/ ) -+ DESTINATION ${CMAKE_INSTALL_BINDIR}/proto/ ) -+ -+ install( FILES generator/proto/__init__.py -+ DESTINATION ${CMAKE_INSTALL_BINDIR}/proto/ ) - endif() - - if(WIN32) diff --git a/ports/nanopb/portfile.cmake b/ports/nanopb/portfile.cmake index 006deb809b..fada669994 100644 --- a/ports/nanopb/portfile.cmake +++ b/ports/nanopb/portfile.cmake @@ -3,12 +3,11 @@ vcpkg_check_linkage(ONLY_STATIC_LIBRARY) vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO nanopb/nanopb - REF 0.4.7 - SHA512 7fb46dad8a432898c8f9e7faa90a55276670dea3b13f15b68010fe126d7f6251ef5715d0dfe5bce66582e80cfdc5d4b1e7f5947e96a058fa7181f0a45da20860 + REF ${VERSION} + SHA512 635577498dfbfb46fd64b8ec83b2a4a9b03b57c665f3c9f67d35c272810c0330b0e9011d7c0e43623e9da74d6ee3a4c1f012878e2bff7e1a7e57fb7c0857ad42 HEAD_REF master PATCHES - fix-cmakelist-and-pb-header.patch - fix-install-location.patch + fix-cmakelist.patch ) string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" nanopb_BUILD_STATIC_LIBS) @@ -32,6 +31,9 @@ vcpkg_cmake_configure( -Dnanopb_PROTOC_PATH="${CURRENT_HOST_INSTALLED_DIR}/tools/protobuf/protoc${VCPKG_HOST_EXECUTABLE_SUFFIX}" ${FEATURE_OPTIONS} -DCMAKE_INSTALL_DATADIR=share/${PORT} + MAYBE_UNUSED_VARIABLES + Python_EXECUTABLE + nanopb_PROTOC_PATH ) vcpkg_cmake_install() @@ -39,18 +41,19 @@ vcpkg_copy_pdbs() vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/${PORT}") -file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share") - if(nanopb_BUILD_GENERATOR) - file(INSTALL "${CURRENT_PACKAGES_DIR}/bin/nanopb_generator.py" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}") + file(INSTALL "${CURRENT_PACKAGES_DIR}/bin/generator/" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}") if(WIN32) + file(INSTALL "${CURRENT_PACKAGES_DIR}/bin/nanopb_generator.bat" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}") file(INSTALL "${CURRENT_PACKAGES_DIR}/bin/protoc-gen-nanopb.bat" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}") - file(INSTALL "${CURRENT_PACKAGES_DIR}/bin/proto/" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}/proto") else() + file(INSTALL "${CURRENT_PACKAGES_DIR}/bin/nanopb_generator" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}") file(INSTALL "${CURRENT_PACKAGES_DIR}/bin/protoc-gen-nanopb" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}") endif() endif() +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share") + if(nanopb_BUILD_STATIC_LIBS) file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") endif() diff --git a/ports/nanopb/vcpkg.json b/ports/nanopb/vcpkg.json index f63e220328..9e44e984d4 100644 --- a/ports/nanopb/vcpkg.json +++ b/ports/nanopb/vcpkg.json @@ -1,7 +1,6 @@ { "name": "nanopb", - "version-semver": "0.4.7", - "port-version": 2, + "version-semver": "0.4.8", "description": "A small code-size Protocol Buffers implementation in ANSI C.", "homepage": "https://jpa.kapsi.fi/nanopb/", "license": "Zlib", diff --git a/versions/baseline.json b/versions/baseline.json index 8a2124a244..6fb571af57 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -6005,8 +6005,8 @@ "port-version": 1 }, "nanopb": { - "baseline": "0.4.7", - "port-version": 2 + "baseline": "0.4.8", + "port-version": 0 }, "nanoprintf": { "baseline": "0.3.4", diff --git a/versions/n-/nanopb.json b/versions/n-/nanopb.json index d77e89c698..87304e3fe0 100644 --- a/versions/n-/nanopb.json +++ b/versions/n-/nanopb.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "4081435b822c87880779d5b6e9a763ee0389aa79", + "version-semver": "0.4.8", + "port-version": 0 + }, { "git-tree": "b27e85ab51605be4fee299a1dcb14f4fe0ac2429", "version-semver": "0.4.7",