|
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/. |
|
4 |
|
5 import errno |
|
6 import os |
|
7 |
|
8 dependencies = [] |
|
9 targets = [] |
|
10 |
|
11 def makeQuote(filename): |
|
12 return filename.replace(' ', '\\ ') # enjoy! |
|
13 |
|
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 |
|
23 |
|
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) |
|
34 |