mirror of
https://github.com/flutter/flutter
synced 2024-08-25 11:07:06 +00:00
Fix frameworks added to bundle multiple times instead of lipo (#144688)
*Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.* *List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.* *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
This commit is contained in:
parent
4d44662242
commit
de72832079
|
@ -148,8 +148,15 @@ Target _getNativeTarget(DarwinArch darwinArch) {
|
||||||
Map<KernelAssetPath, List<Asset>> _fatAssetTargetLocations(List<Asset> nativeAssets) {
|
Map<KernelAssetPath, List<Asset>> _fatAssetTargetLocations(List<Asset> nativeAssets) {
|
||||||
final Set<String> alreadyTakenNames = <String>{};
|
final Set<String> alreadyTakenNames = <String>{};
|
||||||
final Map<KernelAssetPath, List<Asset>> result = <KernelAssetPath, List<Asset>>{};
|
final Map<KernelAssetPath, List<Asset>> result = <KernelAssetPath, List<Asset>>{};
|
||||||
|
final Map<String, KernelAssetPath> idToPath = <String, KernelAssetPath>{};
|
||||||
for (final Asset asset in nativeAssets) {
|
for (final Asset asset in nativeAssets) {
|
||||||
final KernelAssetPath path = _targetLocationIOS(asset, alreadyTakenNames).path;
|
// Use same target path for all assets with the same id.
|
||||||
|
final KernelAssetPath path = idToPath[asset.id] ??
|
||||||
|
_targetLocationIOS(
|
||||||
|
asset,
|
||||||
|
alreadyTakenNames,
|
||||||
|
).path;
|
||||||
|
idToPath[asset.id] = path;
|
||||||
result[path] ??= <Asset>[];
|
result[path] ??= <Asset>[];
|
||||||
result[path]!.add(asset);
|
result[path]!.add(asset);
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,12 +175,16 @@ Map<KernelAssetPath, List<Asset>> _fatAssetTargetLocations(
|
||||||
final Set<String> alreadyTakenNames = <String>{};
|
final Set<String> alreadyTakenNames = <String>{};
|
||||||
final Map<KernelAssetPath, List<Asset>> result =
|
final Map<KernelAssetPath, List<Asset>> result =
|
||||||
<KernelAssetPath, List<Asset>>{};
|
<KernelAssetPath, List<Asset>>{};
|
||||||
|
final Map<String, KernelAssetPath> idToPath = <String, KernelAssetPath>{};
|
||||||
for (final Asset asset in nativeAssets) {
|
for (final Asset asset in nativeAssets) {
|
||||||
final KernelAssetPath path = _targetLocationMacOS(
|
// Use same target path for all assets with the same id.
|
||||||
asset,
|
final KernelAssetPath path = idToPath[asset.id] ??
|
||||||
absolutePath,
|
_targetLocationMacOS(
|
||||||
alreadyTakenNames,
|
asset,
|
||||||
).path;
|
absolutePath,
|
||||||
|
alreadyTakenNames,
|
||||||
|
).path;
|
||||||
|
idToPath[asset.id] = path;
|
||||||
result[path] ??= <Asset>[];
|
result[path] ??= <Asset>[];
|
||||||
result[path]!.add(asset);
|
result[path]!.add(asset);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ class FakeNativeAssetsBuildRunner implements NativeAssetsBuildRunner {
|
||||||
FakeNativeAssetsBuildRunner({
|
FakeNativeAssetsBuildRunner({
|
||||||
this.hasPackageConfigResult = true,
|
this.hasPackageConfigResult = true,
|
||||||
this.packagesWithNativeAssetsResult = const <Package>[],
|
this.packagesWithNativeAssetsResult = const <Package>[],
|
||||||
|
this.onBuild,
|
||||||
this.dryRunResult = const FakeNativeAssetsBuilderResult(),
|
this.dryRunResult = const FakeNativeAssetsBuilderResult(),
|
||||||
this.buildResult = const FakeNativeAssetsBuilderResult(),
|
this.buildResult = const FakeNativeAssetsBuilderResult(),
|
||||||
CCompilerConfig? cCompilerConfigResult,
|
CCompilerConfig? cCompilerConfigResult,
|
||||||
|
@ -25,6 +26,7 @@ class FakeNativeAssetsBuildRunner implements NativeAssetsBuildRunner {
|
||||||
}) : cCompilerConfigResult = cCompilerConfigResult ?? CCompilerConfig(),
|
}) : cCompilerConfigResult = cCompilerConfigResult ?? CCompilerConfig(),
|
||||||
ndkCCompilerConfigResult = ndkCCompilerConfigResult ?? CCompilerConfig();
|
ndkCCompilerConfigResult = ndkCCompilerConfigResult ?? CCompilerConfig();
|
||||||
|
|
||||||
|
final native_assets_builder.BuildResult Function(Target)? onBuild;
|
||||||
final native_assets_builder.BuildResult buildResult;
|
final native_assets_builder.BuildResult buildResult;
|
||||||
final native_assets_builder.DryRunResult dryRunResult;
|
final native_assets_builder.DryRunResult dryRunResult;
|
||||||
final bool hasPackageConfigResult;
|
final bool hasPackageConfigResult;
|
||||||
|
@ -51,7 +53,7 @@ class FakeNativeAssetsBuildRunner implements NativeAssetsBuildRunner {
|
||||||
}) async {
|
}) async {
|
||||||
buildInvocations++;
|
buildInvocations++;
|
||||||
lastBuildMode = buildMode;
|
lastBuildMode = buildMode;
|
||||||
return buildResult;
|
return onBuild?.call(target) ?? buildResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -222,7 +222,8 @@ void main() {
|
||||||
'-create',
|
'-create',
|
||||||
'-output',
|
'-output',
|
||||||
'/build/native_assets/ios/bar.framework/bar',
|
'/build/native_assets/ios/bar.framework/bar',
|
||||||
'libbar.dylib',
|
'arm64/libbar.dylib',
|
||||||
|
'x64/libbar.dylib',
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const FakeCommand(
|
const FakeCommand(
|
||||||
|
@ -253,7 +254,7 @@ void main() {
|
||||||
await packageConfig.parent.create();
|
await packageConfig.parent.create();
|
||||||
await packageConfig.create();
|
await packageConfig.create();
|
||||||
await buildNativeAssetsIOS(
|
await buildNativeAssetsIOS(
|
||||||
darwinArchs: <DarwinArch>[DarwinArch.arm64],
|
darwinArchs: <DarwinArch>[DarwinArch.arm64, DarwinArch.x86_64],
|
||||||
environmentType: EnvironmentType.simulator,
|
environmentType: EnvironmentType.simulator,
|
||||||
projectUri: projectUri,
|
projectUri: projectUri,
|
||||||
buildMode: BuildMode.debug,
|
buildMode: BuildMode.debug,
|
||||||
|
@ -263,13 +264,13 @@ void main() {
|
||||||
packagesWithNativeAssetsResult: <Package>[
|
packagesWithNativeAssetsResult: <Package>[
|
||||||
Package('bar', projectUri),
|
Package('bar', projectUri),
|
||||||
],
|
],
|
||||||
buildResult: FakeNativeAssetsBuilderResult(
|
onBuild: (native_assets_cli.Target target) => FakeNativeAssetsBuilderResult(
|
||||||
assets: <Asset>[
|
assets: <Asset>[
|
||||||
Asset(
|
Asset(
|
||||||
id: 'package:bar/bar.dart',
|
id: 'package:bar/bar.dart',
|
||||||
linkMode: LinkMode.dynamic,
|
linkMode: LinkMode.dynamic,
|
||||||
target: native_assets_cli.Target.iOSArm64,
|
target: target,
|
||||||
path: AssetAbsolutePath(Uri.file('libbar.dylib')),
|
path: AssetAbsolutePath(Uri.file('${target.architecture}/libbar.dylib')),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -278,8 +279,8 @@ void main() {
|
||||||
expect(
|
expect(
|
||||||
(globals.logger as BufferLogger).traceText,
|
(globals.logger as BufferLogger).traceText,
|
||||||
stringContainsInOrder(<String>[
|
stringContainsInOrder(<String>[
|
||||||
'Building native assets for [ios_arm64] debug.',
|
'Building native assets for [ios_arm64, ios_x64] debug.',
|
||||||
'Building native assets for [ios_arm64] done.',
|
'Building native assets for [ios_arm64, ios_x64] done.',
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
|
|
|
@ -259,7 +259,8 @@ void main() {
|
||||||
'-create',
|
'-create',
|
||||||
'-output',
|
'-output',
|
||||||
dylibPath,
|
dylibPath,
|
||||||
'libbar.dylib',
|
'arm64/libbar.dylib',
|
||||||
|
'x64/libbar.dylib',
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (!flutterTester)
|
if (!flutterTester)
|
||||||
|
@ -291,7 +292,7 @@ void main() {
|
||||||
await packageConfig.parent.create();
|
await packageConfig.parent.create();
|
||||||
await packageConfig.create();
|
await packageConfig.create();
|
||||||
final (Uri? nativeAssetsYaml, _) = await buildNativeAssetsMacOS(
|
final (Uri? nativeAssetsYaml, _) = await buildNativeAssetsMacOS(
|
||||||
darwinArchs: <DarwinArch>[DarwinArch.arm64],
|
darwinArchs: <DarwinArch>[DarwinArch.arm64, DarwinArch.x86_64],
|
||||||
projectUri: projectUri,
|
projectUri: projectUri,
|
||||||
buildMode: BuildMode.debug,
|
buildMode: BuildMode.debug,
|
||||||
fileSystem: fileSystem,
|
fileSystem: fileSystem,
|
||||||
|
@ -300,13 +301,13 @@ void main() {
|
||||||
packagesWithNativeAssetsResult: <Package>[
|
packagesWithNativeAssetsResult: <Package>[
|
||||||
Package('bar', projectUri),
|
Package('bar', projectUri),
|
||||||
],
|
],
|
||||||
buildResult: FakeNativeAssetsBuilderResult(
|
onBuild: (native_assets_cli.Target target) => FakeNativeAssetsBuilderResult(
|
||||||
assets: <Asset>[
|
assets: <Asset>[
|
||||||
Asset(
|
Asset(
|
||||||
id: 'package:bar/bar.dart',
|
id: 'package:bar/bar.dart',
|
||||||
linkMode: LinkMode.dynamic,
|
linkMode: LinkMode.dynamic,
|
||||||
target: native_assets_cli.Target.macOSArm64,
|
target: target,
|
||||||
path: AssetAbsolutePath(Uri.file('libbar.dylib')),
|
path: AssetAbsolutePath(Uri.file('${target.architecture}/libbar.dylib')),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -315,8 +316,8 @@ void main() {
|
||||||
expect(
|
expect(
|
||||||
(globals.logger as BufferLogger).traceText,
|
(globals.logger as BufferLogger).traceText,
|
||||||
stringContainsInOrder(<String>[
|
stringContainsInOrder(<String>[
|
||||||
'Building native assets for [macos_arm64] debug.',
|
'Building native assets for [macos_arm64, macos_x64] debug.',
|
||||||
'Building native assets for [macos_arm64] done.',
|
'Building native assets for [macos_arm64, macos_x64] done.',
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
|
|
Loading…
Reference in a new issue