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
|
|
|
|
|
2019-08-19 19:04:24 +00:00
|
|
|
import skqp_gn_args
|
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')
|
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
|
|
|
args = parser.parse_args()
|
2019-08-19 19:04:24 +00:00
|
|
|
result = skqp_gn_args.GetGNArgs(args.arch,
|
|
|
|
os.path.abspath(args.android_ndk_dir),
|
|
|
|
args.debug,
|
|
|
|
args.api_level)
|
|
|
|
return args.target_build_dir, result)
|
2018-02-02 20:05:42 +00:00
|
|
|
|
2019-03-04 22:28:22 +00:00
|
|
|
def write_gn(o, args):
|
2019-08-19 19:04:24 +00:00
|
|
|
l = max(len(k) for k in args)
|
|
|
|
for k, v in sorted(args.items()):
|
|
|
|
o.write('%-*s = %s\n' % (l, k, v))
|
2019-03-04 22:28:22 +00:00
|
|
|
|
2018-02-12 20:54:40 +00:00
|
|
|
def make_args_gn(out_dir, args):
|
2019-03-04 22:28:22 +00:00
|
|
|
if out_dir == '-':
|
|
|
|
write_gn(sys.stdout, args)
|
|
|
|
return
|
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:
|
2019-03-04 22:28:22 +00:00
|
|
|
write_gn(o, args)
|
2018-01-24 18:42:38 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2019-08-19 19:04:24 +00:00
|
|
|
build_dir, args = parse_args()
|
|
|
|
make_args_gn(build_dir, args)
|