Skip to content

Commit 7cea21a

Browse files
committed
PHPC-1496: Add support for compiling with libmongocrypt
1 parent ec848f7 commit 7cea21a

File tree

13 files changed

+269
-16
lines changed

13 files changed

+269
-16
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
url = https://github.com/mongodb/mongo-c-driver.git
44
branch = 1.2.0-dev
55
ignore = untracked
6+
[submodule "src/libmongocrypt"]
7+
path = src/libmongocrypt
8+
url = git://github.com/mongodb/libmongocrypt.git

CONTRIBUTING.md

+28-12
Original file line numberDiff line numberDiff line change
@@ -172,22 +172,24 @@ If something goes awry in the test VM, you can reload it by running:
172172
make test-bootstrap
173173
```
174174

175-
## Updating libmongoc and libbson
175+
## Updating libmongoc, libbson, and libmongocrypt
176176

177-
The PHP driver can use either system libraries or bundled versions of libmongoc
178-
and libbson. If a new version of libmongoc is available, the submodule and build
179-
configuration will need to be updated to reflect the new sources and/or package
180-
version.
177+
The PHP driver can use either system libraries or bundled versions of
178+
libmongoc, libbson, and libmongocrypt. If a new version of either library is
179+
available, the submodule and build configuration will need to be updated to
180+
reflect the new sources and/or package version.
181181

182-
### Update libmongoc to the latest version
182+
### Updating libmongoc and libbson
183+
184+
#### Update libmongoc to the latest version
183185

184186
```
185187
$ cd src/libmongoc
186188
$ git fetch
187189
$ git checkout 1.15.0
188190
```
189191

190-
### Ensure libmongoc version information is correct
192+
#### Ensure libmongoc version information is correct
191193

192194
The build process for Autotools and Windows rely on
193195
`src/LIBMONGOC_VERSION_CURRENT` to infer version information for libmongoc and
@@ -200,7 +202,7 @@ $ make libmongoc-version-current
200202
Alternatively, the `build/calc_release_version.py` script in libmongoc can be
201203
executed directly.
202204

203-
### Update sources in build configurations
205+
#### Update sources in build configurations
204206

205207
The Autotools and Windows build configurations (`config.m4` and `config.w32`,
206208
respectively) define several variables (e.g. `PHP_MONGODB_MONGOC_SOURCES`) that
@@ -212,7 +214,7 @@ should be run to regenerate that particular list of source files. In the event
212214
that either libmongoc or libbson introduce a new source directory, that will
213215
need to be manually added (follow prior art).
214216

215-
### Update package dependencies
217+
#### Update package dependencies
216218

217219
The Autotools configuration additionally includes some `pkg-config` commands for
218220
using libmongoc and libbson as system libraries (in lieu of a bundled build).
@@ -229,7 +231,7 @@ if $PKG_CONFIG libmongoc-1.0 --atleast-version 1.15.0; then
229231
AC_MSG_ERROR(system libmongoc must be upgraded to version >= 1.15.0)
230232
```
231233

232-
### Update tested versions in evergreen configuration
234+
#### Update tested versions in evergreen configuration
233235

234236
Evergreen tests against multiple versions of libmongoc. When updating to a newer
235237
libmongoc version, make sure to update the `libmongoc-version` build axis in
@@ -239,13 +241,13 @@ libmongoc:
239241
`r1.x` branch)
240242
- The upcoming minor release of libmongoc (e.g. the `master` branch)
241243

242-
### Update sources in PECL package generation script
244+
#### Update sources in PECL package generation script
243245

244246
If either libmongoc or libbson introduce a new source directory, that may also
245247
require updating the glob patterns in the `bin/prep-release.php` script to
246248
ensure new source files will be included in any generated PECL package.
247249

248-
### Test and commit your changes
250+
#### Test and commit your changes
249251

250252
Verify that the upgrade was successful by ensuring that the driver can compile
251253
using both the bundled sources and system libraries for libmongoc and libbson,
@@ -256,6 +258,20 @@ of the above files/paths. For example:
256258
$ git commit -m "Bump libmongoc to 1.15.0" config.m4 config.w32 src/libmongoc src/LIBMONGOC_VERSION_CURRENT
257259
```
258260

261+
### Updating libmongocrypt
262+
263+
To update libmongocrypt, the steps are similar to the above:
264+
265+
```
266+
$ cd src/libmongocrypt
267+
$ git fetch
268+
$ git checkout 1.0.1
269+
$ make libmongocrypt-version-current
270+
```
271+
272+
Package dependencies in `config.m4` must also be updated, as do the sources in
273+
the PECL generation script.
274+
259275
## Releasing
260276

261277
The follow steps outline the release process for a maintenance branch (e.g.

Makefile.frag

+3
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,6 @@ package.xml:
8888

8989
libmongoc-version-current:
9090
cd src/libmongoc/ && python build/calc_release_version.py > ../LIBMONGOC_VERSION_CURRENT
91+
92+
libmongocrypt-version-current:
93+
cd src/libmongocrypt/ && cmake -P ./cmake/GetVersion.cmake 2> ../LIBMONGOCRYPT_VERSION_CURRENT

bin/prep-release.php

+10
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ function get_files() {
4040

4141
"src/*.{c,h}",
4242
"src/LIBMONGOC_VERSION_CURRENT",
43+
"src/LIBMONGOCRYPT_VERSION_CURRENT",
4344

4445
"src/MongoDB/*.{c,h}",
4546
"src/MongoDB/Exception/*.{c,h}",
@@ -54,6 +55,15 @@ function get_files() {
5455
"src/libmongoc/src/libmongoc/src/mongoc/*.{c,def,defs,h,h.in}",
5556
"src/libmongoc/src/zlib-1.2.11/*.{c,h,h.in}",
5657
"src/libmongoc/VERSION*",
58+
59+
"src/libmongocrypt-compat/*.{c,h}",
60+
"src/libmongocrypt-compat/mongocrypt/*.{c,h}",
61+
"src/libmongocrypt/src/*.{c,h}",
62+
"src/libmongocrypt/src/crypto/*.{c,h}",
63+
"src/libmongocrypt/src/os_posix/*.{c,h}",
64+
"src/libmongocrypt/src/os_win/*.{c,h}",
65+
"src/libmongocrypt/kms-message/src/*.{c,h}",
66+
"src/libmongocrypt/kms-message/src/message/*.{c,h}",
5767
),
5868
'test' => array(
5969
"Vagrantfile",

config.m4

+89-3
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ if test "$PHP_MONGODB" != "no"; then
181181
[MongoDB: Use system libmongoc [default=no]])],
182182
[no],
183183
[no])
184+
PHP_ARG_WITH([mongodb-client-side-encryption],
185+
[whether to enable client-side encryption],
186+
[AS_HELP_STRING([--with-mongodb-client-side-encryption=@<:@auto/yes/no@:>@],
187+
[MongoDB: Enable client-side encryption [default=auto]])],
188+
[auto],
189+
[no])
184190

185191
if test "$PHP_LIBBSON" != "no"; then
186192
if test "$PHP_LIBMONGOC" = "no"; then
@@ -230,8 +236,38 @@ if test "$PHP_MONGODB" != "no"; then
230236
AC_DEFINE(HAVE_SYSTEM_LIBMONGOC, 1, [Use system libmongoc])
231237
fi
232238

239+
if test "$PHP_MONGODB_CLIENT_SIDE_ENCRYPTION" != "no" -a "$PHP_LIBBSON" = "yes"; then
240+
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
241+
AC_MSG_CHECKING(for libmongocrypt)
242+
243+
if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libmongocrypt-1.0; then
244+
if $PKG_CONFIG libmongocrypt-1.0 --atleast-version 1.0.1; then
245+
PHP_MONGODB_MONGOCRYPT_CFLAGS=`$PKG_CONFIG libmongocrypt-1.0 --cflags`
246+
PHP_MONGODB_MONGOCRYPT_LIBS=`$PKG_CONFIG libmongocrypt-1.0 --libs`
247+
PHP_MONGODB_MONGOCRYPT_VERSION=`$PKG_CONFIG libmongocrypt-1.0 --modversion`
248+
AC_MSG_RESULT(version $PHP_MONGODB_MONGOCRYPT_VERSION found)
249+
250+
PHP_MONGODB_CFLAGS="$PHP_MONGODB_CFLAGS $PHP_MONGODB_MONGOCRYPT_CFLAGS"
251+
PHP_EVAL_LIBLINE($PHP_MONGODB_MONGOCRYPT_LIBS, MONGODB_SHARED_LIBADD)
252+
AC_DEFINE(HAVE_SYSTEM_LIBMONGOCRYPT, 1, [Use system libmongocrypt])
253+
elif test "$PHP_MONGODB_CLIENT_SIDE_ENCRYPTION" = "yes"; then
254+
AC_MSG_ERROR(system libmongocrypt must be upgraded to version >= 1.0.1)
255+
else
256+
AC_MSG_RESULT(found an older version, compiling without client-side encryption)
257+
fi
258+
else
259+
if test "$PHP_MONGODB_CLIENT_SIDE_ENCRYPTION" = "yes"; then
260+
AC_MSG_ERROR(pkgconfig and libmongocrypt must be installed)
261+
else
262+
AC_MSG_RESULT(not found, compiling without client-side encryption)
263+
fi
264+
fi
265+
fi
266+
233267
if test "$PHP_LIBBSON" = "no" -a "$PHP_LIBMONGOC" = "no"; then
234268
PHP_MONGODB_BUNDLED_CFLAGS="$STD_CFLAGS -DBSON_COMPILATION -DMONGOC_COMPILATION"
269+
dnl TODO: MONGOCRYPT-219 makes the -std argument obsolete
270+
PHP_MONGODB_LIBMONGOCRYPT_CFLAGS="$PHP_MONGODB_BUNDLED_CFLAGS -std=gnu99"
235271

236272
dnl M4 doesn't know if we're building statically or as a shared module, so
237273
dnl attempt to include both paths while ignoring errors. If neither path
@@ -273,6 +309,11 @@ if test "$PHP_MONGODB" != "no"; then
273309
_include([scripts/autotools/libmongoc/Versions.m4])
274310
_include([scripts/autotools/libmongoc/WeakSymbols.m4])
275311

312+
dnl This include modifies the value of $PHP_MONGODB_CLIENT_SIDE_ENCRYPTION to "yes"
313+
dnl or "no" depending on whether dependencies for libmongocrypt are fulfilled
314+
_include([scripts/autotools/libmongocrypt/CheckSSL.m4])
315+
_include([scripts/autotools/libmongocrypt/Version.m4])
316+
276317
m4_popdef([_include])
277318

278319
AC_SUBST(BSON_EXTRA_ALIGN, 0)
@@ -283,16 +324,19 @@ if test "$PHP_MONGODB" != "no"; then
283324
AC_SUBST(MONGOC_ENABLE_SHM_COUNTERS, 0)
284325
AC_SUBST(MONGOC_TRACE, 1)
285326

286-
dnl TODO: Replace with detection for libmongocrypt for PHPC-1293
287-
AC_SUBST(MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION, 0)
288-
289327
dnl Assignments for metadata handshake. Leave CFLAGS/LDFLAGS empty as they
290328
dnl would likely cause platform info (PHP version) to be truncated. We can
291329
dnl consider restoring CFLAGS/LDFLAGS once CDRIVER-3134 is resolved.
292330
AC_SUBST(MONGOC_CC, [$CC])
293331
AC_SUBST(MONGOC_USER_SET_CFLAGS, [])
294332
AC_SUBST(MONGOC_USER_SET_LDFLAGS, [])
295333

334+
if test "$PHP_MONGODB_CLIENT_SIDE_ENCRYPTION" = "yes"; then
335+
AC_SUBST(MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION, 1)
336+
else
337+
AC_SUBST(MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION, 0)
338+
fi
339+
296340
dnl On MacOS, use gcut from the coreutils brew package instead of cut
297341
dnl Generated with: find src/libmongoc/src/common -name '*.c' -print0 | cut -sz -d / -f 5- | sort -dz | tr '\000' ' '
298342
PHP_MONGODB_COMMON_SOURCES="common-b64.c common-md5.c"
@@ -342,6 +386,46 @@ if test "$PHP_MONGODB" != "no"; then
342386
PHP_MONGODB_ADD_BUILD_DIR([src/libmongoc/src/zlib-1.2.11/])
343387
AC_CONFIG_FILES([${ac_config_dir}/src/libmongoc/src/zlib-1.2.11/zconf.h])
344388
fi
389+
390+
if test "$PHP_MONGODB_CLIENT_SIDE_ENCRYPTION" = "yes"; then
391+
AC_SUBST(MONGOCRYPT_ENABLE_TRACE, 1)
392+
393+
dnl Generated with: find src/libmongocrypt/src -maxdepth 1 -name '*.c' -print0 | cut -sz -d / -f 4- | sort -dz | tr '\000' ' '
394+
PHP_MONGODB_MONGOCRYPT_SOURCES="mongocrypt-binary.c mongocrypt-buffer.c mongocrypt.c mongocrypt-cache.c mongocrypt-cache-collinfo.c mongocrypt-cache-key.c mongocrypt-ciphertext.c mongocrypt-crypto.c mongocrypt-ctx.c mongocrypt-ctx-datakey.c mongocrypt-ctx-decrypt.c mongocrypt-ctx-encrypt.c mongocrypt-key-broker.c mongocrypt-key.c mongocrypt-kms-ctx.c mongocrypt-log.c mongocrypt-marking.c mongocrypt-opts.c mongocrypt-status.c mongocrypt-traverse-util.c"
395+
396+
dnl Generated with: find src/libmongocrypt/src/crypto -name '*.c' -print0 | cut -sz -d / -f 5- | sort -dz | tr '\000' ' '
397+
PHP_MONGODB_MONGOCRYPT_CRYPTO_SOURCES="cng.c commoncrypto.c libcrypto.c none.c"
398+
399+
dnl Generated with: find src/libmongocrypt/src/os_posix -name '*.c' -print0 | cut -sz -d / -f 5- | sort -dz | tr '\000' ' '
400+
PHP_MONGODB_MONGOCRYPT_OS_POSIX_SOURCES="os_mutex.c os_once.c"
401+
402+
dnl Generated with: find src/libmongocrypt/src/os_win -name '*.c' -print0 | cut -sz -d / -f 5- | sort -dz | tr '\000' ' '
403+
PHP_MONGODB_MONGOCRYPT_OS_WIN_SOURCES="os_mutex.c os_once.c"
404+
405+
dnl Generated with: find src/libmongocrypt/kms-message/src -maxdepth 1 -name '*.c' -print0 | cut -sz -d / -f 5- | sort -dz | tr '\000' ' '
406+
PHP_MONGODB_MONGOCRYPT_KMS_MESSAGE_SOURCES="hexlify.c kms_b64.c kms_caller_identity_request.c kms_crypto_apple.c kms_crypto_libcrypto.c kms_crypto_none.c kms_crypto_windows.c kms_decrypt_request.c kms_encrypt_request.c kms_kv_list.c kms_message.c kms_request.c kms_request_opt.c kms_request_str.c kms_response.c kms_response_parser.c sort.c"
407+
408+
PHP_MONGODB_ADD_SOURCES([src/libmongocrypt/src/], $PHP_MONGODB_MONGOCRYPT_SOURCES, $PHP_MONGODB_LIBMONGOCRYPT_CFLAGS)
409+
PHP_MONGODB_ADD_SOURCES([src/libmongocrypt/src/crypto/], $PHP_MONGODB_MONGOCRYPT_CRYPTO_SOURCES, $PHP_MONGODB_LIBMONGOCRYPT_CFLAGS)
410+
PHP_MONGODB_ADD_SOURCES([src/libmongocrypt/src/os_posix/], $PHP_MONGODB_MONGOCRYPT_OS_POSIX_SOURCES, $PHP_MONGODB_LIBMONGOCRYPT_CFLAGS)
411+
PHP_MONGODB_ADD_SOURCES([src/libmongocrypt/src/os_win/], $PHP_MONGODB_MONGOCRYPT_OS_WIN_SOURCES, $PHP_MONGODB_LIBMONGOCRYPT_CFLAGS)
412+
PHP_MONGODB_ADD_SOURCES([src/libmongocrypt/kms-message/src/], $PHP_MONGODB_MONGOCRYPT_KMS_MESSAGE_SOURCES, $PHP_MONGODB_LIBMONGOCRYPT_CFLAGS)
413+
414+
PHP_MONGODB_ADD_INCLUDE([src/libmongocrypt/src/])
415+
PHP_MONGODB_ADD_INCLUDE([src/libmongocrypt/kms-message/src/])
416+
PHP_MONGODB_ADD_INCLUDE([src/libmongocrypt-compat/])
417+
418+
PHP_MONGODB_ADD_BUILD_DIR([src/libmongocrypt/src/])
419+
PHP_MONGODB_ADD_BUILD_DIR([src/libmongocrypt/src/crypto/])
420+
PHP_MONGODB_ADD_BUILD_DIR([src/libmongocrypt/src/os_posix/])
421+
PHP_MONGODB_ADD_BUILD_DIR([src/libmongocrypt/src/os_win/])
422+
PHP_MONGODB_ADD_BUILD_DIR([src/libmongocrypt/kms-message/src/])
423+
424+
AC_CONFIG_FILES([
425+
${ac_config_dir}/src/libmongocrypt/src/mongocrypt-config.h
426+
${ac_config_dir}/src/libmongocrypt/src/mongocrypt.h
427+
])
428+
fi
345429
fi
346430

347431
PHP_NEW_EXTENSION(mongodb, $PHP_MONGODB_SOURCES, $ext_shared,, $PHP_MONGODB_CFLAGS)
@@ -373,6 +457,7 @@ if test "$PHP_MONGODB" != "no"; then
373457
dnl This must come after PHP_NEW_EXTENSION, otherwise the srcdir won't be set
374458
PHP_ADD_MAKEFILE_FRAGMENT
375459

460+
dnl The libmongocrypt line intentionally uses the PHP_LIBBSON flag as that decides whether to build against bundled or system libraries.
376461
AC_CONFIG_COMMANDS_POST([
377462
if test "$enable_static" = "no"; then
378463
echo "
@@ -385,6 +470,7 @@ Build configuration:
385470
Code Coverage flags (extra slow) : $COVERAGE_CFLAGS
386471
System mongoc : $PHP_LIBMONGOC
387472
System libbson : $PHP_LIBBSON
473+
System libmongocrypt : $PHP_LIBBSON
388474
LDFLAGS : $LDFLAGS
389475
EXTRA_LDFLAGS : $EXTRA_LDFLAGS
390476
MONGODB_SHARED_LIBADD : $MONGODB_SHARED_LIBADD

config.w32

+58-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ function mongodb_parse_version_file(inpath, prefix)
4545

4646
ARG_ENABLE("mongodb", "MongoDB support", "no");
4747
ARG_WITH("mongodb-sasl", "MongoDB: Build against Cyrus-SASL", "yes");
48+
ARG_WITH("mongodb-client-side-encryption", "MongoDB: Enable client-side encryption", "yes");
4849

4950
if (PHP_MONGODB != "no") {
5051
/* Note: ADD_EXTENSION_DEP() cannot be used to declare that we depend on the
@@ -148,7 +149,6 @@ if (PHP_MONGODB != "no") {
148149
MONGOC_ENABLE_SSL: 0,
149150
MONGOC_ENABLE_CRYPTO: 0,
150151
MONGOC_ENABLE_CRYPTO_SYSTEM_PROFILE: 0,
151-
// TODO: Replace with detection for libmongocrypt for PHPC-1293
152152
MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION: 0,
153153
MONGOC_ENABLE_COMPRESSION_SNAPPY: 0,
154154
MONGOC_ENABLE_COMPRESSION_ZLIB: 0,
@@ -226,6 +226,63 @@ if (PHP_MONGODB != "no") {
226226
WARNING("mongodb libsasl support not enabled, libs not found");
227227
}
228228

229+
if (PHP_MONGODB_CLIENT_SIDE_ENCRYPTION != "no" && mongoc_ssl_found) {
230+
mongoc_opts.MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION = 1;
231+
232+
ADD_FLAG("CFLAGS_MONGODB", "/I" + configure_module_dirname + "/src/libmongocrypt/src");
233+
ADD_FLAG("CFLAGS_MONGODB", "/I" + configure_module_dirname + "/src/libmongocrypt/kms-message/src");
234+
ADD_FLAG("CFLAGS_MONGODB", "/I" + configure_module_dirname + "/src/libmongocrypt-compat");
235+
ADD_FLAG("CFLAGS_MONGODB", "/D KMS_MESSAGE_ENABLE_CRYPTO=1 /D KMS_MESSAGE_ENABLE_CRYPTO_LIBCRYPTO=1");
236+
237+
var mongocrypt_opts = {
238+
MONGOCRYPT_ENABLE_TRACE: 1,
239+
MONGOCRYPT_ENABLE_CRYPTO: 1,
240+
MONGOCRYPT_ENABLE_CRYPTO_LIBCRYPTO: 1,
241+
// TODO: Support building with Secure Channel on Windows
242+
MONGOCRYPT_ENABLE_CRYPTO_CNG: 0,
243+
// Secure Transport does not apply to Windows
244+
MONGOCRYPT_ENABLE_CRYPTO_COMMON_CRYPTO: 0
245+
};
246+
247+
// Generated with: find src/libmongocrypt/src -maxdepth 1 -name '*.c' -print0 | cut -sz -d / -f 4- | sort -dz | tr '\000' ' '
248+
var PHP_MONGODB_MONGOCRYPT_SOURCES="mongocrypt-binary.c mongocrypt-buffer.c mongocrypt.c mongocrypt-cache.c mongocrypt-cache-collinfo.c mongocrypt-cache-key.c mongocrypt-ciphertext.c mongocrypt-crypto.c mongocrypt-ctx.c mongocrypt-ctx-datakey.c mongocrypt-ctx-decrypt.c mongocrypt-ctx-encrypt.c mongocrypt-key-broker.c mongocrypt-key.c mongocrypt-kms-ctx.c mongocrypt-log.c mongocrypt-marking.c mongocrypt-opts.c mongocrypt-status.c mongocrypt-traverse-util.c";
249+
250+
// Generated with: find src/libmongocrypt/src/crypto -name '*.c' -print0 | cut -sz -d / -f 5- | sort -dz | tr '\000' ' '
251+
var PHP_MONGODB_MONGOCRYPT_CRYPTO_SOURCES="cng.c commoncrypto.c libcrypto.c none.c";
252+
253+
// Generated with: find src/libmongocrypt/src/os_posix -name '*.c' -print0 | cut -sz -d / -f 5- | sort -dz | tr '\000' ' '
254+
var PHP_MONGODB_MONGOCRYPT_OS_POSIX_SOURCES="os_mutex.c os_once.c";
255+
256+
// Generated with: find src/libmongocrypt/src/os_win -name '*.c' -print0 | cut -sz -d / -f 5- | sort -dz | tr '\000' ' '
257+
var PHP_MONGODB_MONGOCRYPT_OS_WIN_SOURCES="os_mutex.c os_once.c";
258+
259+
// Generated with: find src/libmongocrypt/kms-message/src -maxdepth 1 -name '*.c' -print0 | cut -sz -d / -f 5- | sort -dz | tr '\000' ' '
260+
var PHP_MONGODB_MONGOCRYPT_KMS_MESSAGE_SOURCES="hexlify.c kms_b64.c kms_caller_identity_request.c kms_crypto_apple.c kms_crypto_libcrypto.c kms_crypto_none.c kms_crypto_windows.c kms_decrypt_request.c kms_encrypt_request.c kms_kv_list.c kms_message.c kms_request.c kms_request_opt.c kms_request_str.c kms_response.c kms_response_parser.c sort.c";
261+
262+
ADD_SOURCES(configure_module_dirname + "/src/libmongocrypt/src", PHP_MONGODB_MONGOCRYPT_SOURCES, "mongodb");
263+
ADD_SOURCES(configure_module_dirname + "/src/libmongocrypt/src/crypto", PHP_MONGODB_MONGOCRYPT_SOURCES, "mongodb");
264+
ADD_SOURCES(configure_module_dirname + "/src/libmongocrypt/src/os_posix", PHP_MONGODB_MONGOCRYPT_OS_POSIX_SOURCES, "mongodb");
265+
ADD_SOURCES(configure_module_dirname + "/src/libmongocrypt/src/os_win", PHP_MONGODB_MONGOCRYPT_OS_WIN_SOURCES, "mongodb");
266+
ADD_SOURCES(configure_module_dirname + "/src/libmongocrypt/kms-message/src", PHP_MONGODB_MONGOCRYPT_KMS_MESSAGE_SOURCES, "mongodb");
267+
268+
var mongocrypt_version = mongodb_parse_version_file(configure_module_dirname + "/src/LIBMONGOCRYPT_VERSION_CURRENT", "")
269+
mongocrypt_opts.MONGOCRYPT_BUILD_VERSION = mongocrypt_version.VERSION;
270+
271+
mongodb_generate_header(
272+
configure_module_dirname + "/src/libmongocrypt/src/mongocrypt-config.h.in",
273+
configure_module_dirname + "/src/libmongocrypt/src/mongocrypt-config.h",
274+
mongocrypt_opts
275+
);
276+
277+
mongodb_generate_header(
278+
configure_module_dirname + "/src/libmongocrypt/src/mongocrypt.h.in",
279+
configure_module_dirname + "/src/libmongocrypt/src/mongocrypt.h",
280+
mongocrypt_opts
281+
);
282+
} else if (PHP_MONGODB_CLIENT_SIDE_ENCRYPTION != "no") {
283+
WARNING("mongodb libmongocrypt support not enabled, crypto libs not found");
284+
}
285+
229286
if (CHECK_LIB("dnsapi.lib", "mongodb", PHP_MONGODB) &&
230287
CHECK_HEADER_ADD_INCLUDE("windns.h", "CFLAGS_MONGODB")) {
231288
mongoc_opts.MONGOC_HAVE_DNSAPI = 1;

0 commit comments

Comments
 (0)