Skip to content

Commit e9529e2

Browse files
authored
[flutter_tool] Allow includes relative to shader path (#107862)
1 parent 6bd3e6e commit e9529e2

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class ShaderCompiler {
6868
'--spirv=$outputPath',
6969
'--input=${input.path}',
7070
'--input-type=frag',
71+
'--include=${input.parent.path}',
7172
];
7273
final Process impellercProcess = await _processManager.start(cmd);
7374
final int code = await impellercProcess.exitCode;

packages/flutter_tools/test/general.shard/asset_bundle_test.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ flutter:
397397
late Artifacts artifacts;
398398
late String impellerc;
399399
late Directory output;
400+
late String assetsPath;
400401
late String shaderPath;
401402
late String outputPath;
402403

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

410411
output = fileSystem.directory('asset_output')..createSync(recursive: true);
411-
shaderPath = fileSystem.path.join('assets', 'shader.frag');
412-
outputPath = fileSystem.path.join(output.path, 'assets', 'shader.frag');
412+
assetsPath = 'assets';
413+
shaderPath = fileSystem.path.join(assetsPath, 'shader.frag');
414+
outputPath = fileSystem.path.join(output.path, assetsPath, 'shader.frag');
413415
fileSystem.file(shaderPath).createSync(recursive: true);
414416
});
415417

@@ -445,6 +447,7 @@ flutter:
445447
'--spirv=$outputPath',
446448
'--input=/$shaderPath',
447449
'--input-type=frag',
450+
'--include=/$assetsPath',
448451
],
449452
onRun: () {
450453
fileSystem.file(outputPath).createSync(recursive: true);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/build_system/targets/shader_compiler.dart';
1010
import '../../../src/common.dart';
1111
import '../../../src/fake_process_manager.dart';
1212

13+
const String fragDir = '/shaders';
1314
const String fragPath = '/shaders/my_shader.frag';
1415
const String notFragPath = '/shaders/not_a_frag.file';
1516
const String outputPath = '/output/shaders/my_shader.spv';
@@ -40,6 +41,7 @@ void main() {
4041
'--spirv=$outputPath',
4142
'--input=$fragPath',
4243
'--input-type=frag',
44+
'--include=$fragDir',
4345
],
4446
onRun: () {
4547
fileSystem.file(outputPath).createSync(recursive: true);
@@ -72,6 +74,7 @@ void main() {
7274
'--spirv=$outputPath',
7375
'--input=$notFragPath',
7476
'--input-type=frag',
77+
'--include=$fragDir',
7578
],
7679
onRun: () {
7780
fileSystem.file(outputPath).createSync(recursive: true);
@@ -104,6 +107,7 @@ void main() {
104107
'--spirv=$outputPath',
105108
'--input=$notFragPath',
106109
'--input-type=frag',
110+
'--include=$fragDir',
107111
],
108112
exitCode: 1,
109113
),

0 commit comments

Comments
 (0)