If a script uses `Platform.script` running it with as `dart
<script.dart>` and `dart run <script.dart>` would give the correct
script ("<script.dart>"), but running it with `dart run -r
<script.dart>` would report a dill file in the temp directory which is
not only surprising, but also breaking and for instance running the CFEs
strong_suite.dart via `dart run -r` didn't work.
This CL introduces --script_uri_override to the VM and makes the
resident compiler setup pass it so that when running `dart run -r
<script.dart>`, even though the vm is actually launched from a dill file
that resides in temp, `Platform.script` will actually return
`<script.dart>` - and running the CFEs strong_suite.dart via `dart run
-r` now actually works.
Tested: Added pkg/dartdev/test/commands/run_test.dart and manual testing.
Change-Id: Ia65c01834485fe06af63584baf0448dd5b9ffdb4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/510343
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Given that the standalone target for dart2wasm is feature-complete now,
it makes sense to include it in released SDKs.
This adds the platform and outline files to built SDKs and exposes the
`--standalone` flag in `dart compile wasm`.
It also documents the standalone target in `pkg/dart2wasm/doc`, which
should be helpful as a starting point to use these compiled modules.
Change-Id: I5bd86e9670f03f2955e31789095dd5c462bf149e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506920
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Codes specified on the command-line are force-enabled in all of the
analysis options for all of the files. This is done in a brute force
way, but it should be safe because the code is creating an analysis
context collection just for this one run, so the options objects
should be short lived.
Closes https://github.com/dart-lang/sdk/issues/63345
Change-Id: I8925da426d6cb5b9ce686725e3b95696b552cae0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505045
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This change fixes the following problems when parsing DART_VM_OPTIONS
environment variable:
* Resize vm_options to accomodate for extra flags from
DART_VM_OPTIONS.
* Prepend executable name to the argv to be compatible with
implementation of Platform.executableArguments.
* Use strchr instead of strtok_r to avoid modifying value of
DART_VM_OPTIONS environment variable in place.
TEST=pkg/dartdev/test/commands/compile_test.dart
Fixes https://github.com/dart-lang/sdk/issues/62957
Fixes https://github.com/dart-lang/sdk/issues/62958
Change-Id: I86e0ece20844888333b2a0765c82a5ad1fba54b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/491001
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
The `Match.operator[]` does the same thing and is
generally recommended (and shorter).
(I want to deprecate `group` and `groups`)
Tested: Refactoring.
CoreLibraryReviewExempt: Calling equivalent function.
Change-Id: I4c758968ae622fe16b7322be1b29b05b91e7fcd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489021
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Stream various updates from different components to `stderr` instead
of `stdout` on `dart run`.
TEST=pkg/dartdev/test/
Fixes: https://github.com/dart-lang/sdk/issues/62818
Change-Id: Icd5caa65aab092341d370b09c016f89ae2a57987
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-arm64-try,pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486203
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
This adds handling of upper case letters in `dart create`. This command is run from IDEs (IntelliJ, atleast) and if you use upper case letters in the directory, the `dart create` would (silently) fail instead of normalizing the directing to a valid package name, leaving the created project folder with no content.
All upper case names are normalized to all lower case, and mixed case are normalized to snake case, as if it was from camel case.
Change-Id: If854e17a0273eb0d02f4f0c5dcd4b50752e57bd4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/474641
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
We don't have a way to mechanically verify the exampes and fixed code,
so please look to see whether any of it looks wrong. And, of course, let
me know if any of the text appears to be incorrect or could be better.
Change-Id: I9b059524ffcedc1e3b8a7602b7124f419095a702
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455481
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Enables "run-from-remote" with `dart run`.
```
Run a Dart program from a file, a local package, or a remote package.
Usage: dart [vm-options] run [arguments] [<dart-file>|<local-package>|<remote-executable> [args]]
<dart-file>
A path to a Dart script (e.g., `bin/main.dart`).
<local-package>
An executable from a local package dependency, in the format <package>[:<executable>].
For example, `test:test` runs the `test` executable from the `test` package.
If the executable is not specified, the package name is used.
<remote-executable>
An executable from a remote package. This can be from a hosted package server
(like pub.dev) or a git repository.
When running a remote executable, all other command-line flags are disabled,
except for the options for remote executables. `dart run <remote-executable>`
uses `dart install` under the hood and compiles the app into a standalone
executable, preventing passing VM options.
From a hosted package server:
<hosted-url>/<package>[@<version>][:<executable>]
Downloads the package from a hosted package server and runs the specified
executable.
If a version is provided, the specified version is downloaded.
If an executable is not specified, the package name is used.
For example, `https://pub.dev/dcli@1.0.0:dcli_complete` runs the
`dcli_complete` executable from version 1.0.0 of the `dcli` package.
From a git repository:
<git-url>[:<executable>]
Clones the git repository and runs the specified executable from it.
If an executable is not specified, the package name from the cloned
repository's pubspec.yaml is used.
The git url can be any valid git url.
```
Notable implementation decisions:
* Does not redownload if the pubspec.lock is identical from the last
remote run. Always does a pub resolve to see if the pubspec.lock
would be identical.
* pub urls must start with `https://`. This makes parsing with local
file paths more tractible.
* git urls may use either urls, or git ssh. (Git SSH is not tested due
to not wanting to run an ssh server locally.)
* Shares as much implementation with `dart install` as possible. The
`dart install` implementation was made public where necessary. The
`dart install` implementation was kept in place to keep the git diff
small.
* Test lives in pkg/dartdev/test/native_assets/ so that its not run
on a shard and xcode and git commands are available.
TEST=pkg/dartdev/test/native_assets/run_remote_test.dart
Closes: https://github.com/dart-lang/sdk/issues/61588
Change-Id: I6a641c670a61da309027d3f82c90f4b59e70933b
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-arm64-try,pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/457640
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
To support internal compilations, dart2wasm must be able to run in
phases. There are a few reasons for this:
1) Kernel transforms are run on the program after the CFE has run. We
must emit a dill that frameworks can transform and then pass the
transformed dill back to dart2wasm.
2) This allows us to avoid forge limits by running each phase of the
compiler in separate blaze actions. TFA has the chance of running long
on large programs and so it might be beneficial to run it as its own
action.
This implementation currently supports 3 phases: "cfe", "tfa", "codegen"
They can be run collectively or in any consecutive combination. Phases
are specified via a '--phases' multi-option. Any data that needs to be
passed between the phases is encoded directly into the serialized dill.
This also opens up the opportunity to make "opt" its own phase that
runs wasm-opt on the wasm emitted from the codegen phase.
Change-Id: Ide830763f7063c7ab880e8e54dc47bd32fd4e7cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455280
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Shows a progress update on the interactive terminal for running hooks.
The progress update visually aligns with progress updates from pub
`Building package executable... (1.3s)` as
`Running build hooks... (0.7s)`.
Closes: https://github.com/dart-lang/native/issues/2439
Progress updates visibility:
* `dart run`, only if there are hooks to avoid cluttering stdout more.
https://github.com/dart-lang/sdk/issues/61696
* `dart test`, also only if there are any hooks.
* `dart build`, always show progress update lines.
* `dart install`, always show progress updates lines.
* `dart compile`, changed the check to check for the existence of hooks
but don't ever run them.
This CL also renames some "native assets" to "build hooks".
This CL also fixes an issue with `dart test` run without `pub get` in
a Flutter project.
Closes: https://github.com/dart-lang/sdk/issues/61697
Change-Id: I88f6e07dff1d4f5c0733f83f073640b75cc54e79
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-arm64-try,pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/453920
Reviewed-by: Michael Goderbauer <goderbauer@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
This CL adds three new commands to `dart`:
```
Global
install Install a Dart CLI tool for global use.
installed List globally installed Dart CLI tools.
uninstall Remove a globally installed Dart CLI tool.
```
These commands are intended to replace `dart pub global` subcommands
while adding support for `hook/build.dart` and building packages in
AOT instead of running them with JIT.
Internal design doc: http://go/dart-install-cli.
Implementation details:
* The source of truth is the state of the file system. These commands
write and read directories, files, and symlinks.
* App bundles and symlinks are placed in `DART_DATA_HOME` as per
http://go/dart-data-home.
* On Unix systems we use symlinks and on Windows batchfiles to place
executables in the bin directory that point to an application
bundle. (These OS differences have been encapsulated in a single
class.)
* On Windows, when an application is running, trying to re-install it
will fail.
Test coverage:
* Installing from hosted, git, and local paths.
* Installing a package with hooks.
* Installing a package with hooks and user-defines.
* Surfacing build hook failures during install.
* Installing packages with conflicting executables names. This tests
`--overwrite` flag behavior.
* Installing a new or the same version, this should simply succeed.
* A warning is shown if the bin directory is not on the `PATH`.
* Running an installed app reports the correct exit code on exit.
* Listing all installed versions, including the versions not on
the`PATH`.
* Uninstalling, which uninstalls all versions.
* Re-installing while it is running.
* Uninstalling while it is running.
Out of scope for initial version:
* Saving the SDK version (to display in `dart installed`).
* Short-circuiting if re-installing an exactly installed version.
Bug: https://github.com/dart-lang/sdk/issues/60889
Change-Id: I8f3a60d26e013957ce6fd7f52e564bcaaff30509
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-arm64-try,pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441581
Reviewed-by: Sigurd Meldgaard <sigurdm@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Michael Goderbauer <goderbauer@google.com>
On X64, executables are not required to be signed, and we only sign the
appended executable if the original dartaotruntime used for appending
was signed.
TEST=pkg/dartdev/test/commands/compile_test
Issue: https://github.com/dart-lang/sdk/issues/55455
Change-Id: Iec8f866423a76b93bb3a3cb9befce009bbdc78ef
Cq-Include-Trybots: luci.dart.try:pkg-mac-release-arm64-try,pkg-mac-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443100
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Now that more of dartdev (e.g., generating kernel) uses dartaotruntime,
modifying the built dartaotruntime with a adhoc non-linker-signed
signature causes this test and other tests following it to fail.
Instead, remove this test and just check that the binary generated
by `dart compile exe` is signed on MacOS.
TEST=pkg/dartdev/test/commands/compile_test
Fixes: https://github.com/dart-lang/sdk/issues/55455
Change-Id: If8f645aeccac617a550db7740343327ca8cd1e4a
Cq-Include-Trybots: luci.dart.try:pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442840
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Auto-Submit: Tess Strickland <sstrickl@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
... and not just any flag starting with "protocol".
I believe the original code used `startsWith()` to try and catch both `--protocol` as its own flag, and `--protocol=` when combined with the value. However, it also caught `--protocol-traffic-log`. `wasParsed()` should handle both of the first cases without the latter.
I also unskipped the tests for Windows because the skip was added in 44cee12ebe (Jan 2021) because the `deleteDirectory()` call failed on Windows (file locking) but f40b06a8ac (Jan 2022) already fixed that.
Fixes https://github.com/dart-lang/sdk/issues/52501
Change-Id: I931a3f12dca2683167e999e7fe59bed18159eb73
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441780
Auto-Submit: Danny Tuppeny <danny@tuppeny.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Since current cross compilation tests are flaky due to being dependent
on the uploaded artifacts, separate them out into a separate file that
can be approved without hiding other failures in the compile test suite
until they can be more properly fixed.
Do some cleanup and refactoring to abstract out the common parts of the
cross compilation failure tests as well.
TEST=pkg/dartdev
Issue: https://github.com/dart-lang/sdk/issues/61181
Change-Id: I1bee602f6d19ebd175bd27f6aded7a1909d1944f
Cq-Include-Trybots: luci.dart.try:pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-arm64-try,pkg-win-release-try,dart-sdk-linux-riscv64-try,dart-sdk-linux-arm64-try,dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-arm64-try,dart-sdk-win-try,dart-sdk-mac-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442060
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Separated out from https://dart-review.googlesource.com/c/sdk/+/440224
because cross compilation requires the binaries to have been uploaded
and so Windows -> Linux ARM would fail.
TEST=pkg/dartdev/test/commands/compile_test.dart
Issue: https://github.com/dart-lang/sdk/issues/28617
Change-Id: I0720bf259dbaf6c834e375c5948e22ab4bfbd38d
Cq-Include-Trybots: luci.dart.try:pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-arm64-try,pkg-win-release-try,dart-sdk-linux-riscv64-try,dart-sdk-linux-arm64-try,dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-arm64-try,dart-sdk-win-try,dart-sdk-mac-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441200
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
- split the Dart CLI tool out of the VM into it's own embedder which
runs in AOT mode. The pure Dart VM executable is called 'dartvm' and
has no Dart CLI functionality in it
- the Dart CLI executable parses the CLI commands and invokes the rest
of the AOT tools in the same process, for the 'run' and 'test'
commands it execs a process which runs 'dartvm' to run
- 'dart hello.dart' execs the 'dartvm' process and runs 'hello.dart'
- the Dart CLI is not generated for ia32 as we are not shipping a
Dart SDK for ia32 anymore (support to execute the 'dartvm' for ia32
architecture is retained)
- the Dart CLI tool is not built in the internal Dart SDK builds
TEST=ci
Some performance improvement numbers
'dart format pkg/dartdev' goes from 1.17 secs to 0.22 secs
'dart doc pkg/dartdev' goes from 100.2 secs to 66.6 secs
'dart fix pkg/dartdev' goes from 19.3 secs to 14.5 secs
Change-Id: I66984a26cb2ab014b34dc1873f1f3d2884e13518
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364202
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
`package:native_assets_cli` has been split up and
`package:native_assets_builder` has been renamed.
Change-Id: Ic9d5c21bb3c7ecf7924fdee6b4281153ad37fac5
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-win-release-arm64-try,pkg-mac-release-try,pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425504
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>