def getTargetArch(flavor, currentArch = None): if currentArch is None: currentArch = Flavor() currentArch.addDep(deps.InstructionSetDependency, arch.currentArch[0][0]) setArch = False currentArchName = [ x.name for x in currentArch.iterDepsByClass(deps.InstructionSetDependency) ] assert(len(currentArchName) == 1) currentArchName = currentArchName[0] archNames = [ x.name for x in flavor.iterDepsByClass(deps.InstructionSetDependency) ] if len(archNames) > 1: raise RuntimeError, 'Cannot build trove with two architectures' if not archNames: return False, None targetArch = archNames[0] if targetArch != currentArchName: if targetArch in setArchOk.get(currentArchName, []): setArch = True return setArch, targetArch else: return False, None
def getTargetArch(flavor, currentArch=None): if currentArch is None: currentArch = Flavor() currentArch.addDep(deps.InstructionSetDependency, arch.currentArch[0][0]) setArch = False currentArchName = [ x.name for x in currentArch.iterDepsByClass(deps.InstructionSetDependency) ] assert (len(currentArchName) == 1) currentArchName = currentArchName[0] archNames = [ x.name for x in flavor.iterDepsByClass(deps.InstructionSetDependency) ] if len(archNames) > 1: raise RuntimeError, 'Cannot build trove with two architectures' if not archNames: return False, None targetArch = archNames[0] if targetArch != currentArchName: if targetArch in setArchOk.get(currentArchName, []): setArch = True return setArch, targetArch else: return False, None
def testUnknownFlavor(self): # Adding a flavor that is unknown to the current version of the # code intTag = 65535 stringTag = "yet-to-be-defined" class YetToBeDefinedFlavor(DependencyClass): tag = intTag tagName = stringTag justOne = False depClass = Dependency flv = Flavor() flvName = "was" flvFlag = "flag1" flv.addDep(YetToBeDefinedFlavor, Dependency(flvName, [ (flvFlag, FLAG_SENSE_REQUIRED) ])) frozen = flv.freeze() x = ThawFlavor(frozen) # The code that implements str is very specific to what's currently # implemented self.assertEqual(str(x), '') # However, it's not the empty flavor self.assertNotEqual(x, parseFlavor('')) self.assertEqual(x.freeze(), '65535#was:flag1')
def getCrossCompile(flavor): flavorTargetSet = flavor.getDepClasses().get(deps.DEP_CLASS_TARGET_IS, None) if flavorTargetSet is None: return None targetFlavor = Flavor() for insSet in flavorTargetSet.getDeps(): targetFlavor.addDep(deps.InstructionSetDependency, insSet) isCrossTool = flavor.stronglySatisfies(crossFlavor) return None, targetFlavor, isCrossTool
def getArchFlags(flavor, getTarget=True, withFlags=True): archFlavor = Flavor() flavorInsSet = flavor.getDepClasses().get(deps.DEP_CLASS_IS, None) if flavorInsSet is not None: for insSet in flavorInsSet.getDeps(): if not withFlags: insSet = deps.Dependency(insSet.name) archFlavor.addDep(deps.InstructionSetDependency, insSet) if not getTarget: return archFlavor flavorInsSet = flavor.getDepClasses().get(deps.DEP_CLASS_TARGET_IS, None) if flavorInsSet is not None: for insSet in flavorInsSet.getDeps(): if not withFlags: insSet = deps.Dependency(insSet.name) archFlavor.addDep(deps.TargetInstructionSetDependency, insSet) return archFlavor