def __init__(self,targets,reqs,order_only=None,func=None,PHONY=False): """targets - list of targets reqs - seq of prerequisites order_only - seq of order only prerequisites func - a function that should take one or no arguments. Will be passed this class instance when run in order to have access to its attributes """ super(WildSharedRule,self).__init__(targets,reqs,order_only,func,PHONY) #check parameters pass # A single ExplicitRule will shared between all targets. explicit_targets = fpmatch.only_explicit_paths(targets) self.explicit_rules = [ExplicitTargetRule(targets=explicit_targets, reqs=reqs,order_only=order_only, func=self.func,PHONY=self.PHONY)]
def __init__(self,targets,reqs,order_only=None,func=None,PHONY=False): """targets - list of targets reqs - seq of prerequisites order_only - seq of order only prerequisites func - a function that should take one or no arguments. Will be passed this class instance when run in order to have access to its attributes. """ super(WildRule,self).__init__(targets,reqs,order_only,func,PHONY) #Check parameters pass #Some of the targets may be explicit, in which case we can just directly create ExplicitRules as normal explicit_targets = fpmatch.only_explicit_paths(targets) #saving references to explicit rules to allow us to have late-binding of the build func self.explicit_rules = [ ExplicitTargetRule(targets=target,reqs=reqs,order_only=order_only,func=self.func,PHONY=self.PHONY) for target in explicit_targets]
def ismatch(self,target): """decides if the target is a match for this metarule.""" for pattern in self.re_targets: if pattern.match(target): return True return (target in fpmatch.only_explicit_paths(self.targets))