Back to index

enigmail  1.4.3
Functions | Variables
build.cl Namespace Reference

Functions

def InvokeClWithDependencyGeneration

Variables

tuple CL_INCLUDES_PREFIX = os.environ.get("CL_INCLUDES_PREFIX", "Note: including file:")

Function Documentation

Definition at line 45 of file cl.py.

00045 
00046 def InvokeClWithDependencyGeneration(cmdline):
00047     target = ""
00048     # Figure out what the target is
00049     for arg in cmdline:
00050         if arg.startswith("-Fo"):
00051             target = arg[3:]
00052             break
00053 
00054     if target == None:
00055         print >>sys.stderr, "No target set" and sys.exit(1)
00056 
00057     # The deps target lives here
00058     depstarget = os.path.basename(target) + ".pp"
00059 
00060     cmdline += ['-showIncludes']
00061     cl = subprocess.Popen(cmdline, stdout=subprocess.PIPE)
00062 
00063     deps = set()
00064     for line in cl.stdout:
00065         # cl -showIncludes prefixes every header with "Note: including file:"
00066         # and an indentation corresponding to the depth (which we don't need)
00067         if line.startswith(CL_INCLUDES_PREFIX):
00068             dep = line[len(CL_INCLUDES_PREFIX):].strip()
00069             # We can't handle pathes with spaces properly in mddepend.pl, but
00070             # we can assume that anything in a path with spaces is a system
00071             # header and throw it away.
00072             if dep.find(' ') == -1:
00073                 deps.add(dep)
00074         else:
00075             sys.stdout.write(line) # Make sure we preserve the relevant output
00076                                    # from cl
00077 
00078     ret = cl.wait()
00079     if ret != 0 or target == "":
00080         sys.exit(ret)
00081 
00082     depsdir = os.path.normpath(os.path.join(os.path.dirname(target), ".deps"))
00083     depstarget = os.path.join(depsdir, depstarget)
00084     if not os.path.isdir(depsdir):
00085         try:
00086             os.makedirs(depsdir)
00087         except OSError:
00088             pass # This suppresses the error we get when the dir exists, at the
00089                  # cost of masking failure to create the directory.  We'll just
00090                  # die on the next line though, so it's not that much of a loss.
00091 
00092     f = open(depstarget, "w")
00093     for dep in sorted(deps):
00094         print >>f, "%s: %s" % (target, dep)


Variable Documentation

tuple build.cl.CL_INCLUDES_PREFIX = os.environ.get("CL_INCLUDES_PREFIX", "Note: including file:")

Definition at line 43 of file cl.py.