Unverified Commit db83bc6e authored by Daco Harkes's avatar Daco Harkes Committed by GitHub

Roll native_assets_builder to 0.5.0 (#143472)

Roll of https://github.com/dart-lang/native/pull/964, which separates the `KernelAsset`s (the asset information embedded in the Dart kernel snapshot) from `Asset`s (the assets in the `build.dart` protocol). See the linked issue for why they ought to be different instead of shared.

This PR does not change any functionality in Flutter.

(Now that https://github.com/flutter/flutter/pull/143055 has landed, we can land breaking changes.)

For reference, the same roll in the Dart SDK: https://dart-review.googlesource.com/c/sdk/+/352642
parent 5b005e47
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'package:native_assets_cli/native_assets_cli_internal.dart' show Asset; import 'package:native_assets_builder/native_assets_builder.dart' hide NativeAssetsBuildRunner;
import 'package:package_config/package_config_types.dart'; import 'package:package_config/package_config_types.dart';
import '../../android/gradle_utils.dart'; import '../../android/gradle_utils.dart';
...@@ -56,7 +56,7 @@ class NativeAssets extends Target { ...@@ -56,7 +56,7 @@ class NativeAssets extends Target {
final File nativeAssetsFile = environment.buildDir.childFile('native_assets.yaml'); final File nativeAssetsFile = environment.buildDir.childFile('native_assets.yaml');
if (nativeAssetsEnvironment == 'false') { if (nativeAssetsEnvironment == 'false') {
dependencies = <Uri>[]; dependencies = <Uri>[];
await writeNativeAssetsYaml(<Asset>[], environment.buildDir.uri, fileSystem); await writeNativeAssetsYaml(KernelAssets(), environment.buildDir.uri, fileSystem);
} else { } else {
final String? targetPlatformEnvironment = environment.defines[kTargetPlatform]; final String? targetPlatformEnvironment = environment.defines[kTargetPlatform];
if (targetPlatformEnvironment == null) { if (targetPlatformEnvironment == null) {
...@@ -145,7 +145,7 @@ class NativeAssets extends Target { ...@@ -145,7 +145,7 @@ class NativeAssets extends Target {
} else { } else {
// TODO(dacoharkes): Implement other OSes. https://github.com/flutter/flutter/issues/129757 // TODO(dacoharkes): Implement other OSes. https://github.com/flutter/flutter/issues/129757
// Write the file we claim to have in the [outputs]. // Write the file we claim to have in the [outputs].
await writeNativeAssetsYaml(<Asset>[], environment.buildDir.uri, fileSystem); await writeNativeAssetsYaml(KernelAssets(), environment.buildDir.uri, fileSystem);
dependencies = <Uri>[]; dependencies = <Uri>[];
} }
case TargetPlatform.android_arm: case TargetPlatform.android_arm:
...@@ -165,7 +165,7 @@ class NativeAssets extends Target { ...@@ -165,7 +165,7 @@ class NativeAssets extends Target {
case TargetPlatform.web_javascript: case TargetPlatform.web_javascript:
// TODO(dacoharkes): Implement other OSes. https://github.com/flutter/flutter/issues/129757 // TODO(dacoharkes): Implement other OSes. https://github.com/flutter/flutter/issues/129757
// Write the file we claim to have in the [outputs]. // Write the file we claim to have in the [outputs].
await writeNativeAssetsYaml(<Asset>[], environment.buildDir.uri, fileSystem); await writeNativeAssetsYaml(KernelAssets(), environment.buildDir.uri, fileSystem);
dependencies = <Uri>[]; dependencies = <Uri>[];
} }
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'package:native_assets_builder/native_assets_builder.dart' import 'package:native_assets_builder/native_assets_builder.dart'
show BuildResult, DryRunResult; hide NativeAssetsBuildRunner;
import 'package:native_assets_cli/native_assets_cli_internal.dart' import 'package:native_assets_cli/native_assets_cli_internal.dart'
as native_assets_cli; as native_assets_cli;
import 'package:native_assets_cli/native_assets_cli_internal.dart' import 'package:native_assets_cli/native_assets_cli_internal.dart'
...@@ -31,21 +31,21 @@ Future<Uri?> dryRunNativeAssetsAndroid({ ...@@ -31,21 +31,21 @@ Future<Uri?> dryRunNativeAssetsAndroid({
} }
final Uri buildUri_ = nativeAssetsBuildUri(projectUri, OS.android); final Uri buildUri_ = nativeAssetsBuildUri(projectUri, OS.android);
final Iterable<Asset> nativeAssetPaths = final Iterable<KernelAsset> nativeAssetPaths =
await dryRunNativeAssetsAndroidInternal( await dryRunNativeAssetsAndroidInternal(
fileSystem, fileSystem,
projectUri, projectUri,
buildRunner, buildRunner,
); );
final Uri nativeAssetsUri = await writeNativeAssetsYaml( final Uri nativeAssetsUri = await writeNativeAssetsYaml(
nativeAssetPaths, KernelAssets(nativeAssetPaths),
buildUri_, buildUri_,
fileSystem, fileSystem,
); );
return nativeAssetsUri; return nativeAssetsUri;
} }
Future<Iterable<Asset>> dryRunNativeAssetsAndroidInternal( Future<Iterable<KernelAsset>> dryRunNativeAssetsAndroidInternal(
FileSystem fileSystem, FileSystem fileSystem,
Uri projectUri, Uri projectUri,
NativeAssetsBuildRunner buildRunner, NativeAssetsBuildRunner buildRunner,
...@@ -63,10 +63,9 @@ Future<Iterable<Asset>> dryRunNativeAssetsAndroidInternal( ...@@ -63,10 +63,9 @@ Future<Iterable<Asset>> dryRunNativeAssetsAndroidInternal(
final List<Asset> nativeAssets = dryRunResult.assets; final List<Asset> nativeAssets = dryRunResult.assets;
ensureNoLinkModeStatic(nativeAssets); ensureNoLinkModeStatic(nativeAssets);
globals.logger.printTrace('Dry running native assets for $targetOS done.'); globals.logger.printTrace('Dry running native assets for $targetOS done.');
final Map<Asset, Asset> assetTargetLocations = final Map<Asset, KernelAsset> assetTargetLocations =
_assetTargetLocations(nativeAssets); _assetTargetLocations(nativeAssets);
final Iterable<Asset> nativeAssetPaths = assetTargetLocations.values; return assetTargetLocations.values;
return nativeAssetPaths;
} }
/// Builds native assets. /// Builds native assets.
...@@ -85,7 +84,7 @@ Future<(Uri? nativeAssetsYaml, List<Uri> dependencies)> ...@@ -85,7 +84,7 @@ Future<(Uri? nativeAssetsYaml, List<Uri> dependencies)>
final Uri buildUri_ = nativeAssetsBuildUri(projectUri, targetOS); final Uri buildUri_ = nativeAssetsBuildUri(projectUri, targetOS);
if (!await nativeBuildRequired(buildRunner)) { if (!await nativeBuildRequired(buildRunner)) {
final Uri nativeAssetsYaml = await writeNativeAssetsYaml( final Uri nativeAssetsYaml = await writeNativeAssetsYaml(
<Asset>[], KernelAssets(),
yamlParentDirectory ?? buildUri_, yamlParentDirectory ?? buildUri_,
fileSystem, fileSystem,
); );
...@@ -116,11 +115,11 @@ Future<(Uri? nativeAssetsYaml, List<Uri> dependencies)> ...@@ -116,11 +115,11 @@ Future<(Uri? nativeAssetsYaml, List<Uri> dependencies)>
} }
ensureNoLinkModeStatic(nativeAssets); ensureNoLinkModeStatic(nativeAssets);
globals.logger.printTrace('Building native assets for $targets done.'); globals.logger.printTrace('Building native assets for $targets done.');
final Map<Asset, Asset> assetTargetLocations = final Map<Asset, KernelAsset> assetTargetLocations =
_assetTargetLocations(nativeAssets); _assetTargetLocations(nativeAssets);
await _copyNativeAssetsAndroid(buildUri_, assetTargetLocations, fileSystem); await _copyNativeAssetsAndroid(buildUri_, assetTargetLocations, fileSystem);
final Uri nativeAssetsUri = await writeNativeAssetsYaml( final Uri nativeAssetsUri = await writeNativeAssetsYaml(
assetTargetLocations.values, KernelAssets(assetTargetLocations.values),
yamlParentDirectory ?? buildUri_, yamlParentDirectory ?? buildUri_,
fileSystem); fileSystem);
return (nativeAssetsUri, dependencies.toList()); return (nativeAssetsUri, dependencies.toList());
...@@ -128,7 +127,7 @@ Future<(Uri? nativeAssetsYaml, List<Uri> dependencies)> ...@@ -128,7 +127,7 @@ Future<(Uri? nativeAssetsYaml, List<Uri> dependencies)>
Future<void> _copyNativeAssetsAndroid( Future<void> _copyNativeAssetsAndroid(
Uri buildUri, Uri buildUri,
Map<Asset, Asset> assetTargetLocations, Map<Asset, KernelAsset> assetTargetLocations,
FileSystem fileSystem, FileSystem fileSystem,
) async { ) async {
if (assetTargetLocations.isNotEmpty) { if (assetTargetLocations.isNotEmpty) {
...@@ -142,10 +141,10 @@ Future<void> _copyNativeAssetsAndroid( ...@@ -142,10 +141,10 @@ Future<void> _copyNativeAssetsAndroid(
final Uri archUri = buildUri.resolve('jniLibs/lib/$jniArchDir/'); final Uri archUri = buildUri.resolve('jniLibs/lib/$jniArchDir/');
await fileSystem.directory(archUri).create(recursive: true); await fileSystem.directory(archUri).create(recursive: true);
} }
for (final MapEntry<Asset, Asset> assetMapping for (final MapEntry<Asset, KernelAsset> assetMapping
in assetTargetLocations.entries) { in assetTargetLocations.entries) {
final Uri source = (assetMapping.key.path as AssetAbsolutePath).uri; final Uri source = (assetMapping.key.path as AssetAbsolutePath).uri;
final Uri target = (assetMapping.value.path as AssetAbsolutePath).uri; final Uri target = (assetMapping.value.path as KernelAssetAbsolutePath).uri;
final AndroidArch androidArch = final AndroidArch androidArch =
_getAndroidArch(assetMapping.value.target); _getAndroidArch(assetMapping.value.target);
final String jniArchDir = androidArch.archName; final String jniArchDir = androidArch.archName;
...@@ -190,8 +189,8 @@ AndroidArch _getAndroidArch(Target target) { ...@@ -190,8 +189,8 @@ AndroidArch _getAndroidArch(Target target) {
} }
} }
Map<Asset, Asset> _assetTargetLocations(List<Asset> nativeAssets) { Map<Asset, KernelAsset> _assetTargetLocations(List<Asset> nativeAssets) {
return <Asset, Asset>{ return <Asset, KernelAsset>{
for (final Asset asset in nativeAssets) for (final Asset asset in nativeAssets)
asset: _targetLocationAndroid(asset), asset: _targetLocationAndroid(asset),
}; };
...@@ -199,19 +198,28 @@ Map<Asset, Asset> _assetTargetLocations(List<Asset> nativeAssets) { ...@@ -199,19 +198,28 @@ Map<Asset, Asset> _assetTargetLocations(List<Asset> nativeAssets) {
/// Converts the `path` of [asset] as output from a `build.dart` invocation to /// Converts the `path` of [asset] as output from a `build.dart` invocation to
/// the path used inside the Flutter app bundle. /// the path used inside the Flutter app bundle.
Asset _targetLocationAndroid(Asset asset) { KernelAsset _targetLocationAndroid(Asset asset) {
final AssetPath path = asset.path; final AssetPath path = asset.path;
final KernelAssetPath kernelAssetPath;
switch (path) { switch (path) {
case AssetSystemPath _: case AssetSystemPath _:
kernelAssetPath = KernelAssetSystemPath(path.uri);
case AssetInExecutable _: case AssetInExecutable _:
kernelAssetPath = KernelAssetInExecutable();
case AssetInProcess _: case AssetInProcess _:
return asset; kernelAssetPath = KernelAssetInProcess();
case AssetAbsolutePath _: case AssetAbsolutePath _:
final String fileName = path.uri.pathSegments.last; final String fileName = path.uri.pathSegments.last;
return asset.copyWith(path: AssetAbsolutePath(Uri(path: fileName))); kernelAssetPath = KernelAssetAbsolutePath(Uri(path: fileName));
default:
throw Exception(
'Unsupported asset path type ${path.runtimeType} in asset $asset',
);
} }
throw Exception( return KernelAsset(
'Unsupported asset path type ${path.runtimeType} in asset $asset', id: asset.id,
target: asset.target,
path: kernelAssetPath,
); );
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'package:native_assets_builder/native_assets_builder.dart' import 'package:native_assets_builder/native_assets_builder.dart'
show BuildResult, DryRunResult; hide NativeAssetsBuildRunner;
import 'package:native_assets_cli/native_assets_cli_internal.dart' import 'package:native_assets_cli/native_assets_cli_internal.dart'
hide BuildMode; hide BuildMode;
import 'package:native_assets_cli/native_assets_cli_internal.dart' import 'package:native_assets_cli/native_assets_cli_internal.dart'
...@@ -31,20 +31,20 @@ Future<Uri?> dryRunNativeAssetsIOS({ ...@@ -31,20 +31,20 @@ Future<Uri?> dryRunNativeAssetsIOS({
} }
final Uri buildUri = nativeAssetsBuildUri(projectUri, OS.iOS); final Uri buildUri = nativeAssetsBuildUri(projectUri, OS.iOS);
final Iterable<Asset> assetTargetLocations = await dryRunNativeAssetsIOSInternal( final Iterable<KernelAsset> assetTargetLocations = await dryRunNativeAssetsIOSInternal(
fileSystem, fileSystem,
projectUri, projectUri,
buildRunner, buildRunner,
); );
final Uri nativeAssetsUri = await writeNativeAssetsYaml( final Uri nativeAssetsUri = await writeNativeAssetsYaml(
assetTargetLocations, KernelAssets(assetTargetLocations),
buildUri, buildUri,
fileSystem, fileSystem,
); );
return nativeAssetsUri; return nativeAssetsUri;
} }
Future<Iterable<Asset>> dryRunNativeAssetsIOSInternal( Future<Iterable<KernelAsset>> dryRunNativeAssetsIOSInternal(
FileSystem fileSystem, FileSystem fileSystem,
Uri projectUri, Uri projectUri,
NativeAssetsBuildRunner buildRunner, NativeAssetsBuildRunner buildRunner,
...@@ -61,8 +61,7 @@ Future<Iterable<Asset>> dryRunNativeAssetsIOSInternal( ...@@ -61,8 +61,7 @@ Future<Iterable<Asset>> dryRunNativeAssetsIOSInternal(
final List<Asset> nativeAssets = dryRunResult.assets; final List<Asset> nativeAssets = dryRunResult.assets;
ensureNoLinkModeStatic(nativeAssets); ensureNoLinkModeStatic(nativeAssets);
globals.logger.printTrace('Dry running native assets for $targetOS done.'); globals.logger.printTrace('Dry running native assets for $targetOS done.');
final Iterable<Asset> assetTargetLocations = _assetTargetLocations(nativeAssets).values; return _assetTargetLocations(nativeAssets).values;
return assetTargetLocations;
} }
/// Builds native assets. /// Builds native assets.
...@@ -77,7 +76,7 @@ Future<List<Uri>> buildNativeAssetsIOS({ ...@@ -77,7 +76,7 @@ Future<List<Uri>> buildNativeAssetsIOS({
required FileSystem fileSystem, required FileSystem fileSystem,
}) async { }) async {
if (!await nativeBuildRequired(buildRunner)) { if (!await nativeBuildRequired(buildRunner)) {
await writeNativeAssetsYaml(<Asset>[], yamlParentDirectory, fileSystem); await writeNativeAssetsYaml(KernelAssets(), yamlParentDirectory, fileSystem);
return <Uri>[]; return <Uri>[];
} }
...@@ -107,7 +106,7 @@ Future<List<Uri>> buildNativeAssetsIOS({ ...@@ -107,7 +106,7 @@ Future<List<Uri>> buildNativeAssetsIOS({
} }
ensureNoLinkModeStatic(nativeAssets); ensureNoLinkModeStatic(nativeAssets);
globals.logger.printTrace('Building native assets for $targets done.'); globals.logger.printTrace('Building native assets for $targets done.');
final Map<AssetPath, List<Asset>> fatAssetTargetLocations = _fatAssetTargetLocations(nativeAssets); final Map<KernelAssetPath, List<Asset>> fatAssetTargetLocations = _fatAssetTargetLocations(nativeAssets);
await _copyNativeAssetsIOS( await _copyNativeAssetsIOS(
buildUri, buildUri,
fatAssetTargetLocations, fatAssetTargetLocations,
...@@ -116,9 +115,9 @@ Future<List<Uri>> buildNativeAssetsIOS({ ...@@ -116,9 +115,9 @@ Future<List<Uri>> buildNativeAssetsIOS({
fileSystem, fileSystem,
); );
final Map<Asset, Asset> assetTargetLocations = _assetTargetLocations(nativeAssets); final Map<Asset, KernelAsset> assetTargetLocations = _assetTargetLocations(nativeAssets);
await writeNativeAssetsYaml( await writeNativeAssetsYaml(
assetTargetLocations.values, KernelAssets(assetTargetLocations.values),
yamlParentDirectory, yamlParentDirectory,
fileSystem, fileSystem,
); );
...@@ -146,40 +145,51 @@ Target _getNativeTarget(DarwinArch darwinArch) { ...@@ -146,40 +145,51 @@ Target _getNativeTarget(DarwinArch darwinArch) {
} }
} }
Map<AssetPath, 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<AssetPath, List<Asset>> result = <AssetPath, List<Asset>>{}; final Map<KernelAssetPath, List<Asset>> result = <KernelAssetPath, List<Asset>>{};
for (final Asset asset in nativeAssets) { for (final Asset asset in nativeAssets) {
final AssetPath path = _targetLocationIOS(asset, alreadyTakenNames).path; final KernelAssetPath path = _targetLocationIOS(asset, alreadyTakenNames).path;
result[path] ??= <Asset>[]; result[path] ??= <Asset>[];
result[path]!.add(asset); result[path]!.add(asset);
} }
return result; return result;
} }
Map<Asset, Asset> _assetTargetLocations(List<Asset> nativeAssets) { Map<Asset, KernelAsset> _assetTargetLocations(List<Asset> nativeAssets) {
final Set<String> alreadyTakenNames = <String>{}; final Set<String> alreadyTakenNames = <String>{};
return <Asset, Asset>{ return <Asset, KernelAsset>{
for (final Asset asset in nativeAssets) for (final Asset asset in nativeAssets)
asset: _targetLocationIOS(asset, alreadyTakenNames), asset: _targetLocationIOS(asset, alreadyTakenNames),
}; };
} }
Asset _targetLocationIOS(Asset asset, Set<String> alreadyTakenNames) { KernelAsset _targetLocationIOS(Asset asset, Set<String> alreadyTakenNames) {
final AssetPath path = asset.path; final AssetPath path = asset.path;
final KernelAssetPath kernelAssetPath;
switch (path) { switch (path) {
case AssetSystemPath _: case AssetSystemPath _:
kernelAssetPath = KernelAssetSystemPath(path.uri);
case AssetInExecutable _: case AssetInExecutable _:
kernelAssetPath = KernelAssetInExecutable();
case AssetInProcess _: case AssetInProcess _:
return asset; kernelAssetPath = KernelAssetInProcess();
case AssetAbsolutePath _: case AssetAbsolutePath _:
final String fileName = path.uri.pathSegments.last; final String fileName = path.uri.pathSegments.last;
return asset.copyWith( kernelAssetPath = KernelAssetAbsolutePath(frameworkUri(
path: AssetAbsolutePath(frameworkUri(fileName, alreadyTakenNames)), fileName,
alreadyTakenNames,
));
default:
throw Exception(
'Unsupported asset path type ${path.runtimeType} in asset $asset',
); );
} }
throw Exception( return KernelAsset(
'Unsupported asset path type ${path.runtimeType} in asset $asset'); id: asset.id,
target: asset.target,
path: kernelAssetPath,
);
} }
/// Copies native assets into a framework per dynamic library. /// Copies native assets into a framework per dynamic library.
...@@ -194,7 +204,7 @@ Asset _targetLocationIOS(Asset asset, Set<String> alreadyTakenNames) { ...@@ -194,7 +204,7 @@ Asset _targetLocationIOS(Asset asset, Set<String> alreadyTakenNames) {
/// in xcode_backend.dart. /// in xcode_backend.dart.
Future<void> _copyNativeAssetsIOS( Future<void> _copyNativeAssetsIOS(
Uri buildUri, Uri buildUri,
Map<AssetPath, List<Asset>> assetTargetLocations, Map<KernelAssetPath, List<Asset>> assetTargetLocations,
String? codesignIdentity, String? codesignIdentity,
BuildMode buildMode, BuildMode buildMode,
FileSystem fileSystem, FileSystem fileSystem,
...@@ -202,9 +212,9 @@ Future<void> _copyNativeAssetsIOS( ...@@ -202,9 +212,9 @@ Future<void> _copyNativeAssetsIOS(
if (assetTargetLocations.isNotEmpty) { if (assetTargetLocations.isNotEmpty) {
globals.logger globals.logger
.printTrace('Copying native assets to ${buildUri.toFilePath()}.'); .printTrace('Copying native assets to ${buildUri.toFilePath()}.');
for (final MapEntry<AssetPath, List<Asset>> assetMapping for (final MapEntry<KernelAssetPath, List<Asset>> assetMapping
in assetTargetLocations.entries) { in assetTargetLocations.entries) {
final Uri target = (assetMapping.key as AssetAbsolutePath).uri; final Uri target = (assetMapping.key as KernelAssetAbsolutePath).uri;
final List<Uri> sources = <Uri>[ final List<Uri> sources = <Uri>[
for (final Asset source in assetMapping.value) for (final Asset source in assetMapping.value)
(source.path as AssetAbsolutePath).uri (source.path as AssetAbsolutePath).uri
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'package:native_assets_builder/native_assets_builder.dart'
hide NativeAssetsBuildRunner;
import 'package:native_assets_cli/native_assets_cli_internal.dart' import 'package:native_assets_cli/native_assets_cli_internal.dart'
hide BuildMode; hide BuildMode;
...@@ -31,7 +33,7 @@ Future<Uri?> dryRunNativeAssetsLinux({ ...@@ -31,7 +33,7 @@ Future<Uri?> dryRunNativeAssetsLinux({
); );
} }
Future<Iterable<Asset>> dryRunNativeAssetsLinuxInternal( Future<Iterable<KernelAsset>> dryRunNativeAssetsLinuxInternal(
FileSystem fileSystem, FileSystem fileSystem,
Uri projectUri, Uri projectUri,
bool flutterTester, bool flutterTester,
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'package:native_assets_builder/native_assets_builder.dart' import 'package:native_assets_builder/native_assets_builder.dart'
show BuildResult, DryRunResult; hide NativeAssetsBuildRunner;
import 'package:native_assets_cli/native_assets_cli_internal.dart' import 'package:native_assets_cli/native_assets_cli_internal.dart'
hide BuildMode; hide BuildMode;
import 'package:native_assets_cli/native_assets_cli_internal.dart' import 'package:native_assets_cli/native_assets_cli_internal.dart'
...@@ -31,12 +31,21 @@ Future<Uri?> dryRunNativeAssetsMacOS({ ...@@ -31,12 +31,21 @@ Future<Uri?> dryRunNativeAssetsMacOS({
} }
final Uri buildUri = nativeAssetsBuildUri(projectUri, OS.macOS); final Uri buildUri = nativeAssetsBuildUri(projectUri, OS.macOS);
final Iterable<Asset> nativeAssetPaths = await dryRunNativeAssetsMacOSInternal(fileSystem, projectUri, flutterTester, buildRunner); final Iterable<KernelAsset> nativeAssetPaths = await dryRunNativeAssetsMacOSInternal(
final Uri nativeAssetsUri = await writeNativeAssetsYaml(nativeAssetPaths, buildUri, fileSystem); fileSystem,
projectUri,
flutterTester,
buildRunner,
);
final Uri nativeAssetsUri = await writeNativeAssetsYaml(
KernelAssets(nativeAssetPaths),
buildUri,
fileSystem,
);
return nativeAssetsUri; return nativeAssetsUri;
} }
Future<Iterable<Asset>> dryRunNativeAssetsMacOSInternal( Future<Iterable<KernelAsset>> dryRunNativeAssetsMacOSInternal(
FileSystem fileSystem, FileSystem fileSystem,
Uri projectUri, Uri projectUri,
bool flutterTester, bool flutterTester,
...@@ -57,9 +66,11 @@ Future<Iterable<Asset>> dryRunNativeAssetsMacOSInternal( ...@@ -57,9 +66,11 @@ Future<Iterable<Asset>> dryRunNativeAssetsMacOSInternal(
ensureNoLinkModeStatic(nativeAssets); ensureNoLinkModeStatic(nativeAssets);
globals.logger.printTrace('Dry running native assets for $targetOS done.'); globals.logger.printTrace('Dry running native assets for $targetOS done.');
final Uri? absolutePath = flutterTester ? buildUri : null; final Uri? absolutePath = flutterTester ? buildUri : null;
final Map<Asset, Asset> assetTargetLocations = _assetTargetLocations(nativeAssets, absolutePath); final Map<Asset, KernelAsset> assetTargetLocations = _assetTargetLocations(
final Iterable<Asset> nativeAssetPaths = assetTargetLocations.values; nativeAssets,
return nativeAssetPaths; absolutePath,
);
return assetTargetLocations.values;
} }
/// Builds native assets. /// Builds native assets.
...@@ -82,14 +93,22 @@ Future<(Uri? nativeAssetsYaml, List<Uri> dependencies)> buildNativeAssetsMacOS({ ...@@ -82,14 +93,22 @@ Future<(Uri? nativeAssetsYaml, List<Uri> dependencies)> buildNativeAssetsMacOS({
const OS targetOS = OS.macOS; const OS targetOS = OS.macOS;
final Uri buildUri = nativeAssetsBuildUri(projectUri, targetOS); final Uri buildUri = nativeAssetsBuildUri(projectUri, targetOS);
if (!await nativeBuildRequired(buildRunner)) { if (!await nativeBuildRequired(buildRunner)) {
final Uri nativeAssetsYaml = await writeNativeAssetsYaml(<Asset>[], yamlParentDirectory ?? buildUri, fileSystem); final Uri nativeAssetsYaml = await writeNativeAssetsYaml(
KernelAssets(),
yamlParentDirectory ?? buildUri,
fileSystem,
);
return (nativeAssetsYaml, <Uri>[]); return (nativeAssetsYaml, <Uri>[]);
} }
final List<Target> targets = darwinArchs != null ? darwinArchs.map(_getNativeTarget).toList() : <Target>[Target.current]; final List<Target> targets = darwinArchs != null
final native_assets_cli.BuildMode buildModeCli = nativeAssetsBuildMode(buildMode); ? darwinArchs.map(_getNativeTarget).toList()
: <Target>[Target.current];
final native_assets_cli.BuildMode buildModeCli =
nativeAssetsBuildMode(buildMode);
globals.logger.printTrace('Building native assets for $targets $buildModeCli.'); globals.logger
.printTrace('Building native assets for $targets $buildModeCli.');
final List<Asset> nativeAssets = <Asset>[]; final List<Asset> nativeAssets = <Asset>[];
final Set<Uri> dependencies = <Uri>{}; final Set<Uri> dependencies = <Uri>{};
for (final Target target in targets) { for (final Target target in targets) {
...@@ -108,8 +127,10 @@ Future<(Uri? nativeAssetsYaml, List<Uri> dependencies)> buildNativeAssetsMacOS({ ...@@ -108,8 +127,10 @@ Future<(Uri? nativeAssetsYaml, List<Uri> dependencies)> buildNativeAssetsMacOS({
ensureNoLinkModeStatic(nativeAssets); ensureNoLinkModeStatic(nativeAssets);
globals.logger.printTrace('Building native assets for $targets done.'); globals.logger.printTrace('Building native assets for $targets done.');
final Uri? absolutePath = flutterTester ? buildUri : null; final Uri? absolutePath = flutterTester ? buildUri : null;
final Map<Asset, Asset> assetTargetLocations = _assetTargetLocations(nativeAssets, absolutePath); final Map<Asset, KernelAsset> assetTargetLocations =
final Map<AssetPath, List<Asset>> fatAssetTargetLocations = _fatAssetTargetLocations(nativeAssets, absolutePath); _assetTargetLocations(nativeAssets, absolutePath);
final Map<KernelAssetPath, List<Asset>> fatAssetTargetLocations =
_fatAssetTargetLocations(nativeAssets, absolutePath);
if (flutterTester) { if (flutterTester) {
await _copyNativeAssetsMacOSFlutterTester( await _copyNativeAssetsMacOSFlutterTester(
buildUri, buildUri,
...@@ -127,7 +148,11 @@ Future<(Uri? nativeAssetsYaml, List<Uri> dependencies)> buildNativeAssetsMacOS({ ...@@ -127,7 +148,11 @@ Future<(Uri? nativeAssetsYaml, List<Uri> dependencies)> buildNativeAssetsMacOS({
fileSystem, fileSystem,
); );
} }
final Uri nativeAssetsUri = await writeNativeAssetsYaml(assetTargetLocations.values, yamlParentDirectory ?? buildUri, fileSystem); final Uri nativeAssetsUri = await writeNativeAssetsYaml(
KernelAssets(assetTargetLocations.values),
yamlParentDirectory ?? buildUri,
fileSystem,
);
return (nativeAssetsUri, dependencies.toList()); return (nativeAssetsUri, dependencies.toList());
} }
...@@ -143,14 +168,15 @@ Target _getNativeTarget(DarwinArch darwinArch) { ...@@ -143,14 +168,15 @@ Target _getNativeTarget(DarwinArch darwinArch) {
} }
} }
Map<AssetPath, List<Asset>> _fatAssetTargetLocations( Map<KernelAssetPath, List<Asset>> _fatAssetTargetLocations(
List<Asset> nativeAssets, List<Asset> nativeAssets,
Uri? absolutePath, Uri? absolutePath,
) { ) {
final Set<String> alreadyTakenNames = <String>{}; final Set<String> alreadyTakenNames = <String>{};
final Map<AssetPath, List<Asset>> result = <AssetPath, List<Asset>>{}; final Map<KernelAssetPath, List<Asset>> result =
<KernelAssetPath, List<Asset>>{};
for (final Asset asset in nativeAssets) { for (final Asset asset in nativeAssets) {
final AssetPath path = _targetLocationMacOS( final KernelAssetPath path = _targetLocationMacOS(
asset, asset,
absolutePath, absolutePath,
alreadyTakenNames, alreadyTakenNames,
...@@ -161,28 +187,31 @@ Map<AssetPath, List<Asset>> _fatAssetTargetLocations( ...@@ -161,28 +187,31 @@ Map<AssetPath, List<Asset>> _fatAssetTargetLocations(
return result; return result;
} }
Map<Asset, Asset> _assetTargetLocations( Map<Asset, KernelAsset> _assetTargetLocations(
List<Asset> nativeAssets, List<Asset> nativeAssets,
Uri? absolutePath, Uri? absolutePath,
) { ) {
final Set<String> alreadyTakenNames = <String>{}; final Set<String> alreadyTakenNames = <String>{};
return <Asset, Asset>{ return <Asset, KernelAsset>{
for (final Asset asset in nativeAssets) for (final Asset asset in nativeAssets)
asset: _targetLocationMacOS(asset, absolutePath, alreadyTakenNames), asset: _targetLocationMacOS(asset, absolutePath, alreadyTakenNames),
}; };
} }
Asset _targetLocationMacOS( KernelAsset _targetLocationMacOS(
Asset asset, Asset asset,
Uri? absolutePath, Uri? absolutePath,
Set<String> alreadyTakenNames, Set<String> alreadyTakenNames,
) { ) {
final AssetPath path = asset.path; final AssetPath path = asset.path;
final KernelAssetPath kernelAssetPath;
switch (path) { switch (path) {
case AssetSystemPath _: case AssetSystemPath _:
kernelAssetPath = KernelAssetSystemPath(path.uri);
case AssetInExecutable _: case AssetInExecutable _:
kernelAssetPath = KernelAssetInExecutable();
case AssetInProcess _: case AssetInProcess _:
return asset; kernelAssetPath = KernelAssetInProcess();
case AssetAbsolutePath _: case AssetAbsolutePath _:
final String fileName = path.uri.pathSegments.last; final String fileName = path.uri.pathSegments.last;
Uri uri; Uri uri;
...@@ -194,11 +223,18 @@ Asset _targetLocationMacOS( ...@@ -194,11 +223,18 @@ Asset _targetLocationMacOS(
// "relative" in the context of native assets would be relative to the // "relative" in the context of native assets would be relative to the
// kernel or aot snapshot. // kernel or aot snapshot.
uri = frameworkUri(fileName, alreadyTakenNames); uri = frameworkUri(fileName, alreadyTakenNames);
} }
return asset.copyWith(path: AssetAbsolutePath(uri)); kernelAssetPath = KernelAssetAbsolutePath(uri);
default:
throw Exception(
'Unsupported asset path type ${path.runtimeType} in asset $asset',
);
} }
throw Exception('Unsupported asset path type ${path.runtimeType} in asset $asset'); return KernelAsset(
id: asset.id,
target: asset.target,
path: kernelAssetPath,
);
} }
/// Copies native assets into a framework per dynamic library. /// Copies native assets into a framework per dynamic library.
...@@ -216,15 +252,18 @@ Asset _targetLocationMacOS( ...@@ -216,15 +252,18 @@ Asset _targetLocationMacOS(
/// in macos_assemble.sh. /// in macos_assemble.sh.
Future<void> _copyNativeAssetsMacOS( Future<void> _copyNativeAssetsMacOS(
Uri buildUri, Uri buildUri,
Map<AssetPath, List<Asset>> assetTargetLocations, Map<KernelAssetPath, List<Asset>> assetTargetLocations,
String? codesignIdentity, String? codesignIdentity,
BuildMode buildMode, BuildMode buildMode,
FileSystem fileSystem, FileSystem fileSystem,
) async { ) async {
if (assetTargetLocations.isNotEmpty) { if (assetTargetLocations.isNotEmpty) {
globals.logger.printTrace('Copying native assets to ${buildUri.toFilePath()}.'); globals.logger.printTrace(
for (final MapEntry<AssetPath, List<Asset>> assetMapping in assetTargetLocations.entries) { 'Copying native assets to ${buildUri.toFilePath()}.',
final Uri target = (assetMapping.key as AssetAbsolutePath).uri; );
for (final MapEntry<KernelAssetPath, List<Asset>> assetMapping
in assetTargetLocations.entries) {
final Uri target = (assetMapping.key as KernelAssetAbsolutePath).uri;
final List<Uri> sources = <Uri>[ final List<Uri> sources = <Uri>[
for (final Asset source in assetMapping.value) for (final Asset source in assetMapping.value)
(source.path as AssetAbsolutePath).uri, (source.path as AssetAbsolutePath).uri,
...@@ -273,7 +312,6 @@ Future<void> _copyNativeAssetsMacOS( ...@@ -273,7 +312,6 @@ Future<void> _copyNativeAssetsMacOS(
} }
} }
/// Copies native assets for flutter tester. /// Copies native assets for flutter tester.
/// ///
/// For `flutter run -release` a multi-architecture solution is needed. So, /// For `flutter run -release` a multi-architecture solution is needed. So,
...@@ -284,15 +322,18 @@ Future<void> _copyNativeAssetsMacOS( ...@@ -284,15 +322,18 @@ Future<void> _copyNativeAssetsMacOS(
/// Code signing is also done here. /// Code signing is also done here.
Future<void> _copyNativeAssetsMacOSFlutterTester( Future<void> _copyNativeAssetsMacOSFlutterTester(
Uri buildUri, Uri buildUri,
Map<AssetPath, List<Asset>> assetTargetLocations, Map<KernelAssetPath, List<Asset>> assetTargetLocations,
String? codesignIdentity, String? codesignIdentity,
BuildMode buildMode, BuildMode buildMode,
FileSystem fileSystem, FileSystem fileSystem,
) async { ) async {
if (assetTargetLocations.isNotEmpty) { if (assetTargetLocations.isNotEmpty) {
globals.logger.printTrace('Copying native assets to ${buildUri.toFilePath()}.'); globals.logger.printTrace(
for (final MapEntry<AssetPath, List<Asset>> assetMapping in assetTargetLocations.entries) { 'Copying native assets to ${buildUri.toFilePath()}.',
final Uri target = (assetMapping.key as AssetAbsolutePath).uri; );
for (final MapEntry<KernelAssetPath, List<Asset>> assetMapping
in assetTargetLocations.entries) {
final Uri target = (assetMapping.key as KernelAssetAbsolutePath).uri;
final List<Uri> sources = <Uri>[ final List<Uri> sources = <Uri>[
for (final Asset source in assetMapping.value) for (final Asset source in assetMapping.value)
(source.path as AssetAbsolutePath).uri, (source.path as AssetAbsolutePath).uri,
......
...@@ -195,7 +195,7 @@ class NativeAssetsBuildRunnerImpl implements NativeAssetsBuildRunner { ...@@ -195,7 +195,7 @@ class NativeAssetsBuildRunnerImpl implements NativeAssetsBuildRunner {
/// Write [assets] to `native_assets.yaml` in [yamlParentDirectory]. /// Write [assets] to `native_assets.yaml` in [yamlParentDirectory].
Future<Uri> writeNativeAssetsYaml( Future<Uri> writeNativeAssetsYaml(
Iterable<Asset> assets, KernelAssets assets,
Uri yamlParentDirectory, Uri yamlParentDirectory,
FileSystem fileSystem, FileSystem fileSystem,
) async { ) async {
...@@ -295,7 +295,7 @@ Future<void> ensureNoNativeAssetsOrOsIsSupported( ...@@ -295,7 +295,7 @@ Future<void> ensureNoNativeAssetsOrOsIsSupported(
/// ///
/// Therefore, ensure all `build.dart` scripts return only dynamic libraries. /// Therefore, ensure all `build.dart` scripts return only dynamic libraries.
void ensureNoLinkModeStatic(List<Asset> nativeAssets) { void ensureNoLinkModeStatic(List<Asset> nativeAssets) {
final Iterable<Asset> staticAssets = nativeAssets.whereLinkMode(LinkMode.static); final Iterable<Asset> staticAssets = nativeAssets.where((Asset e) => e.linkMode == LinkMode.static);
if (staticAssets.isNotEmpty) { if (staticAssets.isNotEmpty) {
final String assetIds = staticAssets.map((Asset a) => a.id).toSet().join(', '); final String assetIds = staticAssets.map((Asset a) => a.id).toSet().join(', ');
throwToolExit( throwToolExit(
...@@ -453,7 +453,7 @@ Future<Uri?> dryRunNativeAssetsMultipleOSes({ ...@@ -453,7 +453,7 @@ Future<Uri?> dryRunNativeAssetsMultipleOSes({
} }
final Uri buildUri = buildUriMultiple(projectUri); final Uri buildUri = buildUriMultiple(projectUri);
final Iterable<Asset> nativeAssetPaths = <Asset>[ final Iterable<KernelAsset> nativeAssetPaths = <KernelAsset>[
if (targetPlatforms.contains(build_info.TargetPlatform.darwin) || if (targetPlatforms.contains(build_info.TargetPlatform.darwin) ||
(targetPlatforms.contains(build_info.TargetPlatform.tester) && OS.current == OS.macOS)) (targetPlatforms.contains(build_info.TargetPlatform.tester) && OS.current == OS.macOS))
...await dryRunNativeAssetsMacOSInternal( ...await dryRunNativeAssetsMacOSInternal(
...@@ -497,7 +497,11 @@ Future<Uri?> dryRunNativeAssetsMultipleOSes({ ...@@ -497,7 +497,11 @@ Future<Uri?> dryRunNativeAssetsMultipleOSes({
buildRunner, buildRunner,
), ),
]; ];
final Uri nativeAssetsUri = await writeNativeAssetsYaml(nativeAssetPaths, buildUri, fileSystem); final Uri nativeAssetsUri = await writeNativeAssetsYaml(
KernelAssets(nativeAssetPaths),
buildUri,
fileSystem,
);
return nativeAssetsUri; return nativeAssetsUri;
} }
...@@ -524,7 +528,7 @@ Future<Uri?> dryRunNativeAssetsSingleArchitecture({ ...@@ -524,7 +528,7 @@ Future<Uri?> dryRunNativeAssetsSingleArchitecture({
} }
final Uri buildUri = nativeAssetsBuildUri(projectUri, os); final Uri buildUri = nativeAssetsBuildUri(projectUri, os);
final Iterable<Asset> nativeAssetPaths = await dryRunNativeAssetsSingleArchitectureInternal( final Iterable<KernelAsset> nativeAssetPaths = await dryRunNativeAssetsSingleArchitectureInternal(
fileSystem, fileSystem,
projectUri, projectUri,
flutterTester, flutterTester,
...@@ -532,14 +536,14 @@ Future<Uri?> dryRunNativeAssetsSingleArchitecture({ ...@@ -532,14 +536,14 @@ Future<Uri?> dryRunNativeAssetsSingleArchitecture({
os, os,
); );
final Uri nativeAssetsUri = await writeNativeAssetsYaml( final Uri nativeAssetsUri = await writeNativeAssetsYaml(
nativeAssetPaths, KernelAssets(nativeAssetPaths.toList()),
buildUri, buildUri,
fileSystem, fileSystem,
); );
return nativeAssetsUri; return nativeAssetsUri;
} }
Future<Iterable<Asset>> dryRunNativeAssetsSingleArchitectureInternal( Future<Iterable<KernelAsset>> dryRunNativeAssetsSingleArchitectureInternal(
FileSystem fileSystem, FileSystem fileSystem,
Uri projectUri, Uri projectUri,
bool flutterTester, bool flutterTester,
...@@ -561,12 +565,11 @@ Future<Iterable<Asset>> dryRunNativeAssetsSingleArchitectureInternal( ...@@ -561,12 +565,11 @@ Future<Iterable<Asset>> dryRunNativeAssetsSingleArchitectureInternal(
ensureNoLinkModeStatic(nativeAssets); ensureNoLinkModeStatic(nativeAssets);
globals.logger.printTrace('Dry running native assets for $targetOS done.'); globals.logger.printTrace('Dry running native assets for $targetOS done.');
final Uri? absolutePath = flutterTester ? buildUri : null; final Uri? absolutePath = flutterTester ? buildUri : null;
final Map<Asset, Asset> assetTargetLocations = _assetTargetLocationsSingleArchitecture( final Map<Asset, KernelAsset> assetTargetLocations = _assetTargetLocationsSingleArchitecture(
nativeAssets, nativeAssets,
absolutePath, absolutePath,
); );
final Iterable<Asset> nativeAssetPaths = assetTargetLocations.values; return assetTargetLocations.values;
return nativeAssetPaths;
} }
/// Builds native assets. /// Builds native assets.
...@@ -595,7 +598,7 @@ Future<(Uri? nativeAssetsYaml, List<Uri> dependencies)> buildNativeAssetsSingleA ...@@ -595,7 +598,7 @@ Future<(Uri? nativeAssetsYaml, List<Uri> dependencies)> buildNativeAssetsSingleA
} }
if (!await nativeBuildRequired(buildRunner)) { if (!await nativeBuildRequired(buildRunner)) {
final Uri nativeAssetsYaml = await writeNativeAssetsYaml( final Uri nativeAssetsYaml = await writeNativeAssetsYaml(
<Asset>[], KernelAssets(),
yamlParentDirectory ?? buildUri, yamlParentDirectory ?? buildUri,
fileSystem, fileSystem,
); );
...@@ -619,7 +622,7 @@ Future<(Uri? nativeAssetsYaml, List<Uri> dependencies)> buildNativeAssetsSingleA ...@@ -619,7 +622,7 @@ Future<(Uri? nativeAssetsYaml, List<Uri> dependencies)> buildNativeAssetsSingleA
ensureNoLinkModeStatic(nativeAssets); ensureNoLinkModeStatic(nativeAssets);
globals.logger.printTrace('Building native assets for $target done.'); globals.logger.printTrace('Building native assets for $target done.');
final Uri? absolutePath = flutterTester ? buildUri : null; final Uri? absolutePath = flutterTester ? buildUri : null;
final Map<Asset, Asset> assetTargetLocations = _assetTargetLocationsSingleArchitecture(nativeAssets, absolutePath); final Map<Asset, KernelAsset> assetTargetLocations = _assetTargetLocationsSingleArchitecture(nativeAssets, absolutePath);
await _copyNativeAssetsSingleArchitecture( await _copyNativeAssetsSingleArchitecture(
buildUri, buildUri,
assetTargetLocations, assetTargetLocations,
...@@ -627,18 +630,18 @@ Future<(Uri? nativeAssetsYaml, List<Uri> dependencies)> buildNativeAssetsSingleA ...@@ -627,18 +630,18 @@ Future<(Uri? nativeAssetsYaml, List<Uri> dependencies)> buildNativeAssetsSingleA
fileSystem, fileSystem,
); );
final Uri nativeAssetsUri = await writeNativeAssetsYaml( final Uri nativeAssetsUri = await writeNativeAssetsYaml(
assetTargetLocations.values, KernelAssets(assetTargetLocations.values.toList()),
yamlParentDirectory ?? buildUri, yamlParentDirectory ?? buildUri,
fileSystem, fileSystem,
); );
return (nativeAssetsUri, dependencies.toList()); return (nativeAssetsUri, dependencies.toList());
} }
Map<Asset, Asset> _assetTargetLocationsSingleArchitecture( Map<Asset, KernelAsset> _assetTargetLocationsSingleArchitecture(
List<Asset> nativeAssets, List<Asset> nativeAssets,
Uri? absolutePath, Uri? absolutePath,
) { ) {
return <Asset, Asset>{ return <Asset, KernelAsset>{
for (final Asset asset in nativeAssets) for (final Asset asset in nativeAssets)
asset: _targetLocationSingleArchitecture( asset: _targetLocationSingleArchitecture(
asset, asset,
...@@ -647,13 +650,16 @@ Map<Asset, Asset> _assetTargetLocationsSingleArchitecture( ...@@ -647,13 +650,16 @@ Map<Asset, Asset> _assetTargetLocationsSingleArchitecture(
}; };
} }
Asset _targetLocationSingleArchitecture(Asset asset, Uri? absolutePath) { KernelAsset _targetLocationSingleArchitecture(Asset asset, Uri? absolutePath) {
final AssetPath path = asset.path; final AssetPath path = asset.path;
final KernelAssetPath kernelAssetPath;
switch (path) { switch (path) {
case AssetSystemPath _: case AssetSystemPath _:
kernelAssetPath = KernelAssetSystemPath(path.uri);
case AssetInExecutable _: case AssetInExecutable _:
kernelAssetPath = KernelAssetInExecutable();
case AssetInProcess _: case AssetInProcess _:
return asset; kernelAssetPath = KernelAssetInProcess();
case AssetAbsolutePath _: case AssetAbsolutePath _:
final String fileName = path.uri.pathSegments.last; final String fileName = path.uri.pathSegments.last;
Uri uri; Uri uri;
...@@ -666,9 +672,17 @@ Asset _targetLocationSingleArchitecture(Asset asset, Uri? absolutePath) { ...@@ -666,9 +672,17 @@ Asset _targetLocationSingleArchitecture(Asset asset, Uri? absolutePath) {
// kernel or aot snapshot. // kernel or aot snapshot.
uri = Uri(path: fileName); uri = Uri(path: fileName);
} }
return asset.copyWith(path: AssetAbsolutePath(uri)); kernelAssetPath = KernelAssetAbsolutePath(uri);
default:
throw Exception(
'Unsupported asset path type ${path.runtimeType} in asset $asset',
);
} }
throw Exception('Unsupported asset path type ${path.runtimeType} in asset $asset'); return KernelAsset(
id: asset.id,
target: asset.target,
path: kernelAssetPath,
);
} }
/// Extract the [Target] from a [TargetPlatform]. /// Extract the [Target] from a [TargetPlatform].
...@@ -702,7 +716,7 @@ Target _getNativeTarget(build_info.TargetPlatform targetPlatform) { ...@@ -702,7 +716,7 @@ Target _getNativeTarget(build_info.TargetPlatform targetPlatform) {
Future<void> _copyNativeAssetsSingleArchitecture( Future<void> _copyNativeAssetsSingleArchitecture(
Uri buildUri, Uri buildUri,
Map<Asset, Asset> assetTargetLocations, Map<Asset, KernelAsset> assetTargetLocations,
build_info.BuildMode buildMode, build_info.BuildMode buildMode,
FileSystem fileSystem, FileSystem fileSystem,
) async { ) async {
...@@ -712,9 +726,9 @@ Future<void> _copyNativeAssetsSingleArchitecture( ...@@ -712,9 +726,9 @@ Future<void> _copyNativeAssetsSingleArchitecture(
if (!buildDir.existsSync()) { if (!buildDir.existsSync()) {
buildDir.createSync(recursive: true); buildDir.createSync(recursive: true);
} }
for (final MapEntry<Asset, Asset> assetMapping in assetTargetLocations.entries) { for (final MapEntry<Asset, KernelAsset> assetMapping in assetTargetLocations.entries) {
final Uri source = (assetMapping.key.path as AssetAbsolutePath).uri; final Uri source = (assetMapping.key.path as AssetAbsolutePath).uri;
final Uri target = (assetMapping.value.path as AssetAbsolutePath).uri; final Uri target = (assetMapping.value.path as KernelAssetAbsolutePath).uri;
final Uri targetUri = buildUri.resolveUri(target); final Uri targetUri = buildUri.resolveUri(target);
final String targetFullPath = targetUri.toFilePath(); final String targetFullPath = targetUri.toFilePath();
await fileSystem.file(source).copy(targetFullPath); await fileSystem.file(source).copy(targetFullPath);
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'package:native_assets_builder/native_assets_builder.dart'
hide NativeAssetsBuildRunner;
import 'package:native_assets_cli/native_assets_cli_internal.dart' import 'package:native_assets_cli/native_assets_cli_internal.dart'
hide BuildMode; hide BuildMode;
...@@ -30,7 +32,7 @@ Future<Uri?> dryRunNativeAssetsWindows({ ...@@ -30,7 +32,7 @@ Future<Uri?> dryRunNativeAssetsWindows({
); );
} }
Future<Iterable<Asset>> dryRunNativeAssetsWindowsInternal( Future<Iterable<KernelAsset>> dryRunNativeAssetsWindowsInternal(
FileSystem fileSystem, FileSystem fileSystem,
Uri projectUri, Uri projectUri,
bool flutterTester, bool flutterTester,
......
...@@ -55,7 +55,7 @@ dependencies: ...@@ -55,7 +55,7 @@ dependencies:
cli_config: 0.1.2 cli_config: 0.1.2
graphs: 2.3.1 graphs: 2.3.1
native_assets_builder: 0.3.2 native_assets_builder: 0.5.0
native_assets_cli: 0.4.2 native_assets_cli: 0.4.2
# We depend on very specific internal implementation details of the # We depend on very specific internal implementation details of the
...@@ -118,4 +118,4 @@ dartdoc: ...@@ -118,4 +118,4 @@ dartdoc:
# Exclude this package from the hosted API docs. # Exclude this package from the hosted API docs.
nodoc: true nodoc: true
# PUBSPEC CHECKSUM: 980d # PUBSPEC CHECKSUM: a00d
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment