Files
mongo-php-driver/scripts/update-submodule-sources.php
Jeremy Mikola 8dfe6c31ec PHPC-2256: Build configuration improvements (#1483)
* PHPC-2311: Note that with-libbson and with-libmongoc are deprecated

* PHPC-2312: MONGOC_ENABLE_SASL_GSSAPI is obsolete

* PHPC-1218: Use m4_include with base path for including m4 scripts

This removes the custom _include macro, which used sinclude on two different paths in order to support both shared and static builds. Unlike m4_sinclude, m4_include reports an error if the file is not found, so this also addresses the validation that was disabled to support PECL installs.

* PHPC-2300 and PHPC-2302: Fix configure output for bundled libbson/libmongoc versions

This was missed in 7ccb0949ba and 1c533ffa2d.

* PHPC-2225: Validate PHP_ARG_ENABLE and PHP_ARG_WITH configure options

Introduce a PHP_MONGODB_VALIDATE_ARG macro, which is called after processing a configure option.

PHP may still assign "yes" as a value during parsing, so map that to another value when necessary (e.g. selecting a crypto/TLS library).

* Add deprecation notice for --enable-system-ciphers in shared builds

* PHPC-2155: Remove prefixes for quoted shell variable references

* PHPC-1017: Allow configure options to be specified with PECL install

Introducing <configureoption> tags in package.xml means that PECL installs will now prompt for input. Non-interactive installs can still be achieved by either piping input (e.g. `yes '' | pecl install mongodb`) or explicitly specifying configure options (--configureoptions option for pecl install).

* Refer to update-submodule-sources.php in config.m4/w32 and fix macOS compatibility

* PHPC-2314: Require OpenSSL 1.0.1+ for libmongoc 1.24+

* PHPC-2315: Use PKG_CHECK_MODULES for detecting libmongoc system libs

* Remove superfluous AC_MSG_NOTICE output in CheckSSL.m4
2023-11-01 21:41:56 -04:00

60 lines
2.3 KiB
PHP

<?php
$cmd = "find %s -maxdepth 1 -name '*.c' -print0 | cut -sz -d / -f %d- | sort -dz | tr '\\000' ' '";
// On macOS, use gcut from the coreutils brew package instead of cut
if (PHP_OS_FAMILY === 'Darwin') {
$cmd = str_replace('cut', 'gcut', $cmd);
}
$vars = [
'PHP_MONGODB_COMMON_SOURCES' => 'src/libmongoc/src/common',
'PHP_MONGODB_KMS_MESSAGE_SOURCES' => 'src/libmongoc/src/kms-message/src',
'PHP_MONGODB_BSON_SOURCES' => 'src/libmongoc/src/libbson/src/bson',
'PHP_MONGODB_JSONSL_SOURCES' => 'src/libmongoc/src/libbson/src/jsonsl',
'PHP_MONGODB_MONGOC_SOURCES' => 'src/libmongoc/src/libmongoc/src/mongoc',
'PHP_MONGODB_UTF8PROC_SOURCES' => 'src/libmongoc/src/utf8proc-2.8.0',
'PHP_MONGODB_ZLIB_SOURCES' => 'src/libmongoc/src/zlib-1.2.13',
'PHP_MONGODB_MONGOCRYPT_SOURCES' => 'src/libmongocrypt/src',
'PHP_MONGODB_MONGOCRYPT_CRYPTO_SOURCES' => 'src/libmongocrypt/src/crypto',
'PHP_MONGODB_MONGOCRYPT_OS_POSIX_SOURCES' => 'src/libmongocrypt/src/os_posix',
'PHP_MONGODB_MONGOCRYPT_OS_WIN_SOURCES' => 'src/libmongocrypt/src/os_win',
'PHP_MONGODB_MONGOCRYPT_KMS_MESSAGE_SOURCES' => 'src/libmongocrypt/kms-message/src',
// Note: src/libmongocrypt/src/mlib does not contain source files (as of libmongocrypt 1.3.2)
];
$patterns = [];
$replacements = [];
foreach ($vars as $var => $path) {
$cutNth = 2 + substr_count($path, '/');
$files = trim(shell_exec(sprintf($cmd, $path, $cutNth)));
// Note: utf8proc_data.c is included from utf8proc.c and should not be compiled directly
if ($var === 'PHP_MONGODB_UTF8PROC_SOURCES') {
$files = trim(str_replace('utf8proc_data.c', '', $files));
}
$patterns[] = sprintf('/(%s=")([^"]*)(";?)/', $var);
$replacements[] = '$1' . $files . '$3';
}
$files = [
realpath(__DIR__ . '/../config.m4') => count($patterns),
// config.w32 does not use PHP_MONGODB_ZLIB_SOURCES (PHPC-1111)
realpath(__DIR__ . '/../config.w32') => count($patterns) - 1,
];
foreach ($files as $file => $expectedCount) {
$replaced = preg_replace($patterns, $replacements, file_get_contents($file), 1, $count);
if ($count !== $expectedCount) {
fprintf(STDERR, "Skipping %s: Expected %d replacements but only matched %d\n", basename($file), $expectedCount, $count);
continue;
}
printf("Updated %s\n", basename($file));
file_put_contents($file, $replaced);
}