Пример #1
0
	def setUp(self):
		self.mock_params = Mock()
		self.mock_params.configPath = [generic_path.Path("config")]
		self.mock_params.home = generic_path.Path(test_data)
		self.mock_params.logFileName = generic_path.Path("tmp/foo")
		self.mock_params.timestring = "now"
		
		# where do we expect the output to be written
		self.html_dir = str(self.mock_params.logFileName) + "_html"
Пример #2
0
 def setUp(self):
     self.__logger = TestRaptorXML.Logger()
     self.__nullSysDefRoot = generic_path.Path("smoke_suite/test_resources")
     self.__sysDefRoot = generic_path.Join(
         os.environ[raptor.build.env], "test/smoke_suite/test_resources")
     self.__sysDefFileRoot = generic_path.Join(os.environ[raptor.build.env],
                                               "test/metadata/system")
Пример #3
0
	def resolve(self):
		compilerpreincludeheader = ""
		sourcemacros = []

		evaluator = self._getEvaluator(self.__meaning)

		platform = evaluator.Get("TRADITIONAL_PLATFORM")
			
		# Compiler preinclude files may or may not be present, depending on the configuration.
		if evaluator.Get("PREINCLUDE"):
			compilerpreincludeheader = generic_path.Path(evaluator.Get("PREINCLUDE"))
			
		# Macros arrive as a a list of strings, or a single string, containing definitions of the form "name" or "name=value". 
		# If required, we split to a list, and then processes the constituent parts of the macro.
		sourcemacrolist = evaluator.Get("CDEFS").split()
		sourcemacros.extend([[macrodef.partition("=")[0], macrodef.partition("=")[2]] for macrodef in sourcemacrolist])

		if platform == "TOOLS2":
			# Source macros are determined in the FLM for tools2 builds, therefore we have to
			# mimic the logic here
			if 'win' in raptor.build.hostplatform or 'win32' in self.__meaning:
				sourcemacrolist = evaluator.Get("CDEFS.WIN32").split()
			else:
				sourcemacrolist = evaluator.Get("CDEFS.LINUX").split()
			sourcemacros.extend([[macrodef.partition("=")[0], macrodef.partition("=")[2]] for macrodef in sourcemacrolist])

		if len(sourcemacros):
			self.sourcemacros = [Macro(x[0],x[1]) if x[1] else Macro(x[0]) for x in sourcemacros]
			
		if compilerpreincludeheader:
			self.compilerpreincludeheader = PreInclude(str(compilerpreincludeheader))
Пример #4
0
	def resolve(self):
		includepaths = []
		preincludeheader = ""
		platmacros = []

		evaluator = self._getEvaluator(self.__meaning)

		# Initialise data and metadata objects
		buildunits = raptor.data.GetBuildUnits([self.__meaning], self._raptor.cache, self._raptor)
		metareader = raptor.meta.MetaReader(self._raptor, buildunits)
		metadatafile = raptor.meta.MetaDataFile(generic_path.Path("bld.inf"), "cpp", [], None, self._raptor)
		
		# There is only one build platform here; obtain the pre-processing include paths,
		# OS pre-include file, compiler pre-include file and macros.			
		includepaths = metadatafile.preparePreProcessorIncludePaths(metareader.BuildPlatforms[0])
		preincludeheader = metareader.BuildPlatforms[0]['VARIANT_HRH']
		
		# Macros arrive as a a list of strings, or a single string, containing definitions of the form "name" or "name=value". 
		platmacrolist = metadatafile.preparePreProcessorMacros(metareader.BuildPlatforms[0])
		platmacros.extend([[macrodef.partition("=")[0], macrodef.partition("=")[2]] for macrodef in platmacrolist])

		# Add child elements to appropriate areas if they were calculated
		if len(includepaths) > 0:
			self.includepaths = [Include(str(x)) for x in includepaths]
		
		if preincludeheader != "":
			self.preincludeheader = PreInclude(str(preincludeheader))
		
		if len(platmacros):
			self.platmacros = [Macro(x[0],x[1]) if x[1] else Macro(x[0]) for x in platmacros]
