aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/skqp/remove_unneeded_assets
blob: 67bf9cff037549c159c719d90b13cb70d9c1f070 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#! /usr/bin/env python

# Copyright 2018 Google Inc.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import os
import shutil
import sys

def gset(path):
    s = set()
    if os.path.isfile(path):
        with open(path, 'r') as f:
            for line in f:
                s.add(line.strip())
    return s

def main():
    assets = os.path.join('platform_tools', 'android', 'apps', 'skqp', 'src', 'main', 'assets')
    os.chdir(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, assets))
    known = gset('skqp/KnownGMs.txt')
    nope = gset('skqp/DoNotScoreInCompatibilityTestMode.txt')
    present = set(os.listdir('gmkb'))
    to_delete = present & nope
    if (known):
        to_delete |= (present - known)
    for x in to_delete:
        shutil.rmtree(os.path.join('gmkb', x))
    sys.stdout.write('%s: %d of %d models removed\n' %(sys.argv[0], len(to_delete), len(present)))

if __name__ == '__main__':
    main()