mirror of
https://github.com/dart-lang/sdk
synced 2024-10-02 23:39:19 +00:00
Fuchsia: Build an OS image that includes Dart's test suite.
Guarded by a GN argument, this CL builds a Fuchsia OS image that includes Dart tree, including the test suite, packages, test harness, and sufficient build output to run through the test suite. R=asiva@google.com Review-Url: https://codereview.chromium.org/2547013003 .
This commit is contained in:
parent
c5c7f45be0
commit
306b0ec249
74
BUILD.gn
74
BUILD.gn
|
@ -167,3 +167,77 @@ group("samples") {
|
|||
"runtime/bin:sample_extension",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
# The rules below build a qemu Fuchsia OS image that includes the Dart tree
|
||||
# under /system/test/dart. Building this image is gated by the GN argument
|
||||
# 'dart_build_fuchsia_test_image' because building the image is slow.
|
||||
if (defined(is_fuchsia) && (is_fuchsia)) {
|
||||
declare_args() {
|
||||
dart_build_fuchsia_test_image = false
|
||||
}
|
||||
|
||||
if (dart_build_fuchsia_test_image) {
|
||||
action("generate_dart_test_manifest") {
|
||||
testonly = true
|
||||
|
||||
deps = [
|
||||
"//packages/gn:mkbootfs",
|
||||
]
|
||||
|
||||
output_prefix = "$target_gen_dir/dart_test_tree"
|
||||
outputs = [
|
||||
"$output_prefix.manifest",
|
||||
]
|
||||
|
||||
mode = "release"
|
||||
if (is_debug) {
|
||||
mode = "debug"
|
||||
}
|
||||
|
||||
mkbootfs_gen = get_label_info("//packages/gn:mkbootfs", "target_gen_dir")
|
||||
user_manifest = "$mkbootfs_gen/user.bootfs.manifest"
|
||||
|
||||
script = "tools/gen_fuchsia_test_manifest.py"
|
||||
args = [
|
||||
"-m",
|
||||
mode,
|
||||
"-u",
|
||||
rebase_path(user_manifest),
|
||||
"-o",
|
||||
rebase_path(output_prefix),
|
||||
]
|
||||
}
|
||||
|
||||
action("generate_dart_test_image") {
|
||||
testonly = true
|
||||
deps = [
|
||||
"runtime/bin:dart",
|
||||
"runtime/bin:run_vm_tests",
|
||||
"runtime/bin:process_test",
|
||||
":generate_dart_test_manifest",
|
||||
]
|
||||
|
||||
input = "$target_gen_dir/dart_test_tree.manifest"
|
||||
inputs = [
|
||||
input,
|
||||
]
|
||||
|
||||
output = "$root_out_dir/dart_test_tree.bin"
|
||||
outputs = [
|
||||
output,
|
||||
]
|
||||
|
||||
script = "//packages/gn/make_bootfs.py"
|
||||
args = [
|
||||
"--manifest",
|
||||
rebase_path(input),
|
||||
"--output-file",
|
||||
rebase_path(output),
|
||||
"--build-id-map",
|
||||
rebase_path("$target_gen_dir/build_id_map"),
|
||||
"--compress",
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,9 +118,6 @@ ListType DirectoryListingEntry::Next(DirectoryListing* listing) {
|
|||
// ports.
|
||||
errno = 0;
|
||||
dirent* entry = readdir(reinterpret_cast<DIR*>(lister_));
|
||||
if (entry == NULL) {
|
||||
perror("readdir failed: ");
|
||||
}
|
||||
if (entry != NULL) {
|
||||
if (!listing->path_buffer().Add(entry->d_name)) {
|
||||
done_ = true;
|
||||
|
|
92
tools/gen_fuchsia_test_manifest.py
Executable file
92
tools/gen_fuchsia_test_manifest.py
Executable file
|
@ -0,0 +1,92 @@
|
|||
#!/usr/bin/env python
|
||||
# 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('--user-manifest', '-u',
|
||||
type=str,
|
||||
help='Path to base userspace manifest.')
|
||||
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:
|
||||
# First copy the main user manifest.
|
||||
with open(args.user_manifest, 'r') as user_manifest:
|
||||
for line in user_manifest:
|
||||
if '=' in line:
|
||||
manifest.write(line)
|
||||
|
||||
# Now, 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))
|
|
@ -2302,7 +2302,10 @@ class TestUtils {
|
|||
static String outputDir(Map configuration) {
|
||||
var result = '';
|
||||
var system = configuration['system'];
|
||||
if (system == 'linux' || system == 'android' || system == 'windows') {
|
||||
if (system == 'fuchsia' ||
|
||||
system == 'linux' ||
|
||||
system == 'android' ||
|
||||
system == 'windows') {
|
||||
result = 'out/';
|
||||
} else if (system == 'macos') {
|
||||
result = 'xcodebuild/';
|
||||
|
@ -2412,6 +2415,7 @@ class TestUtils {
|
|||
case 'android':
|
||||
os = 'Android';
|
||||
break;
|
||||
case 'fuchsia':
|
||||
case 'linux':
|
||||
case 'macos':
|
||||
case 'windows':
|
||||
|
|
Loading…
Reference in a new issue