Пример #5
0
def copyfile(_source, _destination):
	"""Copy the source file to the destination file (create a directory
	   to copy into if it does not exist). Don't copy if the destination
	   file exists and has an equal or newer modification time."""
	source = generic_path.Path(str(_source).replace('%20',' '))
	destination = generic_path.Path(str(_destination).replace('%20',' '))
	dest_str = str(destination)
	source_str = str(source)

	try:


		destDir = destination.Dir()
		if not destDir.isDir():
			os.makedirs(str(destDir))
			# preserve permissions
			shutil.copy(source_str, dest_str)
			return 
		# Destination file exists so we have to think about updating it
		sourceMTime = 0
		destMTime = 0
		sourceStat = 0
		try:
			sourceStat = os.stat(source_str)
			sourceMTime = sourceStat[stat.ST_MTIME]
		except OSError as e:
			message = "Source of copyfile does not exist:  " + str(source)
			raise IOError(message)
		try:
			destMTime = os.stat(dest_str)[stat.ST_MTIME]
		except OSError as e:
			pass # destination doesn't have to exist

		if destMTime == 0 or destMTime < sourceMTime:
			# remove old version
			#	- not having ownership prevents chmod
			#	- avoid clobbering the original if it is a hard link
			if os.path.exists(dest_str):
				os.unlink(dest_str)
			# preserve permissions
			shutil.copy(source_str, dest_str)

	except Exception as e:
		message = "Could not update {0} from {1}:{2}".format(dest_str,source_str,str(e))
		raise IOError(message)

	return 
Пример #6
0
    def __init__(self,
                 aLogger,
                 aSystemDefinitionFile=None,
                 aSystemDefinitionBase=None,
                 aDoRead=True):
        self.__Logger = aLogger

        if aSystemDefinitionFile:
            self.__SystemDefinitionFile = aSystemDefinitionFile.GetLocalString(
            )
        else:
            self.__SystemDefinitionFile = generic_path.Path(
                'undefined').GetLocalString()

        if aSystemDefinitionBase:
            self.__SystemDefinitionBase = aSystemDefinitionBase.GetLocalString(
            )
        else:
            self.__SystemDefinitionBase = generic_path.Path(
                'undefined').GetLocalString()

        self.__Version = {'MAJOR': 0, 'MID': 0, 'MINOR': 0}
        self.__IdAttribute = "name"
        self.__ComponentRoot = ""
        self.__TotalComponents = 0
        self.__LayerList = []
        self.__LayerDetails = {}
        self.__MissingBldInfs = {}

        self.__DOM = None
        self.__SystemDefinitionElement = None

        if aDoRead:
            if self.__Read():
                if self.__Validate():
                    self.__Parse()

            if self.__DOM:
                self.__DOM.unlink()
Пример #7
0
    def __init__(self):
        self.analyseonly = False
        self.quiet = False
        # defaults can use EPOCROOT
        if "EPOCROOT" in os.environ:
            self.epocroot = str(generic_path.Path(os.environ["EPOCROOT"]))
        else:
            self.epocroot = str(generic_path.Path('/'))
        self.current_recipe_logged = False
        self.cleaned = 0  # cleaned files
        self.dotcount = 0  # progress dots printed so far
        # list of strings to catch make errors (must be lowercase)
        self.make_error_expr = set([
            "error:", ": ***", "make: interrupt/exception caught (code =",
            "make.exe: interrupt/exception caught (code =",
            "command returned code"
        ])
        # list of strings to catch make warnings (must be lowercase)
        self.make_warning_expr = ["warning:"]

        # list of strings to catch recipe warnings (must be lowercase)
        self.recipe_warning_expr = ["warning:"]

        self.make_returned_error = False
Пример #8
0
    def testClassLinux(self):
        if self.isWin32():
            return

        local1 = generic_path.Path('some/folder/another/')
        local2 = generic_path.Join(local1, "test", "tmp")

        self.assertEqual(str(local2), "some/folder/another/test/tmp")

        msys1 = generic_path.Path('some/folder/another/')
        msys2 = generic_path.Join(msys1, "test", "tmp")

        self.assertEqual(str(msys2), "some/folder/another/test/tmp")

        # Absolute

        local1 = generic_path.Path('some/folder')
        self.failIf(local1.isAbsolute())

        abs1 = local1.Absolute()
        self.assertEqual(str(abs1), self.cwd + "/some/folder")

        local2 = generic_path.Path('/some/folder')
        self.failUnless(local2.isAbsolute())

        abs2 = local2.Absolute()
        self.assertEqual(str(abs2), "/some/folder")

        root = generic_path.Path("/")
        self.assertEqual(str(root), "/")

        # Path

        path = generic_path.Path("some/thing/")
        self.assertEqual(str(path), "some/thing")

        # SpaceSafePath

        # This doesn't mean much on non-Windows platforms, but we confirm nothing breaks if it is used
        pathwithspaces = "/Program Files/Some tool installed with spaces/no_spaces/s p c/no_more_spaces"
        path2 = generic_path.Path(pathwithspaces)

        spacesafe = path2.GetSpaceSafePath()
        self.assertEqual(spacesafe, None)
