diff --git a/config/lib.json b/config/lib.json index 8e728ccd..696f38a7 100644 --- a/config/lib.json +++ b/config/lib.json @@ -589,6 +589,15 @@ "openssl" ] }, + "mimalloc": { + "source": "mimalloc", + "static-libs-unix": [ + "mimalloc.o" + ], + "static-libs-windows": [ + "mimalloc.lib" + ] + }, "ncurses": { "source": "ncurses", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index e5cc9212..006c9d6b 100644 --- a/config/source.json +++ b/config/source.json @@ -636,6 +636,16 @@ "path": "LICENSE" } }, + "mimalloc": { + "type": "ghtagtar", + "repo": "microsoft/mimalloc", + "match": "v2.+", + "provide-pre-built": false, + "license": { + "type": "file", + "path": "LICENSE" + } + }, "mongodb": { "type": "ghrel", "repo": "mongodb/mongo-php-driver", diff --git a/src/SPC/builder/linux/library/mimalloc.php b/src/SPC/builder/linux/library/mimalloc.php new file mode 100644 index 00000000..7ea6d833 --- /dev/null +++ b/src/SPC/builder/linux/library/mimalloc.php @@ -0,0 +1,12 @@ +source_dir . '/build'); + shell()->cd($this->source_dir . '/build') + ->exec( + 'cmake ' . + '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . + "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . + '-DCMAKE_BUILD_TYPE=Release ' . + $args . + '..' + ) + ->exec("make -j{$this->builder->concurrency}") + ->exec('make install'); + } +} diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index 16edeeae..fbaeb7a7 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -69,14 +69,19 @@ class Downloader retry: self::getRetryTime() ), true); - if (($source['prefer-stable'] ?? false) === false) { - $url = $data[0]['tarball_url']; - } else { - $id = 0; - while ($data[$id]['prerelease'] === true) { - ++$id; + $url = null; + for ($i = 0; $i < count($data); ++$i) { + if (($data[$i]['prerelease'] ?? false) === true && ($source['prefer-stable'] ?? false)) { + continue; + } + if (!($source['match'] ?? null)) { + $url = $data[$i]['tarball_url'] ?? null; + break; + } + if (preg_match('|' . $source['match'] . '|', $data[$i]['tarball_url'])) { + $url = $data[$i]['tarball_url']; + break; } - $url = $data[$id]['tarball_url'] ?? null; } if (!$url) { throw new DownloaderException("failed to find {$name} source");