Adds a simple heuristic to filter out the info and error messages that
`emulator -list-avds` can output sometimes. The heuristic assumes that
emulator names can only contain `a-z0-9_.-` in their names.
Fixes https://github.com/flutter/flutter/issues/146125
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
engine/src/flutter/examples contains sample code for the engine embedder
library. The examples include scripts that create and build Flutter
projects that are run through the embedder.
## Summary
`flutter build web --web-define=KEY=VALUE` silently ignored the
`--web-define` flag. The option was registered via
`usesWebDefineOption()` but the values were never extracted or passed
through the build pipeline. `flutter run` was unaffected as it correctly
calls `extractWebDefines()`.
This PR threads web-define values through the full `flutter build web`
chain:
- **`build_web.dart`**: Call `extractWebDefines()` and pass the result
to `buildWeb()`.
- **`compile.dart`**: Add `kWebDefinePrefix` constant and `webDefines`
parameter to `buildWeb()`, storing prefixed entries in
`Environment.defines`.
- **`web.dart`**: In `WebTemplatedFiles.build()`, extract web-define
entries from the environment and pass them to both `withSubstitutions()`
calls (bootstrap + index.html).
Related to #175805.
Fixes#182076
## Test plan
- Added 2 tests in `build_web_test.dart`:
- Verifies `--web-define` values are passed to `Environment.defines`
with `webDefine:` prefix.
- Verifies builds succeed without `--web-define` and no prefixed entries
are present.
- Added 3 tests in `web_test.dart`:
- `WebTemplatedFiles` substitutes web-define variables in `index.html`.
- `WebTemplatedFiles` substitutes web-define variables in
`flutter_bootstrap.js`.
- `WebTemplatedFiles` works correctly with no web-define variables.
- All existing tests in `build_web_test.dart` (24/24), `web_test.dart`
(619/619), and `web_template_test.dart` (16/16) pass.
---------
Co-authored-by: Mouad Debbar <mdebbar@google.com>
This PR fixes two issues. Accidental reuse of code assets between build
modes and SDKs (https://github.com/flutter/flutter/issues/181724), and
the bundling in ios-frameworks
(https://github.com/flutter/flutter/issues/181382).
To fix the accidental caching, the `Target`s related to build hooks and
code assets now output their files to `environment.outputDir` instead of
`$projectDir/$buildDir/native_assets`.
* `xcode_backend` is updated to deal with this.
* `Flutter.kt` has been updated to deal with this.
* Because the `Target`s are responsible for caching, the code has been
refactored to provide the target directories from there. The
"global-ish" function `nativeAssetsBuildUri` that was calculating the
directory before has been removed.
* `runFlutterSpecificHooks` has nothing to do with that directory, it's
access to it has been removed.
* To avoid another cmakefile migration, the Linux and Windows
implementation use the same directory. (Note that output dir and build
dir overlap for Linux and Windows, while they do not for MacOS, iOS, and
Android.)
* This also means that we don't have to read `NativeAssetsManifest.json`
in `xcode_backend` anymore. Instead the `Target` clears the output
directory, so we should not have any stale frameworks.
* Refactored `installCodeAssets` and its platform-specific
implementations to return a list of all produced files. These are now
added to the `Target`'s depfile. This fixes an issue where the build
system would skip re-installing native assets after an Xcode "Clean
Build Folder because it wasn't tracking the frameworks/dylibs as
outputs.
Closes: https://github.com/flutter/flutter/issues/181724
Other `Target`s related tweaks:
* Added proper
`Source.pattern('{BUILD_DIR}/${DartBuild.dartHookResultFilename}'),` for
all `Target`s that depend on that file. These were missing. (The build
system uses `dependencies` for ordering of `Target`s, but relies on
`inputs` and `outputs` for caching.)
* Removed code assets from `CopyAssets`. That target is supposed to make
an asset-bundle that is OS-independent if I understand correctly.
This PR changes the way code assets are bundled in `flutter build
ios-framework`.
* This PR now packages in an `.xcframework`, which is necessary to be
able to package both device and simulator.
* Run through the frameworks of both device and simulator and give
errors on inconsistencies.
Closes: https://github.com/flutter/flutter/issues/181382
Other iOS related tweaks:
* Use `xcrun` for invoking all the commands. (This is used for producing
the app framework, but was not for code assets frameworks.)
* Make sure all commands are added to the traces when running verbose.
(Also to bring it in line for with the other `xcrun` commands.)
Testing:
* The integration test is updated to inspect the `xcframework`s.
* Added a test that simulates Xcode "Product > Clean Build Folder...",
to check that it now correctly triggers a rebuild.
* We do _not_ have an integration test that _runs_ the frameworks output
from `flutter build ios-framework` inside a host app at all as far as
I'm aware.
* dev/devicelab/bin/tasks/build_ios_framework_module_test.dart builds a
framework, but doesn't run it in a host app
* dev/integration_tests/ios_add2app_life_cycle/build_and_test.sh runs,
but does so via `flutter build ios` not as a framework.
* Does not add an integration test for caching behavior between
switching build modes. However, the proper functioning of `flutter build
ios-framework` depends on the `Target`s for different not using
overlapping directories.
Architectural approaches tried but didn't work:
* Subclass `InstallCodeAssets` per OS to be more precise in the
`output`s on what files are output. This doesn't work because other
OS-independent targets on the `InstallCodeAssets` target.
This PR is a reland of https://github.com/flutter/flutter/pull/181685.
The update introduced NBSP to connect time and its period(am or pm), so
some invisible breakages are expected.
Fix is added in the second
[commit](06be40e4bd).
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
Remove use of the `setStartAsyncSynchronously` flag in the DDC
bootstrap. This is long overdue and unblocks removing the unused flag
from the DDC runtime.
Includes:
- Display running apps in a formatted table with age calculation
- Implement mDNS discovery for running apps (multiple
devices/interfaces)
- Deduplicate apps by WebSocket URI
- Centralize mDNS device advertisement in MDNSDeviceDiscovery
- Ensure ResidentRunner advertises correct app name and cleans up
- Add network utility functions and JSON support for running-apps
- Add comprehensive tests for discovery and list command
Lastly, this change uses mDNS to discover running Flutter apps, the
multicast_dns package is used instead of mdns_dart as the discovery
functionality is insufficient in the mdns_dart package, only discovering
a maximum of one service.
Instead of generating assembly code that is then compiled to a Mach-O
dynamic library, use the new app-aot-macho-dylib output option for
gen_snapshot to generate the Mach-O dynamic library without the assembly
step.
This is a reland of https://github.com/flutter/flutter/pull/174870. No
changes from the previously landed PR are needed, as the fixes for the
App Store issue described in
https://github.com/flutter/flutter/issues/178602 are all on the Dart
side: https://github.com/dart-lang/sdk/commit/8cbf864.
Related issues:
* https://github.com/dart-lang/sdk/issues/43299
* https://github.com/dart-lang/sdk/issues/60307
* https://github.com/flutter/flutter/issues/178602
* https://github.com/dart-lang/sdk/issues/62414
## Pre-launch Checklist
- [X] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [X] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [X] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [X] I signed the [CLA].
- [X] I listed at least one issue that this PR fixes in the description
above.
- [X] I updated/added relevant documentation (doc comments with `///`).
- [X] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [X] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [X] All existing and new tests are passing.
Warn when the flag is passed, and prompt to file an issue if disabling
is required for a web development workflow.
The flag is enabled by default. It is still functional, but will be
removed in an upcoming release.
For what the test tests, we only need to build one mode. `flutter build
aar` defaults to building all 3.
Co-authored-by: Gray Mackall <mackall@google.com>
This can cause a confusing error message when tests are run with `dart
test`, which results in `platform.script` returning a dill file. In
particular, tests run using `testWithoutContext` or without a `Platform`
override that invoke `getFlutterRoot()` will encounter an error about
`context.get<Platform>` not being supported.
Fixes https://github.com/flutter/flutter/issues/181856
`dev/devicelab/bin/task/flutter_test_performance.dart` regressed due to
the CFE not being initialized with the correct dill file for the target
test. This change updates `TestCompiler` to pass the correct dill file
when creating the `ResidentCompiler` and adds a test to verify that the
`ResidentCompiler` is initialized with the correct dill.
Moves the initialization logic for web and non-web compilers into the
`ResidentCompiler` factory and reduces code duplication.
Also bumps the flutter_tools Dart SDK version to ^3.10.0 to enable dot
shorthands.
---------
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This PR splits the debug info from code assets into separate dsym files
for MacOS and iOS.
The splitting only happens if the build mode is not debug. This aligns
with whether the debug symbols are separated out for the Flutter
framework and the app Framework.
Closes: https://github.com/flutter/flutter/issues/181377
Testing: Added some tests to the integration test
Add deprecation marker to `flutter create --template=plugin_ffi`.
The new way of bundling native code is `flutter create
--template=package_ffi`. (Or if the Flutter Plugin API or Android Play
components need to be bundled: `flutter create --template=plugin)`
Issue:
* https://github.com/flutter/flutter/issues/131209
Since https://github.com/flutter/flutter/pull/174685, the code assets
are wrongly invoked on in the `flutter run` process (in addition to
rightly in the `flutter assemble` process). This should not be the case:
We don't know the target architectures we want to build for, neither do
we know which native compiler is set by the native build system that is
invoking us
(https://github.com/flutter/flutter/pull/181004#pullrequestreview-3664863551).
This PR changes the way the hooks are invoked:
* From `flutter run` only run for data assets. (Unblocks
https://github.com/flutter/flutter/pull/181004)
* All other remaining calls, run for both. There might be locations
where data assets could be disabled, but they are needed from the
`DartBuild` target at least in some cases.
The architecture becomes as follows:
* `FlutterNativeAssetsBuildRunner` this is basically the wrapper around
the `NativeAssetsBuildRunner` and there should be only one in a
`flutter_tools` instance, unchanged.
* `FlutterHookRunner` seems to be an interface to be able to supply
fakes, unchanged.
* `runFlutterSpecificHooks` get bool arguments whether they should build
code assets and data assets.
* The callers of these APIs know what asset types are needed in that
context. The invocations added in
https://github.com/flutter/flutter/pull/174685 should be data assets
only.
* Simplification: `FlutterHookRunnerNative.runHooks` does no longer use
`globals.buildSystem.build`. Instead, it directly calls
`runFlutterSpecificHooks`.
* This completely avoids writing to the flutter build directory, which
was the cause of https://github.com/flutter/flutter/issues/178529.
* The `ProtocolExtension`s (which determine which asset types are built)
are taken from `AssetBuildTarget`s, and take into account what asset
types to build, unchanged.
Tests:
* Code assets covered by existing integration tests such as
packages/flutter_tools/test/integration.shard/isolated/native_assets_test.dart
* Data assets covered by existing integration tests such as
packages/flutter_tools/test/integration.shard/isolated/dart_data_asset_test.dart
* This PR completely deletes
packages/flutter_tools/test/general.shard/build_system/targets/hook_runner_native_test.dart.
It was a unit test that testsed the specific workaround, not the effect
of the workaround.
* I've manually tested the steps in
https://github.com/flutter/flutter/issues/178529#issuecomment-3542651915,
the issue does not come back.
> the underlying issue did involve conflict between state written by the
original run of the build system versus state written by the secondary
run executed for the data assets. If the secondary run can be avoided,
then that seems cleaner.
Yep, removed.
Relands https://github.com/flutter/flutter/pull/162464
Fixes https://github.com/flutter/flutter/issues/170664
The only test that failed last time was `Linux_pixel_7pro
android_obfuscate_test`, and I ran it locally (`flutter test
test/integration.shard/android_obfuscate_test.dart `) to both repro the
failure and verify it passes on this branch with the additional changes.
Also does some stuff in the FGP:
The reason we failed the tests last time was we were bundling of the
libapp.so code into a jar in the aar case, instead of simply including
it as its own file in the source sets. I let gemini go on that part,
modifying it to no longer pack as a jar, but it looks correct to me. Now
that the `libapp.so` file is simply included in this case, AGP is able
to strip it (it's not hidden inside a jar).
Because this changes the FGP build process for add to app, I manually
verified that the add to app flow isn't broken for including a flutter
module both as source and as an aar.
<details>
<summary>Before and after logs from the gradle task output</summary>
Before:
```
> Task :flutter:stripReleaseDebugSymbols NO-SOURCE
Skipping task ':flutter:stripReleaseDebugSymbols' as it has no source files and no previous output files.
```
After:
```
Task ':flutter:stripReleaseDebugSymbols' is not up-to-date because:
No history is available.
The input changes require a full rebuild for incremental task ':flutter:stripReleaseDebugSymbols'.
C/C++: android.ndkVersion from module build.gradle is [28.2.13676358]
C/C++: android.ndkVersion from module build.gradle is [28.2.13676358]
C/C++: android.ndkPath from module build.gradle is not set
C/C++: android.ndkPath from module build.gradle is not set
C/C++: ndk.dir in local.properties is not set
C/C++: ndk.dir in local.properties is not set
C/C++: Not considering ANDROID_NDK_HOME because support was removed after deprecation period.
C/C++: Not considering ANDROID_NDK_HOME because support was removed after deprecation period.
C/C++: android.ndkVersion from module build.gradle is [28.2.13676358]
C/C++: android.ndkPath from module build.gradle is not set
C/C++: sdkFolder is /Users/mackall/Library/Android/sdk
C/C++: ndk.dir in local.properties is not set
C/C++: Not considering ANDROID_NDK_HOME because support was removed after deprecation period.
C/C++: sdkFolder is /Users/mackall/Library/Android/sdk
C/C++: sdkFolder is /Users/mackall/Library/Android/sdk
Starting process 'command '/Users/mackall/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip''. Working directory:
/Users/mackall/development/BugTesting/mblahm/.android/Flutter Command: /Users/mackall/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip
--strip-unneeded -o
/Users/mackall/development/BugTesting/mblahm/.android/Flutter/build/intermediates/stripped_native_libs/release/stripReleaseDebugSymbols/out/lib/armeabi-v7a/libapp.so
/Users/mackall/development/BugTesting/mblahm/.android/Flutter/build/intermediates/merged_native_libs/release/mergeReleaseNativeLibs/out/lib/armeabi-v7a/libapp.so
Starting process 'command '/Users/mackall/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip''. Working directory:
/Users/mackall/development/BugTesting/mblahm/.android/Flutter Command: /Users/mackall/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip
--strip-unneeded -o
/Users/mackall/development/BugTesting/mblahm/.android/Flutter/build/intermediates/stripped_native_libs/release/stripReleaseDebugSymbols/out/lib/x86_64/libapp.so
/Users/mackall/development/BugTesting/mblahm/.android/Flutter/build/intermediates/merged_native_libs/release/mergeReleaseNativeLibs/out/lib/x86_64/libapp.so
Starting process 'command '/Users/mackall/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip''. Working directory:
/Users/mackall/development/BugTesting/mblahm/.android/Flutter Command: /Users/mackall/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip
--strip-unneeded -o
/Users/mackall/development/BugTesting/mblahm/.android/Flutter/build/intermediates/stripped_native_libs/release/stripReleaseDebugSymbols/out/lib/arm64-v8a/libapp.so
/Users/mackall/development/BugTesting/mblahm/.android/Flutter/build/intermediates/merged_native_libs/release/mergeReleaseNativeLibs/out/lib/arm64-v8a/libapp.so
Successfully started process 'command '/Users/mackall/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip''
Successfully started process 'command '/Users/mackall/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip''
Successfully started process 'command '/Users/mackall/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip''
```
</details>
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
If you need help, consider asking for advice on the #hackers-new channel
on [Discord].
**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.
<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
---------
Co-authored-by: Gray Mackall <mackall@google.com>
Since the `widget_preview_scaffold` project depends on both the Flutter
SDK and `flutter_tools`, `flutter_tools` must use the same version pins
as the Flutter SDK. This change ensures that any packages used by both
the Flutter SDK and `flutter_tools` use the same pinned version.
Fixes https://github.com/flutter/flutter/issues/180503