Пример #9
0
    def testClassCommon(self):

        p1 = generic_path.Path("a", "b")

        p2 = p1.Append("c")
        self.assertEqual(str(p2), "a/b/c")

        p3 = p1.Append("c", "d")
        self.assertEqual(str(p3), "a/b/c/d")

        p4 = p1.Prepend("z")
        self.assertEqual(str(p4), "z/a/b")

        p5 = p1.Prepend("y", "z")
        self.assertEqual(str(p5), "y/z/a/b")

        self.assertEqual(str(p5.Dir()), "y/z/a")
        self.assertEqual(p5.File(), "b")

        p6 = generic_path.Join("test")
        self.assertEqual(str(p6.Dir()), "")
        self.assertEqual(p6.File(), "test")
Пример #10
0
    def testClassWin32(self):
        if not self.isWin32():
            return

        local1 = generic_path.Path('some\\folder\\another\\')
        local2 = generic_path.Join(local1, "test", "tmp")

        self.assertEqual(str(local2), "some/folder/another/test/tmp")

        # Absolute

        local1 = generic_path.Path('some\\folder')
        self.failIf(local1.isAbsolute())

        abs1 = local1.Absolute()
        self.assertEqual(
            str(abs1).lower(), (self.cwd + "/some/folder").lower())

        local2 = generic_path.Path('C:\\some\\folder')
        self.failUnless(local2.isAbsolute())

        abs2 = local2.Absolute()
        self.assertEqual(str(abs2), "C:/some/folder")

        local3 = generic_path.Path('\\somerandomfolder')
        self.failUnless(re.match('^[A-Za-z]:/somerandomfolder$', str(local3)))

        local4 = generic_path.Path('\\my\\folder\\')
        self.failUnless(re.match('^[A-Za-z]:/my/folder$', str(local4)))

        local5 = generic_path.Path('\\')
        self.failUnless(re.match('^[A-Za-z]:$', str(local5)))

        local6 = generic_path.Path("C:")
        self.failUnless(local6.isAbsolute())
        self.failUnless(local6.isDir())
        self.failUnless(local6.Exists())

        local7 = local6.Absolute()
        self.assertEqual(str(local7), "C:")

        local8 = generic_path.Path("C:/")
        self.failUnless(local8.isAbsolute())
        self.failUnless(local8.isDir())
        self.failUnless(local8.Exists())

        local9 = local8.Absolute()
        self.assertEqual(str(local9), "C:")

        # Drives

        driveD = generic_path.Path("D:\\", "folder")
        self.assertEqual(str(driveD), "D:/folder")

        driveA = generic_path.Path("a:\\")
        self.assertEqual(str(driveA), "a:")
        self.assertEqual(str(driveA.Dir()), "a:")

        driveZ = generic_path.Path("Z:\\test")
        self.assertEqual(str(driveZ), "Z:/test")

        joinC = generic_path.Join("C:\\", "something")
        self.assertEqual(str(joinC), "C:/something")

        joinM = generic_path.Join("M:", "something")
        self.assertEqual(str(joinM), "M:/something")

        # Path

        path2 = generic_path.Path("m:/sys/thing/")
        self.assertEqual(str(path2), "m:/sys/thing")

        path3 = generic_path.Path("m:\\sys\\thing\\")
        self.assertEqual(str(path3), "m:/sys/thing")

        path4 = generic_path.Path("m:\\")
        self.assertEqual(str(path4), "m:")

        path5 = generic_path.Path("\\sys\\thing\\")
        self.failUnless(re.match('^[A-Za-z]:/sys/thing$', str(path5)))

        path6 = generic_path.Path("m:/")
        self.assertEqual(str(path6), "m:")

        # SpaceSafePath

        epocroot = os.path.abspath(os.environ.get('EPOCROOT')).replace(
            '\\', '/').rstrip('/')
        pathwithspaces = epocroot + "/epoc32/build/Program Files/Some tool installed with spaces/no_spaces/s p c/no_more_spaces"
        path7 = generic_path.Path(pathwithspaces)

        # SpaceSafe paths on Windows are 8.3 format, and these can only be deduced if they actually exist.
        os.makedirs(pathwithspaces)
        spacesafe = path7.GetSpaceSafePath()
        self.assertTrue(
            spacesafe.endswith("PROGRA~1/SOMETO~1/NO_SPA~1/SPC~1/NO_MOR~1"))

        os.removedirs(pathwithspaces)
        spacesafe = path7.GetSpaceSafePath()
        self.assertEqual(spacesafe, None)
