Skip to content

Commit d9ad7a5

Browse files
JackBoosYvicroms
authored andcommitted
[upb]Add new port. (#8681)
* [upb]Add new port. * [upb]Re-generate patch.
1 parent 0a5b1b7 commit d9ad7a5

File tree

3 files changed

+226
-0
lines changed

3 files changed

+226
-0
lines changed

ports/upb/CONTROL

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Source: upb
2+
Version: 2019-10-21
3+
Homepage: https://github.com/protocolbuffers/upb/
4+
Description: μpb (often written 'upb') is a small protobuf implementation written in C.
5+
6+
Feature: asan
7+
Description: build with asan support
8+
9+
Feature: ubsan
10+
Description: build with ubsan support
11+
12+
Feature: tests
13+
Description: build tests

ports/upb/fix-cmakelists.patch

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 836c5ff..6ee66a7 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -58,90 +58,148 @@ elseif(UNIX)
6+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--build-id")
7+
endif()
8+
9+
-enable_testing()
10+
+if (ENABLE_TEST)
11+
+ enable_testing()
12+
+endif()
13+
14+
+set(UPB_HDRS
15+
+ ${CMAKE_CURRENT_LIST_DIR}/upb/generated_util.h
16+
+ ${CMAKE_CURRENT_LIST_DIR}/upb/msg.h
17+
+ ${CMAKE_CURRENT_LIST_DIR}/upb/table.int.h
18+
+ ${CMAKE_CURRENT_LIST_DIR}/upb/port_def.inc
19+
+ ${CMAKE_CURRENT_LIST_DIR}/upb/port_undef.inc
20+
+ ${CMAKE_CURRENT_LIST_DIR}/upb/decode.h
21+
+ ${CMAKE_CURRENT_LIST_DIR}/upb/encode.h
22+
+ ${CMAKE_CURRENT_LIST_DIR}/upb/upb.h
23+
+)
24+
+
25+
+set(UBP_PROJECTS upb)
26+
add_library(upb
27+
upb/decode.c
28+
upb/encode.c
29+
- upb/generated_util.h
30+
upb/msg.c
31+
- upb/msg.h
32+
upb/port.c
33+
- upb/port_def.inc
34+
- upb/port_undef.inc
35+
upb/table.c
36+
- upb/table.int.h
37+
upb/upb.c
38+
- upb/decode.h
39+
- upb/encode.h
40+
- upb/upb.h)
41+
+ upb/upb.h
42+
+ ${UPB_HDRS})
43+
+
44+
+
45+
+set(UBP_PROJECTS ${UBP_PROJECTS} generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me)
46+
add_library(generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE)
47+
target_link_libraries(generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE
48+
upb)
49+
+
50+
+set(REFLECTION_HDRS
51+
+ ${CMAKE_CURRENT_LIST_DIR}/upb/def.h
52+
+ ${CMAKE_CURRENT_LIST_DIR}/upb/msgfactory.h
53+
+)
54+
+
55+
+set(UBP_PROJECTS ${UBP_PROJECTS} reflection)
56+
add_library(reflection
57+
upb/def.c
58+
upb/msgfactory.c
59+
- upb/def.h
60+
- upb/msgfactory.h)
61+
+ ${REFLECTION_HDRS})
62+
target_link_libraries(reflection
63+
descriptor_upbproto
64+
table
65+
upb)
66+
+
67+
+set(UBP_PROJECTS ${UBP_PROJECTS} table)
68+
add_library(table INTERFACE)
69+
target_link_libraries(table INTERFACE
70+
upb)
71+
+
72+
+set(LEGACY_MSG_HDRS ${CMAKE_CURRENT_LIST_DIR}/upb/legacy_msg_reflection.h)
73+
+
74+
+set(UBP_PROJECTS ${UBP_PROJECTS} legacy_msg_reflection)
75+
add_library(legacy_msg_reflection
76+
upb/legacy_msg_reflection.c
77+
- upb/legacy_msg_reflection.h)
78+
+ ${LEGACY_MSG_HDRS})
79+
target_link_libraries(legacy_msg_reflection
80+
table
81+
upb)
82+
+
83+
+set(HANDLERS_HDRS
84+
+ ${CMAKE_CURRENT_LIST_DIR}/upb/handlers-inl.h
85+
+ ${CMAKE_CURRENT_LIST_DIR}/upb/handlers.h
86+
+ ${CMAKE_CURRENT_LIST_DIR}/upb/sink.h
87+
+)
88+
+
89+
+set(UBP_PROJECTS ${UBP_PROJECTS} handlers)
90+
add_library(handlers
91+
upb/handlers.c
92+
- upb/handlers-inl.h
93+
upb/sink.c
94+
- upb/handlers.h
95+
- upb/sink.h)
96+
+ ${HANDLERS_HDRS})
97+
target_link_libraries(handlers
98+
reflection
99+
table
100+
upb)
101+
+
102+
+set(UPB_PB_HDRS
103+
+ ${CMAKE_CURRENT_LIST_DIR}/upb/pb/decoder.int.h
104+
+ ${CMAKE_CURRENT_LIST_DIR}/upb/pb/varint.int.h
105+
+ ${CMAKE_CURRENT_LIST_DIR}/upb/pb/decoder.h
106+
+ ${CMAKE_CURRENT_LIST_DIR}/upb/pb/encoder.h
107+
+ ${CMAKE_CURRENT_LIST_DIR}/upb/pb/textprinter.h
108+
+)
109+
+
110+
+set(UBP_PROJECTS ${UBP_PROJECTS} upb_pb)
111+
add_library(upb_pb
112+
upb/pb/compile_decoder.c
113+
upb/pb/decoder.c
114+
- upb/pb/decoder.int.h
115+
upb/pb/encoder.c
116+
upb/pb/textprinter.c
117+
upb/pb/varint.c
118+
- upb/pb/varint.int.h
119+
- upb/pb/decoder.h
120+
- upb/pb/encoder.h
121+
- upb/pb/textprinter.h)
122+
+ ${UPB_PB_HDRS})
123+
target_link_libraries(upb_pb
124+
descriptor_upbproto
125+
handlers
126+
reflection
127+
table
128+
upb)
129+
+
130+
+set(UPB_JSON_HDRS
131+
+ ${CMAKE_CURRENT_LIST_DIR}/upb/json/parser.h
132+
+ ${CMAKE_CURRENT_LIST_DIR}/upb/json/printer.h
133+
+)
134+
+
135+
+set(UBP_PROJECTS ${UBP_PROJECTS} upb_json)
136+
add_library(upb_json
137+
generated_for_cmake/upb/json/parser.c
138+
upb/json/printer.c
139+
- upb/json/parser.h
140+
- upb/json/printer.h)
141+
+ ${UPB_JSON_HDRS})
142+
target_link_libraries(upb_json
143+
upb
144+
upb_pb)
145+
+
146+
+set(UBP_PROJECTS ${UBP_PROJECTS} upb_cc_bindings)
147+
add_library(upb_cc_bindings INTERFACE)
148+
target_link_libraries(upb_cc_bindings INTERFACE
149+
descriptor_upbproto
150+
handlers
151+
upb)
152+
-add_library(upb_test
153+
- tests/testmain.cc
154+
- tests/test_util.h
155+
- tests/upb_test.h)
156+
-target_link_libraries(upb_test
157+
- handlers
158+
- upb)
159+
-
160+
161+
+if (ENABLE_TEST)
162+
+ set(UBP_PROJECTS ${UBP_PROJECTS} upb_test)
163+
+ add_library(upb_test
164+
+ tests/testmain.cc
165+
+ tests/test_util.h
166+
+ tests/upb_test.h)
167+
+ target_link_libraries(upb_test
168+
+ handlers
169+
+ upb)
170+
+endif()
171+
+
172+
+install(FILES ${UPB_HDRS} ${REFLECTION_HDRS} ${LEGACY_MSG_HDRS} ${HANDLERS_HDRS} DESTINATION include/upb)
173+
+install(FILES ${UPB_PB_HDRS} DESTINATION include/upb/pb)
174+
+install(FILES ${UPB_JSON_HDRS} DESTINATION include/upb/json)
175+
+
176+
+foreach(PROJ ${UBP_PROJECTS})
177+
+ install(
178+
+ TARGETS ${PROJ}
179+
+ RUNTIME DESTINATION bin
180+
+ LIBRARY DESTINATION lib
181+
+ ARCHIVE DESTINATION lib
182+
+ )
183+
+endforeach()
184+
\ No newline at end of file

ports/upb/portfile.cmake

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
vcpkg_fail_port_install(ON_TARGET "Windows")
2+
3+
vcpkg_from_github(
4+
OUT_SOURCE_PATH SOURCE_PATH
5+
REPO protocolbuffers/upb
6+
REF 9effcbcb27f0a665f9f345030188c0b291e32482
7+
SHA512 416ff26ec21181d53be23e94203205072152ab3a8e4b3b28d16263a601995fd2d2f8afe5d8cfbecdac8543249482287b9fe6129314f7c9a7880660f5508bb85e
8+
HEAD_REF master
9+
PATCHES fix-cmakelists.patch
10+
)
11+
12+
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
13+
asan UPB_ENABLE_ASAN
14+
ubsan UPB_ENABLE_UBSAN
15+
tests ENABLE_TEST
16+
)
17+
18+
vcpkg_configure_cmake(
19+
SOURCE_PATH ${SOURCE_PATH}
20+
PREFER_NINJA
21+
OPTIONS ${FEATURE_OPTIONS}
22+
)
23+
24+
vcpkg_install_cmake()
25+
vcpkg_copy_pdbs()
26+
27+
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
28+
29+
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

0 commit comments

Comments
 (0)