Back to index

enigmail  1.4.3
Public Member Functions | Public Attributes | Private Attributes
pymake.data.Makefile Class Reference

List of all members.

Public Member Functions

def __init__
def foundtarget
def getpatternvariables
def getpatternvariablesfor
def hastarget
def gettarget
def appendimplicitrule
def finishparsing
def include
def addvpath
def clearvpath
def clearallvpaths
def getvpath
def remakemakefiles
def getsubenvironment

Public Attributes

 defaulttarget
 env
 variables
 context
 exportedvars
 keepgoing
 silent
 justprint
 implicitrules
 parsingfinished
 workdir
 included
 makelevel
 error

Private Attributes

 _targets
 _patternvariables
 _patternvpaths
 _vpath

Detailed Description

The top-level data structure for makefile execution. It holds Targets, implicit rules, and other
state data.

Definition at line 1368 of file data.py.


Constructor & Destructor Documentation

def pymake.data.Makefile.__init__ (   self,
  workdir = None,
  env = None,
  restarts = 0,
  make = None,
  makeflags = '',
  makeoverrides = '',
  makelevel = 0,
  context = None,
  targets = (),
  keepgoing = False,
  silent = False,
  justprint = False 
)

Definition at line 1377 of file data.py.

01377 
01378                  silent=False, justprint=False):
01379         self.defaulttarget = None
01380 
01381         if env is None:
01382             env = os.environ
01383         self.env = env
01384 
01385         self.variables = Variables()
01386         self.variables.readfromenvironment(env)
01387 
01388         self.context = context
01389         self.exportedvars = {}
01390         self._targets = {}
01391         self.keepgoing = keepgoing
01392         self.silent = silent
01393         self.justprint = justprint
01394         self._patternvariables = [] # of (pattern, variables)
01395         self.implicitrules = []
01396         self.parsingfinished = False
01397 
01398         self._patternvpaths = [] # of (pattern, [dir, ...])
01399 
01400         if workdir is None:
01401             workdir = os.getcwd()
01402         workdir = os.path.realpath(workdir)
01403         self.workdir = workdir
01404         self.variables.set('CURDIR', Variables.FLAVOR_SIMPLE,
01405                            Variables.SOURCE_AUTOMATIC, workdir.replace('\\','/'))
01406 
01407         # the list of included makefiles, whether or not they existed
01408         self.included = []
01409 
01410         self.variables.set('MAKE_RESTARTS', Variables.FLAVOR_SIMPLE,
01411                            Variables.SOURCE_AUTOMATIC, restarts > 0 and str(restarts) or '')
01412 
01413         self.variables.set('.PYMAKE', Variables.FLAVOR_SIMPLE,
01414                            Variables.SOURCE_MAKEFILE, "1")
01415         if make is not None:
01416             self.variables.set('MAKE', Variables.FLAVOR_SIMPLE,
01417                                Variables.SOURCE_MAKEFILE, make)
01418 
01419         if makeoverrides != '':
01420             self.variables.set('-*-command-variables-*-', Variables.FLAVOR_SIMPLE,
01421                                Variables.SOURCE_AUTOMATIC, makeoverrides)
01422             makeflags += ' -- $(MAKEOVERRIDES)'
01423 
01424         self.variables.set('MAKEOVERRIDES', Variables.FLAVOR_RECURSIVE,
01425                            Variables.SOURCE_ENVIRONMENT,
01426                            '${-*-command-variables-*-}')
01427 
01428         self.variables.set('MAKEFLAGS', Variables.FLAVOR_RECURSIVE,
01429                            Variables.SOURCE_MAKEFILE, makeflags)
01430         self.exportedvars['MAKEFLAGS'] = True
01431 
01432         self.makelevel = makelevel
01433         self.variables.set('MAKELEVEL', Variables.FLAVOR_SIMPLE,
01434                            Variables.SOURCE_MAKEFILE, str(makelevel))
01435 
01436         self.variables.set('MAKECMDGOALS', Variables.FLAVOR_SIMPLE,
01437                            Variables.SOURCE_AUTOMATIC, ' '.join(targets))
01438 
01439         for vname, val in implicit.variables.iteritems():
01440             self.variables.set(vname,
01441                                Variables.FLAVOR_SIMPLE,
01442                                Variables.SOURCE_IMPLICIT, val)


