summaryrefslogtreecommitdiffstats
path: root/build/scripts/find_and_tar.py
blob: 1fe17fc7431a9c5d07f57950f3eb8acd4b706e32 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import os 
import sys 
import tarfile 
 
 
def find_gcno(dirname, tail): 
    for cur, _dirs, files in os.walk(dirname): 
        for f in files: 
            if f.endswith(tail): 
                yield os.path.relpath(os.path.join(cur, f)) 
 
 
def main(args): 
    output = args[0] 
    tail = args[1] if len(args) > 1 else ''
    with tarfile.open(output, 'w:') as tf: 
        for f in find_gcno(os.getcwd(), tail): 
            tf.add(f) 
 
 
if __name__ == '__main__': 
    main(sys.argv[1:])