@@ -69,49 +69,65 @@ bool Main(const fml::CommandLine& command_line) {
69
69
return false ;
70
70
}
71
71
72
- if (!fml::WriteAtomically (*switches.working_directory ,
73
- switches.metal_file_name .c_str (),
74
- *compiler.GetMSLShaderSource ())) {
75
- std::cerr << " Could not write file to " << switches.spirv_file_name
76
- << std::endl;
77
- return false ;
78
- }
79
-
80
- if (!switches.reflection_json_name .empty ()) {
72
+ if (Compiler::TargetPlatformNeedsMSL (options.target_platform )) {
81
73
if (!fml::WriteAtomically (*switches.working_directory ,
82
- switches.reflection_json_name .c_str (),
83
- *compiler.GetReflector ()-> GetReflectionJSON ())) {
84
- std::cerr << " Could not write reflection json to "
85
- << switches. reflection_json_name << std::endl;
74
+ switches.metal_file_name .c_str (),
75
+ *compiler.GetMSLShaderSource ())) {
76
+ std::cerr << " Could not write file to " << switches. spirv_file_name
77
+ << std::endl;
86
78
return false ;
87
79
}
88
80
}
89
81
90
- if (!switches.reflection_header_name .empty ()) {
91
- if (!fml::WriteAtomically (
92
- *switches.working_directory ,
93
- switches.reflection_header_name .c_str (),
94
- *compiler.GetReflector ()->GetReflectionHeader ())) {
95
- std::cerr << " Could not write reflection header to "
96
- << switches.reflection_header_name << std::endl;
97
- return false ;
82
+
83
+ if (Compiler::TargetPlatformNeedsReflection (options.target_platform )) {
84
+ if (!switches.reflection_json_name .empty ()) {
85
+ if (!fml::WriteAtomically (*switches.working_directory ,
86
+ switches.reflection_json_name .c_str (),
87
+ *compiler.GetReflector ()->GetReflectionJSON ())) {
88
+ std::cerr << " Could not write reflection json to "
89
+ << switches.reflection_json_name << std::endl;
90
+ return false ;
91
+ }
98
92
}
99
- }
100
93
101
- if (!switches.reflection_cc_name .empty ()) {
102
- if (!fml::WriteAtomically (*switches.working_directory ,
103
- switches.reflection_cc_name .c_str (),
104
- *compiler.GetReflector ()->GetReflectionCC ())) {
105
- std::cerr << " Could not write reflection CC to "
106
- << switches.reflection_cc_name << std::endl;
107
- return false ;
94
+ if (!switches.reflection_header_name .empty ()) {
95
+ if (!fml::WriteAtomically (
96
+ *switches.working_directory ,
97
+ switches.reflection_header_name .c_str (),
98
+ *compiler.GetReflector ()->GetReflectionHeader ())) {
99
+ std::cerr << " Could not write reflection header to "
100
+ << switches.reflection_header_name << std::endl;
101
+ return false ;
102
+ }
103
+ }
104
+
105
+ if (!switches.reflection_cc_name .empty ()) {
106
+ if (!fml::WriteAtomically (*switches.working_directory ,
107
+ switches.reflection_cc_name .c_str (),
108
+ *compiler.GetReflector ()->GetReflectionCC ())) {
109
+ std::cerr << " Could not write reflection CC to "
110
+ << switches.reflection_cc_name << std::endl;
111
+ return false ;
112
+ }
108
113
}
109
114
}
110
115
111
116
if (!switches.depfile_path .empty ()) {
117
+ std::string result_file;
118
+ switch (switches.target_platform ) {
119
+ case Compiler::TargetPlatform::kMacOS :
120
+ case Compiler::TargetPlatform::kIPhoneOS :
121
+ result_file = switches.metal_file_name ;
122
+ break ;
123
+ case Compiler::TargetPlatform::kFlutterSPIRV :
124
+ case Compiler::TargetPlatform::kUnknown :
125
+ result_file = switches.spirv_file_name ;
126
+ break ;
127
+ }
112
128
if (!fml::WriteAtomically (
113
129
*switches.working_directory , switches.depfile_path .c_str (),
114
- *compiler.CreateDepfileContents ({switches. metal_file_name }))) {
130
+ *compiler.CreateDepfileContents ({result_file }))) {
115
131
std::cerr << " Could not write depfile to " << switches.depfile_path
116
132
<< std::endl;
117
133
return false ;
0 commit comments