Skip to content

Commit

Permalink
Updated Build Configuration for PHP Extension to fix issue building o…
Browse files Browse the repository at this point in the history
…n 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. https://github.com/protocolbuffers/protobuf/blob/72707c38f3580d5ce76eda1d736ddad468219b57/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=#17903 from gwharton:main ebfc0e3
PiperOrigin-RevId: 700529908
  • Loading branch information
gwharton authored and copybara-github committed Nov 27, 2024
1 parent 30ed452 commit 525e16a
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions php/ext/google/protobuf/config.w32
Original file line number Diff line number Diff line change
@@ -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");
}

0 comments on commit 525e16a

Please sign in to comment.