Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
b005a347
Unverified
Commit
b005a347
authored
Jun 30, 2022
by
Zachary Anderson
Committed by
GitHub
Jun 30, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tool] Pass --input-type to impellerc (#106845)
parent
eb3cf24b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
20 deletions
+77
-20
shader_compiler.dart
...r_tools/lib/src/build_system/targets/shader_compiler.dart
+4
-8
bundle_builder.dart
packages/flutter_tools/lib/src/bundle_builder.dart
+15
-1
asset_bundle_test.dart
...s/flutter_tools/test/general.shard/asset_bundle_test.dart
+1
-0
shader_compiler_test.dart
...eral.shard/build_system/targets/shader_compiler_test.dart
+57
-11
No files found.
packages/flutter_tools/lib/src/build_system/targets/shader_compiler.dart
View file @
b005a347
...
...
@@ -5,7 +5,6 @@
import
'package:process/process.dart'
;
import
'../../artifacts.dart'
;
import
'../../base/common.dart'
;
import
'../../base/file_system.dart'
;
import
'../../base/io.dart'
;
import
'../../base/logger.dart'
;
...
...
@@ -43,17 +42,13 @@ class ShaderCompiler {
///
/// All parameters are required.
///
/// If the
input file is not a fragment shader, this returns false.
///
If the shader compiler subprocess fails, it will [throwToolExit].
///
Otherwise, it
will return true.
/// If the
shader compiler subprocess fails, it will print the stdout and
///
stderr to the log and throw a [ShaderCompilerException]. Otherwise, it
/// will return true.
Future
<
bool
>
compileShader
({
required
File
input
,
required
String
outputPath
,
})
async
{
if
(!
input
.
path
.
endsWith
(
'.frag'
))
{
return
false
;
}
final
File
impellerc
=
_fs
.
file
(
_artifacts
.
getHostArtifact
(
HostArtifact
.
impellerc
),
);
...
...
@@ -72,6 +67,7 @@ class ShaderCompiler {
'--flutter-spirv'
,
'--spirv=
$outputPath
'
,
'--input=
${input.path}
'
,
'--input-type=frag'
,
];
final
Process
impellercProcess
=
await
_processManager
.
start
(
cmd
);
final
int
code
=
await
impellercProcess
.
exitCode
;
...
...
packages/flutter_tools/lib/src/bundle_builder.dart
View file @
b005a347
...
...
@@ -169,11 +169,25 @@ Future<void> writeBundle(
// platform channels in the framework will URI encode these values,
// and the native APIs will look for files this way.
final
File
file
=
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
bundleDir
.
path
,
entry
.
key
));
final
AssetKind
assetKind
=
entryKinds
[
entry
.
key
]
??
AssetKind
.
regular
;
file
.
parent
.
createSync
(
recursive:
true
);
final
DevFSContent
devFSContent
=
entry
.
value
;
if
(
devFSContent
is
DevFSFileContent
)
{
final
File
input
=
devFSContent
.
file
as
File
;
if
(!
await
shaderCompiler
.
compileShader
(
input:
input
,
outputPath:
file
.
path
))
{
bool
doCopy
=
true
;
switch
(
assetKind
)
{
case
AssetKind
.
regular
:
break
;
case
AssetKind
.
font
:
break
;
case
AssetKind
.
shader
:
doCopy
=
!
await
shaderCompiler
.
compileShader
(
input:
input
,
outputPath:
file
.
path
,
);
break
;
}
if
(
doCopy
)
{
input
.
copySync
(
file
.
path
);
}
}
else
{
...
...
packages/flutter_tools/test/general.shard/asset_bundle_test.dart
View file @
b005a347
...
...
@@ -444,6 +444,7 @@ flutter:
'--flutter-spirv'
,
'--spirv=
$outputPath
'
,
'--input=/
$shaderPath
'
,
'--input-type=frag'
,
],
onRun:
()
{
fileSystem
.
file
(
outputPath
).
createSync
(
recursive:
true
);
...
...
packages/flutter_tools/test/general.shard/build_system/targets/shader_compiler_test.dart
View file @
b005a347
...
...
@@ -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
shader
Path
=
'/shaders/my_shader.frag'
;
const
String
not
ShaderPath
=
'/shaders/not_a_shader
.file'
;
const
String
frag
Path
=
'/shaders/my_shader.frag'
;
const
String
not
FragPath
=
'/shaders/not_a_frag
.file'
;
const
String
outputPath
=
'/output/shaders/my_shader.spv'
;
void
main
(
)
{
...
...
@@ -27,13 +27,27 @@ void main() {
impellerc
=
artifacts
.
getHostArtifact
(
HostArtifact
.
impellerc
).
path
;
fileSystem
.
file
(
impellerc
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
shader
Path
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
not
Shader
Path
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
frag
Path
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
not
Frag
Path
).
createSync
(
recursive:
true
);
});
testWithoutContext
(
'compileShader returns false for non-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=
$fragPath
'
,
'--input-type=frag'
,
],
onRun:
()
{
fileSystem
.
file
(
outputPath
).
createSync
(
recursive:
true
);
},
),
]);
final
ShaderCompiler
shaderCompiler
=
ShaderCompiler
(
processManager:
FakeProcessManager
.
empty
()
,
processManager:
processManager
,
logger:
logger
,
fileSystem:
fileSystem
,
artifacts:
artifacts
,
...
...
@@ -41,21 +55,23 @@ void main() {
expect
(
await
shaderCompiler
.
compileShader
(
input:
fileSystem
.
file
(
notShader
Path
),
input:
fileSystem
.
file
(
frag
Path
),
outputPath:
outputPath
,
),
fals
e
,
tru
e
,
);
expect
(
fileSystem
.
file
(
outputPath
).
existsSync
(),
true
);
});
testWithoutContext
(
'compileShader
returns true for shader
files'
,
()
async
{
testWithoutContext
(
'compileShader
invokes impellerc for non-.frag
files'
,
()
async
{
final
FakeProcessManager
processManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
FakeCommand
(
command:
<
String
>[
impellerc
,
'--flutter-spirv'
,
'--spirv=
$outputPath
'
,
'--input=
$shaderPath
'
,
'--input=
$notFragPath
'
,
'--input-type=frag'
,
],
onRun:
()
{
fileSystem
.
file
(
outputPath
).
createSync
(
recursive:
true
);
...
...
@@ -71,11 +87,41 @@ void main() {
expect
(
await
shaderCompiler
.
compileShader
(
input:
fileSystem
.
file
(
shader
Path
),
input:
fileSystem
.
file
(
notFrag
Path
),
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
);
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment