Merge pull request #271678 from shyim/frankenphp-darwin-support

frankenphp: add darwin support
This commit is contained in:
Pol Dellaiera 2023-12-05 16:31:30 +01:00 committed by GitHub
commit 17a63a0abc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 5 deletions

View file

@ -5,6 +5,8 @@
, php
, testers
, frankenphp
, darwin
, pkg-config
, runCommand
, writeText
}:
@ -13,6 +15,9 @@ let
phpEmbedWithZts = php.override {
embedSupport = true;
ztsSupport = true;
staticSupport = stdenv.isDarwin;
zendSignalsSupport = false;
zendMaxExecutionTimersSupport = stdenv.isLinux;
};
phpUnwrapped = phpEmbedWithZts.unwrapped;
phpConfig = "${phpUnwrapped.dev}/bin/php-config";
@ -36,6 +41,7 @@ in buildGoModule rec {
vendorHash = "sha256-Lgj/pFtSQIgjrycajJ1zNY3ytvArmuk0E3IjsAzsNdM=";
buildInputs = [ phpUnwrapped ] ++ phpUnwrapped.buildInputs;
nativeBuildInputs = lib.optionals stdenv.isDarwin [ pkg-config darwin.cctools darwin.autoSignDarwinBinariesHook ];
subPackages = [ "frankenphp" ];
@ -52,7 +58,15 @@ in buildGoModule rec {
export CGO_CFLAGS="$(${phpConfig} --includes)"
export CGO_LDFLAGS="-DFRANKENPHP_VERSION=${version} \
$(${phpConfig} --ldflags) \
-Wl,--start-group $(${phpConfig} --libs) -Wl,--end-group"
$(${phpConfig} --libs)"
'' + lib.optionalString stdenv.isDarwin ''
# replace hard-code homebrew path
substituteInPlace ../frankenphp.go \
--replace "-L/opt/homebrew/opt/libiconv/lib" "-L${darwin.libiconv}/lib"
# remove when https://github.com/dunglas/frankenphp/pull/331 is merged and released
substituteInPlace ../frankenphp.go \
--replace "darwin pkg-config: libxml-2.0 sqlite3" "darwin pkg-config: libxml-2.0"
'';
doCheck = false;
@ -82,7 +96,7 @@ in buildGoModule rec {
homepage = "https://github.com/dunglas/frankenphp";
license = licenses.mit;
mainProgram = "frankenphp";
maintainers = with maintainers; [ gaelreyrol ];
platforms = platforms.linux;
maintainers = with maintainers; [ gaelreyrol shyim ];
platforms = platforms.linux ++ platforms.darwin;
};
}

View file

@ -53,7 +53,10 @@ let
, argon2Support ? true
, cgotoSupport ? false
, embedSupport ? false
, staticSupport ? false
, ipv6Support ? true
, zendSignalsSupport ? true
, zendMaxExecutionTimersSupport ? false
, systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd
, valgrindSupport ? !stdenv.isDarwin && lib.meta.availableOn stdenv.hostPlatform valgrind
, ztsSupport ? apxs2Support
@ -236,7 +239,6 @@ let
# PCRE
++ [ "--with-external-pcre=${pcre2.dev}" ]
# Enable sapis
++ lib.optional (!cgiSupport) "--disable-cgi"
++ lib.optional (!cliSupport) "--disable-cli"
@ -250,11 +252,14 @@ let
++ lib.optional apxs2Support "--with-apxs2=${apacheHttpd.dev}/bin/apxs"
++ lib.optional argon2Support "--with-password-argon2=${libargon2}"
++ lib.optional cgotoSupport "--enable-re2c-cgoto"
++ lib.optional embedSupport "--enable-embed"
++ lib.optional embedSupport "--enable-embed${lib.optionalString staticSupport "=static"}"
++ lib.optional (!ipv6Support) "--disable-ipv6"
++ lib.optional systemdSupport "--with-fpm-systemd"
++ lib.optional valgrindSupport "--with-valgrind=${valgrind.dev}"
++ lib.optional ztsSupport "--enable-zts"
++ lib.optional staticSupport "--enable-static"
++ lib.optional (!zendSignalsSupport) ["--disable-zend-signals"]
++ lib.optional zendMaxExecutionTimersSupport "--enable-zend-max-execution-timers"
# Sendmail