Flutter Engine
The Flutter Engine
gen_fuchsia_test_manifest.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# Copyright 2017 The Dart project 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# This script creates a qemu image manifest for Fuchsia that contains the
7# Dart tree. In particular in contains Dart's test suite, and test harness.
8
9import argparse
10import json
11import os
12import sys
13import utils
14
15SCRIPT_DIR = os.path.dirname(sys.argv[0])
16DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..'))
17FUCHSIA_ROOT = os.path.realpath(os.path.join(DART_ROOT, '..', '..'))
18
19FUCHSIA_TEST_MANIFEST_PREFIX = os.path.join('test', 'dart')
20
21EXCLUDE_DIRS = ['.git', 'out', '.jiri']
22
23BINARY_FILES = ['dart', 'run_vm_tests', 'process_test']
24
25
26def parse_args(args):
27 args = args[1:]
28 parser = argparse.ArgumentParser(
29 description='A script that generates Dart/Fuchsia test commands.')
30
31 parser.add_argument(
32 '--arch',
33 '-a',
34 type=str,
35 help='Target architectures (comma-separated).',
36 metavar='[x64]',
37 default='x64')
38 parser.add_argument(
39 '--mode',
40 '-m',
41 type=str,
42 help='Build variant',
43 metavar='[debug,release]',
44 default='debug')
45 parser.add_argument(
46 '--output', '-o', type=str, help='Path to output file prefix.')
47 parser.add_argument(
48 "-v",
49 "--verbose",
50 help='Verbose output.',
51 default=False,
52 action="store_true")
53
54 return parser.parse_args(args)
55
56
57def fuchsia_arch(arch):
58 if arch is 'x64':
59 return 'x86-64'
60 return None
61
62
63def main(argv):
64 args = parse_args(argv)
65
66 manifest_output = args.output + '.manifest'
67 with open(manifest_output, 'w') as manifest:
68 # Write the Dart tree.
69 for root, dirs, files in os.walk(DART_ROOT):
70 dirs[:] = [d for d in dirs if d not in EXCLUDE_DIRS]
71 for file in files:
72 filepath = os.path.join(root, file)
73 relpath = filepath[len(DART_ROOT) + 1:]
74 fuchsiapath = os.path.join(FUCHSIA_TEST_MANIFEST_PREFIX,
75 relpath)
76 manifest.write(
77 '%s=%s\n' % (fuchsiapath, os.path.join(root, file)))
78
79 dart_conf = utils.GetBuildConf(args.mode, args.arch)
80 dart_out = os.path.join(FUCHSIA_TEST_MANIFEST_PREFIX, 'out', dart_conf)
81 fuchsia_conf = '%s-%s' % (args.mode, fuchsia_arch(args.arch))
82 fuchsia_out = os.path.join(FUCHSIA_ROOT, 'out', fuchsia_conf)
83 for file in BINARY_FILES:
84 manifest.write('%s=%s\n' % (os.path.join(dart_out, file),
85 os.path.join(fuchsia_out, file)))
86
87 return 0
88
89
90if __name__ == '__main__':
91 sys.exit(main(sys.argv))
Definition: main.py:1
def GetBuildConf(mode, arch)
Definition: utils.py:139