Unverified Commit 402a5455 authored by Daco Harkes's avatar Daco Harkes Committed by GitHub

Don't build native assets in `flutter build bundle` (#136641)

Closes: https://github.com/flutter/flutter/issues/136547
parent 4b7b4d41
......@@ -967,6 +967,20 @@ const String kSdkRoot = 'SdkRoot';
/// Whether to enable Dart obfuscation and where to save the symbol map.
const String kDartObfuscation = 'DartObfuscation';
/// Whether to enable Native Assets.
///
/// If true, native assets are built and the mapping for native assets lookup
/// at runtime is embedded in the kernel file.
///
/// If false, native assets are not built, and an empty mapping is embedded in
/// the kernel file. Used for targets that trigger kernel builds but
/// are not OS/architecture specific.
///
/// Supported values are 'true' and 'false'.
///
/// Defaults to 'true'.
const String kNativeAssets = 'NativeAssets';
/// An output directory where one or more code-size measurements may be written.
const String kCodeSizeDirectory = 'CodeSizeDirectory';
......
......@@ -26,7 +26,11 @@ class BundleBuilder {
/// Builds the bundle for the given target platform.
///
/// The default `mainPath` is `lib/main.dart`.
/// The default `manifestPath` is `pubspec.yaml`
/// The default `manifestPath` is `pubspec.yaml`.
///
/// If [buildNativeAssets], native assets are built and the mapping for native
/// assets lookup at runtime is embedded in the kernel file, otherwise an
/// empty native assets mapping is embedded in the kernel file.
Future<void> build({
required TargetPlatform platform,
required BuildInfo buildInfo,
......@@ -36,6 +40,7 @@ class BundleBuilder {
String? applicationKernelFilePath,
String? depfilePath,
String? assetDirPath,
bool buildNativeAssets = true,
@visibleForTesting BuildSystem? buildSystem,
}) async {
project ??= FlutterProject.current();
......@@ -60,6 +65,7 @@ class BundleBuilder {
kTargetFile: mainPath,
kDeferredComponents: 'false',
...buildInfo.toBuildSystemEnvironment(),
if (!buildNativeAssets) kNativeAssets: 'false'
},
artifacts: globals.artifacts!,
fileSystem: globals.fs,
......
......@@ -132,6 +132,7 @@ class BuildBundleCommand extends BuildSubCommand {
mainPath: targetFile,
depfilePath: stringArg('depfile'),
assetDirPath: stringArg('asset-dir'),
buildNativeAssets: false,
);
return FlutterCommandResult.success();
}
......
......@@ -252,6 +252,7 @@ void main() {
kIconTreeShakerFlag: 'false',
kDeferredComponents: 'false',
kDartObfuscation: 'false',
kNativeAssets: 'false',
});
}),
FileSystem: fsFactory,
......@@ -285,6 +286,7 @@ void main() {
kIconTreeShakerFlag: 'false',
kDeferredComponents: 'false',
kDartObfuscation: 'false',
kNativeAssets: 'false',
});
}),
FileSystem: fsFactory,
......@@ -317,6 +319,7 @@ void main() {
kIconTreeShakerFlag: 'false',
kDeferredComponents: 'false',
kDartObfuscation: 'false',
kNativeAssets: 'false',
});
}),
FileSystem: fsFactory,
......@@ -350,6 +353,7 @@ void main() {
kIconTreeShakerFlag: 'false',
kDeferredComponents: 'false',
kDartObfuscation: 'false',
kNativeAssets: 'false',
});
}),
FileSystem: fsFactory,
......@@ -383,6 +387,7 @@ void main() {
kIconTreeShakerFlag: 'false',
kDeferredComponents: 'false',
kDartObfuscation: 'false',
kNativeAssets: 'false',
});
}),
FileSystem: fsFactory,
......@@ -416,6 +421,7 @@ void main() {
kIconTreeShakerFlag: 'false',
kDeferredComponents: 'false',
kDartObfuscation: 'false',
kNativeAssets: 'false',
});
}),
FileSystem: fsFactory,
......@@ -457,6 +463,7 @@ void main() {
kIconTreeShakerFlag: 'false',
kDeferredComponents: 'false',
kDartObfuscation: 'false',
kNativeAssets: 'false',
});
}),
FileSystem: fsFactory,
......@@ -498,6 +505,7 @@ void main() {
kIconTreeShakerFlag: 'false',
kDeferredComponents: 'false',
kDartObfuscation: 'false',
kNativeAssets: 'false',
});
}),
FileSystem: fsFactory,
......@@ -516,7 +524,7 @@ class FakeBundleBuilder extends Fake implements BundleBuilder {
String? applicationKernelFilePath,
String? depfilePath,
String? assetDirPath,
Uri? nativeAssets,
bool buildNativeAssets = true,
@visibleForTesting BuildSystem? buildSystem,
}) async {}
}
......@@ -645,6 +645,7 @@ class FakeBundleBuilder extends Fake implements BundleBuilder {
String? depfilePath,
String? assetDirPath,
Uri? nativeAssets,
bool buildNativeAssets = true,
@visibleForTesting BuildSystem? buildSystem
}) async {}
}
......@@ -196,7 +196,7 @@ class FakeBundleBuilder extends Fake implements BundleBuilder {
String? applicationKernelFilePath,
String? depfilePath,
String? assetDirPath,
Uri? nativeAssets,
bool buildNativeAssets = true,
@visibleForTesting BuildSystem? buildSystem
}) async {
final Directory assetDirectory = fileSystem
......
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