skia2/tools/skqp/remove_unneeded_assets

35 lines
989 B
Plaintext
Raw Normal View History

#! /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()