build/unix/add_phony_targets.py

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

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.

     1 import pymake.data
     2 import pymake.parser
     3 import pymake.parserdata
     4 import sys
     6 '''
     7 Modifies the output of Sun Studio's -xM to look more like the output
     8 of gcc's -MD -MP, adding phony targets for dependencies.
     9 '''
    12 def add_phony_targets(path):
    13     print path
    14     deps = set()
    15     targets = set()
    16     for stmt in pymake.parser.parsefile(path):
    17         if isinstance(stmt, pymake.parserdata.Rule):
    18             assert isinstance(stmt.depexp, pymake.data.StringExpansion)
    19             assert isinstance(stmt.targetexp, pymake.data.StringExpansion)
    20             for d in stmt.depexp.s.split():
    21                 deps.add(d)
    22             for t in stmt.targetexp.s.split():
    23                 targets.add(t)
    24     phony_targets = deps - targets
    25     if not phony_targets:
    26         return
    27     with open(path, 'a') as f:
    28         f.writelines('%s:\n' % d for d in phony_targets)
    31 if __name__ == '__main__':
    32     for f in sys.argv[1:]:
    33         add_phony_targets(f)

mercurial