Back to index

enigmail  1.4.3
Classes | Functions | Variables
pymake.command Namespace Reference

Classes

class  _MakeContext

Functions

def parsemakeflags
def _version
def main

Variables

tuple makepypath = util.normaljoin(os.path.dirname(__file__), '../make.py')
tuple _simpleopts = re.compile(r'^[a-zA-Z]+(\s|$)')
tuple _log = logging.getLogger('pymake.execution')

Detailed Description

Makefile execution.

Multiple `makes` can be run within the same process. Each one has an entirely data.Makefile and .Target
structure, environment, and working directory. Typically they will all share a parallel execution context,
except when a submake specifies -j1 when the parent make is building in parallel.

Function Documentation

def pymake.command._version (   args) [private]

Definition at line 61 of file command.py.

00061 
00062 def _version(*args):
00063     print """pymake: GNU-compatible make program
00064 Copyright (C) 2009 The Mozilla Foundation <http://www.mozilla.org/>
00065 This is free software; see the source for copying conditions.
00066 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00067 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00068 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00069 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00070 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00071 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00072 DEALINGS IN THE SOFTWARE."""

Here is the caller graph for this function:

def pymake.command.main (   args,
  env,
  cwd,
  cb 
)
Start a single makefile execution, given a command line, working directory, and environment.

@param cb a callback to notify with an exit code when make execution is finished.

Definition at line 161 of file command.py.

00161 
00162 def main(args, env, cwd, cb):
00163     """
00164     Start a single makefile execution, given a command line, working directory, and environment.
00165 
00166     @param cb a callback to notify with an exit code when make execution is finished.
00167     """
00168 
00169     try:
00170         makelevel = int(env.get('MAKELEVEL', '0'))
00171 
00172         op = OptionParser()
00173         op.add_option('-f', '--file', '--makefile',
00174                       action='append',
00175                       dest='makefiles',
00176                       default=[])
00177         op.add_option('-d',
00178                       action="store_true",
00179                       dest="verbose", default=False)
00180         op.add_option('-k', '--keep-going',
00181                       action="store_true",
00182                       dest="keepgoing", default=False)
00183         op.add_option('--debug-log',
00184                       dest="debuglog", default=None)
00185         op.add_option('-C', '--directory',
00186                       dest="directory", default=None)
00187         op.add_option('-v', '--version', action="store_true",
00188                       dest="printversion", default=False)
00189         op.add_option('-j', '--jobs', type="int",
00190                       dest="jobcount", default=1)
00191         op.add_option('-w', '--print-directory', action="store_true",
00192                       dest="printdir")
00193         op.add_option('--no-print-directory', action="store_false",
00194                       dest="printdir", default=True)
00195         op.add_option('-s', '--silent', action="store_true",
00196                       dest="silent", default=False)
00197         op.add_option('-n', '--just-print', '--dry-run', '--recon',
00198                       action="store_true",
00199                       dest="justprint", default=False)
00200 
00201         options, arguments1 = op.parse_args(parsemakeflags(env))
00202         options, arguments2 = op.parse_args(args, values=options)
00203 
00204         op.destroy()
00205 
00206         arguments = arguments1 + arguments2
00207 
00208         if options.printversion:
00209             _version()
00210             cb(0)
00211             return
00212 
00213         shortflags = []
00214         longflags = []
00215 
00216         if options.keepgoing:
00217             shortflags.append('k')
00218 
00219         if options.printdir:
00220             shortflags.append('w')
00221 
00222         if options.silent:
00223             shortflags.append('s')
00224             options.printdir = False
00225 
00226         if options.justprint:
00227             shortflags.append('n')
00228 
00229         loglevel = logging.WARNING
00230         if options.verbose:
00231             loglevel = logging.DEBUG
00232             shortflags.append('d')
00233 
00234         logkwargs = {}
00235         if options.debuglog:
00236             logkwargs['filename'] = options.debuglog
00237             longflags.append('--debug-log=%s' % options.debuglog)
00238 
00239         if options.directory is None:
00240             workdir = cwd
00241         else:
00242             workdir = util.normaljoin(cwd, options.directory)
00243 
00244         if options.jobcount != 1:
00245             longflags.append('-j%i' % (options.jobcount,))
00246 
00247         makeflags = ''.join(shortflags)
00248         if len(longflags):
00249             makeflags += ' ' + ' '.join(longflags)
00250 
00251         logging.basicConfig(level=loglevel, **logkwargs)
00252 
00253         context = process.getcontext(options.jobcount)
00254 
00255         if options.printdir:
00256             print "make.py[%i]: Entering directory '%s'" % (makelevel, workdir)
00257             sys.stdout.flush()
00258 
00259         if len(options.makefiles) == 0:
00260             if os.path.exists(util.normaljoin(workdir, 'Makefile')):
00261                 options.makefiles.append('Makefile')
00262             else:
00263                 print "No makefile found"
00264                 cb(2)
00265                 return
00266 
00267         ostmts, targets, overrides = parserdata.parsecommandlineargs(arguments)
00268 
00269         _MakeContext(makeflags, makelevel, workdir, context, env, targets, options, ostmts, overrides, cb)
00270     except (util.MakeError), e:
00271         print e
00272         if options.printdir:
00273             print "make.py[%i]: Leaving directory '%s'" % (makelevel, workdir)
00274         sys.stdout.flush()
00275         cb(2)
00276         return

Here is the call graph for this function:

Parse MAKEFLAGS from the environment into a sequence of command-line arguments.

Definition at line 19 of file command.py.

00019 
00020 def parsemakeflags(env):
00021     """
00022     Parse MAKEFLAGS from the environment into a sequence of command-line arguments.
00023     """
00024 
00025     makeflags = env.get('MAKEFLAGS', '')
00026     makeflags = makeflags.strip()
00027 
00028     if makeflags == '':
00029         return []
00030 
00031     if _simpleopts.match(makeflags):
00032         makeflags = '-' + makeflags
00033 
00034     opts = []
00035     curopt = ''
00036 
00037     i = 0
00038     while i < len(makeflags):
00039         c = makeflags[i]
00040         if c.isspace():
00041             opts.append(curopt)
00042             curopt = ''
00043             i += 1
00044             while i < len(makeflags) and makeflags[i].isspace():
00045                 i += 1
00046             continue
00047 
00048         if c == '\\':
00049             i += 1
00050             if i == len(makeflags):
00051                 raise data.DataError("MAKEFLAGS has trailing backslash")
00052             c = makeflags[i]
00053             
00054         curopt += c
00055         i += 1
00056 
00057     if curopt != '':
00058         opts.append(curopt)
00059 
00060     return opts

Here is the caller graph for this function:


Variable Documentation

tuple pymake.command._log = logging.getLogger('pymake.execution')

Definition at line 73 of file command.py.

tuple pymake.command._simpleopts = re.compile(r'^[a-zA-Z]+(\s|$)')

Definition at line 18 of file command.py.

tuple pymake.command.makepypath = util.normaljoin(os.path.dirname(__file__), '../make.py')

Definition at line 16 of file command.py.