skia2/tools/skqp/remove_unneeded_assets
Hal Canary a58bcf7ef8 SkQP: Slimmer APKS
Currently produces 30% smaller APKs.

No-Try: true
Change-Id: Ic04b4bebef78e9a3f8b8dde4bace78ce74e43d66
Reviewed-on: https://skia-review.googlesource.com/106165
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
2018-02-12 17:05:22 +00:00

35 lines
989 B
Python
Executable File

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