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