Пример #11
0
    def write(self, text):
        """Write errors and warnings to stdout"""

        if text.startswith("<error"):
            start = text.find(">")
            end = text.rfind("<")
            if text.find("The make-engine exited with errors") > 0:
                self.make_returned_error = True
            else:
                self.err_count += 1
            if not self.analyseonly:
                m = FilterTerminal.attribute_re.findall(text, 0, start)
                component = ""
                for i in m:
                    if i[0] == 'bldinf':
                        component = " (component " + i[1] + ")"
                sys.stderr.write(
                    self.formatError(text[(start + 1):end] + component))
        elif text.startswith("<warning"):
            start = text.find(">")
            end = text.rfind("<")
            self.warn_count += 1
            if not self.analyseonly:
                m = FilterTerminal.attribute_re.findall(text, 0, start)
                component = ""
                for i in m:
                    if i[0] == 'bldinf':
                        component = " (component " + i[1] + ")"
                sys.stdout.write(
                    self.formatWarning(text[(start + 1):end] + component))
        elif text.startswith("<status "):
            # detect the status report from a recipe
            if text.find('failed') != -1:
                self.failed = True
                if text.find("reason='timeout'") != -1:
                    self.timedout = True
            else:
                self.failed = False
            return
        elif text.startswith("<recipe "):
            # detect the start of a recipe
            if self.inRecipe:
                sys.stdout.flush()
                sys.stderr.write(self.formatError("Opening recipe tag found " \
                   "before closing recipe tag for previous recipe:\n" \
                   "Discarding previous recipe (Possible logfile " \
                   "corruption)"))
                sys.stderr.flush()
            self.inRecipe = True
            self.current_recipe_logged = False
            m = FilterTerminal.attribute_re.findall(text)
            self.recipe_dict = dict()
            for i in m:
                self.recipe_dict[i[0]] = i[1]

            # Decide what to tell the user about this recipe
            # The target file or the source file?
            name = None
            if 'source' in self.recipe_dict:
                name = self.recipe_dict['source']

            name_to_user = ""
            # Make source files relative to the current directory if they are
            # not generated files in epocroot.  Also make sure path is in
            # the appropriate format for the user's shell.
            if name and (name.find("epoc32") == -1
                         or name.endswith('.UID.CPP')):
                for i in name.rsplit():
                    name_to_user += " " + generic_path.Path(i).From(
                        generic_path.CurrentDir()).GetShellPath()
            else:
                # using the target.  Shorten it if it's in epocroot by just chopping off
                # epocroot
                name_to_user = self.recipe_dict['target']
                if name_to_user.find(self.epocroot) != -1:
                    name_to_user = name_to_user.replace(self.epocroot, "")
                    if name_to_user.startswith('/') or name_to_user.startswith(
                            '\\'):
                        name_to_user = name_to_user[1:]
                name_to_user = generic_path.Path(name_to_user).GetShellPath()
            self.recipe_dict['name_to_user'] = name_to_user
            self.recipe_dict['mappedname'] = self.recipe_dict['name']

            # Status message to indicate that we are building
            recipename = self.recipe_dict['name']
            if recipename in FilterTerminal.docare:
                self.recipe_dict['mappedname'] = FilterTerminal.docare[
                    recipename]
                self.logit_if()

            # This variable holds all recipe information
            self.failed = False  # Recipe status
            self.timedout = False  # Did it Timeout?
            self.recipeBody = []
            self.recipelineExceeded = 0
            return
        elif text.startswith("</recipe>"):
            # detect the end of a recipe
            if not self.inRecipe:
                sys.stdout.flush()
                sys.stderr.write(self.formatError("Closing recipe tag found " \
                   "before opening recipe tag:\nUnable to print " \
                   "recipe data (Possible logfile corruption)"))
                sys.stderr.flush()
            else:
                self.inRecipe = False

                if self.failed == True:
                    if not self.analyseonly:
                        reason = ""
                        if self.timedout:
                            reason = "(timeout)"

                        sys.stderr.write("\n FAILED {0} {1} for {2}: {3}\n".format( \
                          self.recipe_dict['name'],
                          reason,
                          self.recipe_dict['config'],
                          self.recipe_dict['name_to_user']))

                        mmppath = generic_path.Path(
                            self.recipe_dict['mmp']).From(
                                generic_path.CurrentDir()).GetShellPath()
                        if mmppath is not "":
                            sys.stderr.write("  mmp: {0}\n".format(mmppath))
                        if self.timedout:
                            sys.stderr.write( \
                     """    Timeouts may be due to network related issues (e.g. license servers),
    tool bugs or abnormally large components. TALON_TIMEOUT can be adjusted 
    in the make engine configuration if required.  Make engines may have 
    their own timeouts that Raptor cannot influence
""")
                        else:
                            for L in self.recipeBody:
                                if not L.startswith('+'):
                                    sys.stdout.write("   {0}\n".format(
                                        L.rstrip()))
                    self.err_count += 1
                else:
                    r = Recipe.factory(self.recipe_dict['name'],
                                       "".join(self.recipeBody))
                    warnings = r.warnings()
                    info = r.info()
                    if len(warnings) or len(info):
                        if not self.analyseonly:
                            for L in self.recipeBody:
                                if not L.startswith('+'):
                                    sys.stdout.write("   {0}\n".format(
                                        L.rstrip()))
                        self.warn_count += len(warnings)

                self.recipeBody = []
            return
        elif not self.inRecipe and self.isMakeError(text):
            # these two statements pick up errors coming from make
            self.err_count += 1
            sys.stderr.write("    {0}\n".format(text.rstrip()))
            return
        elif not self.inRecipe and self.isMakeWarning(text):
            self.warn_count += 1
            sys.stdout.write("    {0}\n".format(text.rstrip()))
            return
        elif text.startswith("<![CDATA["):
            # save CDATA body during a recipe
            if self.inRecipe:
                self.inBody = True
        elif text.startswith("]]>"):
            if self.inRecipe:
                self.inBody = False
                if self.recipelineExceeded > 0:
                    self.recipeBody.append("[filter_terminal: OUTPUT TRUNCATED: " \
                     "Recipe output limit exceeded; see logfile for full output " \
                     "({0} lines shown out of {1})]".format(FilterTerminal.recipelinelimit,
                     FilterTerminal.recipelinelimit + self.recipelineExceeded))
        elif text.startswith("<info>"):
            if text.startswith("<info>Copied"):
                if not self.analyseonly and not self.quiet:
                    start = text.find(" to ") + 4
                    end = text.find("</info>", start)
                    short_target = text[start:end]
                    if short_target.startswith(self.epocroot):
                        short_target = short_target.replace(self.epocroot,
                                                            "")[1:]
                    short_target = generic_path.Path(
                        short_target).GetShellPath()
                    sys.stdout.write(" {0}: {1}\n".format(
                        "export".ljust(FilterTerminal.recipewidth),
                        short_target))
            elif text.startswith("<info>incremental makefile generation: "):
                message = text[text.find("<info>") + 6:text.find("</info>")]
                if not self.analyseonly and not self.quiet:
                    sys.stdout.write(" {0}\n".format(message))
            elif text.startswith("<info>Buildable configuration '"):
                # <info>Buildable configuration 'name'</info>
                self.built_configs.add(text[30:-8])
            elif text.startswith("<info>Linker feedback "):
                # <info>Linker feedback file will be generated by this build ...</info>
                if not self.analyseonly and not self.quiet:
                    message = text[text.find("<info>") +
                                   6:text.find("</info>")]
                    sys.stdout.write(" {0}\n".format(message))
            return
        elif text.startswith("<info project="):
            # <info> entries that include metadata context
            mmp = text[text.find("project='") + 9:text.find("' ")]
            mmppath = generic_path.Path(mmp).From(
                generic_path.CurrentDir()).GetShellPath()

            if text.find("Import library generation suppressed"):
                # <info project='some.mmp' component='bld.inf'>Import library generation suppressed as frozen .def file not present: missing.def.</info> )
                if not self.analyseonly and not self.quiet:
                    message = text[text.find("'>") + 2:text.find("</info>")]
                    sys.stdout.write(" {0}\n".format(message))
                    sys.stdout.write("  mmp: {0}\n".format(mmppath))
            return
        elif text.find("<rm files") != -1 or text.find("<rmdir ") != -1:
            # search for cleaning output but only if we
            # are not in some recipe (that would be pointless)
            if not self.analyseonly and not self.quiet:
                if self.cleaned == 0:
                    sys.stdout.write("\ncleaning ")
                    self.cleaned += 1
                elif self.dotcount < FilterTerminal.maxdots:
                    if self.cleaned % 5 == 0:
                        self.dotcount += 1
                        sys.stdout.write(".")
                    self.cleaned += 1

                return
        elif self.inBody:
            # We are parsing the output from a recipe
            # we have to keep the output until we find out
            # if the recipe failed. But not all of it if it turns
            # out to be very long
            if len(self.recipeBody) <= FilterTerminal.recipelinelimit:
                self.recipeBody.append(text)
            else:
                self.recipelineExceeded += 1
