Updated Build Configuration for PHP Extension to fix issue building on Windows (#17903)

Protobuf PHP Extension

When building the module under Linux, the config.m4 file compiles the module files "arena.c array.c convert.c def.c map.c message.c names.c php-upb.c protobuf.c" and in addition it compiles the third party file "third_party/utf8_range/utf8_range.c"

When building under Windows, a separate config.w32 file is used which compiles the same "arena.c array.c convert.c def.c map.c message.c names.c php-upb.c protobuf.c" module files, but in addition, it compiles *.c from the third_party/utf8_range subfolder. Some of these files are not compatible with windows due to including <sys/time.h>. Only the utf8_range.c file is required, as shown under the config.m4 linux build configuration.

This PR modifies the build script config.w32 so that builds under windows only compile the same files that is compiled under linux. It removes the wildcard compile of the entire third party include, and thus resolves the build error under Windows.

Here is the linux build config.m4 file for reference. 72707c38f3/php/ext/google/protobuf/config.m4 (L1-L11)

Verified working under :

Microsoft Windows 11 Pro 24H2 x64
Micrsoft Visual Studio Community 2022  (17.0 - 14.41.34120) x64 Build Environment
Builds against PHP 8.3.10 from source in full PHP recompile

Closes #17903

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/17903 from gwharton:main ebfc0e3b52
PiperOrigin-RevId: 700529908
pull/19406/head
Graham Wharton 3 months ago committed by Copybara-Service
parent 30ed452edd
commit 525e16a875
  1. 9
      php/ext/google/protobuf/config.w32

@ -1,14 +1,7 @@
ARG_ENABLE("protobuf", "whether to enable Protobuf extension", "no");
if (PHP_PROTOBUF != "no") {
var PHP_PROTOBUF_SRC_ARRAY = glob(configure_module_dirname + "/third_party/utf8_range/*.c");
var PHP_PROTOBUF_SOURCES=" ";
for (var i=0; i<PHP_PROTOBUF_SRC_ARRAY.length; ++i) {
var basename = FSO.GetFileName(PHP_PROTOBUF_SRC_ARRAY[i]);
PHP_PROTOBUF_SOURCES = PHP_PROTOBUF_SOURCES + " " + basename;
}
ADD_SOURCES(configure_module_dirname + "/third_party/utf8_range", PHP_PROTOBUF_SOURCES, "PROTOBUF");
ADD_SOURCES(configure_module_dirname + "/third_party/utf8_range", "utf8_range.c", "PROTOBUF");
ADD_FLAG("CFLAGS_PROTOBUF", "/I" + configure_module_dirname + "/third_party/utf8_range");
EXTENSION("protobuf", "arena.c array.c convert.c def.c map.c message.c names.c php-upb.c protobuf.c");
}

Loading…
Cancel
Save