packagesWithNativeAssets property

Future<List<Package>> packagesWithNativeAssets
latefinal

All packages in packageConfig with native assets.

Whether a package has native assets is defined by whether it contains a hook/build.dart.

For backwards compatibility, a toplevel build.dart is also supported.

Implementation

// TODO(https://github.com/dart-lang/native/issues/823): Remove fallback when
// everyone has migrated. (Probably once we stop backwards compatibility of
// the protocol version pre 1.2.0 on some future version.)
late final Future<List<Package>> packagesWithNativeAssets = () async {
  final result = <Package>[];
  for (final package in packageConfig.packages) {
    final packageRoot = package.root;
    if (packageRoot.scheme == 'file') {
      if (await File.fromUri(
            packageRoot.resolve('hook/').resolve('build.dart'),
          ).exists() ||
          await File.fromUri(
            packageRoot.resolve('build.dart'),
          ).exists()) {
        result.add(package);
      }
    }
  }
  return result;
}();