Пример #12
0
def resolveSymbianPath(aFileRoot, aReference, aMainType="", aSubType="", aEPOCROOT="$(EPOCROOT)"):
	""" Convert raw Symbian metadata path/file references into absolute makefile references, or list of references

	<drive>-prefix	: maps to an emulated drive depending on the following cases:
							(a) If the drive is C:, it maps to the *two* locations
								$(EPOCROOT)/epoc32/data/<drive>/<path> and
								$(EPOCROOT)/epoc32/winscw/<drive>/<path>
							(b) If the drive is A:, B:, or D: to Z:, it maps to the *three* locations
								$(EPOCROOT)/epoc32/data/<drive>/<path> and
								$(EPOCROOT)/epoc32/release/winscw/udeb/<drive>/<path> and
								$(EPOCROOT)/epoc32/release/winscw/urel/<drive>/<path>
	Absolute 		: true absolute if:
							(a) PRJ_*EXPORTS destination or DEFFILE location and
							(b) not starting with an 'epoc32'
						otherwise relative to $(EPOCROOT)
	Relative 		: relative to $(EPOCROOT)/epoc32/include if:
							(a) PRJ_EXPORTS destination and
							(b) not a :zip statement,
					  relative to $(EPOCROOT) if:
							(a) PRJ_(TEST)EXPORTS destination and
							(b) a :zip statement,
						otherwise relative to aFileRoot
	|-prefix 		: relative to aFileRoot
	+-prefix 		: relative to $(EPOCROOT)/epoc32"""

	
	# Both reference and fileroot can have backslashes - so convert them.
	reference = aReference.replace('\\', '/')
	fileroot = aFileRoot.replace('\\', '/')
	
	# Remove Trailing backslashes so that the expansions doesnt mess up the shell
	if reference.endswith('/') and len(reference) > 1:
		reference = reference.rstrip('/')

	emulatedDrive = dosDriveRegEx.match(reference)	
	if emulatedDrive and aMainType in ("PRJ_EXPORTS", "PRJ_TESTEXPORTS"):
		# Interpret drive letters as emulator drives but only when dealing with exports
		# Emulated drive C:/ Z:/ and the like		
		resolvedPath = []
		driveLetter = emulatedDrive.group(1)
		if driveLetter.isupper():
			driveLetter = driveLetter.lower()
		
		# C: drive
		if driveLetter == "c":
			resolvedPath.append(dosDriveRegEx.sub(aEPOCROOT + '/epoc32/data/' + driveLetter, reference))
			resolvedPath.append(dosDriveRegEx.sub(aEPOCROOT + '/epoc32/winscw/' + driveLetter, reference))
		else: # Other letters: A, B and D to Z
			resolvedPath.append(dosDriveRegEx.sub(aEPOCROOT + '/epoc32/data/' + driveLetter, reference))
			resolvedPath.append(dosDriveRegEx.sub(aEPOCROOT + '/epoc32/release/winscw/udeb/' + driveLetter, reference))
			resolvedPath.append(dosDriveRegEx.sub(aEPOCROOT + '/epoc32/release/winscw/urel/' + driveLetter, reference))
	elif os.path.isabs(reference):
		# Absolute
		if re.search("(DEFFILE|PRJ_(TEST)?EXPORTS)", aMainType, re.I) and not re.search("^\/epoc32\/", reference, re.I):
			# Ensures prepending of drive if on Windows
			resolvedPath = os.path.abspath(reference)
		else:
			resolvedPath = aEPOCROOT + reference
		
	elif reference.startswith("+"):
		# '+' prefix
		reference = reference.lstrip(r'+')
		resolvedPath = aEPOCROOT + '/epoc32'+reference
	elif reference.startswith("|"):
		# '|' prefix
		reference = reference.lstrip(r'|')
		resolvedPath = absPathFromFile(fileroot, reference)
	else:
		# Relative
		if aMainType == "PRJ_EXPORTS" and aSubType != ":zip":
			resolvedPath = aEPOCROOT + '/epoc32/include/'+reference
		elif aSubType == ":zip":
			resolvedPath = aEPOCROOT + '/' + reference
		else:
			resolvedPath = absPathFromFile(fileroot, aReference)
	
	if isinstance(resolvedPath, list):
		# In this case, this is a list of export destinations, 
		makefilePath = [str(generic_path.Path(x)) for x in resolvedPath]
	else:
		makefilePath = str(generic_path.Path(resolvedPath))
	
	return makefilePath # Note this is either a list of strings, or a single string
