--- ./packages/flutter_tools/bin/tool_backend.dart.orig +++ ./packages/flutter_tools/bin/tool_backend.dart @@ -73,9 +73,9 @@ exit(1); } final String flutterExecutable = pathJoin([ - flutterRoot, + '/usr', 'bin', - if (Platform.isWindows) 'flutter.bat' else 'flutter', + 'flutter', ]); final String bundlePlatform = targetPlatform; final String target = '${buildMode}_bundle_${bundlePlatform}_assets'; --- ./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:-"/opt/dart-sdk"}/bin/dart" "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.dart" "${@:1}" --- ./packages/flutter_tools/gradle/src/main/kotlin/FlutterPlugin.kt.orig +++ ./packages/flutter_tools/gradle/src/main/kotlin/FlutterPlugin.kt @@ -50,7 +50,7 @@ addTaskForLockfileGeneration(rootProject) } - val flutterRootSystemVal: String? = System.getenv("FLUTTER_ROOT") + val flutterRootSystemVal: String? = System.getenv("FLUTTER_ROOT") ?: "/usr/bin/flutter" val flutterRootPath: String = resolveFlutterSdkProperty(flutterRootSystemVal) ?: throw GradleException( @@ -170,7 +170,7 @@ val flutterExecutableName = getExecutableNameForPlatform("flutter") flutterExecutable = - Paths.get(flutterRoot!!.absolutePath, "bin", flutterExecutableName).toFile() + 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'; @@ -1308,24 +1308,7 @@ } 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'] ?? '/opt/dart-sdk'; } String _getFlutterPrebuiltsPath() { @@ -1382,7 +1343,7 @@ /// Locate the Dart SDK. String _dartSdkPath(Cache cache) { - return cache.getRoot().childDirectory('dart-sdk').path; + return io.Platform.environment['DART_ROOT'] ?? '/opt/dart-sdk'; } 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'; @@ -421,8 +421,8 @@ String get devToolsVersion { if (_devToolsVersion == null) { - const devToolsDirPath = 'dart-sdk/bin/resources/devtools'; - final Directory devToolsDir = getCacheDir(devToolsDirPath, shouldCreate: false); + final String dartSdkRoot = io.Platform.environment['DART_ROOT'] ?? '/opt/dart-sdk'; + 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'; @@ -341,7 +341,7 @@ 'linuxIdentifier': linuxIdentifier, 'windowsIdentifier': windowsIdentifier, 'description': projectDescription, - 'dartSdk': '$flutterRoot/bin/cache/dart-sdk', + 'dartSdk': io.Platform.environment['DART_ROOT'] ?? '/opt/dart-sdk', 'androidMinApiLevel': gradle.minSdkVersion, 'androidSdkVersion': gradle.minSdkVersion, '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 _computePubCommand() { // TODO(zanderso): refactor to use artifacts. final String sdkPath = _fileSystem.path.joinAll([ - Cache.flutterRoot!, - 'bin', - 'cache', - 'dart-sdk', + io.Platform.environment['DART_ROOT'] ?? '/opt/dart-sdk', '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 +27,7 @@ // 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'), + (io.Platform.environment['DART_ROOT'] ?? '/opt/dart-sdk') + '/version', ); if (!versionFile.existsSync() && _inUnitTest()) { return LanguageVersion(2, 12);