flutter329: init at 3.29.2

This commit is contained in:
emaryn
2025-03-28 13:28:58 +00:00
parent 7a5400ad45
commit ce0be78ee3
11 changed files with 1272 additions and 32 deletions
@@ -174,7 +174,11 @@ stdenv.mkDerivation (finalAttrs: {
nativeBuildInputs =
[
python3
(python3.withPackages (
ps: with ps; [
pyyaml
]
))
(tools.vpython python3)
gitMinimal
pkg-config
@@ -295,6 +299,12 @@ stdenv.mkDerivation (finalAttrs: {
export TERM=dumb
${lib.optionalString (lib.versionAtLeast flutterVersion "3.29") ''
# ValueError: ZIP does not support timestamps before 1980
substituteInPlace src/flutter/build/zip.py \
--replace-fail "zipfile.ZipFile(args.output, 'w', zipfile.ZIP_DEFLATED)" "zipfile.ZipFile(args.output, 'w', zipfile.ZIP_DEFLATED, strict_timestamps=False)"
''}
ninja -C $out/out/$outName -j$NIX_BUILD_CORES
runHook postBuild
@@ -48,7 +48,7 @@ runCommand "flutter-engine-source-${version}-${buildPlatform.system}-${targetPla
gclient = writeText "flutter-engine-${version}.gclient" ''
solutions = [{
"managed": False,
"name": "src/flutter",
"name": "${lib.optionalString (lib.versionAtLeast flutterVersion "3.29") "engine/"}src/flutter",
"url": "${url}",
"custom_vars": {
"download_fuchsia_deps": False,
@@ -86,23 +86,44 @@ runCommand "flutter-engine-source-${version}-${buildPlatform.system}-${targetPla
(hashes."${buildPlatform.system}" or { })."${targetPlatform.system}"
or (throw "Hash not set for ${targetPlatform.system} on ${buildPlatform.system}");
}
''
source ${../../../../build-support/fetchgit/deterministic-git}
export -f clean_git
export -f make_deterministic_repo
(
''
source ${../../../../build-support/fetchgit/deterministic-git}
export -f clean_git
export -f make_deterministic_repo
mkdir -p $out
cp $gclient $out/.gclient
cd $out
''
+ (
if lib.versionAtLeast flutterVersion "3.29" then
''
mkdir -p source
cp $gclient source/.gclient
cd source
''
else
''
mkdir -p $out
cp $gclient $out/.gclient
cd $out
''
)
+ ''
export PATH=$PATH:$depot_tools
python3 $depot_tools/gclient.py sync --no-history --shallow --nohooks -j $NIX_BUILD_CORES
find $out -name '.git' -exec rm -rf {} \; || true
export PATH=$PATH:$depot_tools
python3 $depot_tools/gclient.py sync --no-history --shallow --nohooks -j $NIX_BUILD_CORES
''
+ lib.optionalString (lib.versionAtLeast flutterVersion "3.29") ''
cp -r engine/src/flutter/third_party/* engine/src/flutter/engine/src/flutter/third_party/
mv engine/src/flutter/engine $out
''
+ ''
find $out -name '.git' -exec rm -rf {} \; || true
rm -rf $out/src/{buildtools,fuchsia}
rm -rf $out/src/flutter/{buildtools,prebuilts,third_party/swiftshader,third_party/gn/.versions}
rm -rf $out/src/flutter/{third_party/dart/tools/sdks/dart-sdk,third_party/ninja/ninja,third_party/java}
rm -rf $out/src/third_party/{dart/tools/sdks/dart-sdk,libcxx/test}
rm -rf $out/src/{buildtools,fuchsia}
rm -rf $out/src/flutter/{buildtools,prebuilts,third_party/swiftshader,third_party/gn/.versions}
rm -rf $out/src/flutter/{third_party/dart/tools/sdks/dart-sdk,third_party/ninja/ninja,third_party/java}
rm -rf $out/src/third_party/{dart/tools/sdks/dart-sdk,libcxx/test}
rm -rf $out/.cipd $out/.gclient $out/.gclient_entries $out/.gclient_previous_custom_vars $out/.gclient_previous_sync_commits
''
rm -rf $out/.cipd $out/.gclient $out/.gclient_entries $out/.gclient_previous_custom_vars $out/.gclient_previous_sync_commits
''
)
@@ -3,7 +3,11 @@
version,
engineVersion,
engineHashes ? { },
engineUrl ? "https://github.com/flutter/engine.git@${engineVersion}",
engineUrl ?
if lib.versionAtLeast version "3.29" then
"https://github.com/flutter/flutter.git@${engineVersion}"
else
"https://github.com/flutter/engine.git@${engineVersion}",
enginePatches ? [ ],
engineRuntimeModes ? [
"release"
@@ -99,14 +103,6 @@ let
echo "$(git rev-parse HEAD)" > bin/cache/flutter_tools.stamp
ln -s '${flutterTools}/share/flutter_tools.snapshot' bin/cache/flutter_tools.snapshot
# Some of flutter_tools's dependencies contain static assets. The
# application attempts to read its own package_config.json to find these
# assets at runtime.
# TODO: Remove this once Flutter 3.24 is the lowest version in Nixpkgs.
# https://github.com/flutter/flutter/pull/150340 makes it redundant.
mkdir -p packages/flutter_tools/.dart_tool
ln -s '${flutterTools.pubcache}/package_config.json' packages/flutter_tools/.dart_tool/package_config.json
echo -n "${version}" > version
cat <<EOF > bin/cache/flutter.version.json
{
@@ -22,7 +22,7 @@ let
buildPlatform = lib.systems.elaborate buildPlatform;
flutterVersion = version;
version = engineVersion;
url = "https://github.com/flutter/engine.git@${engineVersion}";
url = "https://github.com/flutter/flutter.git@${engineVersion}";
hashes."${buildPlatform}"."${targetPlatform}" = lib.fakeSha256;
})
systemPlatforms)
@@ -203,7 +203,7 @@ def get_pubspec_lock(flutter_compact_version, flutter_src):
return yaml.safe_load(pubspec_lock_yaml)
def get_engine_swiftshader_rev(engine_version):
with urllib.request.urlopen(f"https://github.com/flutter/engine/raw/{engine_version}/DEPS") as f:
with urllib.request.urlopen(f"https://github.com/flutter/flutter/raw/{engine_version}/DEPS") as f:
deps = f.read().decode('utf-8')
pattern = re.compile(r"Var\('swiftshader_git'\) \+ '\/SwiftShader\.git' \+ '@' \+ \'([0-9a-fA-F]{40})\'\,")
rev = pattern.findall(deps)[0]
@@ -257,7 +257,7 @@ def update_all_packages():
new_content = [
"flutterPackages-bin = recurseIntoAttrs (callPackage ../development/compilers/flutter { });",
"flutterPackages-source = recurseIntoAttrs (callPackage ../development/compilers/flutter { useNixpkgsEngine = true; });",
"flutterPackages = flutterPackages-bin;"
"flutterPackages = flutterPackages-bin;",
"flutter = flutterPackages.stable;",
] + [f"flutter{version.replace('_', '')} = flutterPackages.v{version};" for version in versions]
@@ -305,15 +305,17 @@ def find_versions(flutter_version=None, channel=None):
tags = subprocess.Popen(['git',
'ls-remote',
'--tags',
'https://github.com/flutter/engine.git'],
'https://github.com/flutter/flutter.git'],
stdout=subprocess.PIPE,
text=True).communicate()[0].strip()
try:
engine_hash = next(
flutter_hash = next(
filter(
lambda line: line.endswith(f'refs/tags/{flutter_version}'),
tags.splitlines())).split('refs')[0].strip()
engine_hash = urllib.request.urlopen(f'https://github.com/flutter/flutter/raw/{flutter_hash}/bin/internal/engine.version').read().decode('utf-8').strip()
except StopIteration:
exit(
f"Couldn't find Engine hash for Flutter version: {flutter_version}")
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,30 @@
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
@@ -444,12 +444,8 @@ class FlutterCommandRunner extends CommandRunner<void> {
globals.analytics.suppressTelemetry();
}
- globals.flutterVersion.ensureVersionFile();
final bool machineFlag =
topLevelResults[FlutterGlobalOptions.kMachineFlag] as bool? ?? false;
- if (await _shouldCheckForUpdates(topLevelResults, topLevelMachineFlag: machineFlag)) {
- await globals.flutterVersion.checkFlutterVersionFreshness();
- }
// See if the user specified a specific device.
final String? specifiedDeviceId =
@@ -0,0 +1,69 @@
From 6df275df3b8694daf16302b407520e3b1dee6724 Mon Sep 17 00:00:00 2001
From: Philip Hayes <philiphayes9@gmail.com>
Date: Thu, 12 Sep 2024 13:23:00 -0700
Subject: [PATCH] fix: cleanup xcode_backend.sh to fix iOS build w/
`NixOS/nixpkgs` flutter
This patch cleans up `xcode_backend.sh`. It now effectively just runs
`exec $FLUTTER_ROOT/bin/dart ./xcode_backend.dart`.
The previous `xcode_backend.sh` tries to discover `$FLUTTER_ROOT` from
argv[0], even though its presence is already guaranteed (the wrapped
`xcode_backend.dart` also relies on this env).
When using nixpkgs flutter, the flutter SDK directory is composed of several
layers, joined together using symlinks (called a `symlinkJoin`). Without this
patch, the auto-discover traverses the symlinks into the wrong layer, and so it
uses an "unwrapped" `dart` command instead of a "wrapped" dart that sets some
important envs/flags (like `$FLUTTER_ROOT`).
Using the "unwrapped" dart then manifests in this error when compiling, since
it doesn't see the ios build-support artifacts:
```
$ flutter run -d iphone
Running Xcode build...
Xcode build done. 6.4s
Failed to build iOS app
Error (Xcode): Target debug_unpack_ios failed: Error: Flutter failed to create a directory at "/<nix-store>/XXXX-flutter-3.24.1-unwrapped/bin/cache/artifacts".
```
---
packages/flutter_tools/bin/xcode_backend.sh | 25 ++++-----------------
1 file changed, 4 insertions(+), 21 deletions(-)
diff --git a/packages/flutter_tools/bin/xcode_backend.sh b/packages/flutter_tools/bin/xcode_backend.sh
index 2889d7c8e4..48b9d06c6e 100755
--- a/packages/flutter_tools/bin/xcode_backend.sh
+++ b/packages/flutter_tools/bin/xcode_backend.sh
@@ -6,24 +6,7 @@
# 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"
-
-"$DART" "$BIN_DIR/xcode_backend.dart" "$@"
+# 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}" "$@"
--
2.46.0
@@ -0,0 +1,44 @@
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")`.
Now the `.gradle` will be built in `$HOME/.cache/flutter/nix-flutter-tools-gradle/<short engine rev>/`, but `build` doesn't.
To move `build` to `$HOME/.cache/flutter/nix-flutter-tools-gradle/<short engine rev>/` as well, we need to set `buildDirectory`.
diff --git a/packages/flutter_tools/gradle/settings.gradle b/packages/flutter_tools/gradle/settings.gradle
new file mode 100644
index 0000000000..b2485c94b4
--- /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)
+1
View File
@@ -5540,6 +5540,7 @@ with pkgs;
flutterPackages-source = recurseIntoAttrs (callPackage ../development/compilers/flutter { useNixpkgsEngine = true; });
flutterPackages = flutterPackages-bin;
flutter = flutterPackages.stable;
flutter329 = flutterPackages.v3_29;
flutter327 = flutterPackages.v3_27;
flutter326 = flutterPackages.v3_26;
flutter324 = flutterPackages.v3_24;