OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 """Special script for processing the devil config jinja file. |
| 7 |
| 8 This script is needed because the PRODUCT_DIR is not known at gyp time. Many of |
| 9 the jinja variables for the devil template are directories relative to the |
| 10 PRODUCT_DIR. These paths cannot be computed at gyp time and need a separate |
| 11 script. |
| 12 """ |
| 13 |
| 14 # TODO(mikecase): Delete this script once GYP is removed. |
| 15 |
| 16 import argparse |
| 17 import os |
| 18 import subprocess |
| 19 import sys |
| 20 |
| 21 JINJA_TEMPLATE_SCRIPT = os.path.join(os.path.dirname(__file__), |
| 22 'gyp', 'jinja_template.py') |
| 23 |
| 24 def DevilJinjaProcessor(args): |
| 25 |
| 26 gen_dir = os.path.join(args.product_dir, 'gen') |
| 27 |
| 28 rebased_android_sdk_root = os.path.relpath(args.android_sdk_root, gen_dir) |
| 29 rebased_product_dir = os.path.relpath(args.product_dir, gen_dir) |
| 30 |
| 31 variables = ['android_app_abi=%s' % args.android_abi, |
| 32 'android_sdk_root=%s' % rebased_android_sdk_root, |
| 33 'build_tools_version=%s' % args.build_tools_version, |
| 34 'output_dir=%s' % rebased_product_dir] |
| 35 |
| 36 output_file = os.path.join(gen_dir, 'devil_chromium.json') |
| 37 |
| 38 cmd = [JINJA_TEMPLATE_SCRIPT, |
| 39 '--inputs', args.input_file_path, |
| 40 '--output', output_file, |
| 41 '--variables', ' '.join(variables)] |
| 42 |
| 43 subprocess.call(cmd) |
| 44 |
| 45 def main(): |
| 46 parser = argparse.ArgumentParser() |
| 47 |
| 48 parser.add_argument('--android-abi', required=True, |
| 49 help='Android app abi, e.g. armeabi-v7a.') |
| 50 parser.add_argument('--android-sdk-root', required=True, |
| 51 help='Path to the android sdk root.') |
| 52 parser.add_argument('--build-tools-version', required=True, |
| 53 help='Android build tools version.') |
| 54 parser.add_argument('--input-file-path', required=True, |
| 55 help='Path to input template file.') |
| 56 parser.add_argument('--output-file-name', required=True, |
| 57 help='Name of generated file. Will be put in gen/ ' |
| 58 'under product directory.') |
| 59 parser.add_argument('--product-dir', required=True, |
| 60 help='Path to product directory.') |
| 61 |
| 62 args = parser.parse_args() |
| 63 DevilJinjaProcessor(args) |
| 64 |
| 65 if __name__ == '__main__': |
| 66 sys.exit(main()) |
OLD | NEW |