[native assets] Roll dependencies (#155432)

Rolls native deps to the latest version, and cleans up deprecated field from template.

Tests:

* All the unit and integration tests for native assets. The template and dependencies are exercised in the integration test.

Since `package:native_assets_builder` already checks for having no static libraries as output, the custom check in flutter_tools is removed. The tests stubbing out the native assets builder exercising the custom check are also removed. (The integration tests now check for the error message from the native assets builder.)
This commit is contained in:
Daco Harkes 2024-09-24 09:19:09 +02:00 committed by GitHub
parent b411047401
commit aef2758716
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 13 additions and 171 deletions

View File

@ -8,8 +8,8 @@ environment:
dependencies: dependencies:
cli_config: 0.2.0 cli_config: 0.2.0
logging: 1.2.0 logging: 1.2.0
native_assets_cli: 0.7.3 native_assets_cli: 0.8.0
native_toolchain_c: 0.5.3 native_toolchain_c: 0.5.4
_fe_analyzer_shared: 74.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" _fe_analyzer_shared: 74.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
analyzer: 6.9.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" analyzer: 6.9.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
@ -68,4 +68,4 @@ dev_dependencies:
quiver: 3.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" quiver: 3.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
yaml_edit: 2.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml_edit: 2.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
# PUBSPEC CHECKSUM: 43c9 # PUBSPEC CHECKSUM: c1c8

View File

@ -59,8 +59,7 @@ Future<Iterable<KernelAsset>> dryRunNativeAssetsAndroidInternal(
ensureNativeAssetsBuildDryRunSucceed(buildDryRunResult); ensureNativeAssetsBuildDryRunSucceed(buildDryRunResult);
// No link hooks in JIT mode. // No link hooks in JIT mode.
final List<AssetImpl> nativeAssets = buildDryRunResult.assets; final List<AssetImpl> nativeAssets = buildDryRunResult.assets;
ensureNoLinkModeStatic(nativeAssets); globals.logger.printTrace('Dry running native assets for $targetOS done.');
globals.logger.printTrace('Dry running native assets for $targetOS done.');
final Map<AssetImpl, KernelAsset> assetTargetLocations = final Map<AssetImpl, KernelAsset> assetTargetLocations =
_assetTargetLocations(nativeAssets); _assetTargetLocations(nativeAssets);
return assetTargetLocations.values; return assetTargetLocations.values;
@ -128,7 +127,6 @@ Future<(Uri? nativeAssetsYaml, List<Uri> dependencies)>
dependencies.addAll(linkResult.dependencies); dependencies.addAll(linkResult.dependencies);
} }
} }
ensureNoLinkModeStatic(nativeAssets);
globals.logger.printTrace('Building native assets for $targets done.'); globals.logger.printTrace('Building native assets for $targets done.');
final Map<AssetImpl, KernelAsset> assetTargetLocations = final Map<AssetImpl, KernelAsset> assetTargetLocations =
_assetTargetLocations(nativeAssets); _assetTargetLocations(nativeAssets);

View File

@ -56,7 +56,6 @@ Future<Iterable<KernelAsset>> dryRunNativeAssetsIOSInternal(
ensureNativeAssetsBuildDryRunSucceed(buildDryRunResult); ensureNativeAssetsBuildDryRunSucceed(buildDryRunResult);
// No link hooks in JIT. // No link hooks in JIT.
final List<AssetImpl> nativeAssets = buildDryRunResult.assets; final List<AssetImpl> nativeAssets = buildDryRunResult.assets;
ensureNoLinkModeStatic(nativeAssets);
globals.logger.printTrace('Dry running native assets for $targetOS done.'); globals.logger.printTrace('Dry running native assets for $targetOS done.');
return _assetTargetLocations(nativeAssets).values; return _assetTargetLocations(nativeAssets).values;
} }
@ -122,7 +121,6 @@ Future<List<Uri>> buildNativeAssetsIOS({
dependencies.addAll(linkResult.dependencies); dependencies.addAll(linkResult.dependencies);
} }
} }
ensureNoLinkModeStatic(nativeAssets);
globals.logger.printTrace('Building native assets for $targets done.'); globals.logger.printTrace('Building native assets for $targets done.');
final Map<KernelAssetPath, List<AssetImpl>> fatAssetTargetLocations = final Map<KernelAssetPath, List<AssetImpl>> fatAssetTargetLocations =
_fatAssetTargetLocations(nativeAssets); _fatAssetTargetLocations(nativeAssets);