Member Function Documentation

def pymake.data.Makefile.addvpath (   self,
  pattern,
  dirs 
)
Add a directory to the vpath search for the given pattern.

Definition at line 1536 of file data.py.

01536 
01537     def addvpath(self, pattern, dirs):
01538         """
01539         Add a directory to the vpath search for the given pattern.
01540         """
01541         self._patternvpaths.append((pattern, dirs))

def pymake.data.Makefile.appendimplicitrule (   self,
  rule 
)

Definition at line 1486 of file data.py.

01486 
01487     def appendimplicitrule(self, rule):
01488         assert isinstance(rule, PatternRule)
01489         self.implicitrules.append(rule)

Definition at line 1550 of file data.py.

01550 
01551     def clearallvpaths(self):
01552         self._patternvpaths = []

def pymake.data.Makefile.clearvpath (   self,
  pattern 
)
Clear vpaths for the given pattern.

Definition at line 1542 of file data.py.

01542 
01543     def clearvpath(self, pattern):
01544         """
01545         Clear vpaths for the given pattern.
01546         """
01547         self._patternvpaths = [(p, dirs)
01548                                for p, dirs in self._patternvpaths
01549                                if not p.match(pattern)]

Various activities, such as "eval", are not allowed after parsing is
finished. In addition, various warnings and errors can only be issued
after the parsing data model is complete. All dependency resolution
and rule execution requires that parsing be finished.

Definition at line 1490 of file data.py.

01490 
01491     def finishparsing(self):
01492         """
01493         Various activities, such as "eval", are not allowed after parsing is
01494         finished. In addition, various warnings and errors can only be issued
01495         after the parsing data model is complete. All dependency resolution
01496         and rule execution requires that parsing be finished.
01497         """
01498         self.parsingfinished = True
01499 
01500         flavor, source, value = self.variables.get('GPATH')
01501         if value is not None and value.resolvestr(self, self.variables, ['GPATH']).strip() != '':
01502             raise DataError('GPATH was set: pymake does not support GPATH semantics')
01503 
01504         flavor, source, value = self.variables.get('VPATH')
01505         if value is None:
01506             self._vpath = []
01507         else:
01508             self._vpath = filter(lambda e: e != '',
01509                                  re.split('[%s\s]+' % os.pathsep,
01510                                           value.resolvestr(self, self.variables, ['VPATH'])))
01511 
01512         targets = list(self._targets.itervalues())
01513         for t in targets:
01514             t.explicit = True
01515             for r in t.rules:
01516                 for p in r.prerequisites:
01517                     self.gettarget(p).explicit = True
01518 
01519         np = self.gettarget('.NOTPARALLEL')
01520         if len(np.rules):
01521             self.context = process.getcontext(1)
01522 
01523         self.error = False

def pymake.data.Makefile.foundtarget (   self,
  t 
)
Inform the makefile of a target which is a candidate for being the default target,
if there isn't already a default target.

Definition at line 1443 of file data.py.

01443 
01444     def foundtarget(self, t):
01445         """
01446         Inform the makefile of a target which is a candidate for being the default target,
01447         if there isn't already a default target.
01448         """
01449         if self.defaulttarget is None and t != '.PHONY':
01450             self.defaulttarget = t

def pymake.data.Makefile.getpatternvariables (   self,
  pattern 
)

Definition at line 1451 of file data.py.

01451 
01452     def getpatternvariables(self, pattern):
01453         assert isinstance(pattern, Pattern)
01454 
01455         for p, v in self._patternvariables:
01456             if p == pattern:
01457                 return v
01458 
01459         v = Variables()
01460         self._patternvariables.append( (pattern, v) )
01461         return v

def pymake.data.Makefile.getpatternvariablesfor (   self,
  target 
)

Definition at line 1462 of file data.py.

