Skip to content

Commit c5d0d29

Browse files
committed
added handling of -Fo
1 parent 5b392b7 commit c5d0d29

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

tools/nsc/main.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,29 +83,34 @@ class ShaderCompiler final : public system::IApplicationFramework
8383
});
8484
};
8585

86-
auto output_flag_pos = findOutputFlag("-Fc");
87-
86+
auto output_flag_pos_fc = findOutputFlag("-Fc");
87+
auto output_flag_pos_fo = findOutputFlag("-Fo");
88+
if (output_flag_pos_fc != m_arguments.end() && output_flag_pos_fo != m_arguments.end()) {
89+
m_logger->log("Invalid arguments. Passed both -Fo and -Fc.", ILogger::ELL_ERROR);
90+
return false;
91+
}
92+
auto output_flag_pos = output_flag_pos_fc != m_arguments.end() ? output_flag_pos_fc : output_flag_pos_fo;
8893
if (output_flag_pos == m_arguments.end())
8994
{
90-
m_logger->log("Missing arguments. Expecting `-Fc {filename}`.", ILogger::ELL_ERROR);
95+
m_logger->log("Missing arguments. Expecting `-Fc {filename}` or `-Fo {filename}`.", ILogger::ELL_ERROR);
9196
return false;
9297
}
9398
else
9499
{
95100
// we need to assume -Fc may be passed with output file name quoted together with "", so we split it (DXC does it)
96-
const auto& outpufFlag = *output_flag_pos;
97-
auto outputFlagVector = split(outpufFlag, ' ');
101+
const auto& outputFlag = *output_flag_pos;
102+
auto outputFlagVector = split(outputFlag, ' ');
98103

99-
if(outpufFlag == "-Fc")
104+
if(outputFlag == "-Fc" || outputFlag == "-Fo")
100105
{
101106
if (output_flag_pos + 1 != m_arguments.end())
102107
{
103-
output_filepath = *(output_flag_pos + 1);
108+
output_filepath = *(output_flag_pos + 1);
104109
}
105110
else
106111
{
107-
m_logger->log("Incorrect arguments. Expecting filename after -Fc.", ILogger::ELL_ERROR);
108-
return false;
112+
m_logger->log("Incorrect arguments. Expecting filename after %s.", ILogger::ELL_ERROR, outputFlag);
113+
return false;
109114
}
110115
}
111116
else

0 commit comments

Comments
 (0)