commit | 5b3b91be62ff5cf7b687f87a4aa3b930eef8c92d | [log] [tgz] |
---|---|---|
author | Tess Strickland <sstrickl@google.com> | Thu Mar 20 03:53:10 2025 -0700 |
committer | dart-internal-monorepo <dart-internal-monorepo@dart-ci-internal.iam.gserviceaccount.com> | Thu Mar 20 03:55:29 2025 -0700 |
tree | 09f0ed8dfc5986cd1343626919fe406b9a4bde51 | |
parent | fb962217f36e32d13a425812ef99fdd8097642a8 [diff] |
[pkg/vm] Add tool for generating DartEngine shims from entry points. This is an initial cut of a tool for automatically creating shims for C/C++ programs using the entry point annotations in Dart code. The tool has two required arguments: * the .dill file containing the kernel representation of the Dart code * the base path of the header and implementation files to create With a base path of 'dir/name', the header file is created as 'dir/name.h' and the implementation file is created as 'dir/name.cc'. In addition, 'dir/name.h' is used as a basis for creating a #ifndef/#define/#endif header guard around the header contents. The created shims are specific to a single package, either * a user-specified package, provided via '-p'/'--package', or * the package of the main method If the user does not specify a package and there is no main method in the .dill file, the tool fails. Each shim takes the following arguments in order when applicable: * the isolate in which to perform the requested operation, * the instantiated type of the generic class (for invoking, setting, or getting constructors, static methods, and static fields) * the instance (for invoking, getting, or setting instance methods and fields) * the type arguments (for retrieving nullable or non-nullable instantiated types of a generic class) * the arguments (for invoking, setting, or getting constructors, methods, and fields) The generated shims: * cache the package library, types for non-generic classes, and types for generic classes instantiated with default type arguments. The cached persistent handles are cleared if any of the methods are called with a different isolate from the one used to populate the cache. * automatically handle conversions between C int64_t <=> Dart int and C double <=> Dart double. By default, shims are not created for allocation or initializing uninitialized instances. To create such shims, use the '-u' command line argument. Currently, shims are not created for methods that take optional or named arguments. To report an error if a shim cannot be created for any entry points, use the '-e' command line argument. TEST=tests/standalone/embedder_samples_test Change-Id: Ibdf3b52d900ba98038528178485f295c5868ac9d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/410500 Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com> https://dart.googlesource.com/sdk/+/acd16c6aa7d5614fa113f0b8698c003517e6ea9d
Monorepo is:
With depot_tools installed and on your path, create a directory for your monorepo checkout and run these commands to create a gclient solution in that directory:
mkdir monorepo cd monorepo gclient config --unmanaged https://dart.googlesource.com/monorepo gclient sync -D
This gives you a checkout in the monorepo directory that contains:
monorepo/ DEPS - the DEPS used for this gclient checkout commits.json - the pinned commits for Dart, flutter/engine, and flutter/flutter tools/ - scripts used to create monorepo DEPS engine/src/ - the flutter/buildroot repo flutter/ - the flutter/engine repo out/ - the build directory, where Flutter engine builds are created third_party/ - Flutter dependencies checked out by DEPS dart/ - the Dart SDK checkout. third_party - Dart dependencies, also used by Flutter flutter/ - the flutter/flutter repo
Flutter's instructions for building the engine are at Compiling the engine
They can be followed closely, with a few changes:
goma_ctl ensure_start
is sufficient.Example build commands that work on linux:
MONOREPO_PATH=$PWD if [[ ! $PATH =~ (^|:)$MONOREPO_PATH/flutter/bin(:|$) ]]; then PATH=$MONOREPO_PATH/flutter/bin:$PATH fi export GOMA_DIR=$(dirname $(command -v gclient))/.cipd_bin goma_ctl ensure_start pushd engine/src flutter/tools/gn --goma --no-prebuilt-dart-sdk --unoptimized --full-dart-sdk autoninja -C out/host_debug_unopt popd
The Flutter commands used to build and run apps will use the locally built Flutter engine and Dart SDK, instead of the one downloaded by the Flutter tool, if the --local-engine
option is provided.
For example, to build and run the Flutter spinning square sample on the web platform,
MONOREPO_PATH=$PWD cd flutter/examples/layers flutter --local-engine=host_debug_unopt \ -d chrome run widgets/spinning_square.dart cd $MONOREPO_PATH
To build for desktop, specify the desktop platform device in flutter run
as -d macos
or -d linux
or -d windows
. You may also need to run the command
flutter create --platforms=windows,macos,linux
on existing apps, such as sample apps. New apps created with flutter create
already include these support files. Details of desktop support are at Desktop Support for Flutter
Tests in the Flutter source tree can be run with the flutter test
command, run in the directory of a package containing tests. For example:
MONOREPO_PATH=$PWD cd flutter/packages/flutter flutter test --local-engine=host_debug_unopt cd $MONOREPO_PATH
Please file an issue or email the dart-engprod team with any problems with or questions about using monorepo.
We will update this documentation to address them.
flutter
commands may download the engine and Dart SDK files for the configured channel, even though they will be using the local engine and its SDK.gclient sync
needs to be run in an administrator session, because some installed dependencies create symlinks.