python/codegen/makeutils.py

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     1 # This Source Code Form is subject to the terms of the Mozilla Public
     2 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
     3 # You can obtain one at http://mozilla.org/MPL/2.0/.
     5 import errno
     6 import os
     8 dependencies = []
     9 targets = []
    11 def makeQuote(filename):
    12     return filename.replace(' ', '\\ ')  # enjoy!
    14 def writeMakeDependOutput(filename):
    15     print "Creating makedepend file", filename
    16     dir = os.path.dirname(filename)
    17     if dir and not os.path.exists(dir):
    18         try:
    19             os.makedirs(dir)
    20         except OSError as error:
    21             if error.errno != errno.EEXIST:
    22                 raise
    24     with open(filename, 'w') as f:
    25         if len(targets) > 0:
    26             f.write("%s:" % makeQuote(targets[0]))
    27             for filename in dependencies:
    28                 f.write(' \\\n\t\t%s' % makeQuote(filename))
    29             f.write('\n')
    30             for filename in targets[1:]:
    31                 f.write('%s: %s\n' % (makeQuote(filename), makeQuote(targets[0])))
    32             for filename in dependencies:
    33                 f.write('%s:\n' % filename)

mercurial