View File

@ -61,7 +61,6 @@ Future<Iterable<KernelAsset>> dryRunNativeAssetsMacOSInternal(
ensureNativeAssetsBuildDryRunSucceed(buildDryRunResult); ensureNativeAssetsBuildDryRunSucceed(buildDryRunResult);
// No link hooks in JIT mode. // No link hooks in JIT mode.
final List<AssetImpl> nativeAssets = buildDryRunResult.assets; final List<AssetImpl> nativeAssets = buildDryRunResult.assets;
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<AssetImpl, KernelAsset> assetTargetLocations = final Map<AssetImpl, KernelAsset> assetTargetLocations =
@ -143,7 +142,6 @@ Future<(Uri? nativeAssetsYaml, List<Uri> dependencies)> buildNativeAssetsMacOS({
dependencies.addAll(linkResult.dependencies); dependencies.addAll(linkResult.dependencies);
} }
} }
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<AssetImpl, KernelAsset> assetTargetLocations = final Map<AssetImpl, KernelAsset> assetTargetLocations =

View File

@ -382,27 +382,6 @@ Future<void> ensureNoNativeAssetsOrOsIsSupported(
); );
} }
/// Ensure all native assets have a linkmode declared to be dynamic loading.
///
/// In JIT, the link mode must always be dynamic linking.
/// In AOT, the static linking has not yet been implemented in Dart:
/// https://github.com/dart-lang/sdk/issues/49418.
///
/// Therefore, ensure all `build.dart` scripts return only dynamic libraries.
void ensureNoLinkModeStatic(List<AssetImpl> nativeAssets) {
final Iterable<AssetImpl> staticAssets = nativeAssets.where((AssetImpl e) =>
e is NativeCodeAssetImpl && e.linkMode == StaticLinkingImpl());
if (staticAssets.isNotEmpty) {
final String assetIds =
staticAssets.map((AssetImpl a) => a.id).toSet().join(', ');
throwToolExit(
'Native asset(s) $assetIds have their link mode set to static, '
'but this is not yet supported. '
'For more info see https://github.com/dart-lang/sdk/issues/49418.',
);
}
}
/// This should be the same for different archs, debug/release, etc. /// This should be the same for different archs, debug/release, etc.
/// It should work for all macOS. /// It should work for all macOS.
Uri nativeAssetsBuildUri(Uri projectUri, OS os) { Uri nativeAssetsBuildUri(Uri projectUri, OS os) {
@ -665,7 +644,6 @@ Future<Iterable<KernelAsset>> dryRunNativeAssetsSingleArchitectureInternal(
ensureNativeAssetsBuildDryRunSucceed(buildDryRunResult); ensureNativeAssetsBuildDryRunSucceed(buildDryRunResult);
// No link hooks in JIT mode. // No link hooks in JIT mode.
final List<AssetImpl> nativeAssets = buildDryRunResult.assets; final List<AssetImpl> nativeAssets = buildDryRunResult.assets;
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<AssetImpl, KernelAsset> assetTargetLocations = final Map<AssetImpl, KernelAsset> assetTargetLocations =
@ -744,7 +722,6 @@ Future<(Uri? nativeAssetsYaml, List<Uri> dependencies)> buildNativeAssetsSingleA
...buildResult.dependencies, ...buildResult.dependencies,
if (linkingEnabled) ...linkResult.dependencies, if (linkingEnabled) ...linkResult.dependencies,
}; };
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<AssetImpl, KernelAsset> assetTargetLocations = final Map<AssetImpl, KernelAsset> assetTargetLocations =

View File

@ -22,8 +22,8 @@ const Map<String, String> kManuallyPinnedDependencies = <String, String>{
// Add pinned packages here. Please leave a comment explaining why. // Add pinned packages here. Please leave a comment explaining why.
'flutter_gallery_assets': '1.0.2', // Tests depend on the exact version. 'flutter_gallery_assets': '1.0.2', // Tests depend on the exact version.
'flutter_template_images': '4.2.0', // Must always exactly match flutter_tools template. 'flutter_template_images': '4.2.0', // Must always exactly match flutter_tools template.
'native_assets_builder': '0.8.2', // Under active development with breaking changes until 1.0.0. Manually rolled by @dcharkes. 'native_assets_builder': '0.8.3', // Under active development with breaking changes until 1.0.0. Manually rolled by @dcharkes.
'native_assets_cli': '0.7.3', // Under active development with breaking changes until 1.0.0. Manually rolled by @dcharkes. 'native_assets_cli': '0.8.0', // Under active development with breaking changes until 1.0.0. Manually rolled by @dcharkes.
'material_color_utilities': '0.11.1', // Keep pinned to latest until 1.0.0. 'material_color_utilities': '0.11.1', // Keep pinned to latest until 1.0.0.
'leak_tracker': '10.0.7', // https://github.com/flutter/devtools/issues/3951 'leak_tracker': '10.0.7', // https://github.com/flutter/devtools/issues/3951
'leak_tracker_testing': '3.0.1', // https://github.com/flutter/devtools/issues/3951 'leak_tracker_testing': '3.0.1', // https://github.com/flutter/devtools/issues/3951

View File

@ -56,8 +56,8 @@ dependencies:
cli_config: 0.2.0 cli_config: 0.2.0
graphs: 2.3.2 graphs: 2.3.2
native_assets_builder: 0.8.2 native_assets_builder: 0.8.3
native_assets_cli: 0.7.3 native_assets_cli: 0.8.0
# We depend on very specific internal implementation details of the # We depend on very specific internal implementation details of the
# 'test' package, which change between versions, so when upgrading # 'test' package, which change between versions, so when upgrading
@ -122,4 +122,4 @@ dartdoc:
# Exclude this package from the hosted API docs. # Exclude this package from the hosted API docs.
nodoc: true nodoc: true
# PUBSPEC CHECKSUM: 40f5 # PUBSPEC CHECKSUM: 01f4

View File

@ -2,8 +2,6 @@ import 'package:native_toolchain_c/native_toolchain_c.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:native_assets_cli/native_assets_cli.dart'; import 'package:native_assets_cli/native_assets_cli.dart';
const packageName = '{{projectName}}';
void main(List<String> args) async { void main(List<String> args) async {
await build(args, (config, output) async { await build(args, (config, output) async {
final packageName = config.packageName; final packageName = config.packageName;
@ -13,7 +11,6 @@ void main(List<String> args) async {
sources: [ sources: [
'src/$packageName.c', 'src/$packageName.c',
], ],
dartBuildFiles: ['hook/build.dart'],
); );
await cbuilder.run( await cbuilder.run(
config: config, config: config,

View File

@ -9,8 +9,8 @@ environment:
dependencies: dependencies:
cli_config: ^0.2.0 cli_config: ^0.2.0
logging: ^1.2.0 logging: ^1.2.0
native_assets_cli: ^0.7.3 native_assets_cli: ^0.8.0
native_toolchain_c: ^0.5.3 native_toolchain_c: ^0.5.4
dev_dependencies: dev_dependencies:
ffi: ^2.1.3 ffi: ^2.1.3

View File

@ -340,49 +340,6 @@ void main() {
} }
} }
testUsingContext('static libs not supported', overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(isNativeAssetsEnabled: true),
ProcessManager: () => FakeProcessManager.empty(),
}, () async {
final File packageConfig = environment.projectDir.childFile('.dart_tool/package_config.json');
await packageConfig.parent.create();
await packageConfig.create();
expect(
() => dryRunNativeAssetsLinux(
projectUri: projectUri,
fileSystem: fileSystem,
buildRunner: FakeNativeAssetsBuildRunner(
packagesWithNativeAssetsResult: <Package>[
Package('bar', projectUri),
],
buildDryRunResult: FakeNativeAssetsBuilderResult(
assets: <AssetImpl>[
NativeCodeAssetImpl(
id: 'package:bar/bar.dart',
linkMode: StaticLinkingImpl(),
os: OSImpl.macOS,
architecture: ArchitectureImpl.arm64,
file: Uri.file('bar.a'),
),
NativeCodeAssetImpl(
id: 'package:bar/bar.dart',
linkMode: StaticLinkingImpl(),
os: OSImpl.macOS,
architecture: ArchitectureImpl.x64,
file: Uri.file('bar.a'),
),
],
),
),
),
throwsToolExit(
message: 'Native asset(s) package:bar/bar.dart have their link mode set to '
'static, but this is not yet supported. '
'For more info see https://github.com/dart-lang/sdk/issues/49418.',
),
);
});
testUsingContext('Native assets dry run error', overrides: <Type, Generator>{ testUsingContext('Native assets dry run error', overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(isNativeAssetsEnabled: true), FeatureFlags: () => TestFeatureFlags(isNativeAssetsEnabled: true),
ProcessManager: () => FakeProcessManager.empty(), ProcessManager: () => FakeProcessManager.empty(),

View File

@ -541,51 +541,6 @@ void main() {
} }
} }
testUsingContext('static libs not supported', overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(isNativeAssetsEnabled: true),
ProcessManager: () => FakeProcessManager.empty(),
}, () async {
final File packageConfig = environment.projectDir.childFile('.dart_tool/package_config.json');
await packageConfig.parent.create();
await packageConfig.create();
expect(
() => dryRunNativeAssetsMacOS(
projectUri: projectUri,
fileSystem: fileSystem,
buildRunner: FakeNativeAssetsBuildRunner(
packagesWithNativeAssetsResult: <Package>[
Package('bar', projectUri),
],
buildDryRunResult: FakeNativeAssetsBuilderResult(
assets: <AssetImpl>[
NativeCodeAssetImpl(
id: 'package:bar/bar.dart',
linkMode: StaticLinkingImpl(),
os: OSImpl.macOS,
architecture: ArchitectureImpl.arm64,
file: Uri.file('bar.a'),
),
NativeCodeAssetImpl(
id: 'package:bar/bar.dart',
linkMode: StaticLinkingImpl(),
os: OSImpl.macOS,
architecture: ArchitectureImpl.x64,
file: Uri.file('bar.a'),
),
],
),
),
),
throwsToolExit(
message: 'Native asset(s) package:bar/bar.dart have their link mode set to '
'static, but this is not yet supported. '
'For more info see https://github.com/dart-lang/sdk/issues/49418.',
),
);
});
testUsingContext('Native assets dry run error', overrides: <Type, Generator>{ testUsingContext('Native assets dry run error', overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(isNativeAssetsEnabled: true), FeatureFlags: () => TestFeatureFlags(isNativeAssetsEnabled: true),
ProcessManager: () => FakeProcessManager.empty(), ProcessManager: () => FakeProcessManager.empty(),

View File

@ -306,44 +306,6 @@ void main() {
} }
} }
testUsingContext('static libs not supported', overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(isNativeAssetsEnabled: true),
ProcessManager: () => FakeProcessManager.empty(),
}, () async {
final File packageConfig = environment.projectDir.childFile('.dart_tool/package_config.json');
await packageConfig.parent.create();
await packageConfig.create();
expect(
() => dryRunNativeAssetsWindows(
projectUri: projectUri,
fileSystem: fileSystem,
buildRunner: FakeNativeAssetsBuildRunner(
packagesWithNativeAssetsResult: <Package>[
Package('bar', projectUri),
],
buildDryRunResult: FakeNativeAssetsBuilderResult(
assets: <AssetImpl>[
NativeCodeAssetImpl(
id: 'package:bar/bar.dart',
linkMode: StaticLinkingImpl(),
os: OSImpl.windows,
architecture: ArchitectureImpl.x64,
file: Uri.file(OSImpl.windows.staticlibFileName('bar')),
),
],
),
),
),
throwsToolExit(
message: 'Native asset(s) package:bar/bar.dart have their link mode set to '
'static, but this is not yet supported. '
'For more info see https://github.com/dart-lang/sdk/issues/49418.',
),
);
});
testUsingContext('Native assets dry run error', overrides: <Type, Generator>{ testUsingContext('Native assets dry run error', overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(isNativeAssetsEnabled: true), FeatureFlags: () => TestFeatureFlags(isNativeAssetsEnabled: true),
ProcessManager: () => FakeProcessManager.empty(), ProcessManager: () => FakeProcessManager.empty(),

View File

@ -271,13 +271,13 @@ void main() {
'build', 'build',
buildSubcommand, buildSubcommand,
if (buildSubcommand == 'ios') '--no-codesign', if (buildSubcommand == 'ios') '--no-codesign',
if (buildSubcommand == 'windows') '-v' // Requires verbose mode for error. '-v', // Requires verbose mode for error.
], ],
workingDirectory: exampleDirectory.path, workingDirectory: exampleDirectory.path,
); );
expect( expect(
(result.stdout as String) + (result.stderr as String), (result.stdout as String) + (result.stderr as String),
contains('link mode set to static, but this is not yet supported'), contains('has a link mode "static", which is not allowed by by the config link mode preference "dynamic"'),
); );
expect(result.exitCode, isNot(0)); expect(result.exitCode, isNot(0));
}); });