Example #1
0
    def loadProjectConfig(self, name):
        schemaPath = self._varMgr.expandPath('[UnityProjectsDir]/{0}/{1}'.format(name, ProjectConfigFileName))
        schemaPathUser = self._varMgr.expandPath('[UnityProjectsDir]/{0}/{1}'.format(name, ProjectUserConfigFileName))
        schemaPathGlobal = self._varMgr.expandPath('[UnityProjectsDir]/{0}'.format(ProjectConfigFileName))
        schemaPathUserGlobal = self._varMgr.expandPath('[UnityProjectsDir]/{0}'.format(ProjectUserConfigFileName))

        self._log.debug('Loading schema at path "{0}"'.format(schemaPath))
        yamlConfig = Config(loadYamlFilesThatExist(schemaPath, schemaPathUser, schemaPathGlobal, schemaPathUserGlobal))

        config = ProjectConfig()

        config.pluginsFolder = yamlConfig.tryGetList([], 'PluginsFolder')
        config.assetsFolder = yamlConfig.tryGetList([], 'AssetsFolder')
        config.solutionProjects = yamlConfig.tryGetList([], 'SolutionProjects')
        config.targetPlatforms = yamlConfig.tryGetList([Platforms.Windows], 'TargetPlatforms')
        config.solutionFolders = yamlConfig.tryGetOrderedDictionary(OrderedDict(), 'SolutionFolders')
        config.packageFolders = yamlConfig.getList('PackageFolders')
        config.projectSettingsPath = yamlConfig.getString('ProjectSettingsPath')

        # Remove duplicates
        config.assetsFolder = list(set(config.assetsFolder))
        config.pluginsFolder = list(set(config.pluginsFolder))

        for packageName in config.pluginsFolder:
            assertThat(not packageName in config.assetsFolder, "Found package '{0}' in both scripts and plugins.  Must be in only one or the other".format(packageName))

        return config
Example #2
0
    def loadProjectConfig(self, name):
        schemaPath = self._varMgr.expandPath('[UnityProjectsDir]/{0}/{1}'.format(name, ProjectConfigFileName))
        schemaPathUser = self._varMgr.expandPath('[UnityProjectsDir]/{0}/{1}'.format(name, ProjectUserConfigFileName))
        schemaPathGlobal = self._varMgr.expandPath('[UnityProjectsDir]/{0}'.format(ProjectConfigFileName))
        schemaPathUserGlobal = self._varMgr.expandPath('[UnityProjectsDir]/{0}'.format(ProjectUserConfigFileName))

        self._log.debug('Loading schema at path "{0}"'.format(schemaPath))
        yamlConfig = Config(loadYamlFilesThatExist(schemaPath, schemaPathUser, schemaPathGlobal, schemaPathUserGlobal))

        config = ProjectConfig()

        config.pluginsFolder = yamlConfig.tryGetList([], 'PluginsFolder')
        config.assetsFolder = yamlConfig.tryGetList([], 'AssetsFolder')
        config.solutionProjects = yamlConfig.tryGetList([], 'SolutionProjects')
        config.targetPlatforms = yamlConfig.tryGetList([Platforms.Windows], 'TargetPlatforms')
        config.solutionFolders = yamlConfig.tryGetOrderedDictionary(OrderedDict(), 'SolutionFolders')
        config.packageFolders = yamlConfig.getList('PackageFolders')
        config.projectSettingsPath = yamlConfig.getString('ProjectSettingsPath')

        # Remove duplicates
        config.assetsFolder = list(set(config.assetsFolder))
        config.pluginsFolder = list(set(config.pluginsFolder))

        for packageName in config.pluginsFolder:
            assertThat(not packageName in config.assetsFolder, "Found package '{0}' in both scripts and plugins.  Must be in only one or the other".format(packageName))

        return config
