Skip to content

Commit

Permalink
[Nanopb] 0.4.7 (microsoft#28982)
Browse files Browse the repository at this point in the history
* wip

* restore patch

* wip

* wip

* ran x-add-version --all

* address PR comments

* wip

* ran `.\vcpkg x-add-version --all --overwrite-version`
  • Loading branch information
eharshosh authored Jan 18, 2023
1 parent 38c7df1 commit 55f8d1e
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 37 deletions.
49 changes: 49 additions & 0 deletions ports/nanopb/fix-cmakelist-and-pb-header.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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];
25 changes: 0 additions & 25 deletions ports/nanopb/fix-python.patch

This file was deleted.

19 changes: 9 additions & 10 deletions ports/nanopb/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO nanopb/nanopb
REF 0.4.5
SHA512 2f24308440bd961a94449e253627fbe38f6c5217cd70c57e9b3ab702da3c2df03b087ccdd62518940acf6b480a1dbb440ca5681f1766a17b199010d3df7b17a1
REF 0.4.7
SHA512 7fb46dad8a432898c8f9e7faa90a55276670dea3b13f15b68010fe126d7f6251ef5715d0dfe5bce66582e80cfdc5d4b1e7f5947e96a058fa7181f0a45da20860
HEAD_REF master
PATCHES
fix-python.patch
fix-cmakelist-and-pb-header.patch
)

string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" nanopb_BUILD_STATIC_LIBS)
Expand All @@ -21,24 +21,23 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS

vcpkg_find_acquire_program(PYTHON3)

vcpkg_configure_cmake(
vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-DPython_EXECUTABLE=${PYTHON3}
-Dnanopb_BUILD_RUNTIME=ON
-DBUILD_STATIC_LIBS=${nanopb_BUILD_STATIC_LIBS}
-Dnanopb_MSVC_STATIC_RUNTIME=${nanopb_STATIC_LINKING}
-Dnanopb_PROTOC_PATH=${CURRENT_HOST_INSTALLED_DIR}/tools/protobuf/protoc${VCPKG_HOST_EXECUTABLE_SUFFIX}
-Dnanopb_PROTOC_PATH="${CURRENT_HOST_INSTALLED_DIR}/tools/protobuf/protoc${VCPKG_HOST_EXECUTABLE_SUFFIX}"
${FEATURE_OPTIONS}
)
vcpkg_install_cmake()
vcpkg_cmake_install()

vcpkg_copy_pdbs()

vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/${PORT})
vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/${PORT}")

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

if(nanopb_BUILD_GENERATOR)
file(INSTALL "${CURRENT_PACKAGES_DIR}/bin/nanopb_generator.py" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}")
Expand All @@ -54,4 +53,4 @@ if(nanopb_BUILD_STATIC_LIBS)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
endif()
# Handle copyright
configure_file(${SOURCE_PATH}/LICENSE.txt ${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright COPYONLY)
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt")
13 changes: 12 additions & 1 deletion ports/nanopb/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
{
"name": "nanopb",
"version-semver": "0.4.5",
"version-semver": "0.4.7",
"description": "A small code-size Protocol Buffers implementation in ANSI C.",
"homepage": "https://jpa.kapsi.fi/nanopb/",
"license": "Zlib",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"features": {
"generator": {
"description": "build the generator",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -5213,7 +5213,7 @@
"port-version": 4
},
"nanopb": {
"baseline": "0.4.5",
"baseline": "0.4.7",
"port-version": 0
},
"nanoprintf": {
Expand Down
5 changes: 5 additions & 0 deletions versions/n-/nanopb.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "230c55c9370ee3756674be33a6d5740ff04fccda",
"version-semver": "0.4.7",
"port-version": 0
},
{
"git-tree": "855b599338a79c3a7d61c1171110e4dd49c3f164",
"version-semver": "0.4.5",
Expand Down

0 comments on commit 55f8d1e

Please sign in to comment.