def resolve(self, makefile, variables, fd, setting): vname = self.vname.resolvestr(makefile, variables, setting) if vname in setting: raise errors.DataError( "Setting variable '%s' recursively references itself." % (vname, ), self.loc) substfrom = self.substfrom.resolvestr(makefile, variables, setting) substto = self.substto.resolvestr(makefile, variables, setting) flavor, source, value = variables.get(vname) if value is None: log.debug("%s: variable '%s' was not set" % (self.loc, vname)) return f = data.Pattern(substfrom) if not f.ispattern(): f = data.Pattern('%' + substfrom) substto = '%' + substto fd.write(' '.join([ f.subst(substto, word, False) for word in value.resolvesplit(makefile, variables, setting + [vname]) ]))
def execute(self, makefile, context): if context.weak: raise errors.DataError( "Static pattern rules not allowed in includedeps", self.targetexp.loc) targets = list( _expandwildcards( makefile, data.stripdotslashes( self.targetexp.resolvesplit(makefile, makefile.variables)))) if not len(targets): context.currule = DummyRule() return patterns = list( data.stripdotslashes( self.patternexp.resolvesplit(makefile, makefile.variables))) if len(patterns) != 1: raise errors.DataError( "Static pattern rules must have a single pattern", self.patternexp.loc) pattern = data.Pattern(patterns[0]) deps = [ data.Pattern(p) for p in _expandwildcards( makefile, data.stripdotslashes( self.depexp.resolvesplit(makefile, makefile.variables))) ] rule = data.PatternRule([pattern], deps, self.doublecolon, loc=self.targetexp.loc) for t in targets: if data.Pattern(t).ispattern(): raise errors.DataError( "Target '%s' of a static pattern rule must not be a pattern" % (t, ), self.targetexp.loc) stem = pattern.match(t) if stem is None: raise errors.DataError( "Target '%s' does not match the static pattern '%s'" % (t, pattern), self.targetexp.loc) makefile.gettarget(t).addrule( data.PatternRuleInstance(rule, '', stem, pattern.ismatchany())) makefile.foundtarget(targets[0]) context.currule = rule
def resolve(self, makefile, variables, fd, setting): s = self._arguments[0].resolvestr(makefile, variables, setting) r = self._arguments[1].resolvestr(makefile, variables, setting) p = data.Pattern(s) fd.write(' '.join([ p.subst(r, word, False) for word in self._arguments[2].resolvesplit( makefile, variables, setting) ]))
def _execute(self, makefile, context): assert not context.weak atargets = data.stripdotslashes( self.targetexp.resolvesplit(makefile, makefile.variables)) targets = [ data.Pattern(p) for p in _expandwildcards(makefile, atargets) ] if not len(targets): context.currule = DummyRule() return ispatterns = set((t.ispattern() for t in targets)) if len(ispatterns) == 2: raise errors.DataError("Mixed implicit and normal rule", self.targetexp.loc) ispattern, = ispatterns deps = list( _expandwildcards( makefile, data.stripdotslashes( self.depexp.resolvesplit(makefile, makefile.variables)))) if ispattern: prerequisites = [data.Pattern(d) for d in deps] rule = data.PatternRule(targets, prerequisites, self.doublecolon, loc=self.targetexp.loc) makefile.appendimplicitrule(rule) else: rule = data.Rule(deps, self.doublecolon, loc=self.targetexp.loc, weakdeps=False) for t in targets: makefile.gettarget(t.gettarget()).addrule(rule) makefile.foundtarget(targets[0].gettarget()) context.currule = rule
def resolve(self, makefile, variables, fd, setting): plist = [ data.Pattern(p) for p in self._arguments[0].resolvesplit( makefile, variables, setting) ] fd.write(' '.join([ w for w in self._arguments[1].resolvesplit(makefile, variables, setting) if not util.any((p.match(w) for p in plist)) ]))
def execute(self, makefile, context): vname = self.vnameexp.resolvestr(makefile, makefile.variables) if len(vname) == 0: raise errors.DataError("Empty variable name", self.vnameexp.loc) if self.targetexp is None: setvariables = [makefile.variables] else: setvariables = [] targets = [ data.Pattern(t) for t in data.stripdotslashes( self.targetexp.resolvesplit(makefile, makefile.variables)) ] for t in targets: if t.ispattern(): setvariables.append(makefile.getpatternvariables(t)) else: setvariables.append( makefile.gettarget(t.gettarget()).variables) for v in setvariables: if self.token == '+=': v.append(vname, self.source, self.value, makefile.variables, makefile) continue if self.token == '?=': flavor = data.Variables.FLAVOR_RECURSIVE oldflavor, oldsource, oldval = v.get(vname, expand=False) if oldval is not None: continue value = self.value elif self.token == '=': flavor = data.Variables.FLAVOR_RECURSIVE value = self.value else: assert self.token == ':=' flavor = data.Variables.FLAVOR_SIMPLE d = parser.Data.fromstring(self.value, self.valueloc) e, t, o = parser.parsemakesyntax(d, 0, (), parser.iterdata) value = e.resolvestr(makefile, makefile.variables) v.set(vname, flavor, self.source, value)
def execute(self, makefile, context): words = list( data.stripdotslashes( self.exp.resolvesplit(makefile, makefile.variables))) if len(words) == 0: makefile.clearallvpaths() else: pattern = data.Pattern(words[0]) mpaths = words[1:] if len(mpaths) == 0: makefile.clearvpath(pattern) else: dirs = [] for mpath in mpaths: dirs.extend( (dir for dir in mpath.split(os.pathsep) if dir != '')) if len(dirs): makefile.addvpath(pattern, dirs)