Example #3
0
    def _getAllPackageInfos(self, projectConfig, platform):
        configRefDesc = "'{0}' or '{1}'".format(ProjectConfigFileName, ProjectUserConfigFileName)
        allPackageRefs = [PackageReference(x, configRefDesc) for x in projectConfig.pluginsFolder + projectConfig.assetsFolder]

        packageMap = {}

        # Resolve all dependencies for each package
        # by default, put any dependencies that are not declared explicitly into the plugins folder
        for packageRef in allPackageRefs:

            packageName = packageRef.name
            packageDir = None

            for packageFolder in projectConfig.packageFolders:
                candidatePackageDir = os.path.join(packageFolder, packageName)

                if self._sys.directoryExists(candidatePackageDir):
                    packageDir = self._varMgr.expandPath(candidatePackageDir)
                    break

            assertIsNotNone(packageDir, "Could not find package '{0}' in any of the package directories!  Referenced in {1}", packageName, packageRef.sourceDesc)

            configPath = os.path.join(packageDir, PackageConfigFileName)

            if os.path.exists(configPath):
                packageConfig = Config(loadYamlFilesThatExist(configPath))
            else:
                packageConfig = Config([])

            folderType = self._getFolderTypeFromString(packageConfig.tryGetString('', 'FolderType'))

            if not self._shouldIncludeForPlatform(packageName, packageConfig, folderType, platform):
                continue

            createCustomVsProject = self._shouldCreateVsProjectForName(packageName, projectConfig.solutionProjects)

            isPluginsDir = True

            if packageName in projectConfig.assetsFolder:
                assertThat(not packageName in projectConfig.pluginsFolder)
                isPluginsDir = False

            if packageConfig.tryGetBool(False, 'ForceAssetsDirectory'):
                isPluginsDir = False

            explicitDependencies = packageConfig.tryGetList([], 'Dependencies')

            forcePluginsDir = packageConfig.tryGetBool(False, 'ForcePluginsDirectory')

            assemblyProjInfo = self._tryGetAssemblyProjectInfo(packageConfig, packageName)

            sourceDesc = '"{0}"'.format(configPath)

            if assemblyProjInfo != None:
                for assemblyDependName in assemblyProjInfo.dependencies:
                    if assemblyDependName not in [x.name for x in allPackageRefs]:
                        allPackageRefs.append(PackageReference(assemblyDependName, sourceDesc))

                explicitDependencies += assemblyProjInfo.dependencies

            groupedDependencies = packageConfig.tryGetList([], 'GroupWith')
            extraDependencies = packageConfig.tryGetList([], 'Extras')

            assertThat(not packageName in packageMap, "Found duplicate package with name '{0}'", packageName)

            packageMap[packageName] = PackageInfo(
                isPluginsDir, packageName, packageConfig, createCustomVsProject,
                explicitDependencies, forcePluginsDir, folderType, assemblyProjInfo, packageDir, groupedDependencies)

            for dependName in (explicitDependencies + groupedDependencies + extraDependencies):
                if dependName not in [x.name for x in allPackageRefs]:
                    # Yes, python is ok with changing allPackageRefs even while iterating over it
                    allPackageRefs.append(PackageReference(dependName, sourceDesc))

        return packageMap
Example #4
0
    def loadProjectConfig(self, name):
        schemaPath = self._varMgr.expandPath(
            '[UnityProjectsDir]/{0}/{1}'.format(name, ProjectConfigFileName))
        schemaPathUser = self._varMgr.expandPath(
            '[UnityProjectsDir]/{0}/{1}'.format(name,
                                                ProjectUserConfigFileName))
        schemaPathGlobal = self._varMgr.expandPath(
            '[UnityProjectsDir]/{0}'.format(ProjectConfigFileName))
        schemaPathUserGlobal = self._varMgr.expandPath(
            '[UnityProjectsDir]/{0}'.format(ProjectUserConfigFileName))

        self._log.debug('Loading schema at path "{0}"'.format(schemaPath))
        yamlConfig = Config(
            loadYamlFilesThatExist(schemaPath, schemaPathUser,
                                   schemaPathGlobal, schemaPathUserGlobal))

        config = ProjectConfig()

        config.pluginsFolder = yamlConfig.tryGetList([], 'PluginsFolder')
        config.assetsFolder = yamlConfig.tryGetList([], 'AssetsFolder')
        config.solutionProjects = yamlConfig.tryGetList([], 'SolutionProjects')
        config.targetPlatforms = yamlConfig.tryGetList([Platforms.Windows],
                                                       'TargetPlatforms')
        config.solutionFolders = yamlConfig.tryGetOrderedDictionary(
            OrderedDict(), 'SolutionFolders')
        config.packageFolders = yamlConfig.getList('PackageFolders')
        config.projectSettingsPath = yamlConfig.getString(
            'ProjectSettingsPath')
        config.customDirectories = yamlConfig.tryGetDictionary(
            {}, 'CustomPackageDirectories')

        customDirectories = config.customDirectories
        for key, value in customDirectories.items():
            self._varMgr.set(key, value)

        # Remove duplicates
        # config.assetsFolderDict = dict(set(config.assetsFolder))
        tmpList = []
        for x in config.assetsFolder:
            if type(x) is dict:
                tmpList.append(x["name"])
            else:
                tmpList.append(x)

        duplicates = [
            item for item, count in Counter(tmpList).items() if count > 1
        ]
        self._log.debug("duplicates {0}".format(duplicates))
        for d in duplicates:
            self._log.debug("removing {0}".format(d))
            tmpList.remove(d)

        config.pluginsFolder = list(set(config.pluginsFolder))

        for packageName in config.pluginsFolder:
            assertThat(
                not packageName in config.assetsFolder,
                "Found package '{0}' in both scripts and plugins.  Must be in only one or the other"
                .format(packageName))

        return config
