git: 9784fb237cdf - main - cad/libbgcode: new port

From: Michael Zhilin <mizhka_at_FreeBSD.org>
Date: Thu, 28 Mar 2024 19:37:34 UTC
The branch main has been updated by mizhka:

URL: https://cgit.FreeBSD.org/ports/commit/?id=9784fb237cdf00b5f379c90df5c2d9f2bec97ea3

commit 9784fb237cdf00b5f379c90df5c2d9f2bec97ea3
Author:     Michael Zhilin <mizhka@FreeBSD.org>
AuthorDate: 2024-03-06 19:53:23 +0000
Commit:     Michael Zhilin <mizhka@FreeBSD.org>
CommitDate: 2024-03-28 19:31:42 +0000

    cad/libbgcode: new port
    
    It is required by PrusaSlicer 2.7+. This port provides library and
    binary to work with g-code (read/write/convert)
    
    Reported by: Teodor Sigaev <teodorsigaev@gmail.com>
    Reviewed by: lwhsu (mentor)
    Sponsored by: Postgres Professional
    Differential Revision: https://reviews.freebsd.org/D44257
---
 cad/Makefile                                       |  1 +
 cad/libbgcode/Makefile                             | 27 ++++++++++++++++++++++
 cad/libbgcode/distinfo                             |  5 ++++
 cad/libbgcode/files/patch-CMakeLists.txt           | 13 +++++++++++
 cad/libbgcode/files/patch-deps_CMakeLists.txt      | 23 ++++++++++++++++++
 .../files/patch-deps_heatshrink_heatshrink.cmake   | 12 ++++++++++
 cad/libbgcode/pkg-descr                            |  2 ++
 cad/libbgcode/pkg-plist                            | 21 +++++++++++++++++
 8 files changed, 104 insertions(+)

diff --git a/cad/Makefile b/cad/Makefile
index e85ed462ada0..f43f0c101c4f 100644
--- a/cad/Makefile
+++ b/cad/Makefile
@@ -74,6 +74,7 @@
     SUBDIR += ldview
     SUBDIR += leocad
     SUBDIR += lepton-eda
+    SUBDIR += libbgcode
     SUBDIR += libgdsii
     SUBDIR += libopencad
     SUBDIR += librecad
