aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/skqp/generate_gn_args
blob: cead4158adb38f73fdd9bd74953ff05378f8bc4b (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
35
36
37
38
39
#! /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 sys

fmt = '''ndk = "{ndk}"
ndk_api = 26
target_cpu = "{arch}"
skia_embed_resources = true
is_debug = false
skia_enable_pdf = false
'''

def make_args_gn(out_dir, ndk, arch):
    if not os.path.exists(out_dir):
        os.makedirs(out_dir)
    with open(os.path.join(out_dir, 'args.gn'), 'w') as o:
        o.write(fmt.format(ndk=os.path.abspath(ndk), arch=arch))

def usage():
    sys.stderr.write(
            'Usage:\n' +
            '  {} TARGET_BUILD_DIR ANDROID_NDK_DIR ARCHITECTURE\n\n'.format(sys.argv[0]) +
            'ARCHITECTURE should be "arm" "arm64" "x86" or "x64"\n\n')
    exit(1)

if __name__ == '__main__':
    if len(sys.argv) != 4:
        usage()
    build, android_ndk, arch = sys.argv[1:4]
    if len(build) == 0 or len(arch) == 0 or not os.path.isdir(android_ndk):
        usage()
    make_args_gn(build, android_ndk, arch)