Skip to content

Commit b07cabe

Browse files
committed
protobuf-cpp: new port
1 parent 9ed1c97 commit b07cabe

File tree

1 file changed

+130
-5
lines changed

1 file changed

+130
-5
lines changed

devel/protobuf-cpp/Portfile

Lines changed: 130 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,135 @@
11
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
22

3-
PortSystem 1.0
4-
PortGroup obsolete 1.0
3+
PortSystem 1.0
4+
PortGroup compiler_blacklist_versions 1.0
5+
PortGroup github 1.0
6+
PortGroup cmake 1.1
7+
PortGroup legacysupport 1.1
8+
9+
# clock_gettime needed for abseil
10+
# https://github.com/macports/macports-ports/pull/19905#issuecomment-1680281240
11+
legacysupport.newest_darwin_requires_legacy 15
12+
13+
set release_version \
14+
29.4
515

616
name protobuf-cpp
7-
replaced_by protobuf2-cpp
8-
version 2.6.1
9-
revision 1
17+
github.setup protocolbuffers protobuf 5.${release_version} v
18+
git.branch v${release_version}
19+
revision 0
20+
21+
dist_subdir ${name}/${version}
22+
1023
categories devel
24+
maintainers nomaintainer
25+
license BSD
26+
27+
description Encode data in an efficient yet extensible format.
28+
long_description \
29+
Google Protocol Buffers are a flexible, efficient, \
30+
automated mechanism for serializing structured data -- \
31+
think XML, but smaller, faster, and simpler. You \
32+
define how you want your data to be structured once, \
33+
then you can use special generated source code to \
34+
easily write and read your structured data to and from \
35+
a variety of data streams and using a variety of \
36+
languages. You can even update your data structure \
37+
without breaking deployed programs that are compiled \
38+
against the "old" format. You specify how you want \
39+
the information you're serializing to be structured by \
40+
defining protocol buffer message types in .proto \
41+
files. Each protocol buffer message is a small \
42+
logical record of information, containing a series of \
43+
name-value pairs.
44+
homepage https://protobuf.dev
45+
46+
checksums rmd160 3a8a4c815f22f23c5d8363d5fd7972b005d971a9 \
47+
sha256 6bd9dcc91b17ef25c26adf86db71c67ec02431dc92e9589eaf82e22889230496 \
48+
size 9350942
49+
50+
github.tarball_from releases
51+
distname protobuf-${release_version}
52+
worksrcdir protobuf-${release_version}
53+
54+
# Upstream adds zlib include - which is ${prefix}/include - before search path
55+
# of 3rd-party components, like gtest, gmock, etc. That causes the external
56+
# versions of those to be pulled in, and the build fails.
57+
# So don't let the project cmake add zlib; already added (last) by base.
58+
patchfiles-append cmake-zlib-include.diff
59+
60+
# Revert a breakage from dropping mach_time in:
61+
# https://github.com/protocolbuffers/protobuf/commit/a8a9bd2e4990fd5e0f0098bdfbe62bc00783eab7
62+
patchfiles-append patch-unbreak-time.diff
63+
64+
compiler.cxx_standard 2017
65+
compiler.thread_local_storage yes
66+
# error: constexpr constructor never produces a constant expression [-Winvalid-constexpr]
67+
compiler.blacklist {clang < 900}
68+
69+
if { [string match *clang* ${configure.compiler}] } {
70+
# Quiet deprecation warnings
71+
configure.cxxflags-append \
72+
-Wno-deprecated-declarations \
73+
-Wno-error=unknown-warning-option \
74+
-Wno-unknown-warning-option
75+
}
76+
77+
# Clear optflags; controlled by project, via cmake build type
78+
configure.optflags
79+
80+
if {[variant_isset debug]} {
81+
cmake.build_type Debug
82+
} else {
83+
cmake.build_type RelWithDebInfo
84+
}
85+
86+
depends_lib-append \
87+
port:abseil \
88+
port:zlib
89+
90+
configure.args-append \
91+
-DBUILD_SHARED_LIBS:BOOL=ON \
92+
-Dprotobuf_ABSL_PROVIDER=package \
93+
-Dprotobuf_BUILD_LIBPROTOC:BOOL=ON \
94+
-Dprotobuf_BUILD_PROTOC_BINARIES:BOOL=ON \
95+
-Dprotobuf_BUILD_TESTS:BOOL=OFF
96+
97+
post-destroot {
98+
set docdir ${destroot}${prefix}/share/doc/${name}
99+
100+
xinstall -d -m 755 ${docdir}
101+
102+
foreach f {CONTRIBUTING.md CONTRIBUTORS.txt LICENSE README.md SECURITY.md editors examples} {
103+
file copy ${worksrcpath}/${f} ${docdir}
104+
}
105+
}
106+
107+
proc port_test_ver_check {p_name p_ver p_rev} {
108+
if { [catch {set port_ver_info [lindex [registry_active ${p_name}] 0]}] } {
109+
error "Tests require that ${p_name} be active; install, then re-run tests"
110+
} else {
111+
set test_ver ${p_ver}_${p_rev}
112+
set port_ver [lindex ${port_ver_info} 1]_[lindex ${port_ver_info} 2]
113+
ui_info "port_test_ver_check: ${p_name}: test_ver: ${test_ver}; port_ver: ${port_ver}"
114+
115+
if { [vercmp ${port_ver} ${test_ver}] != 0 } {
116+
error "Tests require installed version of ${p_name} to match port; update, then re-run tests"
117+
}
118+
}
119+
}
120+
121+
variant tests description {Build with tests enabled} {
122+
pre-configure {
123+
port_test_ver_check ${subport} ${version} ${revision}
124+
}
125+
126+
configure.args-replace \
127+
-Dprotobuf_BUILD_TESTS:BOOL=OFF \
128+
-Dprotobuf_BUILD_TESTS:BOOL=ON
129+
130+
test.run yes
131+
test.target check
132+
}
133+
134+
livecheck.version ${release_version}
135+
github.livecheck.regex {([0-9.]+)}

0 commit comments

Comments
 (0)