From 0e9991d4c827f28c84ecc7a908c3f2811a4facb7 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Tue, 19 Mar 2013 06:29:48 +0100 Subject: [PATCH] Bug 852103 - Fix race condition with .deps directory creation. r=ted --- python/codegen/makeutils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/python/codegen/makeutils.py b/python/codegen/makeutils.py index da53162d70bb..0a9ef67792cc 100644 --- a/python/codegen/makeutils.py +++ b/python/codegen/makeutils.py @@ -2,6 +2,8 @@ # 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 + dependencies = [] targets = [] @@ -10,6 +12,14 @@ def makeQuote(filename): 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]))