Skip to content

Commit 637e5bc

Browse files
authored
[Impeller] Build Impeller iOS runtime stage shaders when Impeller is enabled (flutter#113689)
1 parent 9ac2cd6 commit 637e5bc

File tree

5 files changed

+27
-9
lines changed

5 files changed

+27
-9
lines changed

packages/flutter_tools/lib/src/build_system/targets/assets.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Future<Depfile> copyAssets(
3232
required TargetPlatform targetPlatform,
3333
BuildMode? buildMode,
3434
required ShaderTarget shaderTarget,
35+
List<File> additionalInputs = const <File>[],
3536
}) async {
3637
// Check for an SkSL bundle.
3738
final String? shaderBundlePath = environment.defines[kBundleSkSLPath] ?? environment.inputs[kBundleSkSLPath];
@@ -65,6 +66,7 @@ Future<Depfile> copyAssets(
6566
// An asset manifest with no assets would have zero inputs if not
6667
// for this pubspec file.
6768
pubspecFile,
69+
...additionalInputs,
6870
];
6971
final List<File> outputs = <File>[];
7072

packages/flutter_tools/lib/src/build_system/targets/ios.dart

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import '../../base/common.dart';
1010
import '../../base/file_system.dart';
1111
import '../../base/io.dart';
1212
import '../../build_info.dart';
13-
import '../../globals.dart' as globals show xcode;
13+
import '../../globals.dart' as globals;
1414
import '../../macos/xcode.dart';
1515
import '../../project.dart';
1616
import '../../reporting/reporting.dart';
@@ -509,12 +509,28 @@ abstract class IosAssetBundle extends Target {
509509
.copySync(dsymOutputBinary.path);
510510
}
511511

512+
final FlutterProject flutterProject = FlutterProject.fromDirectory(environment.projectDir);
513+
514+
bool isImpellerEnabled() {
515+
if (!flutterProject.ios.infoPlist.existsSync()) {
516+
return false;
517+
}
518+
final Map<String, Object> info = globals.plistParser.parseFile(flutterProject.ios.infoPlist.path);
519+
520+
final Object? enableImpeller = info['FLTEnableImpeller'];
521+
return enableImpeller is bool && enableImpeller;
522+
}
523+
512524
// Copy the assets.
513525
final Depfile assetDepfile = await copyAssets(
514526
environment,
515527
assetDirectory,
516528
targetPlatform: TargetPlatform.ios,
517-
shaderTarget: ShaderTarget.sksl,
529+
shaderTarget: isImpellerEnabled() ? ShaderTarget.impelleriOS : ShaderTarget.sksl,
530+
additionalInputs: <File>[
531+
flutterProject.ios.infoPlist,
532+
flutterProject.ios.appFrameworkInfoPlist,
533+
],
518534
);
519535
final DepfileService depfileService = DepfileService(
520536
fileSystem: environment.fileSystem,
@@ -526,8 +542,6 @@ abstract class IosAssetBundle extends Target {
526542
);
527543

528544
// Copy the plist from either the project or module.
529-
// TODO(zanderso): add plist to inputs
530-
final FlutterProject flutterProject = FlutterProject.fromDirectory(environment.projectDir);
531545
flutterProject.ios.appFrameworkInfoPlist
532546
.copySync(environment.outputDir
533547
.childDirectory('App.framework')

packages/flutter_tools/lib/src/build_system/targets/shader_compiler.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import '../build_system.dart';
2121

2222
/// The output shader format that should be used by the [ShaderCompiler].
2323
enum ShaderTarget {
24-
impellerAndroid('--opengl-es'),
25-
impelleriOS('--metal-ios'),
24+
impellerAndroid('--runtime-stage-gles'),
25+
impelleriOS('--runtime-stage-metal'),
2626
sksl('--sksl');
2727

2828
const ShaderTarget(this.target);

packages/flutter_tools/lib/src/xcode_project.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ class IosProject extends XcodeBasedProject {
131131

132132
File get appFrameworkInfoPlist => _flutterLibRoot.childDirectory('Flutter').childFile('AppFrameworkInfo.plist');
133133

134+
File get infoPlist => _editableDirectory.childDirectory('Runner').childFile('Info.plist');
135+
134136
Directory get symlinks => _flutterLibRoot.childDirectory('.symlinks');
135137

136138
/// True, if the app project is using swift.

packages/flutter_tools/test/general.shard/build_system/targets/shader_compiler_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void main() {
8181
FakeCommand(
8282
command: <String>[
8383
impellerc,
84-
'--metal-ios',
84+
'--runtime-stage-metal',
8585
'--iplr',
8686
'--sl=$outputPath',
8787
'--spirv=$outputPath.spirv',
@@ -117,7 +117,7 @@ void main() {
117117
FakeCommand(
118118
command: <String>[
119119
impellerc,
120-
'--opengl-es',
120+
'--runtime-stage-gles',
121121
'--iplr',
122122
'--sl=$outputPath',
123123
'--spirv=$outputPath.spirv',
@@ -275,7 +275,7 @@ void main() {
275275
FakeCommand(
276276
command: <String>[
277277
impellerc,
278-
'--opengl-es',
278+
'--runtime-stage-gles',
279279
'--iplr',
280280
'--sl=/.tmp_rand0/0.8255140718871702.temp',
281281
'--spirv=/.tmp_rand0/0.8255140718871702.temp.spirv',

0 commit comments

Comments
 (0)