mirror of
https://github.com/macintoshplus/mongo-php-driver.git
synced 2026-03-24 00:42:15 +01:00
* PHPC-2473: Bump to libmongoc 1.29.0
Update sources and paths for libmongoc 1.29.0.
Update libmongoc CI builds and re-enable "latest". Also updates the file paths in comment. The test-variants.yml file was moved in e128d2e182
* PHPC-2475: bson_as_legacy_extended_json replaces bson_as_json
* PHPC-2470: Vendor bson-atomic as phongo_atomic
libmongoc 1.29.0 deprecated bson-atomic.h, so this vendors the necessary functionality into PHPC. Also applied clang-format to the new sources.
63 lines
2.4 KiB
PHP
63 lines
2.4 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/src',
|
|
'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.3.1',
|
|
'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 = [];
|
|
|
|
// Paths are relative to the project root directory
|
|
chdir(__DIR__ . '/..');
|
|
|
|
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);
|
|
}
|