aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/skqp/generate_gn_args
blob: c9b1891c475e77318901bd3c195b0a101d76bb7d (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#! /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 argparse
import os
import sys

fmt = '''
target_cpu = "{arch}"
is_debug = {debug}
ndk = "{android_ndk_dir}"
ndk_api = {api_level}
skia_enable_fontmgr_empty = true
skia_enable_pdf = false
skia_skqp_global_error_tolerance = 4
skia_use_dng_sdk = false
skia_use_expat = false
skia_use_icu = false
skia_use_libheif = false
skia_use_lua = false
skia_use_piex = false
skia_use_skcms = false
skia_skqp_enable_driver_correctness_workarounds = {enable_workarounds}
'''

def parse_args():
    parser = argparse.ArgumentParser(description='Generate args.gn file.')
    parser.add_argument('target_build_dir')
    parser.add_argument('android_ndk_dir' )
    parser.add_argument('--arch',  metavar='architecture', default='arm',
        help='defaults to "arm", valid values: "arm" "arm64" "x86" "x64"')
    parser.add_argument('--api_level', type=int, metavar='api_level',
        default=26, help='android API level, defaults to 26')
    parser.add_argument('--enable_workarounds', default=False,
        action='store_true', help="enable GPU work-arounds, defaults to false")
    parser.add_argument('--debug', default=False, action='store_true',
        help='compile native code in debug mode, defaults to false')

    # parse the args and convert bools to strings.
    args = parser.parse_args()
    gn_bool = lambda b : 'true' if b else 'false'
    args.enable_workarounds = gn_bool(args.enable_workarounds)
    args.debug = gn_bool(args.debug)
    args.android_ndk_dir = os.path.abspath(args.android_ndk_dir)
    return args

def make_args_gn(out_dir, args):
    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(**args))

if __name__ == '__main__':
    args = parse_args()
    make_args_gn(args.target_build_dir, vars(args))