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: 68bf34b79b
Signed-off-by: Michal Privoznik <michal.privoznik@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@gentoo.org>
This commit is contained in:
Michal Privoznik 2025-05-27 08:17:03 +02:00 committed by Sam James
parent 2929a88894
commit 748891cc83
No known key found for this signature in database
GPG Key ID: 738409F520DF9190
4 changed files with 244 additions and 0 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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};

View File

@ -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 {