python/codegen/makeutils.py
author Gaia Pushbot <release+gaiajson@mozilla.com>
Fri, 30 Aug 2013 03:50:21 -0700
changeset 153021 c52fb7fbabd7ac94514a17c6f868694faeb722ce
parent 135007 260999a5d63b383d04c070410417828db69196d6
permissions -rw-r--r--
Bumping gaia.json for 2 gaia-central revision(s) ======== https://hg.mozilla.org/integration/gaia-central/rev/9d9dfbc39ce6 Author: Sam Joch <samuel@guiora.com> Desc: Merge pull request #11810 from epang/bug910166_add_missing_browser_graphics Bug 910166 - Add Missing Browser Graphics r=samjoch ======== https://hg.mozilla.org/integration/gaia-central/rev/8b82cb30cfba Author: Eric Pang <epang@mozilla.com> Desc: Bug 910166 - Add Missing Browser Graphics

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.

import errno
import os

dependencies = []
targets = []

def makeQuote(filename):
    return filename.replace(' ', '\\ ')  # enjoy!

def writeMakeDependOutput(filename):
    print "Creating makedepend file", filename
    dir = os.path.dirname(filename)
    if dir and not os.path.exists(dir):
        try:
            os.makedirs(dir)
        except OSError as error:
            if error.errno != errno.EEXIST:
                raise

    with open(filename, 'w') as f:
        if len(targets) > 0:
            f.write("%s:" % makeQuote(targets[0]))
            for filename in dependencies:
                f.write(' \\\n\t\t%s' % makeQuote(filename))
            f.write('\n')
            for filename in targets[1:]:
                f.write('%s: %s\n' % (makeQuote(filename), makeQuote(targets[0])))
            for filename in dependencies:
                f.write('%s:\n' % filename)