mirror of
https://github.com/dart-lang/sdk
synced 2024-11-05 18:22:09 +00:00
Don't depend on dart_bootstrap if there is a usable prebuilt sdk
Also replace invoke_dart() with compiled_action(), and some other cleanups. fixes #27781 R=johnmccutchan@google.com Review URL: https://codereview.chromium.org/2493833002 .
This commit is contained in:
parent
e3f791b00e
commit
90d3962ca3
14 changed files with 86 additions and 107 deletions
9
build/executable_suffix.gni
Normal file
9
build/executable_suffix.gni
Normal file
|
@ -0,0 +1,9 @@
|
|||
# Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
|
||||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
if (defined(is_win) && is_win) {
|
||||
executable_suffix = ".exe"
|
||||
} else {
|
||||
executable_suffix = ""
|
||||
}
|
|
@ -8,15 +8,28 @@ Run with:
|
|||
python gn_run_binary.py <binary_name> [args ...]
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
# This script is designed to run binaries produced by the current build. We
|
||||
# always prefix it with "./" to avoid picking up system versions that might
|
||||
# also be on the path.
|
||||
path = './' + sys.argv[1]
|
||||
# Run a command, swallowing the output unless there is an error.
|
||||
def run_command(command):
|
||||
try:
|
||||
subprocess.check_output(command, stderr=subprocess.STDOUT)
|
||||
return 0
|
||||
except subprocess.CalledProcessError as e:
|
||||
return ("Command failed: " + ' '.join(command) + "\n" +
|
||||
"output: " + e.output)
|
||||
|
||||
# Unless the path is absolute, this script is designed to run binaries produced
|
||||
# by the current build. We always prefix it with "./" to avoid picking up system
|
||||
# versions that might also be on the path.
|
||||
if os.path.isabs(sys.argv[1]):
|
||||
path = sys.argv[1]
|
||||
else:
|
||||
path = './' + sys.argv[1]
|
||||
|
||||
# The rest of the arguements are passed directly to the executable.
|
||||
args = [path] + sys.argv[2:]
|
||||
|
||||
sys.exit(subprocess.call(args))
|
||||
sys.exit(run_command(args))
|
||||
|
|
18
build/prebuilt_dart_sdk.gni
Normal file
18
build/prebuilt_dart_sdk.gni
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
|
||||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import("executable_suffix.gni")
|
||||
|
||||
_dart_root = rebase_path("..")
|
||||
|
||||
_prebuilt_dart_exe = "$_dart_root/tools/sdks/$host_os/dart-sdk/bin/dart"
|
||||
|
||||
# Our gn_run_binary swallows output unless there is an error.
|
||||
_prebuilt_dart_exe_trial = exec_script("gn_run_binary.py",
|
||||
[_prebuilt_dart_exe, "--version"], "string")
|
||||
if (_prebuilt_dart_exe_trial == "") {
|
||||
prebuilt_dart_exe_works = true
|
||||
} else {
|
||||
prebuilt_dart_exe_works = false
|
||||
}
|
|
@ -2,7 +2,8 @@
|
|||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import("../../utils/invoke_dart.gni")
|
||||
import("../../build/executable_suffix.gni")
|
||||
import("../../build/prebuilt_dart_sdk.gni")
|
||||
|
||||
# Currently paths here are hard coded for convenience in building Mojo/Flutter.
|
||||
declare_args() {
|
||||
|
@ -29,19 +30,20 @@ if (dart_host_pub_exe != "") {
|
|||
"--pub-executable",
|
||||
dart_host_pub_exe,
|
||||
]
|
||||
} else {
|
||||
} else if (!prebuilt_dart_exe_works) {
|
||||
pub_build_deps += [ "../bin:dart_bootstrap($host_toolchain)" ]
|
||||
|
||||
dart_out_dir =
|
||||
get_label_info("../bin:dart_bootstrap($host_toolchain)", "root_out_dir")
|
||||
dart_bootstrap =
|
||||
rebase_path("$dart_out_dir/dart_bootstrap$dart_executable_suffix")
|
||||
dart_bootstrap = rebase_path("$dart_out_dir/dart_bootstrap$executable_suffix")
|
||||
|
||||
pub_build_args = [
|
||||
"--sdk=True",
|
||||
"--dart-executable",
|
||||
dart_bootstrap,
|
||||
]
|
||||
} else {
|
||||
pub_build_args = [ "--sdk=True" ]
|
||||
}
|
||||
|
||||
current_dir = rebase_path(".", "//")
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import("../../utils/invoke_dart.gni")
|
||||
import("../../build/executable_suffix.gni")
|
||||
import("../../build/prebuilt_dart_sdk.gni")
|
||||
|
||||
config("libdart_vm_config") {
|
||||
if (defined(is_fuchsia) && is_fuchsia) {
|
||||
|
@ -440,8 +441,10 @@ if (!defined(is_fuchsia) || !is_fuchsia) {
|
|||
# Build the patched sdk out of the concatenated patches and the special
|
||||
# libraries.
|
||||
action(target_name) {
|
||||
deps = [ "../bin:dart_bootstrap($host_toolchain)" ] +
|
||||
concatenation_target_names
|
||||
deps = concatenation_target_names
|
||||
if (!prebuilt_dart_exe_works) {
|
||||
deps += [ "../bin:dart_bootstrap($host_toolchain)" ]
|
||||
}
|
||||
|
||||
patches_dir = "$target_gen_dir/patches"
|
||||
patched_sdk_dir = "$root_out_dir/patched_sdk"
|
||||
|
@ -481,14 +484,18 @@ if (!defined(is_fuchsia) || !is_fuchsia) {
|
|||
"${patched_sdk_dir}/lib/core/core.dart",
|
||||
]
|
||||
|
||||
dart_out_dir = get_label_info("../bin:dart_bootstrap($host_toolchain)",
|
||||
"root_out_dir")
|
||||
dart_bootstrap =
|
||||
rebase_path("$dart_out_dir/dart_bootstrap$dart_executable_suffix")
|
||||
|
||||
args = [
|
||||
"--dart-executable",
|
||||
dart_bootstrap,
|
||||
args = []
|
||||
if (!prebuilt_dart_exe_works) {
|
||||
dart_out_dir = get_label_info("../bin:dart_bootstrap($host_toolchain)",
|
||||
"root_out_dir")
|
||||
dart_bootstrap =
|
||||
rebase_path("$dart_out_dir/dart_bootstrap$executable_suffix")
|
||||
args += [
|
||||
"--dart-executable",
|
||||
dart_bootstrap,
|
||||
]
|
||||
}
|
||||
args += [
|
||||
"vm",
|
||||
rebase_path("../../sdk"),
|
||||
rebase_path(patches_dir, root_build_dir),
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# Copyright 2016 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.
|
||||
|
||||
# Usage: dart_for_gn.py path_to_dart_binary [arguments]
|
||||
#
|
||||
# We have gn set up so that actions can only run python scripts.
|
||||
# We use this wrapper script when we need an action to run the Dart VM
|
||||
# The first command line argument is mandatory and should be the absolute path
|
||||
# to the Dart VM binary.
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
def run_command(command):
|
||||
try:
|
||||
subprocess.check_output(command, stderr=subprocess.STDOUT)
|
||||
return 0
|
||||
except subprocess.CalledProcessError as e:
|
||||
return ("Command failed: " + ' '.join(command) + "\n" +
|
||||
"output: " + e.output)
|
||||
|
||||
def main(argv):
|
||||
if len(argv) < 2:
|
||||
print "Requires path to Dart VM binary as first argument"
|
||||
return -1
|
||||
result = run_command(argv[1:])
|
||||
if result != 0:
|
||||
print result
|
||||
return -1
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv))
|
|
@ -2,7 +2,7 @@
|
|||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import("../invoke_dart.gni")
|
||||
import("../application_snapshot.gni")
|
||||
|
||||
application_snapshot("analysis_server") {
|
||||
main_dart = "../../pkg/analysis_server/bin/server.dart"
|
||||
|
|
|
@ -2,50 +2,10 @@
|
|||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import("//build/compiled_action.gni")
|
||||
|
||||
_dart_root = rebase_path("..")
|
||||
|
||||
if (defined(is_win) && is_win) {
|
||||
dart_executable_suffix = ".exe"
|
||||
} else {
|
||||
dart_executable_suffix = ""
|
||||
}
|
||||
|
||||
template("invoke_dart") {
|
||||
assert(defined(invoker.outputs), "invoke_dart must specify outputs")
|
||||
extra_deps = []
|
||||
if (defined(invoker.deps)) {
|
||||
extra_deps += invoker.deps
|
||||
}
|
||||
|
||||
extra_inputs = []
|
||||
if (defined(invoker.inputs)) {
|
||||
extra_inputs += invoker.inputs
|
||||
}
|
||||
|
||||
extra_args = []
|
||||
if (defined(invoker.args)) {
|
||||
extra_args += invoker.args
|
||||
}
|
||||
|
||||
action(target_name) {
|
||||
relative_dart_root = rebase_path(_dart_root, ".")
|
||||
deps =
|
||||
extra_deps + [ "$relative_dart_root/runtime/bin:dart($host_toolchain)" ]
|
||||
|
||||
dart_out_dir =
|
||||
get_label_info("$relative_dart_root/runtime/bin:dart($host_toolchain)",
|
||||
"root_out_dir")
|
||||
dart = rebase_path("$dart_out_dir/dart$dart_executable_suffix")
|
||||
|
||||
inputs = [ dart ] + extra_inputs
|
||||
|
||||
outputs = invoker.outputs
|
||||
|
||||
script = "$_dart_root/tools/dart_for_gn.py"
|
||||
args = [ dart ] + extra_args
|
||||
}
|
||||
}
|
||||
|
||||
template("application_snapshot") {
|
||||
assert(defined(invoker.main_dart), "Must specify 'main_dart'")
|
||||
assert(defined(invoker.training_args), "Must specify 'training_args'")
|
||||
|
@ -63,7 +23,8 @@ template("application_snapshot") {
|
|||
if (defined(invoker.inputs)) {
|
||||
extra_inputs += invoker.inputs
|
||||
}
|
||||
invoke_dart(target_name) {
|
||||
compiled_action(target_name) {
|
||||
tool = get_path_info("$_dart_root/runtime/bin:dart", "abspath")
|
||||
deps = extra_deps + [ "$_dart_root/pkg:pkg_files_stamp" ]
|
||||
|
||||
inputs = extra_inputs + [
|
|
@ -2,8 +2,9 @@
|
|||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import("//build/compiled_action.gni")
|
||||
import("../create_timestamp.gni")
|
||||
import("../invoke_dart.gni")
|
||||
import("../application_snapshot.gni")
|
||||
|
||||
create_timestamp_file("dart2js_files_stamp") {
|
||||
path = rebase_path("../../pkg/compiler/lib")
|
||||
|
@ -20,7 +21,8 @@ create_timestamp_file("dartdoc_files_stamp") {
|
|||
output = "$target_gen_dir/dartdoc_files.stamp"
|
||||
}
|
||||
|
||||
invoke_dart("dart2js_create_snapshot_entries") {
|
||||
compiled_action("dart2js_create_snapshot_entries") {
|
||||
tool = "../../runtime/bin:dart"
|
||||
deps = [
|
||||
":dart2js_files_stamp",
|
||||
":dartdoc_files_stamp",
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import("../invoke_dart.gni")
|
||||
import("//build/compiled_action.gni")
|
||||
import("../application_snapshot.gni")
|
||||
|
||||
group("dartanalyzer") {
|
||||
deps = [
|
||||
|
@ -37,7 +38,8 @@ template("generate_summary") {
|
|||
assert(defined(invoker.type), "Must specify the summary type")
|
||||
type = invoker.type
|
||||
assert(type == "spec" || type == "strong")
|
||||
invoke_dart(target_name) {
|
||||
compiled_action(target_name) {
|
||||
tool = "../../runtime/bin:dart"
|
||||
inputs = sdk_lib_files + analyzer_files
|
||||
|
||||
output = "$root_gen_dir/$type.sum"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import("../invoke_dart.gni")
|
||||
import("../application_snapshot.gni")
|
||||
|
||||
application_snapshot("dartdevc") {
|
||||
main_dart = "../../pkg/dev_compiler/bin/dartdevc.dart"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import("../invoke_dart.gni")
|
||||
import("../application_snapshot.gni")
|
||||
|
||||
application_snapshot("dartdoc") {
|
||||
main_dart = "../../third_party/pkg/dartdoc/bin/dartdoc.dart"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import("../invoke_dart.gni")
|
||||
import("../application_snapshot.gni")
|
||||
|
||||
application_snapshot("dartfmt") {
|
||||
main_dart = "../../third_party/pkg_tested/dart_style/bin/format.dart"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import("../invoke_dart.gni")
|
||||
import("../application_snapshot.gni")
|
||||
|
||||
application_snapshot("pub") {
|
||||
main_dart = "../../third_party/pkg/pub/bin/pub.dart"
|
||||
|
|
Loading…
Reference in a new issue