michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: # You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: import errno michael@0: import os michael@0: michael@0: dependencies = [] michael@0: targets = [] michael@0: michael@0: def makeQuote(filename): michael@0: return filename.replace(' ', '\\ ') # enjoy! michael@0: michael@0: def writeMakeDependOutput(filename): michael@0: print "Creating makedepend file", filename michael@0: dir = os.path.dirname(filename) michael@0: if dir and not os.path.exists(dir): michael@0: try: michael@0: os.makedirs(dir) michael@0: except OSError as error: michael@0: if error.errno != errno.EEXIST: michael@0: raise michael@0: michael@0: with open(filename, 'w') as f: michael@0: if len(targets) > 0: michael@0: f.write("%s:" % makeQuote(targets[0])) michael@0: for filename in dependencies: michael@0: f.write(' \\\n\t\t%s' % makeQuote(filename)) michael@0: f.write('\n') michael@0: for filename in targets[1:]: michael@0: f.write('%s: %s\n' % (makeQuote(filename), makeQuote(targets[0]))) michael@0: for filename in dependencies: michael@0: f.write('%s:\n' % filename) michael@0: