Skip to content

Windows fixes #411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.win32.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Build Steps for Windows
-------------------------

Follow https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2#building_pecl_extensions

- Add igbinary module to pecl directory if support desired
- Download/Compile libmemcached & add to deps folders (includes & lib). Lib should be named memcache.lib
- Important for 32bit: libmemcached must be built with _USE_32BIT_TIME_T defined (confirmed on PHP 7.2, VC15)
- https://github.com/yshurik/libmemcached-win/tree/1.0.18 is confirmed working
- 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
- Enable all options desired: --enable-memcached=shared --enable-memcached-session --enable-memcached-json
- for igbinary, add --enable-memcached-igbinary --enable-igbinary=shared
- Run nmake
30 changes: 28 additions & 2 deletions config.w32
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// vim:ft=javascript

ARG_WITH('memcached', 'libmemcached extension', 'no');
ARG_ENABLE('memcached', 'libmemcached extension', 'no');

ARG_ENABLE('memcached-session', 'whether to enable memcached session handler support', 'no');
ARG_ENABLE('memcached-igbinary', 'whether to enable memcached igbinary serializer support', 'no');
ARG_ENABLE('memcached-json', 'whether to enable memcached json serializer support', 'no');

if (PHP_MEMCACHED == "yes") {

Expand All @@ -11,7 +15,29 @@ if (PHP_MEMCACHED == "yes") {
if (!CHECK_HEADER_ADD_INCLUDE("libmemcached/memcached.h", "CFLAGS_MEMCACHED")) {
ERROR("memcached: header 'libmemcached/memcached.h' not found");
}
EXTENSION("memcached", "memcached.c");

if (PHP_MEMCACHED_JSON != "no"){
AC_DEFINE("HAVE_JSON_API",1);
}

var memcached_extra_src = "";

if (PHP_MEMCACHED_SESSION != "no"){
AC_DEFINE("HAVE_MEMCACHED_SESSION",1);
ADD_EXTENSION_DEP("memcached", "session", true)
memcached_extra_src += " php_memcached_session.c";
}

if (PHP_MEMCACHED_IGBINARY != "no"){
AC_DEFINE("HAVE_MEMCACHED_IGBINARY",1);
ADD_EXTENSION_DEP("memcached", "igbinary", true);
if (!CHECK_HEADER_ADD_INCLUDE("igbinary.h", "CFLAGS_MEMCACHED")) {
ERROR("memcached: header 'igbinary.h' not found");
}
}

EXTENSION("memcached", "php_memcached.c php_libmemcached_compat.c g_fmt.c"+memcached_extra_src);
ADD_SOURCES(configure_module_dirname+"\\fastlz", "fastlz.c", "memcached");
AC_DEFINE("HAVE_MEMCACHED", 1, "memcached support");
AC_DEFINE("MEMCACHED_EXPORTS", 1)
}
8 changes: 7 additions & 1 deletion php_memcached.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,14 @@
#endif

#ifdef HAVE_MEMCACHED_IGBINARY
#ifdef PHP_WIN32
//Windows extensions are generally built together,
//so it wont be in the installed location
#include "igbinary.h"
#else
# include "ext/igbinary/igbinary.h"
#endif
#endif

#ifdef HAVE_MEMCACHED_MSGPACK
# include "ext/msgpack/php_msgpack.h"
Expand Down Expand Up @@ -1428,7 +1434,7 @@ zend_bool s_get_apply_fn(php_memc_object_t *intern, zend_string *key, zval *valu
static
void php_memc_get_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_key)
{
php_memc_get_ctx_t context = {};
php_memc_get_ctx_t context = {0};
php_memc_keys_t keys = {0};
zend_long get_flags = 0;
zend_string *key;
Expand Down
5 changes: 5 additions & 0 deletions php_memcached.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@

#include "php.h"
#include "Zend/zend_smart_str.h"

#ifdef PHP_WIN32
#include "main/config.w32.h"
#else
#include "main/php_config.h"
#endif

#ifdef HAVE_CONFIG_H
# include "config.h"
Expand Down
4 changes: 4 additions & 0 deletions php_memcached_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
#ifndef PHP_MEMCACHED_PRIVATE_H
#define PHP_MEMCACHED_PRIVATE_H

#ifdef PHP_WIN32
#include "main/config.w32.h"
#else
#include "main/php_config.h"
#endif

#ifdef HAVE_CONFIG_H
# include "config.h"
Expand Down