flutter344: init at 3.44.2

This commit is contained in:
ccicnce113424
2026-06-14 23:23:14 +08:00
parent 8fac8b782a
commit 4fd0f759fb
9 changed files with 1466 additions and 1 deletions
@@ -201,7 +201,9 @@ let
};
meta = {
broken = (lib.versionOlder version "3.32") && useNixpkgsEngine;
# TODO: investigate why nixpkgs engine fails for versions >= 3.34
broken =
((lib.versionOlder version "3.32") || lib.versionAtLeast version "3.34") && useNixpkgsEngine;
description = "Makes it easy and fast to build beautiful apps for mobile and beyond";
longDescription = ''
Flutter is Google's SDK for crafting beautiful,
@@ -14,6 +14,9 @@ let
flutter.sdk
];
strictDeps = true;
__structuredAttrs = true;
nativeBuildInputs = [ makeWrapper ];
postBuild = ''
wrapProgram "$out/bin/flutter" \
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,21 @@
diff --git a/packages/flutter_tools/lib/src/flutter_cache.dart b/packages/flutter_tools/lib/src/flutter_cache.dart
index df67547..eacc7c4 100644
--- a/packages/flutter_tools/lib/src/flutter_cache.dart
+++ b/packages/flutter_tools/lib/src/flutter_cache.dart
@@ -51,16 +51,6 @@ class FlutterCache extends Cache {
registerArtifact(IosUsbArtifacts(artifactName, this, platform: platform));
}
registerArtifact(FontSubsetArtifacts(this, platform: platform));
- registerArtifact(
- PubDependencies(
- logger: logger,
- // flutter root and pub must be lazily initialized to avoid accessing
- // before the version is determined.
- flutterRoot: () => Cache.flutterRoot!,
- pub: () => pub,
- projectFactory: projectFactory,
- ),
- );
}
}
@@ -0,0 +1,29 @@
diff --git a/packages/flutter_tools/lib/src/runner/flutter_command.dart b/packages/flutter_tools/lib/src/runner/flutter_command.dart
index e4e474ab6e..5548599802 100644
--- a/packages/flutter_tools/lib/src/runner/flutter_command.dart
+++ b/packages/flutter_tools/lib/src/runner/flutter_command.dart
@@ -1693,7 +1693,7 @@ Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and
// Populate the cache. We call this before pub get below so that the
// sky_engine package is available in the flutter cache for pub to find.
- if (shouldUpdateCache) {
+ if (false) {
// First always update universal artifacts, as some of these (e.g.
// ios-deploy on macOS) are required to determine `requiredArtifacts`.
final bool offline;
diff --git a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
index a1104da..1749d65 100644
--- a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
+++ b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
@@ -437,11 +437,6 @@
// Required to support `flutter --version` before artifacts are cached.
await globals.cache.updateAll(<DevelopmentArtifact>{DevelopmentArtifact.informative});
- globals.flutterVersion.ensureVersionFile();
- if (await _shouldCheckForUpdates(topLevelResults)) {
- await globals.flutterVersion.checkFlutterVersionFreshness();
- }
-
// See if the user specified a specific device.
final specifiedDeviceId = topLevelResults[FlutterGlobalOptions.kDeviceIdOption] as String?;
if (specifiedDeviceId != null) {
@@ -0,0 +1,39 @@
Fix iOS build issue with NixOS/nixpkgs flutter
This patch cleans up xcode_backend.sh to use the FLUTTER_ROOT
environment variable directly, avoiding symlink traversal issues.
--- a/packages/flutter_tools/bin/xcode_backend.sh
+++ b/packages/flutter_tools/bin/xcode_backend.sh
@@ -10,27 +10,8 @@
#
# -------------------------------------------------------------------------- #
-# exit on error, or usage of unset var
-set -euo pipefail
+# Run `dart ./xcode_backend.dart` with the dart from $FLUTTER_ROOT.
+dart="${FLUTTER_ROOT}/bin/dart"
+xcode_backend_dart="${BASH_SOURCE[0]%.sh}.dart"
+exec "${dart}" "${xcode_backend_dart}" "$@" "ios"
-# Needed because if it is set, cd may print the path it changed to.
-unset CDPATH
-
-function follow_links() (
- cd -P -- "$(dirname -- "$1")"
- file="$PWD/$(basename -- "$1")"
- while [[ -h "$file" ]]; do
- cd -P -- "$(dirname -- "$file")"
- file="$(readlink -- "$file")"
- cd -P -- "$(dirname -- "$file")"
- file="$PWD/$(basename -- "$file")"
- done
- echo "$file"
-)
-
-PROG_NAME="$(follow_links "${BASH_SOURCE[0]}")"
-BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
-FLUTTER_ROOT="$BIN_DIR/../../.."
-DART="$FLUTTER_ROOT/bin/dart"
-
-"$DART" "$BIN_DIR/xcode_backend.dart" "$@" "ios"
@@ -0,0 +1,48 @@
Fix for macOS build issue in Flutter >= 3.35
Since version 3.35, the behavior of macos_assemble.sh and xcode_backend.sh
is almost identical. This caused the same error for macOS that previously
occurred for iOS.
Derived from the iOS patch: ./fix-ios-build-xcode-backend-sh.patch
--- a/packages/flutter_tools/bin/macos_assemble.sh
+++ b/packages/flutter_tools/bin/macos_assemble.sh
@@ -10,32 +10,13 @@
#
# -------------------------------------------------------------------------- #
-# exit on error, or usage of unset var
-set -euo pipefail
-
-# Needed because if it is set, cd may print the path it changed to.
-unset CDPATH
-
-function follow_links() (
- cd -P -- "$(dirname -- "$1")"
- file="$PWD/$(basename -- "$1")"
- while [[ -h "$file" ]]; do
- cd -P -- "$(dirname -- "$file")"
- file="$(readlink -- "$file")"
- cd -P -- "$(dirname -- "$file")"
- file="$PWD/$(basename -- "$file")"
- done
- echo "$file"
-)
-
-PROG_NAME="$(follow_links "${BASH_SOURCE[0]}")"
-BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
-FLUTTER_ROOT="$BIN_DIR/../../.."
-DART="$FLUTTER_ROOT/bin/dart"
+# Run `dart ./xcode_backend.dart` with the dart from $FLUTTER_ROOT.
+dart="${FLUTTER_ROOT}/bin/dart"
+xcode_backend_dart="$(dirname "${BASH_SOURCE[0]}")/xcode_backend.dart"
# Main entry point.
if [[ $# == 0 ]]; then
- "$DART" "$BIN_DIR/xcode_backend.dart" "build" "macos"
+ exec "${dart}" "${xcode_backend_dart}" "build" "macos"
else
- "$DART" "$BIN_DIR/xcode_backend.dart" "$@" "macos"
+ exec "${dart}" "${xcode_backend_dart}" "$@" "macos"
fi
@@ -0,0 +1,220 @@
This patch introduces an intermediate Gradle build step to alter the behavior
of flutter_tools' Gradle project, specifically moving the creation of `build`
and `.gradle` directories from within the Nix Store to somewhere in `$HOME/.cache/flutter/nix-flutter-tools-gradle/$engineShortRev`.
Without this patch, flutter_tools' Gradle project tries to generate `build` and `.gradle`
directories within the Nix Store. Resulting in read-only errors when trying to build a
Flutter Android app at runtime.
This patch takes advantage of the fact settings.gradle takes priority over settings.gradle.kts to build the intermediate Gradle project
when a Flutter app runs `includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")`
`rootProject.buildFileName = "/dev/null"` so that the intermediate project doesn't use `build.gradle.kts` that's in the same directory.
The intermediate project makes a `settings.gradle` file in `$HOME/.cache/flutter/nix-flutter-tools-gradle/<short engine rev>/` and `includeBuild`s it.
This Gradle project will build the actual `packages/flutter_tools/gradle` project by setting
`rootProject.projectDir = new File("$settingsDir")` and `apply from: new File("$settingsDir/settings.gradle.kts")`.
To move `build` to `$HOME/.cache/flutter/nix-flutter-tools-gradle/<short engine rev>/`, we need to set `buildDirectory`.
To move `.gradle` as well, the `--project-cache-dir` argument must be passed to the Gradle wrapper.
Changing the `GradleUtils.getExecutable` function signature is a delibarate choice, to ensure that no new unpatched usages slip in.
--- /dev/null
+++ b/packages/flutter_tools/gradle/settings.gradle
@@ -0,0 +1,19 @@
+rootProject.buildFileName = "/dev/null"
+
+def engineShortRev = (new File("$settingsDir/../../../bin/internal/engine.version")).text.take(10)
+def dir = new File("$System.env.HOME/.cache/flutter/nix-flutter-tools-gradle/$engineShortRev")
+dir.mkdirs()
+def file = new File(dir, "settings.gradle")
+
+file.text = """
+rootProject.projectDir = new File("$settingsDir")
+apply from: new File("$settingsDir/settings.gradle.kts")
+
+gradle.allprojects { project ->
+ project.beforeEvaluate {
+ project.layout.buildDirectory = new File("$dir/build")
+ }
+}
+"""
+
+includeBuild(dir)
--- a/packages/flutter_tools/gradle/build.gradle.kts
+++ b/packages/flutter_tools/gradle/build.gradle.kts
@@ -4,6 +4,11 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
+// While flutter_tools runs Gradle with a --project-cache-dir, this startParameter
+// is not passed correctly to the Kotlin Gradle plugin for some reason, and so
+// must be set here as well.
+gradle.startParameter.projectCacheDir = layout.buildDirectory.dir("cache").get().asFile
+
plugins {
`java-gradle-plugin`
groovy
--- a/packages/flutter_tools/lib/src/android/gradle.dart
+++ b/packages/flutter_tools/lib/src/android/gradle.dart
@@ -474,9 +474,9 @@ class AndroidGradleBuilder implements AndroidBuilder {
// from the local.properties file.
updateLocalProperties(project: project, buildInfo: androidBuildInfo.buildInfo);
- final options = <String>[];
-
- final String gradleExecutablePath = _gradleUtils.getExecutable(project);
+ final [String gradleExecutablePath, ...List<String> options] = _gradleUtils.getExecutable(
+ project,
+ );
// All automatically created files should exist.
if (configOnly) {
@@ -797,7 +797,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
'aar_init_script.gradle',
);
final command = <String>[
- _gradleUtils.getExecutable(project),
+ ..._gradleUtils.getExecutable(project),
'-I=$initScript',
'-Pflutter-root=$flutterRoot',
'-Poutput-dir=${outputDirectory.path}',
@@ -912,6 +912,10 @@ class AndroidGradleBuilder implements AndroidBuilder {
final results = <String>[];
try {
+ final [String gradleExecutablePath, ...List<String> options] = _gradleUtils.getExecutable(
+ project,
+ );
+
exitCode = await _runGradleTask(
_kBuildVariantTaskName,
preRunTask: () {
@@ -927,10 +931,10 @@ class AndroidGradleBuilder implements AndroidBuilder {
),
);
},
- options: const <String>['-q'],
+ options: <String>[...options, '-q'],
project: project,
localGradleErrors: gradleErrors,
- gradleExecutablePath: _gradleUtils.getExecutable(project),
+ gradleExecutablePath: gradleExecutablePath,
outputParser: (String line) {
if (_kBuildVariantRegex.firstMatch(line) case final RegExpMatch match) {
results.add(match.namedGroup(_kBuildVariantRegexGroupName)!);
@@ -964,6 +968,10 @@ class AndroidGradleBuilder implements AndroidBuilder {
late Stopwatch sw;
var exitCode = 1;
try {
+ final [String gradleExecutablePath, ...List<String> options] = _gradleUtils.getExecutable(
+ project,
+ );
+
exitCode = await _runGradleTask(
taskName,
preRunTask: () {
@@ -979,10 +987,10 @@ class AndroidGradleBuilder implements AndroidBuilder {
),
);
},
- options: <String>['-q', '-PoutputPath=$outputPath'],
+ options: <String>[...options, '-q', '-PoutputPath=$outputPath'],
project: project,
localGradleErrors: gradleErrors,
- gradleExecutablePath: _gradleUtils.getExecutable(project),
+ gradleExecutablePath: gradleExecutablePath,
);
} on Error catch (error) {
_logger.printError(error.toString());
--- a/packages/flutter_tools/lib/src/android/gradle_errors.dart
+++ b/packages/flutter_tools/lib/src/android/gradle_errors.dart
@@ -228,7 +228,12 @@ final flavorUndefinedHandler = GradleHandledError(
},
handler: ({required String line, required FlutterProject project, required bool usesAndroidX}) async {
final RunResult tasksRunResult = await globals.processUtils.run(
- <String>[globals.gradleUtils!.getExecutable(project), 'app:tasks', '--all', '--console=auto'],
+ <String>[
+ ...globals.gradleUtils!.getExecutable(project),
+ 'app:tasks',
+ '--all',
+ '--console=auto',
+ ],
throwOnError: true,
workingDirectory: project.android.hostAppGradleRoot.path,
environment: globals.java?.environment,
--- a/packages/flutter_tools/lib/src/android/gradle_utils.dart
+++ b/packages/flutter_tools/lib/src/android/gradle_utils.dart
@@ -3,6 +3,7 @@
// found in the LICENSE file.
import 'package:meta/meta.dart';
+import 'package:path/path.dart';
import 'package:process/process.dart';
import 'package:unified_analytics/unified_analytics.dart';
@@ -197,9 +198,29 @@ class GradleUtils {
final Logger _logger;
final OperatingSystemUtils _operatingSystemUtils;
+ List<String> get _requiredArguments {
+ final String cacheDir = join(
+ switch (globals.platform.environment['XDG_CACHE_HOME']) {
+ final String cacheHome => cacheHome,
+ _ => join(
+ globals.fsUtils.homeDirPath ?? throwToolExit('No cache directory has been specified.'),
+ '.cache',
+ ),
+ },
+ 'flutter',
+ 'nix-flutter-tools-gradle',
+ globals.flutterVersion.engineRevision.substring(0, 10),
+ );
+
+ return <String>[
+ '--project-cache-dir=${join(cacheDir, 'cache')}',
+ '-Pkotlin.project.persistent.dir=${join(cacheDir, 'kotlin')}',
+ ];
+ }
+
/// Gets the Gradle executable path and prepares the Gradle project.
/// This is the `gradlew` or `gradlew.bat` script in the `android/` directory.
- String getExecutable(FlutterProject project) {
+ List<String> getExecutable(FlutterProject project) {
final Directory androidDir = project.android.hostAppGradleRoot;
injectGradleWrapperIfNeeded(androidDir);
@@ -210,7 +231,7 @@ class GradleUtils {
// If the Gradle executable doesn't have execute permission,
// then attempt to set it.
_operatingSystemUtils.makeExecutable(gradle);
- return gradle.absolute.path;
+ return <String>[gradle.absolute.path, ..._requiredArguments];
}
throwToolExit(
'Unable to locate gradlew script. Please check that ${gradle.path} '
--- a/packages/flutter_tools/test/general.shard/android/android_gradle_builder_test.dart
+++ b/packages/flutter_tools/test/general.shard/android/android_gradle_builder_test.dart
@@ -2606,8 +2606,8 @@ Gradle Crashed
class FakeGradleUtils extends Fake implements GradleUtils {
@override
- String getExecutable(FlutterProject project) {
- return 'gradlew';
+ List<String> getExecutable(FlutterProject project) {
+ return const <String>['gradlew'];
}
}
--- a/packages/flutter_tools/test/general.shard/android/gradle_errors_test.dart
+++ b/packages/flutter_tools/test/general.shard/android/gradle_errors_test.dart
@@ -1633,8 +1633,8 @@ Platform fakePlatform(String name) {
class FakeGradleUtils extends Fake implements GradleUtils {
@override
- String getExecutable(FlutterProject project) {
- return 'gradlew';
+ List<String> getExecutable(FlutterProject project) {
+ return const <String>['gradlew'];
}
}
+1
View File
@@ -3442,6 +3442,7 @@ with pkgs;
);
flutterPackages = flutterPackages-bin;
flutter = flutterPackages.stable;
flutter344 = flutterPackages.v3_44;
flutter341 = flutterPackages.v3_41;
flutter338 = flutterPackages.v3_38;
flutter335 = flutterPackages.v3_35;