public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-util/coccinelle/files/, dev-util/coccinelle/
Date: Thu, 29 May 2025 16:49:23 +0000 (UTC)	[thread overview]
Message-ID: <1748537300.748891cc837c6ec46116243941ab8299c244438d.sam@gentoo> (raw)

commit:     748891cc837c6ec46116243941ab8299c244438d
Author:     Michal Privoznik <michal.privoznik <AT> gmail <DOT> com>
AuthorDate: Tue May 27 06:17:03 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu May 29 16:48:20 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=748891cc

dev-util/coccinelle: Add 1.3.0

There was new release [1] which compared to what we currently
have in portage introduces plenty of new features (many of which
are aimed at supporting newer C/C++ standards), though some were
introduced in the 1.2.0 release.

The patches applied are either taken from 1.1.1 version (when
they apply cleanly) or rebased
(coccinelle-1.3.0-find-xxdate.patch) where the line removed
needed to be changed slightly.

Then there's one more patch that's new:
coccinelle-1.3.0-python-3.13.patch which is a patch for pyml
(ocaml bindings to python) so that python-3.13 is supported. It's
backport of the following upstream commit [2]. Unfortunately,
pyml is not in portage yet, so coccinelle uses the bundled
version which hasn't been updated in ages.

1: https://coccinelle.gitlabpages.inria.fr/website/distrib/changes.html
2: https://github.com/ocamllibs/pyml/commit/68bf34b79bd43d145fbf33f8bbd7c4eb520cae34
Signed-off-by: Michal Privoznik <michal.privoznik <AT> gmail.com>
Part-of: https://github.com/gentoo/gentoo/pull/42276
Closes: https://github.com/gentoo/gentoo/pull/42276
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-util/coccinelle/Manifest                       |   1 +
 dev-util/coccinelle/coccinelle-1.3.0.ebuild        | 137 +++++++++++++++++++++
 .../files/coccinelle-1.3.0-find-xxdate.patch       |  11 ++
 .../files/coccinelle-1.3.0-python-3.13.patch       |  95 ++++++++++++++
 4 files changed, 244 insertions(+)

diff --git a/dev-util/coccinelle/Manifest b/dev-util/coccinelle/Manifest
index 55489c38c940..85f4f384e5fc 100644
--- a/dev-util/coccinelle/Manifest
+++ b/dev-util/coccinelle/Manifest
@@ -1 +1,2 @@
 DIST coccinelle-1.1.1.tar.bz2 2118055 BLAKE2B 7efb0c86432c88daa1bce2710acdf2f62b6210c69245b4896ea8c5e39a0b28c538d94deae6ed1544e0ced66b2baa6edf8670f5e02dad40c2d1f5562326ce23e3 SHA512 fcb83203c91dae18122cf95f7db931d2e1576559b74a7a1c664c795437904acdffa005a8b9e732c1d99c8f0ab1c5f529d143eafe79c6397d28c4879848afca45
+DIST coccinelle-1.3.0.tar.bz2 2187014 BLAKE2B a56a85ead694cea26c142ebdf2e7e917bee5310758aeac3a9442b3a99bc52687325ec550362e29a6b922744ea08f76e64fdd65b0da5ffb8baa6713bb66b95d61 SHA512 ba04af40958a39997f01332c01533bf7889a506ce00e95ddbd5d5499cf62c228a1c30642536d2a46da8c58a70a781adc52c9421bbf9410bd3d41a599ce2375d9

