Support `--native-assets` in kernel compilation commands (#3667)
diff --git a/lib/src/dart.dart b/lib/src/dart.dart
index ac13549..1ff10dc 100644
--- a/lib/src/dart.dart
+++ b/lib/src/dart.dart
@@ -105,6 +105,9 @@
/// The [additionalSources], if provided, instruct the compiler to include
/// additional source files into compilation even if they are not referenced
/// from the main library.
+///
+/// The [nativeAssets], if provided, instruct the compiler include a native
+/// assets map.
Future<void> precompile({
required String executablePath,
required String incrementalDillPath,
@@ -112,6 +115,7 @@
required String outputPath,
required String packageConfigPath,
List<String> additionalSources = const [],
+ String? nativeAssets,
}) async {
ensureDir(p.dirname(outputPath));
ensureDir(p.dirname(incrementalDillPath));
@@ -143,6 +147,7 @@
sdkRoot: sdkRoot,
packagesJson: packageConfigPath,
additionalSources: additionalSources,
+ nativeAssets: nativeAssets,
printIncrementalDependencies: false,
);
final result = await client.compile();
diff --git a/lib/src/entrypoint.dart b/lib/src/entrypoint.dart
index 888d02b..fbd582a 100644
--- a/lib/src/entrypoint.dart
+++ b/lib/src/entrypoint.dart
@@ -483,9 +483,13 @@
/// The [additionalSources], if provided, instruct the compiler to include
/// additional source files into compilation even if they are not referenced
/// from the main library.
+ ///
+ /// The [nativeAssets], if provided, instruct the compiler include a native
+ /// assets map.
Future<void> precompileExecutable(
Executable executable, {
List<String> additionalSources = const [],
+ String? nativeAssets,
}) async {
await log.progress('Building package executable', () async {
ensureDir(p.dirname(pathOfExecutable(executable)));
@@ -493,6 +497,7 @@
_precompileExecutable(
executable,
additionalSources: additionalSources,
+ nativeAssets: nativeAssets,
)
]);
});
@@ -501,6 +506,7 @@
Future<void> _precompileExecutable(
Executable executable, {
List<String> additionalSources = const [],
+ String? nativeAssets,
}) async {
final package = executable.package;
@@ -511,6 +517,7 @@
packageConfigPath: packageConfigPath,
name: '$package:${p.basenameWithoutExtension(executable.relativePath)}',
additionalSources: additionalSources,
+ nativeAssets: nativeAssets,
);
}
diff --git a/lib/src/executable.dart b/lib/src/executable.dart
index 68df717..fe8f1db 100644
--- a/lib/src/executable.dart
+++ b/lib/src/executable.dart
@@ -271,6 +271,9 @@
/// The [additionalSources], if provided, instructs the compiler to include
/// additional source files into compilation even if they are not referenced
/// from the main library that [descriptor] resolves to.
+///
+/// The [nativeAssets], if provided, instructs the compiler to include
+/// the native-assets mapping for @Native external functions.
Future<DartExecutableWithPackageConfig> getExecutableForCommand(
String descriptor, {
bool allowSnapshot = true,
@@ -278,6 +281,7 @@
String? pubCacheDir,
PubAnalytics? analytics,
List<String> additionalSources = const [],
+ String? nativeAssets,
}) async {
root ??= p.current;
var asPath = descriptor;
@@ -372,6 +376,7 @@
() => entrypoint.precompileExecutable(
executable,
additionalSources: additionalSources,
+ nativeAssets: nativeAssets,
),
);
} on ApplicationException catch (e) {
diff --git a/pubspec.yaml b/pubspec.yaml
index cc655dc..d34a3f5 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -13,7 +13,7 @@
collection: ^1.15.0
convert: ^3.0.2
crypto: ^3.0.1
- frontend_server_client: ^3.1.0
+ frontend_server_client: ^3.2.0
http: ^0.13.3
http_multi_server: ^3.0.1
http_parser: ^4.0.1