Ejemplo n.º 1
0
def guess_search_flavors(flavor, distro='rPL 1'):
    '''
    Given a build flavor, decide a reasonable search flavor list, possibly
    using a particular distro set.
    '''

    # Determine the major architecture of the given build flavor
    maj_arch = None
    for dep_group in flavor.getDepClasses().itervalues():
        if isinstance(dep_group, deps.InstructionSetDependency):
            maj_arch = arch.getMajorArch(dep_group.getDeps()).name
    if not maj_arch:
        maj_arch = 'x86'

    distro = _DISTROS[distro]
    arch_set = distro['arches'][maj_arch]

    # Start the search flavor with the stock build flavor
    ret = []
    for suffix in arch_set:
        flav = distro['base'].copy()
        flav.union(suffix)
        ret.append(flav)

    return ret
Ejemplo n.º 2
0
def guess_search_flavors(flavor, distro='rPL 1'):
    '''
    Given a build flavor, decide a reasonable search flavor list, possibly
    using a particular distro set.
    '''

    # Determine the major architecture of the given build flavor
    maj_arch = None
    for dep_group in flavor.getDepClasses().itervalues():
        if isinstance(dep_group, deps.InstructionSetDependency):
            maj_arch = arch.getMajorArch(dep_group.getDeps()).name
    if not maj_arch:
        maj_arch = 'x86'

    distro = _DISTROS[distro]
    arch_set = distro['arches'][maj_arch]

    # Start the search flavor with the stock build flavor
    ret = []
    for suffix in arch_set:
        flav = distro['base'].copy()
        flav.union(suffix)
        ret.append(flav)

    return ret
Ejemplo n.º 3
0
 def getTargetArch(flavor, currentArch = None):
     if currentArch is None:
         currentArchName = arch.getMajorArch(arch.currentArch[0]).name
     else:
         currentArchName = arch.getMajorArch(currentArch.iterDepsByClass(
                                     deps.InstructionSetDependency)).name
     setArch = False
     targetArch = arch.getMajorArch(flavor.iterDepsByClass(
                                    deps.InstructionSetDependency))
     if not targetArch:
         return False, None
     targetArchName = targetArch.name
     if targetArchName != currentArchName:
         if targetArchName in setArchOk.get(currentArchName, []):
             setArch = True
         return setArch, targetArchName
     else:
         return False, None
Ejemplo n.º 4
0
    def testGetMajorArch(self):
        deplist = deps.parseFlavor('is: x86 x86_64').iterDepsByClass(
            deps.InstructionSetDependency)
        self.assertEqual(arch.getMajorArch(deplist).name, 'x86_64')

        deplist = deps.parseFlavor('is: x86 ppc').iterDepsByClass(
            deps.InstructionSetDependency)
        self.assertRaises(arch.IncompatibleInstructionSets,
                              arch.getMajorArch, deplist)
Ejemplo n.º 5
0
    def testGetMajorArch(self):
        deplist = deps.parseFlavor('is: x86 x86_64').iterDepsByClass(
            deps.InstructionSetDependency)
        self.assertEqual(arch.getMajorArch(deplist).name, 'x86_64')

        deplist = deps.parseFlavor('is: x86 ppc').iterDepsByClass(
            deps.InstructionSetDependency)
        self.assertRaises(arch.IncompatibleInstructionSets, arch.getMajorArch,
                          deplist)
Ejemplo n.º 6
0
def _getMajorArch(flavor):
    if not isinstance(flavor, deps.Flavor):
        flavor = deps.ThawFlavor(flavor)

    if flavor.members and deps.DEP_CLASS_IS in flavor.members:
        depClass = flavor.members[deps.DEP_CLASS_IS]
        return arch.getMajorArch(depClass.getDeps())

    return None
Ejemplo n.º 7
0
 def getTargetArch(flavor, currentArch=None):
     if currentArch is None:
         currentArchName = arch.getMajorArch(arch.currentArch[0]).name
     else:
         currentArchName = arch.getMajorArch(
             currentArch.iterDepsByClass(
                 deps.InstructionSetDependency)).name
     setArch = False
     targetArch = arch.getMajorArch(
         flavor.iterDepsByClass(deps.InstructionSetDependency))
     if not targetArch:
         return False, None
     targetArchName = targetArch.name
     if targetArchName != currentArchName:
         if targetArchName in setArchOk.get(currentArchName, []):
             setArch = True
         return setArch, targetArchName
     else:
         return False, None
Ejemplo n.º 8
0
def getArchFromFlavor(flavor):
    if flavor.members and cny_deps.DEP_CLASS_IS in flavor.members:
        depClass = flavor.members[cny_deps.DEP_CLASS_IS]
        arch = cny_arch.getMajorArch(depClass.getDeps())
        return arch.name
    return ''
Ejemplo n.º 9
0
def setBuildFlagsFromFlavor(recipeName, flavor, error=True, warn=False,
                            useCross=True):
    """ Sets the truth of the build Flags based on the build flavor.
        All the set build flags must already exist.  Flags not mentioned
        in this flavor will be untouched.
        XXX should this create flags as well as set them?  Problem with that
        is that we don't know whether the flag is required or not based
        on the flavor; we would only be able to do as half-baked job
    """
    crossCompiling = False
    for depGroup in flavor.getDepClasses().values():
        if isinstance(depGroup, deps.UseDependency):
            for dep in depGroup.getDeps():
                for flag, sense in dep.flags.iteritems():
                    if sense in (deps.FLAG_SENSE_REQUIRED,
                                 deps.FLAG_SENSE_PREFERRED):
                        value = True
                    else:
                        value = False
                    # see if there is a . -- indicating this is a
                    # local flag
                    if flag == 'cross':
                        crossCompiling = True
                    parts = flag.split('.',1)
                    if len(parts) == 1:
                        try:
                            Use[flag]._set(value)
                        except KeyError:
                            if error:
                                raise AttributeError(
                                            "No Such Use Flag %s" % flag)
                            elif warn:
                                log.warning(
                                        'ignoring unknown Use flag %s' % flag)
                                continue
                    else:
                        packageName, flag = parts
                        PackageFlags[packageName][flag]._set(value)
                        if recipeName:
                            if packageName == recipeName:
                                # local flag values set from a build flavor
                                # are overrides -- the recipe should not
                                # change these values
                                LocalFlags._override(flag, value)
                        elif error:
                            raise RuntimeError('Trying to set a flavor with '
                                               'localflag %s when no trove '
                                               'name was given' % flag)
        elif isinstance(depGroup, (deps.InstructionSetDependency,
                                   deps.TargetInstructionSetDependency)):
            if isinstance(depGroup, deps.InstructionSetDependency):
                hasTargetISDep = flavor.getDepClasses().get(
                                              deps.DEP_CLASS_TARGET_IS, None)
                if hasTargetISDep and useCross:
                    # use target instruction set dependency instead
                    continue
            elif not useCross:
                continue

            found = False
            try:
                majorArch = arch.getMajorArch(depGroup.getDeps())
            except arch.IncompatibleInstructionSets, e:
                raise RuntimeError(str(e))

            if majorArch is None:
                # No IS deps?
                return

            subarches = []
            for (flag, sense) in majorArch.flags.iteritems():
                if sense in (deps.FLAG_SENSE_REQUIRED,
                             deps.FLAG_SENSE_PREFERRED):
                    subarches.append(flag)
            Arch._setArch(majorArch.name, subarches)