diff --git a/dev-util/coccinelle/coccinelle-1.3.0.ebuild b/dev-util/coccinelle/coccinelle-1.3.0.ebuild
new file mode 100644
index 000000000000..6d6314613e3c
--- /dev/null
+++ b/dev-util/coccinelle/coccinelle-1.3.0.ebuild
@@ -0,0 +1,137 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{10..14} )
+inherit autotools bash-completion-r1 elisp-common python-single-r1
+
+DESCRIPTION="Program matching and transformation engine"
+HOMEPAGE="https://coccinelle.gitlabpages.inria.fr/website/ https://gitlab.inria.fr/coccinelle/coccinelle"
+SRC_URI="https://gitlab.inria.fr/coccinelle/coccinelle/-/archive/${PV}/${P}.tar.bz2"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+IUSE="doc emacs +ocamlopt pcre python test"
+REQUIRED_USE="${PYTHON_REQUIRED_USE}"
+# Test failures need investigation
+RESTRICT="strip !test? ( test ) test"
+
+RDEPEND="
+	>=dev-lang/ocaml-4.08.0:=[ocamlopt?]
+	dev-ml/sexplib:=[ocamlopt(+)?]
+	dev-ml/menhir:=[ocamlopt?]
+	dev-ml/camlp4:=[ocamlopt?]
+	dev-ml/parmap:=[ocamlopt?]
+	dev-ml/findlib:=[ocamlopt?]
+	dev-ml/stdcompat:=
+	emacs? ( >=app-editors/emacs-23.1:* )
+	pcre? (
+		dev-libs/libpcre
+		dev-ml/pcre-ocaml:=[ocamlopt?]
+	)
+	python? ( ${PYTHON_DEPS} )
+"
+DEPEND="${RDEPEND}"
+# dev-texlive/texlive-fontsextra contains 'ifsym.sty'
+BDEPEND="
+	virtual/pkgconfig
+	doc? (
+		dev-texlive/texlive-latexextra
+		dev-texlive/texlive-fontsextra
+		virtual/latex-base
+		dev-tex/hevea
+	)
+"
+
+DOCS=( authors.txt bugs.txt changes.txt credits.txt readme.txt )
+PATCHES=(
+	"${FILESDIR}"/${PN}-1.1.1-bash-completion.patch
+	"${FILESDIR}"/${P}-find-xxdate.patch
+	"${FILESDIR}"/${PN}-1.1.1-shuffle.patch
+	"${FILESDIR}"/${P}-python-3.13.patch
+)
+SITEFILE=50coccinelle-gentoo.el
+
+pkg_setup() {
+	use python && python-single-r1_pkg_setup
+}
+
+src_prepare() {
+	default
+
+	eautoreconf
+
+	if use python ; then
+		# Fix python install location
+		sed -e "s:\$(LIBDIR)/python:$(python_get_sitedir):" \
+			-i Makefile || die
+	fi
+}
+
+src_configure() {
+	local myeconfargs=(
+		--enable-ocaml
+		--with-bash-completion="$(get_bashcompdir)"
+		--with-python="${EPYTHON}"
+
+		$(use_enable python)
+		$(use_enable pcre)
+		$(use_enable pcre pcre-syntax)
+		$(use_enable ocamlopt opt)
+	)
+
+	CONFIG_SHELL="${BROOT}"/bin/bash econf "${myeconfargs[@]}"
+}
+
+src_compile() {
+	export TARGET_SPATCH=$(usev !ocamlopt 'byte-only')
+
+	emake VERBOSE=yes -j1 $(usex ocamlopt 'all.opt' 'all-dev')
+
+	if use doc ; then
+		VARTEXFONTS="${T}"/fonts emake VERBOSE=yes docs
+	fi
+
+	if use emacs ; then
+		elisp-compile editors/emacs/cocci.el || die
+	fi
+}
+
+src_test() {
+	# TODO: See Fedora's method?
+	# https://src.fedoraproject.org/rpms/coccinelle/blob/rawhide/f/coccinelle.spec#_231
+	emake VERBOSE=yes check $(usev python pycocci-check)
+}
+
+src_install() {
+	emake DESTDIR="${D}" PREFIX="${EPREFIX}" VERBOSE=yes -j1 install
+
+	if use python ; then
+		python_optimize
+	else
+		rm -rf "${ED}/usr/$(get_libdir)/${PN}/python" || die
+	fi
+
+	if use emacs ; then
+		elisp-install ${PN} editors/emacs/*
+		elisp-site-file-install "${FILESDIR}"/${SITEFILE}
+	fi
+
+	einstalldocs
+	use doc && dodoc docs/manual/*.pdf
+
+	newdoc editors/vim/README README-vim
+	rm editors/vim/README || die
+	insinto /usr/share/vim/vimfiles
+	doins -r editors/vim/*
+}
+
+pkg_postinst() {
+	use emacs && elisp-site-regen
+}
+
+pkg_postrm() {
+	use emacs && elisp-site-regen
+}

diff --git a/dev-util/coccinelle/files/coccinelle-1.3.0-find-xxdate.patch b/dev-util/coccinelle/files/coccinelle-1.3.0-find-xxdate.patch
new file mode 100644
index 000000000000..915e3f1e7bb3
--- /dev/null
+++ b/dev-util/coccinelle/files/coccinelle-1.3.0-find-xxdate.patch
@@ -0,0 +1,11 @@
+--- a/docs/manual/find-xxdate
++++ b/docs/manual/find-xxdate
+@@ -9,7 +9,7 @@
+ # Otherwise, a warning is printed on stderr and the script returns 1
+ 
+ file=xxdate.exe
+-directories="$(opam var hevea:lib 2>/dev/null) /usr/lib64/hevea /usr/share/hevea /usr/local/lib/hevea /opt/local/share/hevea"
++directories="/usr/lib/hevea /usr/lib64/hevea /usr/share/hevea /usr/local/lib/hevea /opt/local/share/hevea"
+ 
+ for dir in ${directories}; do
+   fullpath=${dir}/${file};

diff --git a/dev-util/coccinelle/files/coccinelle-1.3.0-python-3.13.patch b/dev-util/coccinelle/files/coccinelle-1.3.0-python-3.13.patch
new file mode 100644
index 000000000000..560d16b25753
--- /dev/null
+++ b/dev-util/coccinelle/files/coccinelle-1.3.0-python-3.13.patch
@@ -0,0 +1,95 @@
+diff --git a/Makefile b/Makefile
+index c59461b..eef2c2a 100644
+--- a/bundles/pyml/pyml-current/Makefile
++++ b/bundles/pyml/pyml-current/Makefile
+@@ -207,13 +207,13 @@ test : test.bytecode $(TESTOPT)
+ 
+ .PHONY : test.bytecode
+ test.bytecode : pyml_tests.bytecode numpy_tests.bytecode
+-	./pyml_tests.bytecode
+-	./numpy_tests.bytecode
++	./pyml_tests.bytecode $(TEST_OPTIONS)
++	./numpy_tests.bytecode $(TEST_OPTIONS)
+ 
+ .PHONY : test.native
+ test.native : pyml_tests.native numpy_tests.native
+-	./pyml_tests.native
+-	./numpy_tests.native
++	./pyml_tests.native $(TEST_OPTIONS)
++	./numpy_tests.native $(TEST_OPTIONS)
+ 
+ .PHONY : install
+ install : $(INSTALL_FILES)
+diff --git a/pyml_stubs.c b/pyml_stubs.c
+index 149695c..40e3481 100644
+--- a/bundles/pyml/pyml-current/pyml_stubs.c
++++ b/bundles/pyml/pyml-current/pyml_stubs.c
+@@ -136,8 +136,6 @@ file_of_file_descr(value file_descr, const char *mode)
+ }
+ #endif
+ 
+-static void *Python27__PyObject_NextNotImplemented;
+-
+ /* Global variables for the library */
+ 
+ /* version_major != 0 iff the library is initialized */
+@@ -743,15 +741,18 @@ guess_debug_build()
+     PyObject *debug_build_py;
+     char *py_debug_str = "Py_DEBUG";
+     if (version_major >= 3) {
+-        py_debug = Python3_PyUnicode_FromStringAndSize(py_debug_str, 8);
++        py_debug = Python3_PyUnicode_FromStringAndSize(py_debug_str, strlen(py_debug_str));
+     }
+     else {
+-        py_debug = Python2_PyString_FromStringAndSize(py_debug_str, 8);
++        py_debug = Python2_PyString_FromStringAndSize(py_debug_str, strlen(py_debug_str));
+     }
+     assert(py_debug);
+     args = singleton(py_debug);
+     debug_build_py = Python_PyObject_Call(get_config_var, args, NULL);
+-    assert(debug_build_py);
++    if (!debug_build_py) {
++        Python_PyErr_Print();
++        caml_failwith("Cannot check for debug build");
++    }
+     if (debug_build_py == Python__Py_NoneStruct) {
+         debug_build = 0;
+     }
+@@ -797,8 +798,6 @@ py_load_library(value filename_ocaml, value debug_build_ocaml)
+         Python27_PyCapsule_New = resolve("PyCapsule_New");
+         Python27_PyCapsule_GetPointer = resolve("PyCapsule_GetPointer");
+         Python27_PyCapsule_IsValid = resolve("PyCapsule_IsValid");
+-        Python27__PyObject_NextNotImplemented =
+-            resolve("_PyObject_NextNotImplemented");
+     }
+     Python_PyObject_CallFunctionObjArgs =
+         resolve("PyObject_CallFunctionObjArgs");
+@@ -970,6 +969,17 @@ enum pytype_labels {
+     Set
+ };
+ 
++static bool is_iterable(PyObject *obj) {
++    PyObject *iter = Python_PyObject_GetIter(obj);
++    if (iter) {
++        Py_DECREF(iter);
++        return true;
++    } else {
++        Python_PyErr_Clear();
++        return false;
++    }
++}
++
+ CAMLprim value
+ pytype(value object_ocaml)
+ {
+@@ -1035,8 +1045,7 @@ pytype(value object_ocaml)
+     else if (ob_type == Python_PySet_Type) {
+         result = Set;
+     }
+-    else if (typeobj->tp_iternext != NULL &&
+-        typeobj->tp_iternext != &Python27__PyObject_NextNotImplemented) {
++    else if (is_iterable(object)) {
+         result = Iter;
+     }
+     else {
+


             reply	other threads:[~2025-05-29 16:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-29 16:49 Sam James [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-09-13 17:18 [gentoo-commits] repo/gentoo:master commit in: dev-util/coccinelle/files/, dev-util/coccinelle/ Alfredo Tupone
2024-06-06  6:41 Alfredo Tupone
2022-10-29 18:26 Sam James
2016-06-28 19:04 Michał Górny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1748537300.748891cc837c6ec46116243941ab8299c244438d.sam@gentoo \
    --to=sam@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox