def GetDefaultConfigForTest( enableTestMode: bool = False, customUnitTestRoots: Optional[List[str]] = None) -> Config: strToolAppTitle = "UnitTest" log = Log(strToolAppTitle, 0) currentDir = IOUtil.GetEnvironmentVariableForDirectory( "FSL_GRAPHICS_INTERNAL") basicConfig = BasicConfig(log) localToolConfig = LowLevelToolConfig(log.Verbosity, False, False, False, False, currentDir) projectRootConfig = ToolAppMain.GetProjectRootConfig( localToolConfig, basicConfig, currentDir) buildPlatformType = PlatformUtil.DetectBuildPlatformType() toolConfig = ToolConfig(localToolConfig, buildPlatformType, Version(1, 3, 3, 7), basicConfig, projectRootConfig.ToolConfigFile, projectRootConfig) config = Config(log, toolConfig, PluginSharedValues.TYPE_UNIT_TEST, None, True) config.ForceDisableAllWrite() if enableTestMode: config.SetTestMode() if customUnitTestRoots is not None: TEST_AddPackageRoots(config, customUnitTestRoots, True) return config
def __DoBasicPathResolve(self, pathName: str, defaultResult: str, tag: Optional[object] = None) -> str: """ Resolve a path It can start with a environment variable $() or It can start with a variable ${} """ result = None environmentName = self.TryExtractLeadingEnvironmentVariableName( pathName, True, tag) if environmentName is not None: path = IOUtil.GetEnvironmentVariableForDirectory(environmentName) result = pathName.replace("$({0})".format(environmentName), path) else: variableName = self.__TryExtractLeadingVariableName( pathName, True, tag) if variableName is not None: if not variableName in self.Variables.Dict: raise VariableNotDefinedException( variableName, cast(Dict[str, Optional[object]], self.Variables.Dict)) strReplace = "${{{0}}}".format(variableName) result = pathName.replace(strReplace, self.Variables.Dict[variableName]) return IOUtil.NormalizePath( result if result is not None else defaultResult)
def __init__( self, basicConfig: BasicConfig, basedUponXML: XmlConfigFileAddTemplateImportDirectory) -> None: super().__init__() self.BasedOn = basedUponXML self.Name = self.BasedOn.Name variableProcessor = VariableProcessor(basicConfig) # NOTE: workaround Union of tuples not being iterable bug in mypy https://github.com/python/mypy/issues/1575 tupleResult = variableProcessor.TrySplitLeadingEnvironmentVariablesNameAndPath( self.Name) envName = tupleResult[0] rest = tupleResult[1] if envName is None: raise Exception( "Template import dirs are expected to contain environment variables" ) rest = rest if rest is not None else "" self.DecodedName = envName self.BashName = IOUtil.Join('$' + self.DecodedName, rest) self.DosName = IOUtil.Join('%' + self.DecodedName + '%', rest) if self.Name is None: raise XmlException2( basedUponXML.XmlElement, "Dirs are expected to contain environment variables") self.ResolvedPath = IOUtil.Join( IOUtil.GetEnvironmentVariableForDirectory(self.DecodedName), rest) self.ResolvedPathEx = "{0}/".format( self.ResolvedPath) if len(self.ResolvedPath) > 0 else ""
def __init__( self, basicConfig: BasicConfig, basedUponXML: XmlConfigFileAddNewProjectTemplatesRootDirectory ) -> None: super().__init__() self.BasedOn = basedUponXML self.Id = basedUponXML.Id self.Name = basedUponXML.Name self.DynamicName = basedUponXML.Name variableProcessor = VariableProcessor(basicConfig) # NOTE: workaround Union of tuples not being iterable bug in mypy https://github.com/python/mypy/issues/1575 tupleResult = variableProcessor.TryExtractLeadingEnvironmentVariableNameAndPath( self.DynamicName, True) env = tupleResult[0] remainingPath = tupleResult[1] if env is None: raise Exception( "Root dirs are expected to contain environment variables '{0}'" .format(self.DynamicName)) remainingPath = remainingPath if remainingPath is not None else "" resolvedPath = IOUtil.GetEnvironmentVariableForDirectory( env) + remainingPath self.BashName = '${0}{1}'.format(env, remainingPath) self.DosName = '%{0}%{1}'.format(env, remainingPath) self.ResolvedPath = IOUtil.ToUnixStylePath(resolvedPath) self.ResolvedPathEx = "{0}/".format( self.ResolvedPath) if len(self.ResolvedPath) > 0 else "" self.__EnvironmentVariableName = env
def __init__(self, log: Log, basedUponXML: Optional[XmlConfigFileAddRootDirectory], projectId: ProjectId, dynamicSourceRootDir: Union[ Optional[XmlConfigFileAddRootDirectory], Optional['ToolConfigRootDirectory']] = None, dynamicRootName: Optional[str] = None, dynamicPath: Optional[str] = None) -> None: super().__init__() dirMustExist = True self.ProjectId = projectId if basedUponXML is not None: self.BasedOn = basedUponXML # type: Union[XmlConfigFileAddRootDirectory, 'ToolConfigRootDirectory'] self.Name = basedUponXML.Name # type: str self.DynamicName = basedUponXML.Name # type: str dirMustExist = not basedUponXML.Create else: if dynamicSourceRootDir is None: raise Exception("dynamicSourceRootDir can not be none") if dynamicRootName is None: raise Exception("dynamicRootName can not be none") if dynamicPath is None: raise Exception("dynamicPath can not be none") self.BasedOn = dynamicSourceRootDir self.Name = dynamicRootName self.DynamicName = dynamicPath variableProcessor = VariableProcessor(log) # NOTE: workaround Union of tuples not being iterable bug in mypy https://github.com/python/mypy/issues/1575 tupleResult = variableProcessor.TryExtractLeadingEnvironmentVariableNameAndPath( self.DynamicName, dynamicSourceRootDir != None) env = tupleResult[0] remainingPath = tupleResult[1] if env is None: raise Exception( "Root dirs are expected to contain environment variables '{0}'" .format(self.DynamicName)) remainingPath = remainingPath if remainingPath is not None else "" resolvedPath = IOUtil.GetEnvironmentVariableForDirectory( env, dirMustExist) if not IOUtil.Exists(resolvedPath): IOUtil.SafeMakeDirs(resolvedPath) if not IOUtil.IsDirectory(resolvedPath): raise EnvironmentError( "The {0} environment variable content '{1}' does not point to a valid directory" .format(env, resolvedPath)) resolvedPath = resolvedPath + remainingPath self.BashName = '${0}{1}'.format(env, remainingPath) # type: str self.DosName = '%{0}%{1}'.format(env, remainingPath) # type: str self.ResolvedPath = IOUtil.ToUnixStylePath(resolvedPath) # type: str self.ResolvedPathEx = "{0}/".format(self.ResolvedPath) if len( self.ResolvedPath) > 0 else "" # type: str self.__EnvironmentVariableName = env # type: str
def __init__(self, log: Log, toolConfig: ToolConfig) -> None: super().__init__(log) if toolConfig is None: raise Exception("Missing param") sdkPath = IOUtil.GetEnvironmentVariableForDirectory(ToolEnvironmentVariableName.FSL_GRAPHICS_SDK) # type: str sdkPathAndroidProjectDir = IOUtil.GetEnvironmentVariableForAbsolutePath(ToolEnvironmentVariableName.FSL_GRAPHICS_SDK_ANDROID_PROJECT_DIR) # type: str dateNow = datetime.datetime.now() self.CurrentYearString = "{0}".format(dateNow.year) # type: str self.SDKPath = sdkPath # type: str self.SDKPathAndroidProjectDir = sdkPathAndroidProjectDir # type: str self.SDKConfigTemplatePath = toolConfig.TemplateFolder.ResolvedPath self.TemplateImportDirectories = toolConfig.TemplateImportDirectories self.ToolConfig = toolConfig # type: ToolConfig if not IOUtil.IsDirectory(self.SDKConfigTemplatePath): raise EnvironmentError("Config template path '{0}' does not point to a directory".format(self.SDKConfigTemplatePath))
def GetNDKPath() -> str: return IOUtil.GetEnvironmentVariableForDirectory('ANDROID_NDK')
def GetSDKPath() -> str: return IOUtil.GetEnvironmentVariableForDirectory("ANDROID_HOME")
def CheckWindowsGLESCommon(log: Log) -> None: IOUtil.GetEnvironmentVariableForDirectory("FSL_GLES_EMULATOR_PATH") IOUtil.GetEnvironmentVariableForDirectory("FSL_GLES_INCLUDE_PATH") IOUtil.GetEnvironmentVariableForDirectory("FSL_GLES_LIB_PATH")
def CheckCommon(log: Log, verbosityLevel: int) -> None: log.LogPrintVerbose(verbosityLevel, "- Common SDK environment") IOUtil.GetEnvironmentVariableForDirectory( ToolEnvironmentVariableName.FSL_GRAPHICS_SDK)