--- ./packages/flutter_tools/bin/tool_backend.dart.orig +++ ./packages/flutter_tools/bin/tool_backend.dart @@ -69,12 +69,9 @@ exit(1); } final String flutterExecutable = pathJoin([ - flutterRoot, + '/usr', 'bin', - if (Platform.isWindows) - 'flutter.bat' - else - 'flutter', + 'flutter', ]); final String bundlePlatform = targetPlatform.startsWith('windows') ? 'windows' : 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/groovy/flutter.groovy.orig +++ ./packages/flutter_tools/gradle/src/main/groovy/flutter.groovy @@ -264,7 +264,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(); if (project.hasProperty("multidex-enabled") && project.property("multidex-enabled").toBoolean()) { --- ./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'; @@ -1059,48 +1061,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; - } - - throw ToolExit('Unable to find a built dart sdk at: "$builtPath" or a prebuilt dart sdk at: "$prebuiltPath"'); - } - - 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.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'); - } + return io.Platform.environment['DART_ROOT'] ?? '/opt/dart-sdk'; } String _getFlutterWebSdkPath() { @@ -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'; @@ -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'] ?? '/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/dart/pub.dart.orig +++ ./packages/flutter_tools/lib/src/dart/pub.dart @@ -545,9 +545,7 @@ List _computePubCommand() { // TODO(zanderso): refactor to use artifacts. final String sdkPath = _fileSystem.path.joinAll([ - Cache.flutterRoot!, - 'bin', - 'cache', + '/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'; @@ -26,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')); + final File versionFile = fileSystem.file(io.Platform.environment['DART_ROOT'] ?? '/opt/dart-sdk'); if (!versionFile.existsSync() && _inUnitTest()) { return LanguageVersion(2, 12); }