2018-01-24 18:42:38 +00:00
|
|
|
#! /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.
|
|
|
|
|
2018-02-02 20:05:42 +00:00
|
|
|
import argparse
|
2018-01-24 18:42:38 +00:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
2018-01-30 16:35:47 +00:00
|
|
|
fmt = '''
|
2018-02-12 20:54:40 +00:00
|
|
|
target_cpu = "{arch}"
|
|
|
|
is_debug = {debug}
|
|
|
|
ndk = "{android_ndk_dir}"
|
|
|
|
ndk_api = {api_level}
|
|
|
|
skia_enable_fontmgr_empty = true
|
|
|
|
skia_enable_pdf = false
|
2018-02-01 19:06:13 +00:00
|
|
|
skia_skqp_global_error_tolerance = 4
|
2018-02-12 20:54:40 +00:00
|
|
|
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
|
2018-02-02 20:05:42 +00:00
|
|
|
skia_skqp_enable_driver_correctness_workarounds = {enable_workarounds}
|
2018-04-24 15:47:23 +00:00
|
|
|
skia_tools_require_resources = true
|
2018-01-24 18:42:38 +00:00
|
|
|
'''
|
|
|
|
|
2018-02-02 20:05:42 +00:00
|
|
|
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")
|
2018-02-12 20:54:40 +00:00
|
|
|
parser.add_argument('--debug', default=False, action='store_true',
|
|
|
|
help='compile native code in debug mode, defaults to false')
|
2018-02-02 20:05:42 +00:00
|
|
|
|
2018-02-12 20:54:40 +00:00
|
|
|
# parse the args and convert bools to strings.
|
2018-02-02 20:05:42 +00:00
|
|
|
args = parser.parse_args()
|
2018-02-12 20:54:40 +00:00
|
|
|
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)
|
2018-02-02 20:05:42 +00:00
|
|
|
return args
|
|
|
|
|
2018-02-12 20:54:40 +00:00
|
|
|
def make_args_gn(out_dir, args):
|
2018-01-24 18:42:38 +00:00
|
|
|
if not os.path.exists(out_dir):
|
|
|
|
os.makedirs(out_dir)
|
|
|
|
with open(os.path.join(out_dir, 'args.gn'), 'w') as o:
|
2018-02-12 20:54:40 +00:00
|
|
|
o.write(fmt.format(**args))
|
2018-01-24 18:42:38 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2018-02-02 20:05:42 +00:00
|
|
|
args = parse_args()
|
2018-02-12 20:54:40 +00:00
|
|
|
make_args_gn(args.target_build_dir, vars(args))
|