Skip to content

Commit f8e65ac

Browse files
committed
Merge pull request #48 from datastax/windows-build-updates
Windows Build Updates to Address PECL Binaries
2 parents 59c6f40 + 493ab2a commit f8e65ac

File tree

4 files changed

+266
-183
lines changed

4 files changed

+266
-183
lines changed

Diff for: ext/README.md

+19
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,25 @@ Usage: VC_BUILD.BAT [OPTION...]
142142
*** Default target architecture is determined based on system architecture
143143
```
144144

145+
#### Manual/PHP Step-by-Step Windows Build
146+
147+
The PHP driver extension can also be built using the
148+
[Build your own PHP on Windows](https://wiki.php.net/internals/windows/stepbystepbuild)
149+
instructions followed by the
150+
[Building PECL extensions](https://wiki.php.net/internals/windows/stepbystepbuild#building_pecl_extensions)
151+
instruction where the driver can be statically linked into the PHP executable
152+
or as an import (DLL) library. This process requires that the binary
153+
dependencies of the PHP driver extension be included in the
154+
`phpdev\vc##\x##\deps` directory along with the standard PHP library
155+
dependencies. Use `--enable-cassandra` to built library into the PHP executable
156+
and `--enable-cassandra=shared` for import (DLL) library.
157+
158+
The PHP driver extension dependencies that are not included with the
159+
standard PHP library can be download [here](http://downloads.datastax.com/cpp-driver/windows/).
160+
161+
**Note** The binary libraries downloaded/used must be compatible with the
162+
MSVC++ compiler and the PHP driver extension.
163+
145164
#### Enable Testing
146165

147166
Ensure the driver is built with --ENABLE-TEST-CONFIGURATION in order to execute

Diff for: ext/config.w32

+144-140
Original file line numberDiff line numberDiff line change
@@ -1,160 +1,164 @@
11
// vim:ft=javascript
22

33
ARG_ENABLE("cassandra", "Enable DataStax PHP Cassandra extension", "no");
4-
ARG_WITH("cassandra-cpp-driver", "Where to find DataStax C/C++ driver", "no");
5-
ARG_WITH("libuv-libs", "Where to find libuv libraries", "no");
6-
ARG_WITH("mpir", "Where to find MPIR (GNU MP)", "no");
7-
ARG_WITH("zlib-libs", "Where to find zlib libraries (optional)", "no");
84

9-
if (PHP_CASSANDRA != "no" &&
10-
PHP_CASSANDRA_CPP_DRIVER != "no" && PHP_LIBUV_LIBS != "no" && ADD_EXTENSION_DEP("cassandra", "openssl") &&
11-
PHP_MPIR != "no") {
5+
if (PHP_CASSANDRA != "no") {
6+
// Allow for DataStax C/C++ and libuv default locations to be overridden
7+
ARG_WITH("cassandra-cpp-driver", "Where to find DataStax C/C++ driver", "yes");
8+
ARG_WITH("libuv", "Where to find libuv libraries", "yes");
9+
1210
if (CHECK_LIB("cassandra_static.lib", "cassandra", PHP_CASSANDRA_CPP_DRIVER) &&
13-
CHECK_LIB("libuv.lib", "cassandra", PHP_LIBUV_LIBS) &&
14-
CHECK_LIB("psapi.lib", "cassandra") &&
15-
CHECK_LIB("iphlpapi.lib", "cassandra") &&
16-
CHECK_LIB("libeay32.lib", "cassandra") && CHECK_LIB("ssleay32.lib", "cassandra") &&
17-
CHECK_HEADER_ADD_INCLUDE("uv.h", "CFLAGS_CASSANDRA_CPP_DRIVER", PHP_LIBUV_LIBS + "/include") &&
18-
CHECK_HEADER_ADD_INCLUDE("cassandra.h", "CFLAGS_CASSANDRA_CPP_DRIVER", PHP_CASSANDRA_CPP_DRIVER + "/include")) {
11+
CHECK_HEADER_ADD_INCLUDE("cassandra.h", "CFLAGS_CASSANDRA", PHP_CASSANDRA_CPP_DRIVER + "/include")) {
12+
if (CHECK_LIB("libuv.lib", "cassandra", PHP_LIBUV) &&
13+
CHECK_LIB("iphlpapi.lib", "cassandra") &&
14+
CHECK_LIB("psapi.lib", "cassandra") &&
15+
CHECK_LIB("userenv.lib", "cassandra") && // Required for libuv v1.6.0+
16+
CHECK_LIB("ws2_32.lib", "cassandra") &&
17+
CHECK_LIB("wsock32.lib", "cassandra") &&
18+
CHECK_HEADER_ADD_INCLUDE("uv.h", "CFLAGS_CASSANDRA", PHP_LIBUV + "/include")) {
1919

20-
if (PHP_ZLIB_LIBS != "no") {
21-
if(CHECK_LIB("zlibstatic.lib", "cassandra", PHP_ZLIB_LIBS)) {
22-
// Ensure zlibstatic.lib is linked for all dependency extensions
23-
ADD_FLAG("LIBS", "zlibstatic.lib");
24-
} else {
25-
WARNING("Unable to locate zlib");
26-
}
27-
}
20+
// Indicate the DataStax C/C++ driver and dependencies are available
21+
AC_DEFINE("HAVE_CASSANDRA_CPP_DRIVER", 1, "Have DataStax C/C++ driver");
22+
AC_DEFINE("HAVE_LIBUV", 1, "Have libuv");
2823

29-
AC_DEFINE("HAVE_CASSANDRA_CPP_DRIVER", PHP_CASSANDRA_CPP_DRIVER ? 0 : 1, "Have DataStax C/C++ driver");
30-
if (CHECK_LIB("mpir.lib", "cassandra", PHP_MPIR) &&
31-
CHECK_HEADER_ADD_INCLUDE("mpir.h", "CFLAGS_MPIR", PHP_MPIR + "/include")) {
32-
AC_DEFINE("HAVE_MPIR", PHP_MPIR ? 0 : 1, "Have MPIR");
33-
if (ADD_EXTENSION_DEP("cassandra", "spl")) {
34-
EXTENSION("cassandra", "php_cassandra.c");
24+
if (CHECK_LIB("libeay32.lib", "cassandra") && CHECK_LIB("ssleay32.lib", "cassandra")) {
25+
if (!CHECK_LIB("zlib_a.lib", "cassandra")) {
26+
WARNING("Unable to Locate zlib Library: Cassandra extension may not link correctly");
27+
}
28+
} else {
29+
ERROR("Unable to Locate OpenSSL Libraries: https://wiki.php.net/internals/windows/stepbystepbuild");
30+
}
3531

36-
ADD_SOURCES(configure_module_dirname + "/src",
37-
"Cassandra.c", "cassandra");
38-
ADD_SOURCES(configure_module_dirname + "/src/Cassandra",
39-
"BatchStatement.c " +
40-
"Bigint.c " +
41-
"Blob.c " +
42-
"Cluster.c " +
43-
"Collection.c " +
44-
"Decimal.c " +
45-
"DefaultCluster.c " +
46-
"DefaultSession.c " +
47-
"Exception.c " +
48-
"ExecutionOptions.c " +
49-
"Float.c " +
50-
"Future.c " +
51-
"FutureClose.c " +
52-
"FuturePreparedStatement.c " +
53-
"FutureRows.c " +
54-
"FutureSession.c " +
55-
"FutureValue.c " +
56-
"Inet.c " +
57-
"Map.c " +
58-
"Numeric.c " +
59-
"PreparedStatement.c " +
60-
"Rows.c " +
61-
"Session.c " +
62-
"Set.c " +
63-
"SimpleStatement.c " +
64-
"SSLOptions.c " +
65-
"Statement.c " +
66-
"Timestamp.c " +
67-
"Timeuuid.c " +
68-
"Uuid.c " +
69-
"UuidInterface.c " +
70-
"Varint.c" +
71-
"Column.c" +
72-
"DefaultColumn.c" +
73-
"DefaultKeyspace.c" +
74-
"DefaultSchema.c" +
75-
"DefaultTable.c" +
76-
"Keyspace.c" +
77-
"Schema.c" +
78-
"Table.c" +
79-
"Type.c", "cassandra");
80-
ADD_SOURCES(configure_module_dirname + "/src/Cassandra/Type",
81-
"Collection.c" +
82-
"Map.c" +
83-
"Scalar.c" +
84-
"Set.c" +
85-
"Custom.c", "cassandra");
86-
ADD_SOURCES(configure_module_dirname + "/src/Cassandra/Cluster",
87-
"Builder.c", "cassandra");
88-
ADD_SOURCES(configure_module_dirname + "/src/Cassandra/Exception",
89-
"AlreadyExistsException.c " +
90-
"AuthenticationException.c " +
91-
"ConfigurationException.c " +
92-
"DivideByZeroException.c " +
93-
"DomainException.c " +
94-
"ExecutionException.c " +
95-
"InvalidArgumentException.c " +
96-
"InvalidQueryException.c " +
97-
"InvalidSyntaxException.c " +
98-
"IsBootstrappingException.c " +
99-
"LogicException.c " +
100-
"OverloadedException.c " +
101-
"ProtocolException.c " +
102-
"RangeException.c " +
103-
"ReadTimeout.c " +
104-
"RuntimeException.c " +
105-
"ServerException.c " +
106-
"TimeoutException.c " +
107-
"TruncateException.c " +
108-
"UnauthorizedException.c " +
109-
"UnavailableException.c " +
110-
"UnpreparedException.c " +
111-
"ValidationException.c " +
112-
"WriteTimeoutException.c", "cassandra");
113-
ADD_SOURCES(configure_module_dirname + "/src/Cassandra/SSLOptions",
114-
"Builder.c", "cassandra");
32+
if (CHECK_LIB("mpir_a.lib", "cassandra") &&
33+
CHECK_HEADER_ADD_INCLUDE("gmp.h", "CFLAGS_CASSANDRA", PHP_GMP + ";" + PHP_PHP_BUILD + "\\include\\mpir")) {
34+
if (ADD_EXTENSION_DEP("cassandra", "spl")) {
35+
EXTENSION("cassandra", "php_cassandra.c");
11536

116-
ADD_SOURCES(configure_module_dirname + "/util",
117-
"bytes.c " +
118-
"collections.c " +
119-
"consistency.c " +
120-
"future.c " +
121-
"inet.c " +
122-
"math.c " +
123-
"ref.c " +
124-
"result.c " +
125-
"types.c " +
126-
"uuid_gen.c", "cassandra");
37+
ADD_SOURCES(configure_module_dirname + "/src",
38+
"Cassandra.c", "cassandra");
39+
ADD_SOURCES(configure_module_dirname + "/src/Cassandra",
40+
"BatchStatement.c " +
41+
"Bigint.c " +
42+
"Blob.c " +
43+
"Cluster.c " +
44+
"Collection.c " +
45+
"Column.c " +
46+
"Decimal.c " +
47+
"DefaultCluster.c " +
48+
"DefaultColumn.c " +
49+
"DefaultKeyspace.c " +
50+
"DefaultSchema.c " +
51+
"DefaultSession.c " +
52+
"DefaultTable.c " +
53+
"Exception.c " +
54+
"ExecutionOptions.c " +
55+
"Float.c " +
56+
"Future.c " +
57+
"FutureClose.c " +
58+
"FuturePreparedStatement.c " +
59+
"FutureRows.c " +
60+
"FutureSession.c " +
61+
"FutureValue.c " +
62+
"Inet.c " +
63+
"Keyspace.c " +
64+
"Map.c " +
65+
"Numeric.c " +
66+
"PreparedStatement.c " +
67+
"Rows.c " +
68+
"Schema.c " +
69+
"Session.c " +
70+
"Set.c " +
71+
"SimpleStatement.c " +
72+
"SSLOptions.c " +
73+
"Statement.c " +
74+
"Table.c " +
75+
"Timestamp.c " +
76+
"Timeuuid.c " +
77+
"Type.c " +
78+
"Uuid.c " +
79+
"UuidInterface.c " +
80+
"Varint.c", "cassandra");
81+
ADD_SOURCES(configure_module_dirname + "/src/Cassandra/Cluster",
82+
"Builder.c", "cassandra");
83+
ADD_SOURCES(configure_module_dirname + "/src/Cassandra/Exception",
84+
"AlreadyExistsException.c " +
85+
"AuthenticationException.c " +
86+
"ConfigurationException.c " +
87+
"DivideByZeroException.c " +
88+
"DomainException.c " +
89+
"ExecutionException.c " +
90+
"InvalidArgumentException.c " +
91+
"InvalidQueryException.c " +
92+
"InvalidSyntaxException.c " +
93+
"IsBootstrappingException.c " +
94+
"LogicException.c " +
95+
"OverloadedException.c " +
96+
"ProtocolException.c " +
97+
"RangeException.c " +
98+
"ReadTimeout.c " +
99+
"RuntimeException.c " +
100+
"ServerException.c " +
101+
"TimeoutException.c " +
102+
"TruncateException.c " +
103+
"UnauthorizedException.c " +
104+
"UnavailableException.c " +
105+
"UnpreparedException.c " +
106+
"ValidationException.c " +
107+
"WriteTimeoutException.c", "cassandra");
108+
ADD_SOURCES(configure_module_dirname + "/src/Cassandra/SSLOptions",
109+
"Builder.c", "cassandra");
110+
ADD_SOURCES(configure_module_dirname + "/src/Cassandra/Type",
111+
"Collection.c " +
112+
"Custom.c " +
113+
"Map.c " +
114+
"Scalar.c " +
115+
"Set.c", "cassandra");
127116

128-
ADD_FLAG("LDFLAGS_CASSANDRA",
129-
"/INCREMENTAL:NO " +
130-
"/LTCG " +
131-
"/NODEFAULTLIB:LIBCMT.LIB " +
132-
"/NODEFAULTLIB:LIBCMTD.LIB");
133-
ADD_FLAG("CFLAGS_CASSANDRA",
134-
"/I " + configure_module_dirname + " " +
135-
"/I " + PHP_CASSANDRA_CPP_DRIVER + "/include " +
136-
"/I " + PHP_LIBUV_LIBS + "/include " +
137-
"/I " + PHP_MPIR + "/include " +
138-
"/I " + configure_module_dirname + "/src/Cassandra " +
139-
"/I " + configure_module_dirname + "/util " +
140-
"/DCASS_STATIC " +
141-
"/wd4267");
117+
ADD_SOURCES(configure_module_dirname + "/util",
118+
"bytes.c " +
119+
"collections.c " +
120+
"consistency.c " +
121+
"future.c " +
122+
"inet.c " +
123+
"math.c " +
124+
"ref.c " +
125+
"result.c " +
126+
"types.c " +
127+
"uuid_gen.c", "cassandra");
142128

143-
// Determine if MSVC++ stdint definitions should be disabled
144-
if(PHP_VERSION == "5" && PHP_MINOR_VERSION <= 4) {
129+
ADD_FLAG("LDFLAGS_CASSANDRA",
130+
"/INCREMENTAL:NO " +
131+
"/LTCG " +
132+
"/NODEFAULTLIB:LIBCMT.LIB " +
133+
"/NODEFAULTLIB:LIBCMTD.LIB");
145134
ADD_FLAG("CFLAGS_CASSANDRA",
146-
"/DDISABLE_MSVC_STDINT");
147-
}
135+
"/I " + configure_module_dirname + " " +
136+
"/I " + PHP_CASSANDRA_CPP_DRIVER + "/include " +
137+
"/I " + PHP_LIBUV + "/include " +
138+
"/I " + configure_module_dirname + "/src " +
139+
"/DCASS_STATIC " +
140+
"/wd4267");
141+
142+
// Determine if MSVC++ stdint definitions should be disabled
143+
if (PHP_VERSION == "5" && PHP_MINOR_VERSION <= 4) {
144+
ADD_FLAG("CFLAGS_CASSANDRA",
145+
"/DDISABLE_MSVC_STDINT");
146+
}
148147

149-
// Ensure gdi32.lib is linked for all dependency extensions
150-
ADD_FLAG("LIBS", "gdi32.lib");
148+
// Ensure gdi32.lib is linked for all dependency extensions
149+
ADD_FLAG("LIBS", "gdi32.lib"); // This is needed for vc_build.bat
150+
151+
AC_DEFINE("HAVE_CASSANDRA_EXT", PHP_CASSANDRA_SHARED ? 0 : 1, "Have DataStax PHP driver extension");
152+
} else {
153+
ERROR("Unable to Add Dependency SPL: This should never happen (SPL is part of PHP core)");
154+
}
151155
} else {
152-
ERROR("Unable to add dependency spl");
156+
ERROR("Unable to Locate MPIR (GMP) Library/Headers: https://wiki.php.net/internals/windows/stepbystepbuild");
153157
}
154158
} else {
155-
ERROR("Unable to locate MPIR");
159+
ERROR("Unable to Locate libuv Library/Header: https://wiki.php.net/internals/windows/stepbystepbuild");
156160
}
157161
} else {
158-
ERROR("Unable to locate DataStax C/C++ driver or its dependencies");
162+
ERROR("Unable to Locate DataStax C/C++ driver Library/Header: https://wiki.php.net/internals/windows/stepbystepbuild");
159163
}
160164
}

Diff for: ext/src/Cassandra/Float.c

-11
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@
22
#include "util/math.h"
33
#include <float.h>
44

5-
#ifdef _WIN32
6-
float fabsf(float value) {
7-
return (float) fabs((float) value);
8-
}
9-
# if defined _M_IX86
10-
float sqrtf(float value) {
11-
return (float) sqrt((float) value);
12-
}
13-
# endif
14-
#endif
15-
165
zend_class_entry* cassandra_float_ce = NULL;
176

187
static int

0 commit comments

Comments
 (0)