Пример #13
0
    def __ProcessSystemModelElement(self, aElement):
        """Search for XML <unit/> elements with 'bldFile' attributes and resolve concrete bld.inf locations
		with an appreciation of different schema versions."""

        # Metadata elements are processed separately - there are no further child nodes
        # to process in this context
        if aElement.tagName == "meta":
            return self.__ProcessSystemModelMetaElement(aElement)

        # The effective "layer" is the item whose parent does not have an id (or name in 2.x and earlier)
        if not aElement.parentNode.hasAttribute(self.__IdAttribute):
            currentLayer = aElement.getAttribute(self.__IdAttribute)

            if currentLayer not in self.__LayerDetails:
                self.__LayerDetails[currentLayer] = []

            if not currentLayer in self.__LayerList:
                self.__LayerList.append(currentLayer)

        elif aElement.tagName == "unit" and aElement.hasAttributes():
            bldFileValue = aElement.getAttribute("bldFile")

            if bldFileValue:
                bldInfRoot = self.__ComponentRoot

                if self.__Version['MAJOR'] == 1:
                    # version 1.x schema paths can use DOS slashes
                    bldFileValue = bldFileValue.replace('\\', '/')
                elif self.__Version['MAJOR'] >= 2:
                    # version 2.x.x schema paths are subject to a "root" attribute off-set, if it exists
                    rootValue = aElement.getAttribute("root")

                    if rootValue:
                        if rootValue in os.environ:
                            bldInfRoot = generic_path.Path(
                                os.environ[rootValue])
                        else:
                            # Assume that this is an error i.e. don't attempt to resolve in relation to SOURCEROOT
                            bldInfRoot = None
                            self.__Logger.Error(
                                "Cannot resolve \'root\' attribute value \"{0}\" in {1}"
                                .format(rootValue,
                                        self.__SystemDefinitionFile))
                            return

                bldinfval = generic_path.Path(bldFileValue)

                if self.__Version['MAJOR'] < 3:
                    # absolute paths are not changed by root var in 1.x and 2.x
                    if not bldinfval.isAbsolute() and bldInfRoot:
                        bldinfval = generic_path.Join(bldInfRoot, bldinfval)
                else:
                    # relative paths for v3
                    if not bldinfval.isAbsolute():
                        bldinfval = generic_path.Join(
                            generic_path.Join(
                                self.__SystemDefinitionFile).Dir(), bldinfval)
                    # absolute paths for v3
                    # are relative to bldInfRoot if set, or relative to the drive root otherwise
                    elif bldInfRoot:
                        bldinfval = generic_path.Join(bldInfRoot, bldinfval)

                if self.__fullbldinfs:
                    bldinf = bldinfval.FindCaseless()
                else:
                    bldinf = generic_path.Join(bldinfval,
                                               "bld.inf").FindCaseless()

                if bldinf == None:
                    # recording layers containing non existent bld.infs
                    bldinfname = bldinfval.GetLocalString()
                    if not self.__fullbldinfs:
                        bldinfname = bldinfname + '/' + 'bld.inf'
                    layer = self.__GetEffectiveLayer(aElement)
                    if not layer in self.__MissingBldInfs:
                        self.__MissingBldInfs[layer] = []
                    self.__MissingBldInfs[layer].append(bldinfname)

                else:
                    component = self.__CreateComponent(bldinf, aElement)
                    layer = component.GetLayerName()
                    if layer:
                        self.__LayerDetails[layer].append(component)
                        self.__TotalComponents += 1
                    else:
                        self.__Logger.Error(
                            "No containing layer found for {0} in {1}".format(
                                str(bldinf), self.__SystemDefinitionFile))

        # search the sub-elements
        for child in aElement.childNodes:
            if child.nodeType == child.ELEMENT_NODE:
                self.__ProcessSystemModelElement(child)
