Hal Canary | 181ec2f | 2018-01-24 13:42:38 -0500 | [diff] [blame^] | 1 | #! /usr/bin/env python |
| 2 | |
| 3 | # Copyright 2018 Google Inc. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
| 7 | import os |
| 8 | import sys |
| 9 | |
| 10 | fmt = '''ndk = "{ndk}" |
| 11 | ndk_api = 26 |
| 12 | target_cpu = "{arch}" |
| 13 | skia_embed_resources = true |
| 14 | is_debug = false |
| 15 | skia_enable_pdf = false |
| 16 | ''' |
| 17 | |
| 18 | def make_args_gn(out_dir, ndk, arch): |
| 19 | if not os.path.exists(out_dir): |
| 20 | os.makedirs(out_dir) |
| 21 | with open(os.path.join(out_dir, 'args.gn'), 'w') as o: |
| 22 | o.write(fmt.format(ndk=os.path.abspath(ndk), arch=arch)) |
| 23 | |
| 24 | def usage(): |
| 25 | sys.stderr.write( |
| 26 | 'Usage:\n' + |
| 27 | ' {} TARGET_BUILD_DIR ANDROID_NDK_DIR ARCHITECTURE\n\n'.format(sys.argv[0]) + |
| 28 | 'ARCHITECTURE should be "arm" "arm64" "x86" or "x64"\n\n') |
| 29 | exit(1) |
| 30 | |
| 31 | if __name__ == '__main__': |
| 32 | if len(sys.argv) != 4: |
| 33 | usage() |
| 34 | build, android_ndk, arch = sys.argv[1:4] |
| 35 | if len(build) == 0 or len(arch) == 0 or not os.path.isdir(android_ndk): |
| 36 | usage() |
| 37 | make_args_gn(build, android_ndk, arch) |
| 38 | |
| 39 | |