git: 8898daafe91d - main - math/mathpresso: New port: Mathematical expression parser and JIT compiler

From: Yuri Victorovich <yuri_at_FreeBSD.org>
Date: Mon, 26 Dec 2022 06:13:19 UTC
The branch main has been updated by yuri:

URL: https://cgit.FreeBSD.org/ports/commit/?id=8898daafe91dd1bce0fe8d09b6b80df6936c1b7e

commit 8898daafe91dd1bce0fe8d09b6b80df6936c1b7e
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2022-12-26 03:10:14 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2022-12-26 06:13:13 +0000

    math/mathpresso: New port: Mathematical expression parser and JIT compiler
---
 math/Makefile                              |  1 +
 math/mathpresso/Makefile                   | 34 ++++++++++++++++++++++++++++++
 math/mathpresso/distinfo                   |  3 +++
 math/mathpresso/files/patch-CMakeLists.txt | 28 ++++++++++++++++++++++++
 math/mathpresso/pkg-descr                  |  5 +++++
 5 files changed, 71 insertions(+)

diff --git a/math/Makefile b/math/Makefile
index 852c866cff0c..c6374d77dabb 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -477,6 +477,7 @@
     SUBDIR += mathlibtools
     SUBDIR += mathmod
     SUBDIR += mathomatic
+    SUBDIR += mathpresso
     SUBDIR += matio
     SUBDIR += matlab-installer
     SUBDIR += maxima
diff --git a/math/mathpresso/Makefile b/math/mathpresso/Makefile
new file mode 100644
index 000000000000..ca5a3da7158e
--- /dev/null
+++ b/math/mathpresso/Makefile
@@ -0,0 +1,34 @@
+PORTNAME=	mathpresso
+DISTVERSION=	g20211213
+CATEGORIES=	math
+
+MAINTAINER=	yuri@FreeBSD.org
+COMMENT=	Mathematical expression parser and JIT compiler
+WWW=		https://github.com/kobalicek/mathpresso
+
+LICENSE=	ZLIB
+LICENSE_FILE=	${WRKSRC}/LICENSE.md
+
+LIB_DEPENDS=	libasmjit.so:devel/asmjit
+
+USES=		cmake:testing localbase:ldflags
+USE_LDCONFIG=	yes
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	kobalicek
+GH_TAGNAME=	9256fa3
+
+CMAKE_ARGS=	-DASMJIT_CFLAGS="-I${LOCALBASE}/include" -DASMJIT_LIBS=asmjit
+CMAKE_TESTING_ON=	MATHPRESSO_TEST
+CMAKE_TESTING_TARGET=	mptest
+
+PLIST_FILES=	include/mathpresso/mathpresso.h \
+		lib/libmathpresso.so
+
+post-install: # workaround for https://github.com/kobalicek/mathpresso/issues/18
+	${INSTALL_LIB} ${BUILD_WRKSRC}/libmathpresso.so ${STAGEDIR}${PREFIX}/lib
+
+post-test:
+	@cd ${TEST_WRKSRC} && ./mptest
+
+.include <bsd.port.mk>
diff --git a/math/mathpresso/distinfo b/math/mathpresso/distinfo
new file mode 100644
index 000000000000..be3abb586e61
--- /dev/null
+++ b/math/mathpresso/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1672022436
+SHA256 (kobalicek-mathpresso-g20211213-9256fa3_GH0.tar.gz) = 8c6e67abc5572ff34e6a29640089d03a63b680a5b216eda36fc8593396797f38
+SIZE (kobalicek-mathpresso-g20211213-9256fa3_GH0.tar.gz) = 53143
diff --git a/math/mathpresso/files/patch-CMakeLists.txt b/math/mathpresso/files/patch-CMakeLists.txt
new file mode 100644
index 000000000000..92d78b4abd39
--- /dev/null
+++ b/math/mathpresso/files/patch-CMakeLists.txt
@@ -0,0 +1,28 @@
+--- CMakeLists.txt.orig	2022-12-26 02:50:03 UTC
++++ CMakeLists.txt
+@@ -13,12 +13,12 @@ if (NOT DEFINED MATHPRESSO_DIR)
+   set(MATHPRESSO_DIR "${CMAKE_CURRENT_LIST_DIR}")
+ endif()
+ 
+-if (NOT DEFINED ASMJIT_DIR)
+-  set(ASMJIT_DIR "${MATHPRESSO_DIR}/../asmjit")
+-endif()
++#if (NOT DEFINED ASMJIT_DIR)
++#  set(ASMJIT_DIR "${MATHPRESSO_DIR}/../asmjit")
++#endif()
+ 
+ set(MATHPRESSO_DIR    "${MATHPRESSO_DIR}" CACHE PATH "Location of 'mathpresso'")
+-set(ASMJIT_DIR        "${ASMJIT_DIR}"     CACHE PATH "Location of 'asmjit'")
++#set(ASMJIT_DIR        "${ASMJIT_DIR}"     CACHE PATH "Location of 'asmjit'")
+ 
+ set(MATHPRESSO_TEST   FALSE               CACHE BOOL "Build 'mathpresso' test applications")
+ set(MATHPRESSO_EMBED  FALSE               CACHE BOOL "Embed 'mathpresso' library (no targets)")
+@@ -53,7 +53,7 @@ endif()
+ if (NOT DEFINED ASMJIT_EMBED)
+   set(ASMJIT_EMBED TRUE)
+ endif()
+-include("${ASMJIT_DIR}/CMakeLists.txt")
++#include("${ASMJIT_DIR}/CMakeLists.txt")
+ 
+ list(APPEND MATHPRESSO_DEPS ${ASMJIT_LIBS})
+ list(APPEND MATHPRESSO_PRIVATE_CFLAGS "${ASMJIT_CFLAGS}")
diff --git a/math/mathpresso/pkg-descr b/math/mathpresso/pkg-descr
new file mode 100644
index 000000000000..11ac92a47c2a
--- /dev/null
+++ b/math/mathpresso/pkg-descr
@@ -0,0 +1,5 @@
+MathPresso is a C++ library designed to parse mathematical expressions and
+compile them into machine code. It's much faster than traditional AST or
+byte-code based evaluators, because there is basically no overhead in the
+expression's execution. The JIT compiler is based on AsmJit and works on
+X86 and X64 architectures.