aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Falsi <madpilot@FreeBSD.org>2022-11-22 17:33:49 +0000
committerGuido Falsi <madpilot@FreeBSD.org>2022-11-22 17:33:49 +0000
commitf2183b130f8a2158ac036307c5f592962613b189 (patch)
tree542213e8663faf81a3c36d38363ca8128717e503
parente7693e387ca0224d30dc2bd7ec86205961d4a8c5 (diff)
downloadports-f2183b130f8a2158ac036307c5f592962613b189.tar.gz
ports-f2183b130f8a2158ac036307c5f592962613b189.zip
graphics/ocaml-cairo: Objective Caml binding for the Cairo library
Importing a slightly outdated release that supports the ocaml and dune versions available in the ports tree. Including an upstream commit fixing a memory leak that was discovered in this release.
-rw-r--r--graphics/Makefile1
-rw-r--r--graphics/ocaml-cairo/Makefile40
-rw-r--r--graphics/ocaml-cairo/distinfo3
-rw-r--r--graphics/ocaml-cairo/files/patch-issue-1964
-rw-r--r--graphics/ocaml-cairo/pkg-descr2
-rw-r--r--graphics/ocaml-cairo/pkg-plist53
6 files changed, 163 insertions, 0 deletions
diff --git a/graphics/Makefile b/graphics/Makefile
index 92fe658afe02..ef1dd67f4d3f 100644
--- a/graphics/Makefile
+++ b/graphics/Makefile
@@ -588,6 +588,7 @@
SUBDIR += nsxiv
SUBDIR += nurbs++
SUBDIR += nvidia-texture-tools
+ SUBDIR += ocaml-cairo
SUBDIR += ocaml-images
SUBDIR += ocaml-lablgl
SUBDIR += ocrad
diff --git a/graphics/ocaml-cairo/Makefile b/graphics/ocaml-cairo/Makefile
new file mode 100644
index 000000000000..1285f883c22d
--- /dev/null
+++ b/graphics/ocaml-cairo/Makefile
@@ -0,0 +1,40 @@
+PORTNAME= cairo
+PORTVERSION= 0.6.1
+CATEGORIES= graphics
+PKGNAMEPREFIX= ocaml-
+
+MAINTAINER= madpilot@FreeBSD.org
+COMMENT= Objective Caml binding for the Cairo library
+WWW= https://github.com/Chris00/ocaml-cairo
+
+LICENSE= LGPL3
+LICENSE_FILE= ${WRKSRC}/LICENSE.md
+
+BUILD_DEPENDS= dune:devel/ocaml-dune
+LIB_DEPENDS+= libfreetype.so:print/freetype2 \
+ libfontconfig.so:x11-fonts/fontconfig
+
+USES= gnome pkgconfig
+USE_GNOME= cairo
+USE_OCAML= yes
+
+USE_GITHUB= yes
+GH_ACCOUNT= Chris00
+GH_PROJECT= ${PKGNAMEPREFIX}${PORTNAME}
+
+DOCSDIR= ${OCAML_DOCSDIR}/cairo2
+EXAMPLESDIR= ${OCAML_EXAMPLESDIR}/${PORTNAME}
+
+OPTIONS_DEFINE= DOCS EXAMPLES
+
+do-build:
+ cd ${BUILD_WRKSRC} && dune build --verbose -j ${MAKE_JOBS_NUMBER} -p cairo2
+
+do-install:
+ cd ${INSTALL_WRKSRC} && dune install --destdir=${STAGEDIR} \
+ --libdir=${OCAML_SITELIBDIR} cairo2
+
+post-install-EXAMPLES-on:
+ @(cd ${WRKSRC}/examples && ${COPYTREE_SHARE} . ${STAGEDIR}${EXAMPLESDIR})
+
+.include <bsd.port.mk>
diff --git a/graphics/ocaml-cairo/distinfo b/graphics/ocaml-cairo/distinfo
new file mode 100644
index 000000000000..47a0b8e02d71
--- /dev/null
+++ b/graphics/ocaml-cairo/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1669022120
+SHA256 (Chris00-ocaml-cairo-0.6.1_GH0.tar.gz) = 2d4492b62b31e714a7a98fcf54b98a46ae5f6430ebc7f1620568a9a28498ad11
+SIZE (Chris00-ocaml-cairo-0.6.1_GH0.tar.gz) = 109786
diff --git a/graphics/ocaml-cairo/files/patch-issue-19 b/graphics/ocaml-cairo/files/patch-issue-19
new file mode 100644
index 000000000000..23a1a684d73e
--- /dev/null
+++ b/graphics/ocaml-cairo/files/patch-issue-19
@@ -0,0 +1,64 @@
+From 3c70f2ff18650c4794556049cd4ea22a58cc719e Mon Sep 17 00:00:00 2001
+From: Christophe Troestler <Christophe.Troestler@umons.ac.be>
+Date: Sun, 27 Sep 2020 23:20:52 +0200
+Subject: [PATCH] Do not store the Caml_ba_array_val pointer during surface
+ creation
+
+Fixes https://github.com/Chris00/ocaml-cairo/issues/19
+---
+ src/cairo_stubs.c | 3 ++-
+ tests/image_create.ml | 5 +++--
+ 2 files changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/src/cairo_stubs.c b/src/cairo_stubs.c
+index 641ee2c..200abf3 100644
+--- src/cairo_stubs.c
++++ src/cairo_stubs.c
+@@ -1580,6 +1580,7 @@ static cairo_status_t caml_cairo_image_bigarray_attach_proxy
+ caml_cairo_image_bigarray_finalize);
+ }
+
++#define b (Caml_ba_array_val(vb))
+ #define SURFACE_CREATE_DATA(name) \
+ CAMLexport value caml_cairo_image_surface_create_for_##name \
+ (value vb, value vformat, value vwidth, value vheight, value vstride) \
+@@ -1588,7 +1589,6 @@ static cairo_status_t caml_cairo_image_bigarray_attach_proxy
+ CAMLlocal1(vsurf); \
+ cairo_surface_t* surf; \
+ const int width = Int_val(vwidth); \
+- struct caml_ba_array *b = Caml_ba_array_val(vb); \
+ cairo_status_t status; \
+ \
+ if ((b->flags & CAML_BA_MANAGED_MASK) == CAML_BA_MAPPED_FILE) \
+@@ -1610,6 +1610,7 @@ static cairo_status_t caml_cairo_image_bigarray_attach_proxy
+
+ SURFACE_CREATE_DATA(data8)
+ SURFACE_CREATE_DATA(data32)
++#undef b
+
+ #define SURFACE_GET_DATA(type, num_dims, dims ...) \
+ CAMLexport value caml_cairo_image_surface_get_##type(value vsurf) \
+diff --git a/tests/image_create.ml b/tests/image_create.ml
+index eec98d6..b13c206 100644
+--- tests/image_create.ml
++++ tests/image_create.ml
+@@ -10,6 +10,7 @@ let create() =
+
+ let () =
+ let cr = create() in
++ printf "With Cairo handle:\n%!";
+ set_source_rgb cr 1. 1. 1.;
+ rectangle cr 0. 0. ~w:300. ~h:300.;
+ fill cr;
+@@ -21,9 +22,9 @@ let () =
+ show_text cr "Hello";
+ Gc.compact(); Gc.compact();
+
+- eprintf "Write image\n%!";
++ eprintf "- Write image\n%!";
+ PNG.write (get_target cr) "test_image.png";
+- eprintf "Finish surface\n%!";
++ eprintf "- Finish surface\n%!";
+ Surface.finish (get_target cr);
+ Gc.compact()
+
diff --git a/graphics/ocaml-cairo/pkg-descr b/graphics/ocaml-cairo/pkg-descr
new file mode 100644
index 000000000000..9e1b6f841de9
--- /dev/null
+++ b/graphics/ocaml-cairo/pkg-descr
@@ -0,0 +1,2 @@
+This is an OCaml binding for the Cairo library, a 2D graphics library
+with support for multiple output devices.
diff --git a/graphics/ocaml-cairo/pkg-plist b/graphics/ocaml-cairo/pkg-plist
new file mode 100644
index 000000000000..f6511b7207d8
--- /dev/null
+++ b/graphics/ocaml-cairo/pkg-plist
@@ -0,0 +1,53 @@
+%%OCAML_SITELIBDIR%%/cairo2/META
+%%OCAML_SITELIBDIR%%/cairo2/cairo.a
+%%OCAML_SITELIBDIR%%/cairo2/cairo.cma
+%%OCAML_SITELIBDIR%%/cairo2/cairo.cmi
+%%OCAML_SITELIBDIR%%/cairo2/cairo.cmt
+%%OCAML_SITELIBDIR%%/cairo2/cairo.cmti
+%%OCAML_SITELIBDIR%%/cairo2/cairo.cmx
+%%OCAML_SITELIBDIR%%/cairo2/cairo.cmxa
+%%OCAML_SITELIBDIR%%/cairo2/cairo.cmxs
+%%OCAML_SITELIBDIR%%/cairo2/cairo.ml
+%%OCAML_SITELIBDIR%%/cairo2/cairo.mli
+%%OCAML_SITELIBDIR%%/cairo2/cairo_ocaml.h
+%%OCAML_SITELIBDIR%%/cairo2/dune-package
+%%OCAML_SITELIBDIR%%/cairo2/libcairo_stubs.a
+%%OCAML_SITELIBDIR%%/cairo2/opam
+%%OCAML_SITELIBDIR%%/stublibs/dllcairo_stubs.so
+%%PORTDOCS%%%%DOCSDIR%%/CHANGES.md
+%%PORTDOCS%%%%DOCSDIR%%/LICENSE.md
+%%PORTDOCS%%%%DOCSDIR%%/README.md
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/arcs.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/clip.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/curve_to.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/dash.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/diagram.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/draw.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/dune
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/fill.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/fill_stroke.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/fill_style.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/gradient.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/graphics_demo.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/mask.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/paint.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/path_close.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/pythagoras_tree.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/recording.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/set_line_cap.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/set_line_join.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/setsourcegradient.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/setsourcergba.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/showtext.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/stroke.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/text.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/text_align_center.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/text_extents.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/text_rotate.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/textextents.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/tips_ellipse.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/tips_font.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/tips_letter.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/word_cloud/cloud.ml
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/word_cloud/cloud.mli
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/word_cloud/run.ml