Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | import pymake.data |
michael@0 | 2 | import pymake.parser |
michael@0 | 3 | import pymake.parserdata |
michael@0 | 4 | import sys |
michael@0 | 5 | |
michael@0 | 6 | ''' |
michael@0 | 7 | Modifies the output of Sun Studio's -xM to look more like the output |
michael@0 | 8 | of gcc's -MD -MP, adding phony targets for dependencies. |
michael@0 | 9 | ''' |
michael@0 | 10 | |
michael@0 | 11 | |
michael@0 | 12 | def add_phony_targets(path): |
michael@0 | 13 | print path |
michael@0 | 14 | deps = set() |
michael@0 | 15 | targets = set() |
michael@0 | 16 | for stmt in pymake.parser.parsefile(path): |
michael@0 | 17 | if isinstance(stmt, pymake.parserdata.Rule): |
michael@0 | 18 | assert isinstance(stmt.depexp, pymake.data.StringExpansion) |
michael@0 | 19 | assert isinstance(stmt.targetexp, pymake.data.StringExpansion) |
michael@0 | 20 | for d in stmt.depexp.s.split(): |
michael@0 | 21 | deps.add(d) |
michael@0 | 22 | for t in stmt.targetexp.s.split(): |
michael@0 | 23 | targets.add(t) |
michael@0 | 24 | phony_targets = deps - targets |
michael@0 | 25 | if not phony_targets: |
michael@0 | 26 | return |
michael@0 | 27 | with open(path, 'a') as f: |
michael@0 | 28 | f.writelines('%s:\n' % d for d in phony_targets) |
michael@0 | 29 | |
michael@0 | 30 | |
michael@0 | 31 | if __name__ == '__main__': |
michael@0 | 32 | for f in sys.argv[1:]: |
michael@0 | 33 | add_phony_targets(f) |