Example #5
0
    def _getAllPackageInfos(self, projectConfig, platform):
        configRefDesc = "'{0}' or '{1}'".format(ProjectConfigFileName, ProjectUserConfigFileName)
        allPackageRefs = [PackageReference(x, configRefDesc) for x in projectConfig.pluginsFolder + projectConfig.assetsFolder]

        packageMap = {}

        # Resolve all dependencies for each package
        # by default, put any dependencies that are not declared explicitly into the plugins folder
        for packageRef in allPackageRefs:

            packageName = packageRef.name
            packageDir = None

            for packageFolder in projectConfig.packageFolders:
                candidatePackageDir = os.path.join(packageFolder, packageName)

                if self._sys.directoryExists(candidatePackageDir):
                    packageDir = self._varMgr.expandPath(candidatePackageDir)
                    break

            assertIsNotNone(packageDir, "Could not find package '{0}' in any of the package directories!  Referenced in {1}", packageName, packageRef.sourceDesc)

            configPath = os.path.join(packageDir, PackageConfigFileName)

            if os.path.exists(configPath):
                packageConfig = Config(loadYamlFilesThatExist(configPath))
            else:
                packageConfig = Config([])

            folderType = self._getFolderTypeFromString(packageConfig.tryGetString('', 'FolderType'))

            if not self._shouldIncludeForPlatform(packageName, packageConfig, folderType, platform):
                continue

            createCustomVsProject = self._shouldCreateVsProjectForName(packageName, projectConfig.solutionProjects)

            isPluginsDir = True

            if packageName in projectConfig.assetsFolder:
                assertThat(not packageName in projectConfig.pluginsFolder)
                isPluginsDir = False

            if packageConfig.tryGetBool(False, 'ForceAssetsDirectory'):
                isPluginsDir = False

            explicitDependencies = packageConfig.tryGetList([], 'Dependencies')

            forcePluginsDir = packageConfig.tryGetBool(False, 'ForcePluginsDirectory')

            assemblyProjInfo = self._tryGetAssemblyProjectInfo(packageConfig, packageName)

            sourceDesc = '"{0}"'.format(configPath)

            if assemblyProjInfo != None:
                for assemblyDependName in assemblyProjInfo.dependencies:
                    if assemblyDependName not in [x.name for x in allPackageRefs]:
                        allPackageRefs.append(PackageReference(assemblyDependName, sourceDesc))

                explicitDependencies += assemblyProjInfo.dependencies

            groupedDependencies = packageConfig.tryGetList([], 'GroupWith')
            extraDependencies = packageConfig.tryGetList([], 'Extras')

            assertThat(not packageName in packageMap, "Found duplicate package with name '{0}'", packageName)

            packageMap[packageName] = PackageInfo(
                isPluginsDir, packageName, packageConfig, createCustomVsProject,
                explicitDependencies, forcePluginsDir, folderType, assemblyProjInfo, packageDir, groupedDependencies)

            for dependName in (explicitDependencies + groupedDependencies + extraDependencies):
                if dependName not in [x.name for x in allPackageRefs]:
                    # Yes, python is ok with changing allPackageRefs even while iterating over it
                    allPackageRefs.append(PackageReference(dependName, sourceDesc))

        return packageMap