Пример #14
0
    def __Validate(self):
        # account for different schema versions in processing
        # old format : version >= 1.3.0
        # new format : version >= 2.0.0 (assume later versions are compatible...at least for now)
        version = re.match(
            r'(?P<MAJOR>\d)\.(?P<MID>\d)(\.(?P<MINOR>\d))?',
            self.__SystemDefinitionElement.getAttribute("schema"))

        if not version:
            self.__Logger.Error(
                "Cannot determine schema version of XML file {0}".format(
                    self.__SystemDefinitionFile))
            return False

        self.__Version['MAJOR'] = int(version.group('MAJOR'))
        self.__Version['MID'] = int(version.group('MID'))
        self.__Version['MINOR'] = int(version.group('MINOR'))

        self.__fullbldinfs = None
        if self.__SystemDefinitionElement.hasAttribute('fullbldinfs'):
            # Lower case it since we're not evil
            if self.__SystemDefinitionElement.getAttribute(
                    'fullbldinfs').lower() == 'true':
                self.__fullbldinfs = 1

        if self.__Version['MAJOR'] == 1 and self.__Version['MID'] > 2:
            self.__ComponentRoot = self.__SystemDefinitionBase
        elif self.__Version['MAJOR'] == 2 or self.__Version['MAJOR'] == 3:
            # 2.0.x and 3.0.0 formats support SOURCEROOT or SRCROOT as an environment specified base - we respect this, unless
            # explicitly overridden on the command line
            if 'SRCROOT' in os.environ:
                self.__ComponentRoot = generic_path.Path(os.environ['SRCROOT'])
            elif 'SOURCEROOT' in os.environ:
                self.__ComponentRoot = generic_path.Path(
                    os.environ['SOURCEROOT'])

            if self.__SystemDefinitionBase and self.__SystemDefinitionBase != ".":
                self.__ComponentRoot = self.__SystemDefinitionBase
                if 'SRCROOT' in os.environ:
                    self.__Logger.Info(
                        "Command line specified System Definition file base \'{0}\'"
                        " overriding environment SRCROOT \'{1}\'".format(
                            self.__SystemDefinitionBase,
                            os.environ['SRCROOT']))
                elif 'SOURCEROOT' in os.environ:
                    self.__Logger.Info(
                        "Command line specified System Definition file base \'{0}\'"
                        " overriding environment SOURCEROOT \'{1}\'".format(
                            self.__SystemDefinitionBase,
                            os.environ['SOURCEROOT']))
        else:
            self.__Logger.Error(
                "Cannot process schema version {0} of file {1}".format(
                    version.string, self.__SystemDefinitionFile))
            return False

        if self.__Version['MAJOR'] >= 3:
            # id is the unique identifier for 3.0 and later schema
            self.__IdAttribute = "id"

        return True