Skip to content

Commit

Permalink
[native_assets] Fix framework name deduplication (#149761)
Browse files Browse the repository at this point in the history
Applies flutter/flutter@02d5286 to MacOS.

I'm hoping this will fix:

* flutter/flutter#148955
  • Loading branch information
dcharkes authored Jun 7, 2024
1 parent ae47eda commit 2a543aa
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,19 @@ Map<AssetImpl, KernelAsset> _assetTargetLocations(
Uri? absolutePath,
) {
final Set<String> alreadyTakenNames = <String>{};
return <AssetImpl, KernelAsset>{
for (final AssetImpl asset in nativeAssets)
asset: _targetLocationMacOS(asset, absolutePath, alreadyTakenNames),
};
final Map<String, KernelAssetPath> idToPath = <String, KernelAssetPath>{};
final Map<AssetImpl, KernelAsset> result = <AssetImpl, KernelAsset>{};
for (final AssetImpl asset in nativeAssets) {
final KernelAssetPath path = idToPath[asset.id] ??
_targetLocationMacOS(asset, absolutePath, alreadyTakenNames).path;
idToPath[asset.id] = path;
result[asset] = KernelAsset(
id: (asset as NativeCodeAssetImpl).id,
target: Target.fromArchitectureAndOS(asset.architecture!, asset.os),
path: path,
);
}
return result;
}

KernelAsset _targetLocationMacOS(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,25 @@ void main() {
nativeAssetsYaml,
projectUri.resolve('build/native_assets/macos/native_assets.yaml'),
);
final String nativeAssetsYamlContents =
await fileSystem.file(nativeAssetsYaml).readAsString();
expect(
await fileSystem.file(nativeAssetsYaml).readAsString(),
nativeAssetsYamlContents,
contains('package:bar/bar.dart'),
);
expect(buildRunner.buildDryRunInvocations, 1);
expect(buildRunner.linkDryRunInvocations, 1);
// Check that the framework uri is identical for both archs.
final String pathSeparator = const LocalPlatform().pathSeparator;
expect(
nativeAssetsYamlContents,
stringContainsInOrder(
<String>[
'bar.framework${pathSeparator}bar',
'bar.framework${pathSeparator}bar',
],
),
);
});

testUsingContext('build with assets but not enabled', overrides: <Type, Generator>{
Expand Down

0 comments on commit 2a543aa

Please sign in to comment.