Skip to content

Commit

Permalink
[flutter_tool] Allow includes relative to shader path (#107862)
Browse files Browse the repository at this point in the history
  • Loading branch information
zanderso authored Jul 19, 2022
1 parent 6bd3e6e commit e9529e2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class ShaderCompiler {
'--spirv=$outputPath',
'--input=${input.path}',
'--input-type=frag',
'--include=${input.parent.path}',
];
final Process impellercProcess = await _processManager.start(cmd);
final int code = await impellercProcess.exitCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ flutter:
late Artifacts artifacts;
late String impellerc;
late Directory output;
late String assetsPath;
late String shaderPath;
late String outputPath;

Expand All @@ -408,8 +409,9 @@ flutter:
fileSystem.file(impellerc).createSync(recursive: true);

output = fileSystem.directory('asset_output')..createSync(recursive: true);
shaderPath = fileSystem.path.join('assets', 'shader.frag');
outputPath = fileSystem.path.join(output.path, 'assets', 'shader.frag');
assetsPath = 'assets';
shaderPath = fileSystem.path.join(assetsPath, 'shader.frag');
outputPath = fileSystem.path.join(output.path, assetsPath, 'shader.frag');
fileSystem.file(shaderPath).createSync(recursive: true);
});

Expand Down Expand Up @@ -445,6 +447,7 @@ flutter:
'--spirv=$outputPath',
'--input=/$shaderPath',
'--input-type=frag',
'--include=/$assetsPath',
],
onRun: () {
fileSystem.file(outputPath).createSync(recursive: true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:flutter_tools/src/build_system/targets/shader_compiler.dart';
import '../../../src/common.dart';
import '../../../src/fake_process_manager.dart';

const String fragDir = '/shaders';
const String fragPath = '/shaders/my_shader.frag';
const String notFragPath = '/shaders/not_a_frag.file';
const String outputPath = '/output/shaders/my_shader.spv';
Expand Down Expand Up @@ -40,6 +41,7 @@ void main() {
'--spirv=$outputPath',
'--input=$fragPath',
'--input-type=frag',
'--include=$fragDir',
],
onRun: () {
fileSystem.file(outputPath).createSync(recursive: true);
Expand Down Expand Up @@ -72,6 +74,7 @@ void main() {
'--spirv=$outputPath',
'--input=$notFragPath',
'--input-type=frag',
'--include=$fragDir',
],
onRun: () {
fileSystem.file(outputPath).createSync(recursive: true);
Expand Down Expand Up @@ -104,6 +107,7 @@ void main() {
'--spirv=$outputPath',
'--input=$notFragPath',
'--input-type=frag',
'--include=$fragDir',
],
exitCode: 1,
),
Expand Down

0 comments on commit e9529e2

Please sign in to comment.