Skip to content

Commit

Permalink
Enable building PHP extension on Windows (#13097)
Browse files Browse the repository at this point in the history
This PR adds a config.w32 for the PHP extension and includes it in the tgz for PECL.
I used this to build php_protobuf.dll for PHP 8.2.7.
See phalcon/cphalcon#16318 (comment) for the request to build the extension and the result.

Please review and merge.

Closes #13097

COPYBARA_INTEGRATE_REVIEW=#13097 from Jan-E:php-windows 4259af1
PiperOrigin-RevId: 542050878
  • Loading branch information
Jan-E authored and copybara-github committed Jun 20, 2023
1 parent 33b8c45 commit 4d9bbac
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions php/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ pkg_files(
]) + [
"//:LICENSE",
"ext/google/protobuf/config.m4",
"ext/google/protobuf/config.w32",
"ext/google/protobuf/wkt.inc",
],
)
Expand Down
14 changes: 14 additions & 0 deletions php/ext/google/protobuf/config.w32
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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_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");
}

1 comment on commit 4d9bbac

@gwharton
Copy link
Contributor

@gwharton gwharton commented on 4d9bbac Aug 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is over a year ago that this was committed, but the module no longer builds under windows, as highlighted by this issue.

#17852

The above config attempts to compile all files in utf8_range, but a couple of them include <sys/time.h> which isn't compatible with windows. Only one file from the utf8_range library is needed, as is shown in the Linux build config which only compiles third_party/utf8_range/utf8_range.c

I added a workaround in the issue, but it could probably be simplified even further, fixing the issue.

I'm happy to put the work in and produce a PR, just let me know, but perhaps could gain more acceptance if it was to come from yourself.

Let me know if I can help.

@Jan-E

Please sign in to comment.