@@ -80,7 +80,7 @@ class NativeAssetsBuildRunner {
80
80
singleHookTimeout = singleHookTimeout ?? const Duration (minutes: 5 ),
81
81
hookEnvironment =
82
82
hookEnvironment ??
83
- filteredEnvironment (hookEnvironmentVariablesFilter ) {
83
+ filteredEnvironment (includeHookEnvironmentVariable ) {
84
84
_fileSystem = TracingFileSystem (fileSystem, _task);
85
85
}
86
86
@@ -538,23 +538,31 @@ class NativeAssetsBuildRunner {
538
538
),
539
539
);
540
540
541
- /// The list of environment variables used if [hookEnvironment] is not passed
542
- /// in.
543
- /// This allowlist lists environment variables needed to run mainstream
544
- /// compilers.
545
- static const hookEnvironmentVariablesFilter = {
546
- 'ANDROID_HOME' , // Needed for the NDK.
547
- 'HOME' , // Needed to find tools in default install locations.
548
- 'PATH' , // Needed to invoke native tools.
549
- 'PROGRAMDATA' , // Needed for vswhere.exe.
550
- 'SYSTEMDRIVE' , // Needed for CMake.
551
- 'SYSTEMROOT' , // Needed for process invocations on Windows.
552
- 'TEMP' , // Needed for temp dirs in Dart process.
553
- 'TMP' , // Needed for temp dirs in Dart process.
554
- 'TMPDIR' , // Needed for temp dirs in Dart process.
555
- 'USERPROFILE' , // Needed to find tools in default install locations.
556
- 'WINDIR' , // Needed for CMake.
557
- };
541
+ /// Determines whether to allow an environment variable through
542
+ /// if [hookEnvironment] is not passed in.
543
+ ///
544
+ /// This allows environment variables needed to run mainstream compilers.
545
+ static bool includeHookEnvironmentVariable (String environmentVariableName) {
546
+ const staticVariablesFilter = {
547
+ 'ANDROID_HOME' , // Needed for the NDK.
548
+ 'HOME' , // Needed to find tools in default install locations.
549
+ 'PATH' , // Needed to invoke native tools.
550
+ 'PROGRAMDATA' , // Needed for vswhere.exe.
551
+ 'SYSTEMDRIVE' , // Needed for CMake.
552
+ 'SYSTEMROOT' , // Needed for process invocations on Windows.
553
+ 'TEMP' , // Needed for temp dirs in Dart process.
554
+ 'TMP' , // Needed for temp dirs in Dart process.
555
+ 'TMPDIR' , // Needed for temp dirs in Dart process.
556
+ 'USERPROFILE' , // Needed to find tools in default install locations.
557
+ 'WINDIR' , // Needed for CMake.
558
+ };
559
+ const variablePrefixesFilter = {
560
+ 'NIX_' , // Needed for Nix-installed toolchains.
561
+ };
562
+
563
+ return staticVariablesFilter.contains (environmentVariableName) ||
564
+ variablePrefixesFilter.any (environmentVariableName.startsWith);
565
+ }
558
566
559
567
Future <Result <HookOutput , HooksRunnerFailure >> _runHookForPackage (
560
568
Hook hook,
@@ -1198,7 +1206,7 @@ Future<List<Uri>> _readDepFile(File depFile) async {
1198
1206
}
1199
1207
1200
1208
@internal
1201
- Map <String , String > filteredEnvironment (Set < String > allowList ) => {
1209
+ Map <String , String > filteredEnvironment (bool Function ( String ) include ) => {
1202
1210
for (final entry in Platform .environment.entries)
1203
- if (allowList. contains (entry.key.toUpperCase ())) entry.key: entry.value,
1211
+ if (include (entry.key.toUpperCase ())) entry.key: entry.value,
1204
1212
};
0 commit comments