| 1674 | //----------------------------------------------------------------------------- |
| 1675 | |
| 1676 | bool ModuleManager::mergeModules( const char* pMergeTargetPath, const bool removeMergeDefinition, const bool registerNewModules ) |
| 1677 | { |
| 1678 | // Sanity! |
| 1679 | AssertFatal( pMergeTargetPath != NULL, "Cannot merge modules with a target path of NULL." ); |
| 1680 | |
| 1681 | // Is a module merge available? |
| 1682 | if ( !isModuleMergeAvailable() ) |
| 1683 | { |
| 1684 | // No, so warn. |
| 1685 | Con::warnf( "Cannot merge modules as a module merge is not available." ); |
| 1686 | return false; |
| 1687 | } |
| 1688 | |
| 1689 | // Expand the target path. |
| 1690 | char targetPathBuffer[1024]; |
| 1691 | Con::expandPath( targetPathBuffer, sizeof(targetPathBuffer), pMergeTargetPath ); |
| 1692 | pMergeTargetPath = targetPathBuffer; |
| 1693 | |
| 1694 | // Fetch module merge file path. |
| 1695 | StringTableEntry moduleMergeFilePath = getModuleMergeFilePath(); |
| 1696 | |
| 1697 | // Read module merge definition. |
| 1698 | Taml taml; |
| 1699 | ModuleMergeDefinition* pModuleMergeDefinition = taml.read<ModuleMergeDefinition>( moduleMergeFilePath ); |
| 1700 | |
| 1701 | // Do we have a module merge definition. |
| 1702 | if ( pModuleMergeDefinition == NULL ) |
| 1703 | { |
| 1704 | // No, so warn. |
| 1705 | Con::warnf( "Cannot merge modules as the module merge definition file failed to load '%s'.", moduleMergeFilePath ); |
| 1706 | return false; |
| 1707 | } |
| 1708 | |
| 1709 | // Fetch the merge source path. |
| 1710 | StringTableEntry mergeSourcePath = pModuleMergeDefinition->getModuleMergePath(); |
| 1711 | |
| 1712 | // Remove the module merge definition. |
| 1713 | pModuleMergeDefinition->deleteObject(); |
| 1714 | pModuleMergeDefinition = NULL; |
| 1715 | |
| 1716 | // If we cannot merge the modules then we only process modules flagged as critical merge. |
| 1717 | const bool criticalMergeOnly = !canMergeModules( mergeSourcePath ); |
| 1718 | |
| 1719 | // Initialize the target module manager and scan the target folder for modules. |
| 1720 | ModuleManager targetModuleManager; |
| 1721 | targetModuleManager.mEnforceDependencies = false; |
| 1722 | targetModuleManager.mEchoInfo = false; |
| 1723 | targetModuleManager.scanModules( pMergeTargetPath ); |
| 1724 | |
| 1725 | // Initialize the source module manager and scan the source folder for modules. |
| 1726 | ModuleManager sourceModuleManager; |
| 1727 | sourceModuleManager.mEnforceDependencies = false; |
| 1728 | sourceModuleManager.mEchoInfo = false; |
| 1729 | sourceModuleManager.scanModules( mergeSourcePath ); |
| 1730 | |
| 1731 | // Find all the source modules. |
| 1732 | typeModuleDefinitionVector sourceModules; |
| 1733 | sourceModuleManager.findModules( false, sourceModules ); |
no test coverage detected