aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/skqp/setup_resources
blob: 45b9b70e093f5dca953edef4dc5f5216c5a669af (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
#! /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

if __name__ == '__main__':
    if len(sys.argv) != 3 or not os.path.isdir(sys.argv[1]) or not os.path.isdir(sys.argv[2]):
        sys.stderr.write('Usage\n  %s SKIA_DIR BUILD_DIR\n\n' % sys.argv[0])
        sys.exit(1)
    skia = sys.argv[1]
    gen = os.path.join(sys.argv[2], 'gen')
    if not os.path.isdir(gen):
        os.mkdir(gen)
    with open(os.path.join(gen, 'binary_resources.cpp'), 'w') as o:
        o.write('#include "BinaryAsset.h"\n'
                'BinaryAsset gResources[] = { {nullptr, nullptr, 0} };\n')
    dst = os.path.join(skia, 'platform_tools', 'android', 'apps', 'skqp',
                       'src', 'main', 'assets', 'resources')
    if os.path.isdir(dst) and not os.path.islink(dst):
        shutil.rmtree(dst)
    elif os.path.exists(dst):
        os.remove(dst)
    shutil.copytree(os.path.join(skia, 'resources'), dst)