| 1444 | //----------------------------------------------------------------------------- |
| 1445 | |
| 1446 | bool ModuleManager::synchronizeDependencies( ModuleDefinition* pRootModuleDefinition, const char* pTargetDependencyPath ) |
| 1447 | { |
| 1448 | // Sanity! |
| 1449 | AssertFatal( pRootModuleDefinition != NULL, "Cannot synchronize dependencies with NULL root module definition." ); |
| 1450 | AssertFatal( pTargetDependencyPath != NULL, "Cannot synchronize dependencies with NULL target dependency path." ); |
| 1451 | |
| 1452 | // Fetch the root module Id. |
| 1453 | StringTableEntry rootModuleId = pRootModuleDefinition->getModuleId(); |
| 1454 | |
| 1455 | // Is the root module definition registered with this module manager? |
| 1456 | if ( pRootModuleDefinition->getModuleManager() != this ) |
| 1457 | { |
| 1458 | // No, so warn. |
| 1459 | Con::warnf("Cannot synchronize dependencies for module Id '%s' as it is not registered with this module manager.", rootModuleId ); |
| 1460 | return false; |
| 1461 | } |
| 1462 | |
| 1463 | // Expand the path. |
| 1464 | char targetPathBuffer[1024]; |
| 1465 | Con::expandPath( targetPathBuffer, sizeof(targetPathBuffer), pTargetDependencyPath ); |
| 1466 | pTargetDependencyPath = targetPathBuffer; |
| 1467 | |
| 1468 | // Is the target dependency folder a directory? |
| 1469 | if ( !Platform::isDirectory( pTargetDependencyPath ) ) |
| 1470 | { |
| 1471 | // No, so we have to ensure that there is a trailing slash as that indicates a folder (not a file) when creating a path in the platform code. |
| 1472 | char createDirectoryBuffer[1024]; |
| 1473 | Con::expandPath( createDirectoryBuffer, sizeof(createDirectoryBuffer), pTargetDependencyPath, NULL, true ); |
| 1474 | |
| 1475 | // No, so can we create it? |
| 1476 | if ( !Platform::createPath( createDirectoryBuffer ) ) |
| 1477 | { |
| 1478 | // No, so warn. |
| 1479 | Con::warnf("Cannot synchronize dependencies for module Id '%s' using target directory '%s' as directory was not found and could not be created.", |
| 1480 | rootModuleId, pTargetDependencyPath ); |
| 1481 | return false; |
| 1482 | } |
| 1483 | } |
| 1484 | |
| 1485 | typeModuleLoadEntryVector resolvingQueue; |
| 1486 | typeModuleLoadEntryVector sourceModulesNeeded; |
| 1487 | |
| 1488 | // Could we resolve source dependencies? |
| 1489 | if ( !resolveModuleDependencies( rootModuleId, pRootModuleDefinition->getVersionId(), pRootModuleDefinition->getModuleGroup(), true, resolvingQueue, sourceModulesNeeded ) ) |
| 1490 | { |
| 1491 | // No, so warn. |
| 1492 | Con::warnf("Cannot synchronize dependencies for root module Id '%s' as its dependencies could not be resolved.", rootModuleId ); |
| 1493 | return false; |
| 1494 | } |
| 1495 | |
| 1496 | // Sanity! |
| 1497 | AssertFatal( sourceModulesNeeded.size() > 0, "Cannot synchronize dependencies as no modules were returned." ); |
| 1498 | |
| 1499 | // Remove the root module definition. |
| 1500 | sourceModulesNeeded.pop_back(); |
| 1501 | |
| 1502 | // Initialize the target module manager and scan the target folder for modules. |
| 1503 | ModuleManager targetModuleManager; |
no test coverage detected