Skip to content

Commit 6d8f5d5

Browse files
thiakilsodabrew
authored andcommitted
Windows fixes (#411)
1 parent 6220e20 commit 6d8f5d5

5 files changed

+57
-3
lines changed

README.win32.txt

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Build Steps for Windows
2+
-------------------------
3+
4+
Follow https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2#building_pecl_extensions
5+
6+
- Add igbinary module to pecl directory if support desired
7+
- Download/Compile libmemcached & add to deps folders (includes & lib). Lib should be named memcache.lib
8+
- Important for 32bit: libmemcached must be built with _USE_32BIT_TIME_T defined (confirmed on PHP 7.2, VC15)
9+
- https://github.com/yshurik/libmemcached-win/tree/1.0.18 is confirmed working
10+
- To use the dll on the releases page you'd likely need to change the header files to use __time64_t instead of time_t
11+
- Enable all options desired: --enable-memcached=shared --enable-memcached-session --enable-memcached-json
12+
- for igbinary, add --enable-memcached-igbinary --enable-igbinary=shared
13+
- Run nmake

config.w32

+28-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// vim:ft=javascript
22

3-
ARG_WITH('memcached', 'libmemcached extension', 'no');
3+
ARG_ENABLE('memcached', 'libmemcached extension', 'no');
4+
5+
ARG_ENABLE('memcached-session', 'whether to enable memcached session handler support', 'no');
6+
ARG_ENABLE('memcached-igbinary', 'whether to enable memcached igbinary serializer support', 'no');
7+
ARG_ENABLE('memcached-json', 'whether to enable memcached json serializer support', 'no');
48

59
if (PHP_MEMCACHED == "yes") {
610

@@ -11,7 +15,29 @@ if (PHP_MEMCACHED == "yes") {
1115
if (!CHECK_HEADER_ADD_INCLUDE("libmemcached/memcached.h", "CFLAGS_MEMCACHED")) {
1216
ERROR("memcached: header 'libmemcached/memcached.h' not found");
1317
}
14-
EXTENSION("memcached", "memcached.c");
18+
19+
if (PHP_MEMCACHED_JSON != "no"){
20+
AC_DEFINE("HAVE_JSON_API",1);
21+
}
22+
23+
var memcached_extra_src = "";
24+
25+
if (PHP_MEMCACHED_SESSION != "no"){
26+
AC_DEFINE("HAVE_MEMCACHED_SESSION",1);
27+
ADD_EXTENSION_DEP("memcached", "session", true)
28+
memcached_extra_src += " php_memcached_session.c";
29+
}
30+
31+
if (PHP_MEMCACHED_IGBINARY != "no"){
32+
AC_DEFINE("HAVE_MEMCACHED_IGBINARY",1);
33+
ADD_EXTENSION_DEP("memcached", "igbinary", true);
34+
if (!CHECK_HEADER_ADD_INCLUDE("igbinary.h", "CFLAGS_MEMCACHED")) {
35+
ERROR("memcached: header 'igbinary.h' not found");
36+
}
37+
}
38+
39+
EXTENSION("memcached", "php_memcached.c php_libmemcached_compat.c g_fmt.c"+memcached_extra_src);
40+
ADD_SOURCES(configure_module_dirname+"\\fastlz", "fastlz.c", "memcached");
1541
AC_DEFINE("HAVE_MEMCACHED", 1, "memcached support");
1642
AC_DEFINE("MEMCACHED_EXPORTS", 1)
1743
}

php_memcached.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,14 @@
4242
#endif
4343

4444
#ifdef HAVE_MEMCACHED_IGBINARY
45+
#ifdef PHP_WIN32
46+
//Windows extensions are generally built together,
47+
//so it wont be in the installed location
48+
#include "igbinary.h"
49+
#else
4550
# include "ext/igbinary/igbinary.h"
4651
#endif
52+
#endif
4753

4854
#ifdef HAVE_MEMCACHED_MSGPACK
4955
# include "ext/msgpack/php_msgpack.h"
@@ -1428,7 +1434,7 @@ zend_bool s_get_apply_fn(php_memc_object_t *intern, zend_string *key, zval *valu
14281434
static
14291435
void php_memc_get_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_key)
14301436
{
1431-
php_memc_get_ctx_t context = {};
1437+
php_memc_get_ctx_t context = {0};
14321438
php_memc_keys_t keys = {0};
14331439
zend_long get_flags = 0;
14341440
zend_string *key;

php_memcached.h

+5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@
1919

2020
#include "php.h"
2121
#include "Zend/zend_smart_str.h"
22+
23+
#ifdef PHP_WIN32
24+
#include "main/config.w32.h"
25+
#else
2226
#include "main/php_config.h"
27+
#endif
2328

2429
#ifdef HAVE_CONFIG_H
2530
# include "config.h"

php_memcached_private.h

+4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
#ifndef PHP_MEMCACHED_PRIVATE_H
1818
#define PHP_MEMCACHED_PRIVATE_H
1919

20+
#ifdef PHP_WIN32
21+
#include "main/config.w32.h"
22+
#else
2023
#include "main/php_config.h"
24+
#endif
2125

2226
#ifdef HAVE_CONFIG_H
2327
# include "config.h"

0 commit comments

Comments
 (0)