01462 
01463     def getpatternvariablesfor(self, target):
01464         for p, v in self._patternvariables:
01465             if p.match(target):
01466                 yield v

def pymake.data.Makefile.getsubenvironment (   self,
  variables 
)

Definition at line 1573 of file data.py.

01573 
01574     def getsubenvironment(self, variables):
01575         env = dict(self.env)
01576         for vname, v in self.exportedvars.iteritems():
01577             if v:
01578                 flavor, source, val = variables.get(vname)
01579                 if val is None:
01580                     strval = ''
01581                 else:
01582                     strval = val.resolvestr(self, variables, [vname])
01583                 env[vname] = strval
01584             else:
01585                 env.pop(vname, None)
01586 
01587         makeflags = ''
01588 
01589         env['MAKELEVEL'] = str(self.makelevel + 1)
01590         return env
def pymake.data.Makefile.gettarget (   self,
  target 
)

Definition at line 1470 of file data.py.

01470 
01471     def gettarget(self, target):
01472         assert isinstance(target, str)
01473 
01474         target = target.rstrip('/')
01475 
01476         assert target != '', "empty target?"
01477 
01478         if target.find('*') != -1 or target.find('?') != -1 or target.find('[') != -1:
01479             raise DataError("wildcards should have been expanded by the parser: '%s'" % (target,))
01480 
01481         t = self._targets.get(target, None)
01482         if t is None:
01483             t = Target(target, self)
01484             self._targets[target] = t
01485         return t

Here is the caller graph for this function:

def pymake.data.Makefile.getvpath (   self,
  target 
)

Definition at line 1553 of file data.py.

01553 
01554     def getvpath(self, target):
01555         vp = list(self._vpath)
01556         for p, dirs in self._patternvpaths:
01557             if p.match(target):
01558                 vp.extend(dirs)
01559 
01560         return withoutdups(vp)

Here is the call graph for this function:

def pymake.data.Makefile.hastarget (   self,
  target 
)

Definition at line 1467 of file data.py.

01467 
01468     def hastarget(self, target):
01469         return target in self._targets

def pymake.data.Makefile.include (   self,
  path,
  required = True,
  weak = False,
  loc = None 
)
Include the makefile at `path`.

Definition at line 1524 of file data.py.

01524 
01525     def include(self, path, required=True, weak=False, loc=None):
01526         """
01527         Include the makefile at `path`.
01528         """
01529         self.included.append((path, required))
01530         fspath = util.normaljoin(self.workdir, path)
01531         if os.path.exists(fspath):
01532             stmts = parser.parsefile(fspath)
01533             self.variables.append('MAKEFILE_LIST', Variables.SOURCE_AUTOMATIC, path, None, self)
01534             stmts.execute(self, weak=weak)
01535             self.gettarget(path).explicit = True

Here is the call graph for this function:

def pymake.data.Makefile.remakemakefiles (   self,
  cb 
)

Definition at line 1561 of file data.py.

01561 
01562     def remakemakefiles(self, cb):
01563         mlist = []
01564         for f, required in self.included:
01565             t = self.gettarget(f)
01566             t.explicit = True
01567             t.resolvevpath(self)
01568             oldmtime = t.mtime
01569 
01570             mlist.append((t, oldmtime))
01571 
01572         _RemakeContext(self, cb)

Here is the call graph for this function:


Member Data Documentation

Definition at line 1393 of file data.py.

Definition at line 1397 of file data.py.

Definition at line 1389 of file data.py.

Definition at line 1505 of file data.py.

Definition at line 1387 of file data.py.

Definition at line 1378 of file data.py.

Definition at line 1382 of file data.py.

Definition at line 1522 of file data.py.

Definition at line 1388 of file data.py.

Definition at line 1394 of file data.py.

Definition at line 1407 of file data.py.

Definition at line 1392 of file data.py.

Definition at line 1390 of file data.py.

Definition at line 1431 of file data.py.

Definition at line 1395 of file data.py.

Definition at line 1391 of file data.py.

Definition at line 1384 of file data.py.

Definition at line 1402 of file data.py.


The documentation for this class was generated from the following file: