Merge pull request #128521 from aanderse/php-mkExtension

php: expose mkExtension
This commit is contained in:
Elis Hirwing 2021-06-30 13:16:43 +02:00 committed by GitHub
commit f091739337
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 68 additions and 67 deletions

View File

@ -133,7 +133,7 @@ let
unwrapped = php;
# Select the right php tests for the php version
tests = nixosTests."php${lib.strings.replaceStrings [ "." ] [ "" ] (lib.versions.majorMinor php.version)}";
inherit (php-packages) extensions buildPecl;
inherit (php-packages) extensions buildPecl mkExtension;
packages = php-packages.tools;
meta = php.meta // {
outputsToInstall = [ "out" ];

View File

@ -59,6 +59,73 @@ lib.makeScope pkgs.newScope (self: with self; {
pname = "php-${pname}";
});
# Function to build an extension which is shipped as part of the php
# source, based on the php version.
#
# Name passed is the name of the extension and is automatically used
# to add the configureFlag "--enable-${name}", which can be overriden.
#
# Build inputs is used for extra deps that may be needed. And zendExtension
# will mark the extension as a zend extension or not.
mkExtension =
{ name
, configureFlags ? [ "--enable-${name}" ]
, internalDeps ? [ ]
, postPhpize ? ""
, buildInputs ? [ ]
, zendExtension ? false
, doCheck ? true
, ...
}@args: stdenv.mkDerivation ((builtins.removeAttrs args [ "name" ]) // {
pname = "php-${name}";
extensionName = name;
inherit (php.unwrapped) version src;
sourceRoot = "php-${php.version}/ext/${name}";
enableParallelBuilding = true;
nativeBuildInputs = [ php.unwrapped autoconf pkg-config re2c ];
inherit configureFlags internalDeps buildInputs
zendExtension doCheck;
prePatch = "pushd ../..";
postPatch = "popd";
preConfigure = ''
nullglobRestore=$(shopt -p nullglob)
shopt -u nullglob # To make ?-globbing work
# Some extensions have a config0.m4 or config9.m4
if [ -f config?.m4 ]; then
mv config?.m4 config.m4
fi
$nullglobRestore
phpize
${postPhpize}
${lib.concatMapStringsSep "\n"
(dep: "mkdir -p ext; ln -s ${dep.dev}/include ext/${dep.extensionName}")
internalDeps}
'';
checkPhase = "runHook preCheck; NO_INTERACTON=yes make test; runHook postCheck";
outputs = [ "out" "dev" ];
installPhase = ''
mkdir -p $out/lib/php/extensions
cp modules/${name}.so $out/lib/php/extensions/${name}.so
mkdir -p $dev/include
${rsync}/bin/rsync -r --filter="+ */" \
--filter="+ *.h" \
--filter="- *" \
--prune-empty-dirs \
. $dev/include/
'';
meta = {
description = "PHP upstream extension: ${name}";
inherit (php.meta) maintainers homepage license;
};
});
php = phpPackage;
# This is a set of interactive tools based on PHP.
@ -171,72 +238,6 @@ lib.makeScope pkgs.newScope (self: with self; {
yaml = callPackage ../development/php-packages/yaml { };
} // (
let
# Function to build a single php extension based on the php version.
#
# Name passed is the name of the extension and is automatically used
# to add the configureFlag "--enable-${name}", which can be overriden.
#
# Build inputs is used for extra deps that may be needed. And zendExtension
# will mark the extension as a zend extension or not.
mkExtension =
{ name
, configureFlags ? [ "--enable-${name}" ]
, internalDeps ? [ ]
, postPhpize ? ""
, buildInputs ? [ ]
, zendExtension ? false
, doCheck ? true
, ...
}@args: stdenv.mkDerivation ((builtins.removeAttrs args [ "name" ]) // {
pname = "php-${name}";
extensionName = name;
inherit (php.unwrapped) version src;
sourceRoot = "php-${php.version}/ext/${name}";
enableParallelBuilding = true;
nativeBuildInputs = [ php.unwrapped autoconf pkg-config re2c ];
inherit configureFlags internalDeps buildInputs
zendExtension doCheck;
prePatch = "pushd ../..";
postPatch = "popd";
preConfigure = ''
nullglobRestore=$(shopt -p nullglob)
shopt -u nullglob # To make ?-globbing work
# Some extensions have a config0.m4 or config9.m4
if [ -f config?.m4 ]; then
mv config?.m4 config.m4
fi
$nullglobRestore
phpize
${postPhpize}
${lib.concatMapStringsSep "\n"
(dep: "mkdir -p ext; ln -s ${dep.dev}/include ext/${dep.extensionName}")
internalDeps}
'';
checkPhase = "runHook preCheck; NO_INTERACTON=yes make test; runHook postCheck";
outputs = [ "out" "dev" ];
installPhase = ''
mkdir -p $out/lib/php/extensions
cp modules/${name}.so $out/lib/php/extensions/${name}.so
mkdir -p $dev/include
${rsync}/bin/rsync -r --filter="+ */" \
--filter="+ *.h" \
--filter="- *" \
--prune-empty-dirs \
. $dev/include/
'';
meta = {
description = "PHP upstream extension: ${name}";
inherit (php.meta) maintainers homepage license;
};
});
# This list contains build instructions for different modules that one may
# want to build.
#