aports/testing/flutter/system-dart.patch
2025-02-23 21:16:00 +00:00

204 lines
7.2 KiB
Diff

Thanks a lot, Braid
--- ./packages/flutter_tools/bin/tool_backend.dart.orig
+++ ./packages/flutter_tools/bin/tool_backend.dart
@@ -73,7 +73,7 @@
exit(1);
}
final String flutterExecutable = pathJoin(<String>[
- flutterRoot,
+ '/usr',
'bin',
if (Platform.isWindows) 'flutter.bat' else 'flutter',
]);
--- ./packages/flutter_tools/bin/tool_backend.sh.orig
+++ ./packages/flutter_tools/bin/tool_backend.sh
@@ -3,7 +3,4 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-readonly flutter_bin_dir="${FLUTTER_ROOT}/bin"
-readonly dart_bin_dir="${flutter_bin_dir}/cache/dart-sdk/bin"
-
-exec "${dart_bin_dir}/dart" "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.dart" "${@:1}"
+exec "${DART_ROOT:-"/usr/lib/dart"}/bin/dart" "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.dart" "${@:1}"
--- ./packages/flutter_tools/gradle/src/main/groovy/flutter.groovy.orig
+++ ./packages/flutter_tools/gradle/src/main/groovy/flutter.groovy
@@ -324,7 +324,7 @@
}
String flutterExecutableName = Os.isFamily(Os.FAMILY_WINDOWS) ? "flutter.bat" : "flutter"
- flutterExecutable = Paths.get(flutterRoot.absolutePath, "bin", flutterExecutableName).toFile()
+ flutterExecutable = Paths.get("/usr", "bin", flutterExecutableName).toFile()
// Validate that the provided Gradle, Java, AGP, and KGP versions are all within our
// supported range.
--- ./packages/flutter_tools/lib/src/artifacts.dart.orig
+++ ./packages/flutter_tools/lib/src/artifacts.dart
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+import 'dart:io' as io show Platform;
+
import 'package:file/memory.dart';
import 'package:meta/meta.dart';
import 'package:process/process.dart';
@@ -1463,60 +1465,9 @@
}
String _getDartSdkPath() {
- final String builtPath = _fileSystem.path.join(_hostEngineOutPath, 'dart-sdk');
- if (_fileSystem.isDirectorySync(_fileSystem.path.join(builtPath, 'bin'))) {
- return builtPath;
- }
-
- // If we couldn't find a built dart sdk, let's look for a prebuilt one.
- final String prebuiltPath = _fileSystem.path.join(
- _getFlutterPrebuiltsPath(),
- _getPrebuiltTarget(),
- 'dart-sdk',
- );
- if (_fileSystem.isDirectorySync(prebuiltPath)) {
- return prebuiltPath;
- }
-
- throwToolExit(
- 'Unable to find a built dart sdk at: "$builtPath" or a prebuilt dart sdk at: "$prebuiltPath"',
- );
+ return io.Platform.environment['DART_ROOT'] ?? '/usr/lib/dart';
}
- String _getFlutterPrebuiltsPath() {
- final String engineSrcPath = _fileSystem.path.dirname(
- _fileSystem.path.dirname(_hostEngineOutPath),
- );
- return _fileSystem.path.join(engineSrcPath, 'flutter', 'prebuilts');
- }
-
- String _getPrebuiltTarget() {
- final TargetPlatform hostPlatform = _currentHostPlatform(_platform, _operatingSystemUtils);
- switch (hostPlatform) {
- case TargetPlatform.darwin:
- return 'macos-x64';
- case TargetPlatform.linux_arm64:
- return 'linux-arm64';
- case TargetPlatform.linux_x64:
- return 'linux-x64';
- case TargetPlatform.windows_x64:
- return 'windows-x64';
- case TargetPlatform.windows_arm64:
- return 'windows-arm64';
- case TargetPlatform.ios:
- case TargetPlatform.android:
- case TargetPlatform.android_arm:
- case TargetPlatform.android_arm64:
- case TargetPlatform.android_x64:
- case TargetPlatform.android_x86:
- case TargetPlatform.fuchsia_arm64:
- case TargetPlatform.fuchsia_x64:
- case TargetPlatform.web_javascript:
- case TargetPlatform.tester:
- throwToolExit('Unsupported host platform: $hostPlatform');
- }
- }
-
String _getFlutterWebSdkPath() {
return _fileSystem.path.join(localEngineInfo.targetOutPath, 'flutter_web_sdk');
}
@@ -1889,7 +1840,7 @@
/// Locate the Dart SDK.
String _dartSdkPath(Cache cache) {
- return cache.getRoot().childDirectory('dart-sdk').path;
+ return io.Platform.environment['DART_ROOT'] ?? '/usr/lib/dart';
}
class _TestArtifacts implements Artifacts {
--- ./packages/flutter_tools/lib/src/cache.dart.orig
+++ ./packages/flutter_tools/lib/src/cache.dart
@@ -3,6 +3,7 @@
// found in the LICENSE file.
import 'dart:async';
+import 'dart:io' as io show Platform;
import 'package:crypto/crypto.dart';
import 'package:file/memory.dart';
@@ -380,8 +381,8 @@
String get devToolsVersion {
if (_devToolsVersion == null) {
- const String devToolsDirPath = 'dart-sdk/bin/resources/devtools';
- final Directory devToolsDir = getCacheDir(devToolsDirPath, shouldCreate: false);
+ final String dartSdkRoot = io.Platform.environment['DART_ROOT'] ?? '/usr/lib/dart';
+ final Directory devToolsDir = _fileSystem.directory(dartSdkRoot + '/bin/resources/devtools');
if (!devToolsDir.existsSync()) {
throw Exception('Could not find directory at ${devToolsDir.path}');
}
--- ./packages/flutter_tools/lib/src/commands/create_base.dart.orig
+++ ./packages/flutter_tools/lib/src/commands/create_base.dart
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+import 'dart:io' as io show Platform;
+
import 'package:meta/meta.dart';
import 'package:uuid/uuid.dart';
@@ -391,7 +393,7 @@
'linuxIdentifier': linuxIdentifier,
'windowsIdentifier': windowsIdentifier,
'description': projectDescription,
- 'dartSdk': '$flutterRoot/bin/cache/dart-sdk',
+ 'dartSdk': io.Platform.environment['DART_ROOT'] ?? '/usr/lib/dart',
'androidMinApiLevel': android_common.minApiLevel,
'androidSdkVersion': kAndroidSdkMinVersion,
'pluginClass': pluginClass,
--- ./packages/flutter_tools/lib/src/dart/pub.dart.orig
+++ ./packages/flutter_tools/lib/src/dart/pub.dart
@@ -3,6 +3,7 @@
// found in the LICENSE file.
import 'dart:async';
+import 'dart:io' as io show Platform;
import 'package:meta/meta.dart';
import 'package:package_config/package_config.dart';
@@ -545,10 +546,7 @@
List<String> _computePubCommand() {
// TODO(zanderso): refactor to use artifacts.
final String sdkPath = _fileSystem.path.joinAll(<String>[
- Cache.flutterRoot!,
- 'bin',
- 'cache',
- 'dart-sdk',
+ io.Platform.environment['DART_ROOT'] ?? '/usr/lib/dart',
'bin',
'dart',
]);
--- ./packages/flutter_tools/lib/src/dart/language_version.dart.orig
+++ ./packages/flutter_tools/lib/src/dart/language_version.dart
@@ -3,6 +3,7 @@
// found in the LICENSE file.
import 'dart:async';
+import 'dart:io' as io show Platform;
import 'package:file/file.dart';
import 'package:package_config/package_config.dart';
@@ -27,7 +28,13 @@
// Either reading the file or parsing the version could fail on a corrupt Dart SDK.
// let it crash so it shows up in crash logging.
final File versionFile = fileSystem.file(
- fileSystem.path.join(flutterRoot, 'bin', 'cache', 'dart-sdk', 'version'),
+ fileSystem.path.join(
+ io.Platform.environment['DART_ROOT'] ?? '/usr/lib/dart',
+ 'bin',
+ 'cache',
+ 'dart-sdk',
+ 'version',
+ ),
);
if (!versionFile.existsSync() && _inUnitTest()) {
return LanguageVersion(2, 12);