Skip to content

Commit 66efcfa

Browse files
committed
Updated flutter_tools to 72321c82f99852685c5f9a25a44adbadb7d020ff.
1 parent 3f9ef04 commit 66efcfa

119 files changed

Lines changed: 6349 additions & 1005 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/flutter_tools/bin/xcode_backend.dart

Lines changed: 254 additions & 80 deletions
Large diffs are not rendered by default.

packages/flutter_tools/lib/src/android/android_device.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ class AndroidDevice extends Device {
228228
case TargetPlatform.fuchsia_x64:
229229
case TargetPlatform.ios:
230230
case TargetPlatform.linux_arm64:
231+
case TargetPlatform.linux_riscv64:
231232
case TargetPlatform.linux_x64:
232233
case TargetPlatform.tester:
233234
case TargetPlatform.web_javascript:
@@ -551,6 +552,7 @@ class AndroidDevice extends Device {
551552
case TargetPlatform.fuchsia_x64:
552553
case TargetPlatform.ios:
553554
case TargetPlatform.linux_arm64:
555+
case TargetPlatform.linux_riscv64:
554556
case TargetPlatform.linux_x64:
555557
case TargetPlatform.tester:
556558
case TargetPlatform.web_javascript:

packages/flutter_tools/lib/src/android/gradle_utils.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const maxKnownAndSupportedGradleVersion = '9.1.0';
7979
//
8080
// Supported here means supported by the tooling for
8181
// flutter analyze --suggestions and does not imply broader flutter support.
82-
const maxKnownAndSupportedKgpVersion = '2.2.20';
82+
const maxKnownAndSupportedKgpVersion = '2.3.0';
8383

8484
// Update this when new versions of AGP come out.
8585
//
@@ -92,7 +92,7 @@ const maxKnownAndSupportedAgpVersion = '9.0';
9292
//
9393
// Supported here means supported by the tooling for
9494
// flutter analyze --suggestions and does not imply broader flutter support.
95-
const maxKnownAgpVersionWithFullKotlinSupport = '8.11.1';
95+
const maxKnownAgpVersionWithFullKotlinSupport = '8.13.0';
9696

9797
// Update this when new versions of AGP come out.
9898
const maxKnownAgpVersion = '9.0';
@@ -683,6 +683,12 @@ bool validateAgpAndKgp(Logger logger, {required String? kgpV, required String? a
683683
// Continuous KGP version handling is prefered in case an emergency patch to a
684684
// past release is shipped this code will assume the version range that is closest.
685685

686+
// Documented max is 2.3.0
687+
if (isWithinVersionRange(kgpV, min: '2.3.0', max: '2.3.0')) {
688+
// Documented max is 8.13.0
689+
return isWithinVersionRange(agpV, min: '8.2.2', max: '8.14', inclusiveMax: false);
690+
}
691+
686692
// Documented max is 2.2.20
687693
if (isWithinVersionRange(kgpV, min: '2.2.20', max: '2.2.29')) {
688694
// Documented max is 8.11.1

packages/flutter_tools/lib/src/artifacts.dart

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ enum Artifact {
3030
/// The tool which compiles a dart kernel file into native code.
3131
genSnapshot,
3232
genSnapshotArm64,
33+
genSnapshotRiscv64,
3334
genSnapshotX64,
3435

3536
/// The flutter tester binary.
@@ -155,6 +156,7 @@ TargetPlatform? _mapTargetPlatform(TargetPlatform? targetPlatform) {
155156
case TargetPlatform.darwin:
156157
case TargetPlatform.linux_x64:
157158
case TargetPlatform.linux_arm64:
159+
case TargetPlatform.linux_riscv64:
158160
case TargetPlatform.windows_x64:
159161
case TargetPlatform.windows_arm64:
160162
case TargetPlatform.fuchsia_arm64:
@@ -177,6 +179,8 @@ String? _artifactToFileName(Artifact artifact, Platform hostPlatform, [BuildMode
177179
return 'gen_snapshot';
178180
case Artifact.genSnapshotArm64:
179181
return 'gen_snapshot_arm64';
182+
case Artifact.genSnapshotRiscv64:
183+
return 'gen_snapshot_riscv64';
180184
case Artifact.genSnapshotX64:
181185
return 'gen_snapshot_x64';
182186
case Artifact.flutterTester:
@@ -519,6 +523,7 @@ class CachedArtifacts implements Artifacts {
519523
case TargetPlatform.darwin:
520524
case TargetPlatform.linux_x64:
521525
case TargetPlatform.linux_arm64:
526+
case TargetPlatform.linux_riscv64:
522527
case TargetPlatform.windows_x64:
523528
case TargetPlatform.windows_arm64:
524529
return _getDesktopArtifactPath(artifact, platform!, mode);
@@ -550,6 +555,7 @@ class CachedArtifacts implements Artifacts {
550555
switch (artifact) {
551556
case Artifact.genSnapshot:
552557
case Artifact.genSnapshotArm64:
558+
case Artifact.genSnapshotRiscv64:
553559
case Artifact.genSnapshotX64:
554560
return _fileSystem.path.join(engineDir, _artifactToFileName(artifact, _platform));
555561
case Artifact.engineDartSdkPath:
@@ -590,6 +596,7 @@ class CachedArtifacts implements Artifacts {
590596
switch (artifact) {
591597
case Artifact.genSnapshot:
592598
case Artifact.genSnapshotArm64:
599+
case Artifact.genSnapshotRiscv64:
593600
case Artifact.genSnapshotX64:
594601
assert(mode != BuildMode.debug, 'Artifact $artifact only available in non-debug mode.');
595602

@@ -647,6 +654,7 @@ class CachedArtifacts implements Artifacts {
647654
switch (artifact) {
648655
case Artifact.genSnapshot:
649656
case Artifact.genSnapshotArm64:
657+
case Artifact.genSnapshotRiscv64:
650658
case Artifact.genSnapshotX64:
651659
case Artifact.flutterXcframework:
652660
final String artifactFileName = _artifactToFileName(artifact, _platform)!;
@@ -699,6 +707,7 @@ class CachedArtifacts implements Artifacts {
699707
final genSnapshot = mode.isRelease ? 'gen_snapshot_product' : 'gen_snapshot';
700708
return _fileSystem.path.join(root, runtime, 'dart_binaries', genSnapshot);
701709
case Artifact.genSnapshotArm64:
710+
case Artifact.genSnapshotRiscv64:
702711
case Artifact.genSnapshotX64:
703712
throw ArgumentError('$artifact is not available on this platform');
704713
case Artifact.flutterPatchedSdkPath:
@@ -757,6 +766,7 @@ class CachedArtifacts implements Artifacts {
757766
switch (artifact) {
758767
case Artifact.genSnapshot:
759768
case Artifact.genSnapshotArm64:
769+
case Artifact.genSnapshotRiscv64:
760770
case Artifact.genSnapshotX64:
761771
// For script snapshots any gen_snapshot binary will do. Returning gen_snapshot for
762772
// android_arm in profile mode because it is available on all supported host platforms.
@@ -878,6 +888,7 @@ class CachedArtifacts implements Artifacts {
878888
switch (platform) {
879889
case TargetPlatform.linux_x64:
880890
case TargetPlatform.linux_arm64:
891+
case TargetPlatform.linux_riscv64:
881892
case TargetPlatform.darwin:
882893
case TargetPlatform.windows_x64:
883894
case TargetPlatform.windows_arm64:
@@ -919,9 +930,11 @@ TargetPlatform _currentHostPlatform(Platform platform, OperatingSystemUtils oper
919930
return TargetPlatform.darwin;
920931
}
921932
if (platform.isLinux) {
922-
return operatingSystemUtils.hostPlatform == HostPlatform.linux_x64
923-
? TargetPlatform.linux_x64
924-
: TargetPlatform.linux_arm64;
933+
return switch (operatingSystemUtils.hostPlatform) {
934+
HostPlatform.linux_x64 => TargetPlatform.linux_x64,
935+
HostPlatform.linux_riscv64 => TargetPlatform.linux_riscv64,
936+
_ => TargetPlatform.linux_arm64,
937+
};
925938
}
926939
if (platform.isWindows) {
927940
return operatingSystemUtils.hostPlatform == HostPlatform.windows_arm64
@@ -1197,6 +1210,7 @@ class CachedLocalEngineArtifacts implements Artifacts {
11971210
switch (artifact) {
11981211
case Artifact.genSnapshot:
11991212
case Artifact.genSnapshotArm64:
1213+
case Artifact.genSnapshotRiscv64:
12001214
case Artifact.genSnapshotX64:
12011215
return _genSnapshotPath(artifact);
12021216
case Artifact.flutterTester:
@@ -1338,6 +1352,8 @@ class CachedLocalEngineArtifacts implements Artifacts {
13381352
switch (hostPlatform) {
13391353
case TargetPlatform.darwin:
13401354
return 'macos-x64';
1355+
case TargetPlatform.linux_riscv64:
1356+
return 'linux-riscv64';
13411357
case TargetPlatform.linux_arm64:
13421358
return 'linux-arm64';
13431359
case TargetPlatform.linux_x64:
@@ -1373,6 +1389,7 @@ class CachedLocalEngineArtifacts implements Artifacts {
13731389
'clang_x86',
13741390
'clang_i386',
13751391
'clang_arm64',
1392+
'clang_riscv64',
13761393
];
13771394
final String genSnapshotName = _artifactToFileName(artifact, _platform)!;
13781395
for (final clangDir in clangDirs) {
@@ -1445,6 +1462,7 @@ class CachedLocalWebSdkArtifacts implements Artifacts {
14451462
);
14461463
case Artifact.genSnapshot:
14471464
case Artifact.genSnapshotArm64:
1465+
case Artifact.genSnapshotRiscv64:
14481466
case Artifact.genSnapshotX64:
14491467
case Artifact.flutterTester:
14501468
case Artifact.flutterFramework:
@@ -1570,6 +1588,8 @@ class CachedLocalWebSdkArtifacts implements Artifacts {
15701588
return 'macos-x64';
15711589
case TargetPlatform.linux_arm64:
15721590
return 'linux-arm64';
1591+
case TargetPlatform.linux_riscv64:
1592+
return 'linux-riscv64';
15731593
case TargetPlatform.linux_x64:
15741594
return 'linux-x64';
15751595
case TargetPlatform.windows_x64:

packages/flutter_tools/lib/src/base/build.dart

Lines changed: 116 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -154,37 +154,11 @@ class AOTSnapshotter {
154154
}
155155
}
156156

157-
String aotSharedLibrary = _fileSystem.path.join(outputDir.path, 'app.so');
158-
String? frameworkPath;
157+
final String assembly = _fileSystem.path.join(outputDir.path, 'snapshot_assembly.S');
159158
if (targetingApplePlatform) {
160-
// On iOS and macOS, we use Xcode to compile the snapshot into a dynamic
161-
// library that the end-developer can link into their app.
162-
const frameworkName = 'App.framework';
163-
if (!quiet) {
164-
final String targetArch = darwinArch!.name;
165-
_logger.printStatus('Building $frameworkName for $targetArch...');
166-
}
167-
frameworkPath = _fileSystem.path.join(outputPath, frameworkName);
168-
_fileSystem.directory(frameworkPath).createSync(recursive: true);
169-
170-
const frameworkSnapshotName = 'App';
171-
aotSharedLibrary = _fileSystem.path.join(frameworkPath, frameworkSnapshotName);
172-
final String relocatableObject = _fileSystem.path.join(outputPath, 'app.o');
173-
// When the minimum version is updated, remember to update
174-
// template MinimumOSVersion.
175-
// https://github.com/flutter/flutter/pull/62902
176-
final minOSVersion = platform == TargetPlatform.ios
177-
? FlutterDarwinPlatform.ios.deploymentTarget().toString()
178-
: FlutterDarwinPlatform.macos.deploymentTarget().toString();
179-
genSnapshotArgs.addAll(<String>[
180-
'--snapshot_kind=app-aot-macho-dylib',
181-
'--macho=$aotSharedLibrary',
182-
'--macho-object=$relocatableObject',
183-
'--macho-min-os-version=$minOSVersion',
184-
'--macho-rpath=@executable_path/Frameworks,@loader_path/Frameworks',
185-
'--macho-install-name=@rpath/$frameworkName/$frameworkSnapshotName',
186-
]);
159+
genSnapshotArgs.addAll(<String>['--snapshot_kind=app-aot-assembly', '--assembly=$assembly']);
187160
} else {
161+
final String aotSharedLibrary = _fileSystem.path.join(outputDir.path, 'app.so');
188162
genSnapshotArgs.addAll(<String>['--snapshot_kind=app-aot-elf', '--elf=$aotSharedLibrary']);
189163
}
190164

@@ -246,38 +220,123 @@ class AOTSnapshotter {
246220
return genSnapshotExitCode;
247221
}
248222

223+
// On iOS and macOS, we use Xcode to compile the snapshot into a dynamic library that the
224+
// end-developer can link into their app.
249225
if (targetingApplePlatform) {
250-
if (extractAppleDebugSymbols) {
251-
final RunResult dsymResult = await _xcode.dsymutil(<String>[
252-
'-o',
253-
'$frameworkPath.dSYM',
254-
aotSharedLibrary,
255-
]);
256-
if (dsymResult.exitCode != 0) {
226+
return _buildFramework(
227+
appleArch: darwinArch!,
228+
isIOS: platform == TargetPlatform.ios,
229+
sdkRoot: sdkRoot,
230+
assemblyPath: assembly,
231+
outputPath: outputDir.path,
232+
quiet: quiet,
233+
stripAfterBuild: stripAfterBuild,
234+
extractAppleDebugSymbols: extractAppleDebugSymbols,
235+
);
236+
} else {
237+
return 0;
238+
}
239+
}
240+
241+
/// Builds an iOS or macOS framework at [outputPath]/App.framework from the assembly
242+
/// source at [assemblyPath].
243+
Future<int> _buildFramework({
244+
required DarwinArch appleArch,
245+
required bool isIOS,
246+
String? sdkRoot,
247+
required String assemblyPath,
248+
required String outputPath,
249+
required bool quiet,
250+
required bool stripAfterBuild,
251+
required bool extractAppleDebugSymbols,
252+
}) async {
253+
final String targetArch = appleArch.name;
254+
if (!quiet) {
255+
_logger.printStatus('Building App.framework for $targetArch...');
256+
}
257+
258+
final commonBuildOptions = <String>[
259+
'-arch',
260+
targetArch,
261+
if (isIOS)
262+
// When the minimum version is updated, remember to update
263+
// template MinimumOSVersion.
264+
// https://github.com/flutter/flutter/pull/62902
265+
'-miphoneos-version-min=${FlutterDarwinPlatform.ios.deploymentTarget()}',
266+
if (sdkRoot != null) ...<String>['-isysroot', sdkRoot],
267+
];
268+
269+
final String assemblyO = _fileSystem.path.join(outputPath, 'snapshot_assembly.o');
270+
271+
final RunResult compileResult = await _xcode.cc(<String>[
272+
...commonBuildOptions,
273+
'-c',
274+
assemblyPath,
275+
'-o',
276+
assemblyO,
277+
]);
278+
if (compileResult.exitCode != 0) {
279+
_logger.printError(
280+
'Failed to compile AOT snapshot. Compiler terminated with exit code ${compileResult.exitCode}',
281+
);
282+
return compileResult.exitCode;
283+
}
284+
285+
final String frameworkDir = _fileSystem.path.join(outputPath, 'App.framework');
286+
_fileSystem.directory(frameworkDir).createSync(recursive: true);
287+
final String appLib = _fileSystem.path.join(frameworkDir, 'App');
288+
final linkArgs = <String>[
289+
...commonBuildOptions,
290+
'-dynamiclib',
291+
'-Xlinker',
292+
'-rpath',
293+
'-Xlinker',
294+
'@executable_path/Frameworks',
295+
'-Xlinker',
296+
'-rpath',
297+
'-Xlinker',
298+
'@loader_path/Frameworks',
299+
'-fapplication-extension',
300+
'-install_name',
301+
'@rpath/App.framework/App',
302+
'-o',
303+
appLib,
304+
assemblyO,
305+
];
306+
307+
final RunResult linkResult = await _xcode.clang(linkArgs);
308+
if (linkResult.exitCode != 0) {
309+
_logger.printError(
310+
'Failed to link AOT snapshot. Linker terminated with exit code ${linkResult.exitCode}',
311+
);
312+
return linkResult.exitCode;
313+
}
314+
315+
if (extractAppleDebugSymbols) {
316+
final RunResult dsymResult = await _xcode.dsymutil(<String>[
317+
'-o',
318+
'$frameworkDir.dSYM',
319+
appLib,
320+
]);
321+
if (dsymResult.exitCode != 0) {
322+
_logger.printError(
323+
'Failed to generate dSYM - dsymutil terminated with exit code ${dsymResult.exitCode}',
324+
);
325+
return dsymResult.exitCode;
326+
}
327+
328+
if (stripAfterBuild) {
329+
// See https://www.unix.com/man-page/osx/1/strip/ for arguments
330+
final RunResult stripResult = await _xcode.strip(<String>['-x', appLib, '-o', appLib]);
331+
if (stripResult.exitCode != 0) {
257332
_logger.printError(
258-
'Failed to generate dSYM - dsymutil terminated with exit code ${dsymResult.exitCode}',
333+
'Failed to strip debugging symbols from the generated AOT snapshot - strip terminated with exit code ${stripResult.exitCode}',
259334
);
260-
return dsymResult.exitCode;
335+
return stripResult.exitCode;
261336
}
262-
263-
if (stripAfterBuild) {
264-
// See https://www.unix.com/man-page/osx/1/strip/ for arguments
265-
final RunResult stripResult = await _xcode.strip(<String>[
266-
'-x',
267-
aotSharedLibrary,
268-
'-o',
269-
aotSharedLibrary,
270-
]);
271-
if (stripResult.exitCode != 0) {
272-
_logger.printError(
273-
'Failed to strip debugging symbols from the generated AOT snapshot - strip terminated with exit code ${stripResult.exitCode}',
274-
);
275-
return stripResult.exitCode;
276-
}
277-
}
278-
} else {
279-
assert(!stripAfterBuild);
280337
}
338+
} else {
339+
assert(!stripAfterBuild);
281340
}
282341

283342
return 0;
@@ -295,6 +354,7 @@ class AOTSnapshotter {
295354
TargetPlatform.darwin,
296355
TargetPlatform.linux_x64,
297356
TargetPlatform.linux_arm64,
357+
TargetPlatform.linux_riscv64,
298358
TargetPlatform.windows_x64,
299359
TargetPlatform.windows_arm64,
300360
].contains(platform);

0 commit comments

Comments
 (0)