[flutter_tool] Pass --input-type to impellerc (#106845)
This commit is contained in:
@@ -444,6 +444,7 @@ flutter:
|
||||
'--flutter-spirv',
|
||||
'--spirv=$outputPath',
|
||||
'--input=/$shaderPath',
|
||||
'--input-type=frag',
|
||||
],
|
||||
onRun: () {
|
||||
fileSystem.file(outputPath).createSync(recursive: true);
|
||||
|
||||
@@ -10,8 +10,8 @@ import 'package:flutter_tools/src/build_system/targets/shader_compiler.dart';
|
||||
import '../../../src/common.dart';
|
||||
import '../../../src/fake_process_manager.dart';
|
||||
|
||||
const String shaderPath = '/shaders/my_shader.frag';
|
||||
const String notShaderPath = '/shaders/not_a_shader.file';
|
||||
const String fragPath = '/shaders/my_shader.frag';
|
||||
const String notFragPath = '/shaders/not_a_frag.file';
|
||||
const String outputPath = '/output/shaders/my_shader.spv';
|
||||
|
||||
void main() {
|
||||
@@ -27,35 +27,19 @@ void main() {
|
||||
impellerc = artifacts.getHostArtifact(HostArtifact.impellerc).path;
|
||||
|
||||
fileSystem.file(impellerc).createSync(recursive: true);
|
||||
fileSystem.file(shaderPath).createSync(recursive: true);
|
||||
fileSystem.file(notShaderPath).createSync(recursive: true);
|
||||
fileSystem.file(fragPath).createSync(recursive: true);
|
||||
fileSystem.file(notFragPath).createSync(recursive: true);
|
||||
});
|
||||
|
||||
testWithoutContext('compileShader returns false for non-shader files', () async {
|
||||
final ShaderCompiler shaderCompiler = ShaderCompiler(
|
||||
processManager: FakeProcessManager.empty(),
|
||||
logger: logger,
|
||||
fileSystem: fileSystem,
|
||||
artifacts: artifacts,
|
||||
);
|
||||
|
||||
expect(
|
||||
await shaderCompiler.compileShader(
|
||||
input: fileSystem.file(notShaderPath),
|
||||
outputPath: outputPath,
|
||||
),
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
testWithoutContext('compileShader returns true for shader files', () async {
|
||||
testWithoutContext('compileShader invokes impellerc for .frag files', () async {
|
||||
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
|
||||
FakeCommand(
|
||||
command: <String>[
|
||||
impellerc,
|
||||
'--flutter-spirv',
|
||||
'--spirv=$outputPath',
|
||||
'--input=$shaderPath',
|
||||
'--input=$fragPath',
|
||||
'--input-type=frag',
|
||||
],
|
||||
onRun: () {
|
||||
fileSystem.file(outputPath).createSync(recursive: true);
|
||||
@@ -71,11 +55,73 @@ void main() {
|
||||
|
||||
expect(
|
||||
await shaderCompiler.compileShader(
|
||||
input: fileSystem.file(shaderPath),
|
||||
input: fileSystem.file(fragPath),
|
||||
outputPath: outputPath,
|
||||
),
|
||||
true,
|
||||
);
|
||||
expect(fileSystem.file(outputPath).existsSync(), true);
|
||||
});
|
||||
|
||||
testWithoutContext('compileShader invokes impellerc for non-.frag files', () async {
|
||||
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
|
||||
FakeCommand(
|
||||
command: <String>[
|
||||
impellerc,
|
||||
'--flutter-spirv',
|
||||
'--spirv=$outputPath',
|
||||
'--input=$notFragPath',
|
||||
'--input-type=frag',
|
||||
],
|
||||
onRun: () {
|
||||
fileSystem.file(outputPath).createSync(recursive: true);
|
||||
},
|
||||
),
|
||||
]);
|
||||
final ShaderCompiler shaderCompiler = ShaderCompiler(
|
||||
processManager: processManager,
|
||||
logger: logger,
|
||||
fileSystem: fileSystem,
|
||||
artifacts: artifacts,
|
||||
);
|
||||
|
||||
expect(
|
||||
await shaderCompiler.compileShader(
|
||||
input: fileSystem.file(notFragPath),
|
||||
outputPath: outputPath,
|
||||
),
|
||||
true,
|
||||
);
|
||||
expect(fileSystem.file(outputPath).existsSync(), true);
|
||||
});
|
||||
|
||||
testWithoutContext('compileShader throws an exception when impellerc fails', () async {
|
||||
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
|
||||
FakeCommand(
|
||||
command: <String>[
|
||||
impellerc,
|
||||
'--flutter-spirv',
|
||||
'--spirv=$outputPath',
|
||||
'--input=$notFragPath',
|
||||
'--input-type=frag',
|
||||
],
|
||||
exitCode: 1,
|
||||
),
|
||||
]);
|
||||
final ShaderCompiler shaderCompiler = ShaderCompiler(
|
||||
processManager: processManager,
|
||||
logger: logger,
|
||||
fileSystem: fileSystem,
|
||||
artifacts: artifacts,
|
||||
);
|
||||
|
||||
await expectLater(
|
||||
() => shaderCompiler.compileShader(
|
||||
input: fileSystem.file(notFragPath),
|
||||
outputPath: outputPath,
|
||||
),
|
||||
throwsA(isA<ShaderCompilerException>()),
|
||||
);
|
||||
expect(fileSystem.file(outputPath).existsSync(), false);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user