diff options
author | Steven Knight <knight@baldmt.com> | 2004-09-25 02:50:45 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2004-09-25 02:50:45 (GMT) |
commit | f5f2d8ad9d24df1b0f58477006b784adc4bc8a03 (patch) | |
tree | 5c0fc7d7e7bec84d3e88ca77133d693f7eb98cd1 /src/engine/SCons/Environment.py | |
parent | e4a3739689eac21ce5db67d606a9fe29a7695394 (diff) | |
download | SCons-f5f2d8ad9d24df1b0f58477006b784adc4bc8a03.zip SCons-f5f2d8ad9d24df1b0f58477006b784adc4bc8a03.tar.gz SCons-f5f2d8ad9d24df1b0f58477006b784adc4bc8a03.tar.bz2 |
Add a ParseDepends() function to read up mkdep-style files.
Diffstat (limited to 'src/engine/SCons/Environment.py')
-rw-r--r-- | src/engine/SCons/Environment.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index df2a93a..9fa7b34 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -792,6 +792,32 @@ class Base: command = self.subst(command) return function(self, os.popen(command).read()) + def ParseDepends(self, filename, must_exist=None): + """ + Parse a mkdep-style file for explicit dependencies. This is + completely abusable, and should be unnecessary in the "normal" + case of proper SCons configuration, but it may help make + the transition from a Make hierarchy easier for some people + to swallow. It can also be genuinely useful when using a tool + that can write a .d file, but for which writing a scanner would + be too complicated. + """ + try: + fp = open(filename, 'r') + except IOError: + if must_exist: + raise + return + for line in SCons.Util.LogicalLines(fp).readlines(): + if line[0] == '#': + continue + try: + target, depends = string.split(line, ':', 1) + except: + pass + else: + self.Depends(string.split(target), string.split(depends)) + def Platform(self, platform): platform = self.subst(platform) return SCons.Platform.Platform(platform)(self) |