Skip to content

Commit a6c057c

Browse files
authored
[native_assets] Filter hook environment (#161084)
Follow up of flutter/flutter#160672 to filter the environment keys being passed in to build hooks. ~~Failures don't reproduce locally, so this is a draft PR to see which environment keys are needed for the tests to succeed on CI.~~ Edit: Fixed issues by stopping to use the Flutter-self-update-dart-executable and instead using the Dart-sdk-dart-executable. Relevant bug (already addressed in Dart standalone). * dart-lang/native#32 ## 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 `///`). - [ ] 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. <!-- 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
1 parent 2d17299 commit a6c057c

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

packages/flutter_tools/lib/src/isolated/native_assets/native_assets.dart

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,17 +221,28 @@ class FlutterNativeAssetsBuildRunnerImpl implements FlutterNativeAssetsBuildRunn
221221
}
222222
});
223223

224-
late final Uri _dartExecutable = fileSystem.directory(Cache.flutterRoot).uri.resolve('bin/dart');
224+
// Flutter wraps the Dart executable to update it in place
225+
// ($FLUTTER_ROOT/bin/dart). However, since this is a Dart process invocation
226+
// in a Flutter process invocation, it should not try to update in place, so
227+
// use the Dart standalone executable
228+
// ($FLUTTER_ROOT/bin/cache/dart-sdk/bin/dart).
229+
late final Uri _dartExecutable = fileSystem
230+
.directory(Cache.flutterRoot)
231+
.uri
232+
.resolve('bin/cache/dart-sdk/bin/dart');
225233

226234
late final NativeAssetsBuildRunner _buildRunner = NativeAssetsBuildRunner(
227235
logger: _logger,
228236
dartExecutable: _dartExecutable,
229237
fileSystem: fileSystem,
230-
// TODO(dcharkes): Filter the environment with
231-
// NativeAssetsBuildRunner.hookEnvironmentVariablesFilter.
232-
hookEnvironment: const LocalPlatform().environment,
238+
hookEnvironment: filteredEnvironment(NativeAssetsBuildRunner.hookEnvironmentVariablesFilter),
233239
);
234240

241+
static Map<String, String> filteredEnvironment(Set<String> allowList) => <String, String>{
242+
for (final MapEntry<String, String> entry in const LocalPlatform().environment.entries)
243+
if (allowList.contains(entry.key.toUpperCase())) entry.key: entry.value,
244+
};
245+
235246
@override
236247
Future<bool> hasPackageConfig() {
237248
return fileSystem.file(packageConfigPath).exists();

0 commit comments

Comments
 (0)