<?php require_once __DIR__ . '/../boost_version.php'; $develop = BoostVersion::develop(); $master = BoostVersion::master(); $boost_1_55_0 = BoostVersion::release(1, 55, 0); $boost_1_54_0 = BoostVersion::release(1, 54, 0); $boost_1_56_0 = BoostVersion::release(1, 56, 0); $boost_1_56_0_b1 = BoostVersion::release(1, 56, 0, 1); $boost_1_56_0_b2 = BoostVersion::release(1, 56, 0, 2); assert($develop->compare($master) > 0); assert($master->compare($develop) < 0); assert($develop->compare($boost_1_55_0) > 0); assert($boost_1_55_0->compare($develop) < 0); assert($boost_1_55_0->compare($boost_1_54_0) > 0); assert($boost_1_54_0->compare($boost_1_55_0) < 0); assert($boost_1_55_0->compare('boost_1_55_0') == 0); assert($boost_1_55_0->compare('boost_1_54_0') > 0); assert($boost_1_55_0->compare('boost_1_56_0') < 0); assert($develop->dir() == 'develop'); assert($master->dir() == 'master'); assert($boost_1_55_0->dir() == 'boost_1_55_0'); assert((string) $boost_1_55_0 == '1.55.0'); assert($boost_1_56_0_b1->compare($boost_1_56_0_b1) == 0); assert($boost_1_56_0_b1->compare($boost_1_56_0_b2) < 0); assert($boost_1_56_0_b1->compare($boost_1_56_0) < 0); assert($boost_1_56_0_b2->compare($boost_1_56_0_b1) > 0); assert($boost_1_56_0_b2->compare($boost_1_56_0_b2) == 0); assert($boost_1_56_0_b2->compare($boost_1_56_0) < 0); assert($boost_1_56_0->compare($boost_1_56_0_b1) > 0); assert($boost_1_56_0->compare($boost_1_56_0_b2) > 0);
/** * * @param string $location The location of the super project in the mirror. * @param BoostVersion $version The version of the release. * @param \BoostLibraries $libs The existing libraries. * @throws RuntimeException */ function read_metadata_from_release($location, $version, $libs) { // We don't have a list for modules, so have to work it out from the // existing library data. // If we're updating an old version, then use that as the basis, // For a new version, take the data from the master branch, as this // may contain new modules that aren't in a release yet. $equivalent_version = BoostVersion::$current->compare($version) >= 0 ? $version : BoostVersion::master(); // Grab the modules from the metadata. $module_for_keys = array(); foreach ($libs->get_for_version($equivalent_version) as $details) { $module_for_keys[$details['key']] = $details['module']; } // Scan release for metadata files. $module_paths = array(); foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator("{$location}/libs", FilesystemIterator::CURRENT_AS_SELF | FilesystemIterator::UNIX_PATHS)) as $info) { if ($info->isDot() && $info->getFilename() == '.') { $path = dirname($info->getSubPathname()); if (is_file("{$info->getPathname()}/libraries.json")) { $module_paths[] = "libs/" . dirname($path); } } } $updated_libs = array(); foreach ($module_paths as $path) { $json_path = "{$location}/{$path}/meta/libraries.json"; try { $libraries = BoostLibrary::read_libraries_json(file_get_contents($json_path)); // Get the module for each library. foreach ($libraries as $lib) { if (!isset($module_for_keys[$lib->details['key']])) { echo "No module for key: {$lib->details['key']}.\n"; } else { $lib->set_module($module_for_keys[$lib->details['key']], $path); } } $updated_libs = array_merge($updated_libs, $libraries); } catch (library_decode_exception $e) { echo "Error decoding metadata for module at {$json_path}:\n{$e->content()}\n"; } } return $updated_libs; }