Skip to content

opencv4: use protobuf #28450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions devel/protobuf/Portfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# -*- 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

PortSystem 1.0
PortGroup compiler_blacklist_versions 1.0
PortGroup github 1.0
PortGroup cmake 1.1
PortGroup legacysupport 1.1

# clock_gettime needed for abseil
# https://github.com/macports/macports-ports/pull/19905#issuecomment-1680281240
legacysupport.newest_darwin_requires_legacy 15

name protobuf
github.setup protocolbuffers protobuf 30.2 v
git.branch v${version}
revision 0

dist_subdir ${name}/${version}

categories devel
maintainers nomaintainer
license BSD

description Encode data in an efficient yet extensible format.
long_description \
Google Protocol Buffers are a flexible, efficient, \
automated mechanism for serializing structured data -- \
think XML, but smaller, faster, and simpler. You \
define how you want your data to be structured once, \
then you can use special generated source code to \
easily write and read your structured data to and from \
a variety of data streams and using a variety of \
languages. You can even update your data structure \
without breaking deployed programs that are compiled \
against the "old" format. You specify how you want \
the information you're serializing to be structured by \
defining protocol buffer message types in .proto \
files. Each protocol buffer message is a small \
logical record of information, containing a series of \
name-value pairs.
homepage https://protobuf.dev

checksums rmd160 ef4d5bfc28aaec952d4300296016fd0ce8db3e66 \
sha256 fb06709acc393cc36f87c251bb28a5500a2e12936d4346099f2c6240f6c7a941 \
size 9506934

github.tarball_from releases
distname protobuf-${version}
worksrcdir protobuf-${version}

# Upstream adds zlib include - which is ${prefix}/include - before search path
# of 3rd-party components, like gtest, gmock, etc. That causes the external
# versions of those to be pulled in, and the build fails.
# So don't let the project cmake add zlib; already added (last) by base.
patchfiles-append cmake-zlib-include.diff

compiler.cxx_standard 2017
compiler.thread_local_storage yes
# error: constexpr constructor never produces a constant expression [-Winvalid-constexpr]
compiler.blacklist {clang < 900}

if { [string match *clang* ${configure.compiler}] } {
# Quiet deprecation warnings
configure.cxxflags-append \
-Wno-deprecated-declarations \
-Wno-error=unknown-warning-option \
-Wno-unknown-warning-option
}

# Clear optflags; controlled by project, via cmake build type
configure.optflags

if {[variant_isset debug]} {
cmake.build_type Debug
} else {
cmake.build_type RelWithDebInfo
}

depends_lib-append \
port:abseil \
port:zlib

configure.args-append \
-DBUILD_SHARED_LIBS:BOOL=ON \
-Dprotobuf_ABSL_PROVIDER=package \
-Dprotobuf_BUILD_LIBPROTOC:BOOL=ON \
-Dprotobuf_BUILD_PROTOC_BINARIES:BOOL=ON \
-Dprotobuf_BUILD_TESTS:BOOL=OFF

post-destroot {
set docdir ${destroot}${prefix}/share/doc/${name}

xinstall -d -m 755 ${docdir}

foreach f {CONTRIBUTING.md CONTRIBUTORS.txt LICENSE README.md SECURITY.md editors examples} {
file copy ${worksrcpath}/${f} ${docdir}
}
}

proc port_test_ver_check {p_name p_ver p_rev} {
if { [catch {set port_ver_info [lindex [registry_active ${p_name}] 0]}] } {
error "Tests require that ${p_name} be active; install, then re-run tests"
} else {
set test_ver ${p_ver}_${p_rev}
set port_ver [lindex ${port_ver_info} 1]_[lindex ${port_ver_info} 2]
ui_info "port_test_ver_check: ${p_name}: test_ver: ${test_ver}; port_ver: ${port_ver}"

if { [vercmp ${port_ver} ${test_ver}] != 0 } {
error "Tests require installed version of ${p_name} to match port; update, then re-run tests"
}
}
}

variant tests description {Build with tests enabled} {
pre-configure {
port_test_ver_check ${subport} ${version} ${revision}
}

configure.args-replace \
-Dprotobuf_BUILD_TESTS:BOOL=OFF \
-Dprotobuf_BUILD_TESTS:BOOL=ON

test.run yes
test.target check
}
10 changes: 10 additions & 0 deletions devel/protobuf/files/cmake-zlib-include.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- CMakeLists.txt.orig 2025-05-07 15:35:24
+++ CMakeLists.txt 2025-05-07 15:46:49
@@ -259,7 +259,6 @@
endif (MSVC)