diff --git a/cad/libbgcode/Makefile b/cad/libbgcode/Makefile
new file mode 100644
index 000000000000..ffa5500927c5
--- /dev/null
+++ b/cad/libbgcode/Makefile
@@ -0,0 +1,27 @@
+PORTNAME=	libbgcode
+DISTVERSION=	0.2.0
+CATEGORIES=	cad
+
+MAINTAINER=	teodorsigaev@gmail.com
+COMMENT=	Prusa Block & Binary G-code reader/writer/converter
+WWW=		https://github.com/prusa3d/libbgcode
+
+LICENSE=	AGPLv3
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+LIB_DEPENDS=	libboost_nowide.so:devel/boost-libs
+
+USES=	cmake
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	prusa3d
+GH_TAGNAME=	6f43cb004ef3d3bda37dde49f6235e24d2717629
+GH_TUPLE=	atomicobject:heatshrink:v0.4.1:heatshrink
+
+CMAKE_ARGS+=	-DBUILD_SHARED_LIBS=ON \
+		-DLibBGCode_BUILD_DEPS=ON \
+		-DLibBGCode_BUILD_TESTS=OFF
+
+PORTDATA=	*
+
+.include <bsd.port.mk>
diff --git a/cad/libbgcode/distinfo b/cad/libbgcode/distinfo
new file mode 100644
index 000000000000..835c43181731
--- /dev/null
+++ b/cad/libbgcode/distinfo
@@ -0,0 +1,5 @@
+TIMESTAMP = 1709747111
+SHA256 (prusa3d-libbgcode-0.2.0-6f43cb004ef3d3bda37dde49f6235e24d2717629_GH0.tar.gz) = 315349d55fcee2eaf41ca7ba6a4b8e0e442c74b04f6074d6e108c169fa36e908
+SIZE (prusa3d-libbgcode-0.2.0-6f43cb004ef3d3bda37dde49f6235e24d2717629_GH0.tar.gz) = 455740
+SHA256 (atomicobject-heatshrink-v0.4.1_GH0.tar.gz) = 7529a1c8ac501191ad470b166773364e66d9926aad632690c72c63a1dea7e9a6
+SIZE (atomicobject-heatshrink-v0.4.1_GH0.tar.gz) = 36945
diff --git a/cad/libbgcode/files/patch-CMakeLists.txt b/cad/libbgcode/files/patch-CMakeLists.txt
new file mode 100644
index 000000000000..b03fc2532691
--- /dev/null
+++ b/cad/libbgcode/files/patch-CMakeLists.txt
@@ -0,0 +1,13 @@
+--- CMakeLists.txt.orig	2024-03-06 18:20:01 UTC
++++ CMakeLists.txt
+@@ -27,10 +27,6 @@ endif ()
+     include(deps/autobuild.cmake)
+ endif ()
+ 
+-if (NOT CMAKE_DEBUG_POSTFIX)
+-    set(CMAKE_DEBUG_POSTFIX "d")
+-endif ()
+-
+ include(CMakeDependentOption)
+ cmake_dependent_option(${PROJECT_NAME}_BUILD_COMPONENT_Convert "Include Convert component in the library" ON 
+                        "${PROJECT_NAME}_BUILD_COMPONENT_Binarize" OFF)
diff --git a/cad/libbgcode/files/patch-deps_CMakeLists.txt b/cad/libbgcode/files/patch-deps_CMakeLists.txt
new file mode 100644
index 000000000000..7bc456adc57c
--- /dev/null
+++ b/cad/libbgcode/files/patch-deps_CMakeLists.txt
@@ -0,0 +1,23 @@
+--- deps/CMakeLists.txt.orig	2024-01-22 12:56:01 UTC
++++ deps/CMakeLists.txt
+@@ -41,16 +41,16 @@ include(${PROJECT_SOURCE_DIR}/../cmake/modules/AddCMak
+ 
+ include(${PROJECT_SOURCE_DIR}/../cmake/modules/AddCMakeProject.cmake)
+ 
+-set(supported_packages Boost heatshrink Catch2 ZLIB pybind11)
++set(supported_packages heatshrink)
+ 
+ include(CMakeDependentOption)
+ option(${PROJECT_NAME}_SELECT_ALL "Choose all external projects to be selected (create build target for them)." ON)
+ option(${PROJECT_NAME}_BUILD_ALL "Choose all external projects to be built." OFF)
+ 
+-find_package(Git REQUIRED)
+-
++#find_package(Git REQUIRED)
++#
+ # The default command line for patching. Only works for newer
+-set(PATCH_CMD ${GIT_EXECUTABLE} apply --verbose --ignore-space-change --whitespace=fix)
++#set(PATCH_CMD ${GIT_EXECUTABLE} apply --verbose --ignore-space-change --whitespace=fix)
+ 
+ foreach (pkg ${supported_packages})
+     option(${PROJECT_NAME}_BUILD_${pkg} "Select package ${pkg} to be built." OFF)
diff --git a/cad/libbgcode/files/patch-deps_heatshrink_heatshrink.cmake b/cad/libbgcode/files/patch-deps_heatshrink_heatshrink.cmake
new file mode 100644
index 000000000000..849910764089
--- /dev/null
+++ b/cad/libbgcode/files/patch-deps_heatshrink_heatshrink.cmake
@@ -0,0 +1,12 @@
+--- deps/heatshrink/heatshrink.cmake.orig	2023-11-16 13:57:12 UTC
++++ deps/heatshrink/heatshrink.cmake
+@@ -1,6 +1,5 @@
+ add_cmake_project(heatshrink
+-    URL https://github.com/atomicobject/heatshrink/archive/refs/tags/v0.4.1.zip
+-    URL_HASH SHA256=2e2db2366bdf36cb450f0b3229467cbc6ea81a8c690723e4227b0b46f92584fe
++    URL file://../../heatshrink-0.4.1
+     PATCH_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt ./CMakeLists.txt &&
+                   ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/Config.cmake.in ./Config.cmake.in
+-)
+\ No newline at end of file
++)
diff --git a/cad/libbgcode/pkg-descr b/cad/libbgcode/pkg-descr
new file mode 100644
index 000000000000..f83c7d33e36a
--- /dev/null
+++ b/cad/libbgcode/pkg-descr
@@ -0,0 +1,2 @@
+Prusa Block & Binary G-code reader/writer/converter.
+libbgcode provides three API: core, binarize and convert.
diff --git a/cad/libbgcode/pkg-plist b/cad/libbgcode/pkg-plist
new file mode 100644
index 000000000000..962a25c25bdf
--- /dev/null
+++ b/cad/libbgcode/pkg-plist
@@ -0,0 +1,21 @@
+bin/bgcode
+include/LibBGCode/binarize/binarize.hpp
+include/LibBGCode/binarize/export.h
+include/LibBGCode/convert/convert.hpp
+include/LibBGCode/convert/export.h
+include/LibBGCode/core/core.hpp
+include/LibBGCode/core/export.h
+lib/cmake/LibBGCode/LibBGCodeBinarizeTargets-%%CMAKE_BUILD_TYPE%%.cmake
+lib/cmake/LibBGCode/LibBGCodeBinarizeTargets.cmake
+lib/cmake/LibBGCode/LibBGCodeConfig.cmake
+lib/cmake/LibBGCode/LibBGCodeConfigVersion.cmake
+lib/cmake/LibBGCode/LibBGCodeConvertTargets-%%CMAKE_BUILD_TYPE%%.cmake
+lib/cmake/LibBGCode/LibBGCodeConvertTargets.cmake
+lib/cmake/LibBGCode/LibBGCodeCoreTargets-%%CMAKE_BUILD_TYPE%%.cmake
+lib/cmake/LibBGCode/LibBGCodeCoreTargets.cmake
+lib/libbgcode_binarize.so
+lib/libbgcode_binarize.so.0.2.0
+lib/libbgcode_convert.so
+lib/libbgcode_convert.so.0.2.0
+lib/libbgcode_core.so
+lib/libbgcode_core.so.0.2.0