예제 #1
0
    def __init__(self, config: Config, packages: List[Package],
                 platformName: str) -> None:
        super(GeneratorCMake, self).__init__()
        strTemplatePath = "CMake"
        extTemplate = CMakeGeneratorUtil.CodeTemplateCMake(
            config, strTemplatePath, "Ext", False)
        libTemplate = CMakeGeneratorUtil.CodeTemplateCMake(
            config, strTemplatePath, "Lib", False)
        exeTemplate = CMakeGeneratorUtil.CodeTemplateCMake(
            config, strTemplatePath, "Exe", False)
        rootTemplate = CMakeGeneratorUtil.CodeTemplateCMake(
            config, strTemplatePath, "Root", False)

        for package in packages:
            if package.Type == PackageType.ExternalLibrary or package.Type == PackageType.HeaderLibrary:
                self.__GenerateCMakeFile(config, package, platformName,
                                         extTemplate)
            elif package.Type == PackageType.Library:
                self.__GenerateCMakeFile(config, package, platformName,
                                         libTemplate)
            elif package.Type == PackageType.Executable:
                self.__GenerateCMakeFile(config, package, platformName,
                                         exeTemplate)
            elif package.Type == PackageType.TopLevel:
                self.__GenerateCMakeFile(config, package, platformName,
                                         rootTemplate)
    def __init__(self, config: Config, packages: List[Package],
                 platformName: str, templateName: str,
                 overrideTemplateName: Optional[str]) -> None:
        super().__init__()

        self.__DisableWrite = config.DisableWrite

        # Create a quick lookup table
        toolProjectContextsDict = {
            projectContext.ProjectId: projectContext
            for projectContext in config.ToolConfig.ProjectInfo.Contexts
        }

        strTemplatePath = templateName
        extTemplate = CMakeGeneratorUtil.CodeTemplateCMake(
            config, strTemplatePath, "Ext", False, overrideTemplateName)
        libTemplate = CMakeGeneratorUtil.CodeTemplateCMake(
            config, strTemplatePath, "Lib", False, overrideTemplateName)
        exeTemplate = CMakeGeneratorUtil.CodeTemplateCMake(
            config, strTemplatePath, "Exe", False, overrideTemplateName)
        rootTemplate = CMakeGeneratorUtil.CodeTemplateCMake(
            config, strTemplatePath, "Root", False, overrideTemplateName)
        notSupportedTemplate = CMakeGeneratorUtil.CodeTemplateCMake(
            config, strTemplatePath, "NotSupported", False,
            overrideTemplateName)

        useExtendedProjectHack = True
        for package in packages:
            isSupported = not package.ResolvedPlatformNotSupported
            if package.Type == PackageType.ExternalLibrary or package.Type == PackageType.HeaderLibrary:
                self.__GenerateCMakeFile(
                    config, package, platformName,
                    extTemplate if isSupported else notSupportedTemplate,
                    toolProjectContextsDict, useExtendedProjectHack)
            elif package.Type == PackageType.Library:
                self.__GenerateCMakeFile(
                    config, package, platformName,
                    libTemplate if isSupported else notSupportedTemplate,
                    toolProjectContextsDict, useExtendedProjectHack)
            elif package.Type == PackageType.Executable:
                self.__GenerateCMakeFile(
                    config, package, platformName,
                    exeTemplate if isSupported else notSupportedTemplate,
                    toolProjectContextsDict, useExtendedProjectHack)
            elif package.Type == PackageType.TopLevel:
                self.__GenerateRootCMakeFile(config, package, platformName,
                                             rootTemplate,
                                             toolProjectContextsDict,
                                             useExtendedProjectHack)
    def __init__(self, config: Config, packages: List[Package], platformName: str, androidABIList: List[str]) -> None:
        super().__init__()

        if config.SDKPathAndroidProjectDir is None:
            raise EnvironmentError("Android environment variable {0} not defined".format(ToolEnvironmentVariableName.FSL_GRAPHICS_SDK_ANDROID_PROJECT_DIR))

        strAppTemplatePath = "AndroidGradleCMake"
        templateFilePath = IOUtil.Join(config.SDKConfigTemplatePath, strAppTemplatePath)
        templateFileRecordManager = TemplateFileRecordManager(templateFilePath)
        templateFileProcessor = TemplateFileProcessor(config, platformName)

        strTemplatePath = IOUtil.Join(strAppTemplatePath, "CMake")
        extTemplate = CMakeGeneratorUtil.CodeTemplateCMake(config, strTemplatePath, "Ext", False, None)
        libTemplate = CMakeGeneratorUtil.CodeTemplateCMake(config, strTemplatePath, "Lib", False, None)
        exeTemplate = CMakeGeneratorUtil.CodeTemplateCMake(config, strTemplatePath, "Exe", False, None)

        templatePath = IOUtil.Join(config.SDKConfigTemplatePath, strAppTemplatePath)
        exeFileList = self.__ParseExeFileList(IOUtil.Join(templatePath, "ExeFiles.txt"))

        localSnippets = AndroidGradleCMakeSnippets(templatePath)

        cmakePackageRootVariables = self.__GenerateCmakePackageRootVariables(config, localSnippets)

        totalExeCount = 0
        for mainPackage in packages:
            if mainPackage.Type == PackageType.Executable:
                totalExeCount = totalExeCount + 1
                appPackageTemplateInfo = AndroidGeneratorUtil.AppPackageTemplateInfo(mainPackage)
                androidProjectDir = IOUtil.Join(config.SDKPathAndroidProjectDir, appPackageTemplateInfo.ProjectPathName)
                androidProjectCMakeDir = IOUtil.Join(androidProjectDir, ".FslCMake")

                for package in mainPackage.ResolvedBuildOrder:
                    if not package.ResolvedPlatformNotSupported:
                        if package.Type == PackageType.ExternalLibrary or package.Type == PackageType.HeaderLibrary:
                            self.__GenerateCMakeFile(config, package, platformName, extTemplate, androidProjectDir, androidProjectCMakeDir)
                        elif package.Type == PackageType.Library:
                            self.__GenerateCMakeFile(config, package, platformName, libTemplate, androidProjectDir, androidProjectCMakeDir)
                        elif package.Type == PackageType.Executable:
                            self.__GenerateExecutable(config, package, platformName, exeTemplate, templateFileRecordManager, templateFileProcessor,
                                                      appPackageTemplateInfo, androidProjectDir, androidProjectCMakeDir,
                                                      exeFileList, androidABIList, cmakePackageRootVariables)

        # For now we only support doing 'exe' builds using full source for everything (like the old builder)
        if totalExeCount <= 0:
            config.DoPrint("No executables provided, nothing to build.")