include_directories(
- ${ZLIB_INCLUDE_DIRECTORIES}
${protobuf_BINARY_DIR}
# Support #include-ing other top-level directories, i.e. upb_generator.
${protobuf_SOURCE_DIR}
10 changes: 5 additions & 5 deletions graphics/opencv4-devel/Portfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- 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

Check warning on line 1 in graphics/opencv4-devel/Portfile

View workflow job for this annotation

GitHub Actions / macos-14

port lint py313-opencv4-devel: Error: conflicts references unknown port: py313-opencv3 Error: conflicts references unknown port: py313-opencv3-devel

Check warning on line 1 in graphics/opencv4-devel/Portfile

View workflow job for this annotation

GitHub Actions / macos-14

port lint py312-opencv4-devel: Error: conflicts references unknown port: py312-opencv3 Error: conflicts references unknown port: py312-opencv3-devel

Check warning on line 1 in graphics/opencv4-devel/Portfile

View workflow job for this annotation

GitHub Actions / macos-15

port lint py313-opencv4-devel: Error: conflicts references unknown port: py313-opencv3 Error: conflicts references unknown port: py313-opencv3-devel

Check warning on line 1 in graphics/opencv4-devel/Portfile

View workflow job for this annotation

GitHub Actions / macos-15

port lint py312-opencv4-devel: Error: conflicts references unknown port: py312-opencv3 Error: conflicts references unknown port: py312-opencv3-devel

Check warning on line 1 in graphics/opencv4-devel/Portfile

View workflow job for this annotation

GitHub Actions / macos-13

port lint py313-opencv4-devel: Error: conflicts references unknown port: py313-opencv3 Error: conflicts references unknown port: py313-opencv3-devel

Check warning on line 1 in graphics/opencv4-devel/Portfile

View workflow job for this annotation

GitHub Actions / macos-13

port lint py312-opencv4-devel: Error: conflicts references unknown port: py312-opencv3 Error: conflicts references unknown port: py312-opencv3-devel

PortSystem 1.0
PortGroup cmake 1.1
Expand Down Expand Up @@ -56,7 +56,7 @@
github.setup opencv opencv 4.9.0
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision 4
revision 5
epoch 1

checksums-append \
Expand All @@ -68,7 +68,7 @@
github.setup opencv opencv 4.5.0
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision 30
revision 31

checksums-append \
${distname}${extract.suffix} \
Expand Down Expand Up @@ -362,9 +362,9 @@
subport py${python_version}-${name} {
# NOTE: Only rev-bump subports, for major changes/additions
if {${opencv_latest}} {
revision 1
revision 2
} else {
revision 12
revision 13
}

conflicts-append \
Expand Down Expand Up @@ -511,7 +511,7 @@
port:gflags \
port:google-glog \
port:hdf5 \
port:protobuf3-cpp
port:protobuf

extract.only \
${github.project}-${version}${extract.suffix} \
Expand Down
10 changes: 5 additions & 5 deletions graphics/opencv4/Portfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- 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

Check warning on line 1 in graphics/opencv4/Portfile

View workflow job for this annotation

GitHub Actions / macos-14

port lint py313-opencv4: Error: conflicts references unknown port: py313-opencv3 Error: conflicts references unknown port: py313-opencv3-devel

Check warning on line 1 in graphics/opencv4/Portfile

View workflow job for this annotation

GitHub Actions / macos-14

port lint py312-opencv4: Error: conflicts references unknown port: py312-opencv3 Error: conflicts references unknown port: py312-opencv3-devel

Check warning on line 1 in graphics/opencv4/Portfile

View workflow job for this annotation

GitHub Actions / macos-15

port lint py313-opencv4: Error: conflicts references unknown port: py313-opencv3 Error: conflicts references unknown port: py313-opencv3-devel

Check warning on line 1 in graphics/opencv4/Portfile

View workflow job for this annotation

GitHub Actions / macos-15

port lint py312-opencv4: Error: conflicts references unknown port: py312-opencv3 Error: conflicts references unknown port: py312-opencv3-devel

Check warning on line 1 in graphics/opencv4/Portfile

View workflow job for this annotation

GitHub Actions / macos-13

port lint py313-opencv4: Error: conflicts references unknown port: py313-opencv3 Error: conflicts references unknown port: py313-opencv3-devel

Check warning on line 1 in graphics/opencv4/Portfile

View workflow job for this annotation

GitHub Actions / macos-13

port lint py312-opencv4: Error: conflicts references unknown port: py312-opencv3 Error: conflicts references unknown port: py312-opencv3-devel

PortSystem 1.0
PortGroup cmake 1.1
Expand Down Expand Up @@ -56,7 +56,7 @@
github.setup opencv opencv 4.9.0
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision 4
revision 5
epoch 1

checksums-append \
Expand All @@ -68,7 +68,7 @@
github.setup opencv opencv 4.5.0
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision 35
revision 36

checksums-append \
${distname}${extract.suffix} \
Expand Down Expand Up @@ -411,9 +411,9 @@
subport py${python_version}-${name} {
# NOTE: Only rev-bump subports, for major changes/additions
if {${opencv_latest}} {
revision 1
revision 2
} else {
revision 18
revision 19
}

conflicts-append \
Expand Down Expand Up @@ -560,7 +560,7 @@
port:gflags \
port:google-glog \
port:hdf5 \
port:protobuf3-cpp
port:protobuf

extract.only \
${github.project}-${version}${extract.suffix} \
Expand Down