Enable PHP bindings

resolves: rhbz#2097718
This commit is contained in:
Richard W.M. Jones 2022-06-17 08:31:47 +01:00
parent 86277c2cc0
commit 919dd2dd10
2 changed files with 95 additions and 11 deletions

View File

@ -0,0 +1,90 @@
From 7f5b5b3ac884fbe215267c32a88e3740bd9f0117 Mon Sep 17 00:00:00 2001
From: Geoff Amey <gamey@datto.com>
Date: Wed, 15 Jun 2022 17:06:56 -0400
Subject: [PATCH] php: add arginfo to php bindings
Starting with PHP8, arginfo is mandatory for PHP extensions. This patch
updates the generator for the PHP bindings to generate the arginfo
structures, using the Zend API macros. Only basic arginfo is added,
without full documentation of argument and return types, in order to
ensure compatibility with as many versions of PHP as possible.
(cherry picked from commit ec27979398b0871c1a3e0e244849f8435c9c9a8d)
---
.gitignore | 1 +
generator/php.ml | 37 ++++++++++++++++++++++++++++++++++---
2 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/.gitignore b/.gitignore
index a36ccc86a..356c01fbd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -325,6 +325,7 @@ Makefile.in
/php/extension/configure.in
/php/extension/env
/php/extension/guestfs_php.c
+/php/extension/guestfs_php.dep
/php/extension/install-sh
/php/extension/libtool
/php/extension/ltmain.sh
diff --git a/generator/php.ml b/generator/php.ml
index 5c7ef48e8..acdc7b877 100644
--- a/generator/php.ml
+++ b/generator/php.ml
@@ -130,6 +130,37 @@ typedef size_t guestfs_string_length;
typedef int guestfs_string_length;
#endif
+/* Declare argument info structures */
+ZEND_BEGIN_ARG_INFO_EX(arginfo_create, 0, 0, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_last_error, 0, 0, 1)
+ ZEND_ARG_INFO(0, g)
+ZEND_END_ARG_INFO()
+
+";
+ List.iter (
+ fun { name = shortname; style = ret, args, optargs; } ->
+ let len = List.length args in
+ pr "ZEND_BEGIN_ARG_INFO_EX(arginfo_%s, 0, 0, %d)\n" shortname (len + 1);
+ pr " ZEND_ARG_INFO(0, g)\n";
+ List.iter (
+ function
+ | BufferIn n | Bool n | Int n | Int64 n | OptString n
+ | Pointer(_, n) | String (_, n) | StringList (_, n) ->
+ pr " ZEND_ARG_INFO(0, %s)\n" n
+ ) args;
+
+ List.iter (
+ function
+ | OBool n | OInt n | OInt64 n | OString n | OStringList n ->
+ pr " ZEND_ARG_INFO(0, %s)\n" n
+ ) optargs;
+ pr "ZEND_END_ARG_INFO()\n\n";
+ ) (actions |> external_functions |> sort);
+
+ pr "
+
/* Convert array to list of strings.
* http://marc.info/?l=pecl-dev&m=112205192100631&w=2
*/
@@ -204,12 +235,12 @@ PHP_MINIT_FUNCTION (guestfs_php)
}
static zend_function_entry guestfs_php_functions[] = {
- PHP_FE (guestfs_create, NULL)
- PHP_FE (guestfs_last_error, NULL)
+ PHP_FE (guestfs_create, arginfo_create)
+ PHP_FE (guestfs_last_error, arginfo_last_error)
";
List.iter (
- fun { name } -> pr " PHP_FE (guestfs_%s, NULL)\n" name
+ fun { name } -> pr " PHP_FE (guestfs_%s, arginfo_%s)\n" name name
) (actions |> external_functions |> sort);
pr " { NULL, NULL, NULL }
--
2.31.1

View File

@ -48,7 +48,7 @@ Summary: Access and modify virtual machine disk images
Name: libguestfs Name: libguestfs
Epoch: 1 Epoch: 1
Version: 1.48.3 Version: 1.48.3
Release: 2%{?dist} Release: 3%{?dist}
License: LGPLv2+ License: LGPLv2+
# Build only for architectures that have a kernel # Build only for architectures that have a kernel
@ -106,6 +106,7 @@ Patch0013: 0013-RHEL-Reject-use-of-libguestfs-winsupport-features-ex.patch
Patch0014: 0014-RHEL-Create-etc-crypto-policies-back-ends-opensslcnf.patch Patch0014: 0014-RHEL-Create-etc-crypto-policies-back-ends-opensslcnf.patch
Patch0015: 0015-build-Pick-first-field-in-ID_LIKE.patch Patch0015: 0015-build-Pick-first-field-in-ID_LIKE.patch
Patch0016: 0016-appliance-daemon-disable-lvm2-devicesfile.patch Patch0016: 0016-appliance-daemon-disable-lvm2-devicesfile.patch
Patch0017: 0017-php-add-arginfo-to-php-bindings.patch
%if 0%{patches_touch_autotools} %if 0%{patches_touch_autotools}
BuildRequires: autoconf, automake, libtool, gettext-devel BuildRequires: autoconf, automake, libtool, gettext-devel
@ -198,9 +199,7 @@ BuildRequires: rubygem(json)
BuildRequires: rubygem(rdoc) BuildRequires: rubygem(rdoc)
BuildRequires: rubygem(test-unit) BuildRequires: rubygem(test-unit)
BuildRequires: ruby-irb BuildRequires: ruby-irb
%if !0%{?rhel}
BuildRequires: php-devel BuildRequires: php-devel
%endif
BuildRequires: gobject-introspection-devel BuildRequires: gobject-introspection-devel
BuildRequires: gjs BuildRequires: gjs
%if !0%{?rhel} %if !0%{?rhel}
@ -421,9 +420,7 @@ Language bindings:
lua-guestfs Lua bindings lua-guestfs Lua bindings
ocaml-libguestfs-devel OCaml bindings ocaml-libguestfs-devel OCaml bindings
perl-Sys-Guestfs Perl bindings perl-Sys-Guestfs Perl bindings
%if !0%{?rhel}
php-libguestfs PHP bindings php-libguestfs PHP bindings
%endif
python3-libguestfs Python 3 bindings python3-libguestfs Python 3 bindings
ruby-libguestfs Ruby bindings ruby-libguestfs Ruby bindings
%if !0%{?rhel} %if !0%{?rhel}
@ -645,7 +642,6 @@ Provides: ruby(guestfs) = %{version}
ruby-%{name} contains Ruby bindings for %{name}. ruby-%{name} contains Ruby bindings for %{name}.
%if !0%{?rhel}
%package -n php-%{name} %package -n php-%{name}
Summary: PHP bindings for %{name} Summary: PHP bindings for %{name}
Requires: %{name}%{?_isa} = %{epoch}:%{version}-%{release} Requires: %{name}%{?_isa} = %{epoch}:%{version}-%{release}
@ -654,7 +650,6 @@ Requires: php(api) = %{php_core_api}
%description -n php-%{name} %description -n php-%{name}
php-%{name} contains PHP bindings for %{name}. php-%{name} contains PHP bindings for %{name}.
%endif
%package -n lua-guestfs %package -n lua-guestfs
@ -790,7 +785,6 @@ fi
%endif %endif
%if 0%{?rhel} && !0%{?eln} %if 0%{?rhel} && !0%{?eln}
--with-qemu="qemu-kvm qemu-system-%{_build_arch} qemu" \ --with-qemu="qemu-kvm qemu-system-%{_build_arch} qemu" \
--disable-php \
%endif %endif
%ifnarch %{golang_arches} %ifnarch %{golang_arches}
--disable-golang \ --disable-golang \
@ -1089,13 +1083,11 @@ rm ocaml/html/.gitignore
%{_mandir}/man3/guestfs-ruby.3* %{_mandir}/man3/guestfs-ruby.3*
%if !0%{?rhel}
%files -n php-%{name} %files -n php-%{name}
%doc php/README-PHP %doc php/README-PHP
%dir %{_sysconfdir}/php.d %dir %{_sysconfdir}/php.d
%{_sysconfdir}/php.d/guestfs_php.ini %{_sysconfdir}/php.d/guestfs_php.ini
%{_libdir}/php/modules/guestfs_php.so %{_libdir}/php/modules/guestfs_php.so
%endif
%files -n lua-guestfs %files -n lua-guestfs
@ -1149,7 +1141,7 @@ rm ocaml/html/.gitignore
%changelog %changelog
* Mon Jun 13 2022 Richard W.M. Jones <rjones@redhat.com> - 1:1.48.3-2 * Fri Jun 17 2022 Richard W.M. Jones <rjones@redhat.com> - 1:1.48.3-3
- Rebase to new stable branch version 1.48.3 - Rebase to new stable branch version 1.48.3
resolves: rhbz#2059285 resolves: rhbz#2059285
- Disable 5-level page tables when using -cpu max - Disable 5-level page tables when using -cpu max
@ -1165,6 +1157,8 @@ rm ocaml/html/.gitignore
resolves: rhbz#2033247 resolves: rhbz#2033247
- Fix lvm-set-filter failed in guestfish with the latest lvm2 package - Fix lvm-set-filter failed in guestfish with the latest lvm2 package
resolves: rhbz#1965941 resolves: rhbz#1965941
- Enable PHP bindings
resolves: rhbz#2097718
* Thu Mar 17 2022 Richard W.M. Jones <rjones@redhat.com> - 1:1.48.0-2 * Thu Mar 17 2022 Richard W.M. Jones <rjones@redhat.com> - 1:1.48.0-2
- Disable signature checking in librpm - Disable signature checking in librpm