Browse Source

feat: set SAPI version

Kévin Dunglas 1 year ago
parent
commit
09b2282441
7 changed files with 12 additions and 6 deletions
  1. 1 1
      .circleci/config.yml
  2. 1 1
      .github/workflows/static.yml
  3. 1 1
      Dockerfile
  4. 1 1
      alpine.Dockerfile
  5. 1 1
      frankenphp.c
  6. 6 0
      frankenphp.h
  7. 1 1
      static-builder.Dockerfile

+ 1 - 1
.circleci/config.yml

@@ -35,7 +35,7 @@ jobs:
           working_directory: static-php-cli/
           name: Set CGO flags
           command: |
-            echo "export CGO_CFLAGS='$(./buildroot/bin/php-config --includes | sed s#-I/#-I$PWD/buildroot/#g)'" >> "$BASH_ENV"
+            echo "export CGO_CFLAGS='-DFRANKENPHP_VERSION=$CIRCLE_SHA1 $(./buildroot/bin/php-config --includes | sed s#-I/#-I$PWD/buildroot/#g)'" >> "$BASH_ENV"
             echo "export CGO_LDFLAGS='-framework CoreFoundation -framework SystemConfiguration $(./buildroot/bin/php-config --ldflags) $(./buildroot/bin/php-config --libs)'" >> "$BASH_ENV"
             echo "export PHP_VERSION='$(./buildroot/bin/php-config --version)'" >> "$BASH_ENV"
       - restore_cache:

+ 1 - 1
.github/workflows/static.yml

@@ -88,7 +88,7 @@ jobs:
       - name: Set CGO flags
         working-directory: static-php-cli/
         run: |
-           echo "CGO_CFLAGS=$(./buildroot/bin/php-config --includes | sed s#-I/#-I$PWD/buildroot/#g)" >> "$GITHUB_ENV"
+           echo "CGO_CFLAGS=-DFRANKENPHP_VERSION=${{ github.sha }} $(./buildroot/bin/php-config --includes | sed s#-I/#-I$PWD/buildroot/#g)" >> "$GITHUB_ENV"
            echo "CGO_LDFLAGS=-framework CoreFoundation -framework SystemConfiguration $(./buildroot/bin/php-config --ldflags) $(./buildroot/bin/php-config --libs)" >> "$GITHUB_ENV"
            echo "PHP_VERSION=$(./buildroot/bin/php-config --version)" >> "$GITHUB_ENV"
 

+ 1 - 1
Dockerfile

@@ -83,7 +83,7 @@ COPY --link testdata testdata
 
 # todo: automate this?
 # see https://github.com/docker-library/php/blob/master/8.2/bookworm/zts/Dockerfile#L57-L59 for PHP values
-ENV CGO_LDFLAGS="-lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLAGS" CGO_CFLAGS=$PHP_CFLAGS CGO_CPPFLAGS=$PHP_CPPFLAGS
+ENV CGO_LDFLAGS="-lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLAGS" CGO_CFLAGS="-DFRANKENPHP_VERSION=$FRANKENPHP_VERSION $PHP_CFLAGS" CGO_CPPFLAGS=$PHP_CPPFLAGS
 
 RUN cd caddy/frankenphp && \
     GOBIN=/usr/local/bin go install -ldflags "-X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy'" && \

+ 1 - 1
alpine.Dockerfile

@@ -80,7 +80,7 @@ COPY --link testdata testdata
 
 # todo: automate this?
 # see https://github.com/docker-library/php/blob/master/8.2/bookworm/zts/Dockerfile#L57-L59 for php values
-ENV CGO_LDFLAGS="-lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLAGS" CGO_CFLAGS=$PHP_CFLAGS CGO_CPPFLAGS=$PHP_CPPFLAGS
+ENV CGO_LDFLAGS="-lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLAGS" CGO_CFLAGS="-DFRANKENPHP_VERSION=$FRANKENPHP_VERSION $PHP_CFLAGS" CGO_CPPFLAGS=$PHP_CPPFLAGS
 
 RUN cd caddy/frankenphp && \
 	GOBIN=/usr/local/bin go install -ldflags "-X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy'" && \

+ 1 - 1
frankenphp.c

@@ -310,7 +310,7 @@ static zend_module_entry frankenphp_module = {
     NULL,			/* request initialization */
     NULL,			/* request shutdown */
     NULL,			/* information */
-    "dev",
+    TOSTRING(FRANKENPHP_VERSION),
     STANDARD_MODULE_PROPERTIES
 };
 

+ 6 - 0
frankenphp.h

@@ -5,6 +5,12 @@
 #include <stdbool.h>
 #include <Zend/zend_types.h>
 
+#ifndef FRANKENPHP_VERSION
+#define FRANKENPHP_VERSION dev
+#endif
+#define STRINGIFY(x) #x
+#define TOSTRING(x) STRINGIFY(x)
+
 typedef struct frankenphp_version {
 	unsigned char major_version;
 	unsigned char minor_version;

+ 1 - 1
static-builder.Dockerfile

@@ -77,7 +77,7 @@ COPY C-Thread-Pool C-Thread-Pool
 
 RUN cd caddy/frankenphp && \
     CGO_CFLAGS="$(/static-php-cli/buildroot/bin/php-config --includes | sed s#-I/#-I/static-php-cli/buildroot/#g)" \
-    CGO_LDFLAGS="$(/static-php-cli/buildroot/bin/php-config --ldflags) $(/static-php-cli/buildroot/bin/php-config --libs | sed -e 's/-lgcc_s//g')" \
+    CGO_LDFLAGS="-DFRANKENPHP_VERSION=$FRANKENPHP_VERSION $(/static-php-cli/buildroot/bin/php-config --ldflags) $(/static-php-cli/buildroot/bin/php-config --libs | sed -e 's/-lgcc_s//g')" \
     LIBPHP_VERSION="$(/static-php-cli/buildroot/bin/php-config --version)" \
     go build -buildmode=pie -tags "cgo netgo osusergo static_build" -ldflags "-linkmode=external -extldflags -static-pie -s -w -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $LIBPHP_VERSION Caddy'" && \
     ./frankenphp version