community/libarcus: upgrade to 5.2.0

This commit is contained in:
Aiden Grossman 2022-10-21 04:36:35 +00:00 committed by psykose
parent 39e5b1f652
commit ad078141cb
4 changed files with 99 additions and 60 deletions

View File

@ -2,8 +2,8 @@
# Maintainer: Aiden Grossman <agrossman154@yahoo.com>
pkgname=libarcus
# Needs to be upgraded in sync with the curaengine aport
pkgver=4.13.1
pkgrel=3
pkgver=5.2.0
pkgrel=0
pkgdesc="Communication library for Cura"
url="https://github.com/Ultimaker/libArcus"
arch="all"
@ -11,23 +11,25 @@ license="LGPL-3.0-or-later"
makedepends="
cmake
protobuf-dev
py3-sip4-dev
py3-sip
python3-dev
samurai
"
subpackages="$pkgname-dev py3-$pkgname:_py"
subpackages="$pkgname-dev"
options="!check" # no test suite
source="https://github.com/Ultimaker/libArcus/archive/$pkgver/libArcus-$pkgver.tar.gz
protobuf.patch
"
cmake-build.patch
ArcusConfig.patch"
builddir="$srcdir/libArcus-$pkgver"
build() {
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=None \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LIBDIR=lib \
-DBUILD_PYTHON=ON
-DCMAKE_INSTALL_INCLUDEDIR=/usr/include \
-DBUILD_SHARED_LIBS=ON \
-DARCUS_VERSION=$pkgver
cmake --build build
}
@ -35,13 +37,8 @@ package() {
DESTDIR="$pkgdir" cmake --install build
}
_py() {
pkgdesc="Python bindings for libarcus"
depends="python3"
amove usr/lib/python3*
}
sha512sums="
ffb14595f23c47f71082b994eae01471f45e2e9e1ae9a8ad01df577b9445594c30173388beab016a92be9723638ca6e46b5cecddddc6adc97e9d212fc0fa23fa libArcus-4.13.1.tar.gz
6b1994507776148a07f8adfa56590259bd6142a780c7660ed7b1c007f79a9399a0914565b66e9422597ae052f0988c3ae09a20f096902f3a9e2daee20c42d363 protobuf.patch
09e3a8ee34eee207ae20028ad7847d0922e2306af0db9018745ebb8b61af317380ee5e47d24684a26f268ac786e6abcee76ac05e6ebc8c0e72f2b88e0758e0cb libArcus-5.2.0.tar.gz
87c8d80afca0be287d8686e3a2133753f95dbc361fbffda8f0cfd63a8890fff9a9374e00bb6d42040ef23def9a116126e0d5a1a001d596dc74934292ed0791d7 cmake-build.patch
9a058e240014de0c6698b3cc38a4b5064455adc0901fad05c0f78b67ae6cf82e9ca5dd4e74a8cc95d8915fd57b10336c7974b19f061e5a53a28d7b63f80c4851 ArcusConfig.patch
"

View File

@ -0,0 +1,13 @@
--- /dev/null
+++ ./ArcusConfig.cmake.in
@@ -0,0 +1,10 @@
+@PACKAGE_INIT@
+
+# We want to have access to protobuf_generate_cpp and other FindProtobuf features.
+# However, if ProtobufConfig is used instead, there is a CMake option that controls
+# this, which defaults to OFF. We need to force this option to ON instead.
+set(protobuf_MODULE_COMPATIBLE ON CACHE "" INTERNAL FORCE)
+find_package(Protobuf REQUIRED)
+
+get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+include(${SELF_DIR}/Arcus-targets.cmake)

View File

@ -0,0 +1,73 @@
--- ./CMakeLists.txt.orig
+++ ./CMakeLists.txt
@@ -1,10 +1,11 @@
cmake_policy(SET CMP0091 NEW)
project(libarcus)
cmake_minimum_required(VERSION 3.20)
-find_package(standardprojectsettings REQUIRED)
-find_package(protobuf 3.17.1 REQUIRED)
+include(CMakePackageConfigHelpers)
+find_package(Protobuf REQUIRED)
+
set(arcus_SRCS
src/Socket.cpp
src/SocketListener.cpp
@@ -13,14 +14,20 @@
src/Error.cpp
)
+set(arcus_HDRS
+ include/Arcus/Socket.h
+ include/Arcus/SocketListener.h
+ include/Arcus/Types.h
+ include/Arcus/MessageTypeStore.h
+ include/Arcus/Error.h
+)
+
if(BUILD_SHARED_LIBS)
add_library(Arcus SHARED ${arcus_SRCS})
else()
add_library(Arcus STATIC ${arcus_SRCS})
endif()
-use_threads(Arcus)
-
target_include_directories(Arcus
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
@@ -41,3 +48,33 @@
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug" OR ${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")
target_compile_definitions(Arcus PRIVATE -DARCUS_DEBUG)
endif()
+
+set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+
+set_target_properties(Arcus PROPERTIES
+ FRAMEWORK FALSE
+ VERSION ${ARCUS_VERSION}
+ PUBLIC_HEADER "${arcus_HDRS}"
+)
+
+configure_package_config_file(ArcusConfig.cmake.in ${CMAKE_BINARY_DIR}/ArcusConfig.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Arcus)
+write_basic_package_version_file(${CMAKE_BINARY_DIR}/ArcusConfigVersion.cmake VERSION ${ARCUS_VERSION} COMPATIBILITY SameMajorVersion)
+
+install(FILES
+ ${CMAKE_BINARY_DIR}/ArcusConfig.cmake
+ ${CMAKE_BINARY_DIR}/ArcusConfigVersion.cmake
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Arcus
+)
+
+install(TARGETS Arcus
+ EXPORT Arcus-targets
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/Arcus
+)
+
+install(EXPORT Arcus-targets
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Arcus
+)
+

View File

@ -1,44 +0,0 @@
Migrate away from previously deprecated functions dropped in protobuf>=3.18.0_1.
Upstream issue: https://github.com/Ultimaker/libArcus/issues/121
--- a/src/Socket_p.h
+++ b/src/Socket_p.h
@@ -128,9 +128,6 @@
static const int keep_alive_rate = 500; //Number of milliseconds between sending keepalive packets
- // This value determines when protobuf should warn about very large messages.
- static const int message_size_warning = 400 * 1048576;
-
// This value determines when protobuf should error out because the message is too large.
// Due to the way Protobuf is implemented, messages large than 512MiB will cause issues.
static const int message_size_maximum = 500 * 1048576;
@@ -362,11 +359,15 @@
return;
}
- uint32_t message_size = message->ByteSize();
- if(platform_socket.writeUInt32(message_size) == -1)
+ auto message_size = message->ByteSizeLong();
+ if (message_size > UINT32_MAX) {
+ error(ErrorCode::SendFailedError, "Message size is too large to send");
+ return;
+ }
+
+ if(platform_socket.writeUInt32(static_cast<uint32_t>(message_size)) == -1)
{
error(ErrorCode::SendFailedError, "Could not send message size");
- return;
}
uint32_t type_id = message_types.getMessageTypeId(message);
@@ -548,7 +549,7 @@
google::protobuf::io::ArrayInputStream array(wire_message->data, wire_message->size);
google::protobuf::io::CodedInputStream stream(&array);
- stream.SetTotalBytesLimit(message_size_maximum, message_size_warning);
+ stream.SetTotalBytesLimit(message_size_maximum);
if(!message->ParseFromCodedStream(&stream))
{
error(ErrorCode::ParseFailedError, "Failed to parse message:" + std::string(wire_message->data));