mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
e842c9b0b5
This change shifts logic for invoking Dart scripts during the build from a couple of python scripts to a new template called dart_action(). Change-Id: Ic0818122cd7317cbd22a7255d880fe8f87271b7e Reviewed-on: https://dart-review.googlesource.com/39260 Commit-Queue: Zach Anderson <zra@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com>
93 lines
2.6 KiB
Plaintext
93 lines
2.6 KiB
Plaintext
# Copyright (c) 2018, 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("compiled_action.gni")
|
|
import("executable_suffix.gni")
|
|
import("prebuilt_dart_sdk.gni")
|
|
|
|
_dart_root = get_path_info("..", "abspath")
|
|
|
|
# A template for running Dart scripts during the build. This should *not* be
|
|
# used for generating snapshots. It uses the dart binary from the prebuilt
|
|
# Dart SDK if one is available, and dart_bootstrap otherwise.
|
|
#
|
|
# Parameters:
|
|
# script:
|
|
# The un-rebased path to the Dart script.
|
|
#
|
|
# args:
|
|
# The arguments to pass to the Dart script.
|
|
|
|
# packages (optional):
|
|
# The un-rebased path to the .packages file.
|
|
#
|
|
# Forwarded to action() with the usual meaning:
|
|
# depfile
|
|
# deps
|
|
# inputs
|
|
# outputs
|
|
# visibility
|
|
template("dart_action") {
|
|
assert(defined(invoker.script), "script must be defined for $target_name")
|
|
assert(defined(invoker.outputs), "outputs must be defined for $target_name")
|
|
assert(defined(invoker.args), "args must be defined for $target_name")
|
|
assert(!defined(invoker.sources),
|
|
"dart_action doesn't take a sources arg. Use inputs instead.")
|
|
|
|
if (prebuilt_dart_exe_works) {
|
|
action(target_name) {
|
|
forward_variables_from(invoker, [
|
|
"inputs",
|
|
"outputs",
|
|
"deps",
|
|
"visibility",
|
|
"depfile",
|
|
])
|
|
script = "$_dart_root/build/gn_run_binary.py"
|
|
prebuilt_dart_binary =
|
|
"$_dart_root/tools/sdks/$host_os/dart-sdk/bin/dart$executable_suffix"
|
|
|
|
inputs += [ invoker.script ]
|
|
if (defined(invoker.packages)) {
|
|
inputs += [ invoker.packages ]
|
|
}
|
|
|
|
args = [
|
|
"compiled_action",
|
|
rebase_path(prebuilt_dart_binary),
|
|
]
|
|
if (defined(invoker.packages)) {
|
|
args += [
|
|
"--packages=" + rebase_path(invoker.packages),
|
|
]
|
|
}
|
|
args += [ rebase_path(invoker.script) ] + invoker.args
|
|
}
|
|
} else {
|
|
compiled_action(target_name) {
|
|
forward_variables_from(invoker, [
|
|
"inputs",
|
|
"outputs",
|
|
"deps",
|
|
"visibility",
|
|
"depfile",
|
|
])
|
|
|
|
inputs += [ invoker.script ]
|
|
if (defined(invoker.packages)) {
|
|
inputs += [ invoker.packages ]
|
|
}
|
|
|
|
tool = "runtime/bin:dart_bootstrap"
|
|
args = []
|
|
if (defined(invoker.packages)) {
|
|
args += [
|
|
"--packages=" + rebase_path(invoker.packages),
|
|
]
|
|
}
|
|
args += [ rebase_path(invoker.script) ] + invoker.args
|
|
}
|
|
}
|
|
}
|