[upb]Add new port. (#8681)

* [upb]Add new port.

* [upb]Re-generate patch.
This commit is contained in:
JackBoosY 2019-10-30 14:17:31 +08:00 committed by Victor Romero
parent 0a5b1b7917
commit d9ad7a516d
3 changed files with 226 additions and 0 deletions

13
ports/upb/CONTROL Normal file
View File

@ -0,0 +1,13 @@
Source: upb
Version: 2019-10-21
Homepage: https://github.com/protocolbuffers/upb/
Description: μpb (often written 'upb') is a small protobuf implementation written in C.
Feature: asan
Description: build with asan support
Feature: ubsan
Description: build with ubsan support
Feature: tests
Description: build tests

View File

@ -0,0 +1,184 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 836c5ff..6ee66a7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -58,90 +58,148 @@ elseif(UNIX)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--build-id")
endif()
-enable_testing()
+if (ENABLE_TEST)
+ enable_testing()
+endif()
+set(UPB_HDRS
+ ${CMAKE_CURRENT_LIST_DIR}/upb/generated_util.h
+ ${CMAKE_CURRENT_LIST_DIR}/upb/msg.h
+ ${CMAKE_CURRENT_LIST_DIR}/upb/table.int.h
+ ${CMAKE_CURRENT_LIST_DIR}/upb/port_def.inc
+ ${CMAKE_CURRENT_LIST_DIR}/upb/port_undef.inc
+ ${CMAKE_CURRENT_LIST_DIR}/upb/decode.h
+ ${CMAKE_CURRENT_LIST_DIR}/upb/encode.h
+ ${CMAKE_CURRENT_LIST_DIR}/upb/upb.h
+)
+
+set(UBP_PROJECTS upb)
add_library(upb
upb/decode.c
upb/encode.c
- upb/generated_util.h
upb/msg.c
- upb/msg.h
upb/port.c
- upb/port_def.inc
- upb/port_undef.inc
upb/table.c
- upb/table.int.h
upb/upb.c
- upb/decode.h
- upb/encode.h
- upb/upb.h)
+ upb/upb.h
+ ${UPB_HDRS})
+
+
+set(UBP_PROJECTS ${UBP_PROJECTS} generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me)
add_library(generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE)
target_link_libraries(generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE
upb)
+
+set(REFLECTION_HDRS
+ ${CMAKE_CURRENT_LIST_DIR}/upb/def.h
+ ${CMAKE_CURRENT_LIST_DIR}/upb/msgfactory.h
+)
+
+set(UBP_PROJECTS ${UBP_PROJECTS} reflection)
add_library(reflection
upb/def.c
upb/msgfactory.c
- upb/def.h
- upb/msgfactory.h)
+ ${REFLECTION_HDRS})
target_link_libraries(reflection
descriptor_upbproto
table
upb)
+
+set(UBP_PROJECTS ${UBP_PROJECTS} table)
add_library(table INTERFACE)
target_link_libraries(table INTERFACE
upb)
+
+set(LEGACY_MSG_HDRS ${CMAKE_CURRENT_LIST_DIR}/upb/legacy_msg_reflection.h)
+
+set(UBP_PROJECTS ${UBP_PROJECTS} legacy_msg_reflection)
add_library(legacy_msg_reflection
upb/legacy_msg_reflection.c
- upb/legacy_msg_reflection.h)
+ ${LEGACY_MSG_HDRS})
target_link_libraries(legacy_msg_reflection
table
upb)
+
+set(HANDLERS_HDRS
+ ${CMAKE_CURRENT_LIST_DIR}/upb/handlers-inl.h
+ ${CMAKE_CURRENT_LIST_DIR}/upb/handlers.h
+ ${CMAKE_CURRENT_LIST_DIR}/upb/sink.h
+)
+
+set(UBP_PROJECTS ${UBP_PROJECTS} handlers)
add_library(handlers
upb/handlers.c
- upb/handlers-inl.h
upb/sink.c
- upb/handlers.h
- upb/sink.h)
+ ${HANDLERS_HDRS})
target_link_libraries(handlers
reflection
table
upb)
+
+set(UPB_PB_HDRS
+ ${CMAKE_CURRENT_LIST_DIR}/upb/pb/decoder.int.h
+ ${CMAKE_CURRENT_LIST_DIR}/upb/pb/varint.int.h
+ ${CMAKE_CURRENT_LIST_DIR}/upb/pb/decoder.h
+ ${CMAKE_CURRENT_LIST_DIR}/upb/pb/encoder.h
+ ${CMAKE_CURRENT_LIST_DIR}/upb/pb/textprinter.h
+)
+
+set(UBP_PROJECTS ${UBP_PROJECTS} upb_pb)
add_library(upb_pb
upb/pb/compile_decoder.c
upb/pb/decoder.c
- upb/pb/decoder.int.h
upb/pb/encoder.c
upb/pb/textprinter.c
upb/pb/varint.c
- upb/pb/varint.int.h
- upb/pb/decoder.h
- upb/pb/encoder.h
- upb/pb/textprinter.h)
+ ${UPB_PB_HDRS})
target_link_libraries(upb_pb
descriptor_upbproto
handlers
reflection
table
upb)
+
+set(UPB_JSON_HDRS
+ ${CMAKE_CURRENT_LIST_DIR}/upb/json/parser.h
+ ${CMAKE_CURRENT_LIST_DIR}/upb/json/printer.h
+)
+
+set(UBP_PROJECTS ${UBP_PROJECTS} upb_json)
add_library(upb_json
generated_for_cmake/upb/json/parser.c
upb/json/printer.c
- upb/json/parser.h
- upb/json/printer.h)
+ ${UPB_JSON_HDRS})
target_link_libraries(upb_json
upb
upb_pb)
+
+set(UBP_PROJECTS ${UBP_PROJECTS} upb_cc_bindings)
add_library(upb_cc_bindings INTERFACE)
target_link_libraries(upb_cc_bindings INTERFACE
descriptor_upbproto
handlers
upb)
-add_library(upb_test
- tests/testmain.cc
- tests/test_util.h
- tests/upb_test.h)
-target_link_libraries(upb_test
- handlers
- upb)
-
+if (ENABLE_TEST)
+ set(UBP_PROJECTS ${UBP_PROJECTS} upb_test)
+ add_library(upb_test
+ tests/testmain.cc
+ tests/test_util.h
+ tests/upb_test.h)
+ target_link_libraries(upb_test
+ handlers
+ upb)
+endif()
+
+install(FILES ${UPB_HDRS} ${REFLECTION_HDRS} ${LEGACY_MSG_HDRS} ${HANDLERS_HDRS} DESTINATION include/upb)
+install(FILES ${UPB_PB_HDRS} DESTINATION include/upb/pb)
+install(FILES ${UPB_JSON_HDRS} DESTINATION include/upb/json)
+
+foreach(PROJ ${UBP_PROJECTS})
+ install(
+ TARGETS ${PROJ}
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+ )
+endforeach()
\ No newline at end of file

29
ports/upb/portfile.cmake Normal file
View File

@ -0,0 +1,29 @@
vcpkg_fail_port_install(ON_TARGET "Windows")
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO protocolbuffers/upb
REF 9effcbcb27f0a665f9f345030188c0b291e32482
SHA512 416ff26ec21181d53be23e94203205072152ab3a8e4b3b28d16263a601995fd2d2f8afe5d8cfbecdac8543249482287b9fe6129314f7c9a7880660f5508bb85e
HEAD_REF master
PATCHES fix-cmakelists.patch
)
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
asan UPB_ENABLE_ASAN
ubsan UPB_ENABLE_UBSAN
tests ENABLE_TEST
)
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS ${FEATURE_OPTIONS}
)
vcpkg_install_cmake()
vcpkg_copy_pdbs()
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)