summaryrefslogtreecommitdiff
path: root/source/slang/slang-options.cpp
diff options
context:
space:
mode:
authorRobert Stepinski <rob.stepinski@gmail.com>2019-11-22 18:20:18 -0500
committerTim Foley <tfoleyNV@users.noreply.github.com>2019-11-22 15:20:18 -0800
commit63dcbe50d40afc15196eeca6ba0b04657adf6953 (patch)
tree05f63d4f83cdd34a5788f0c6d449a94fb3104d0b /source/slang/slang-options.cpp
parent1d51b01cc7a6ab5fa26e0eb109ca29ed0f24ebe1 (diff)
Add command line option to override language file extension (#1135)
Diffstat (limited to 'source/slang/slang-options.cpp')
-rw-r--r--source/slang/slang-options.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp
index 97dca94ca..92310c1c1 100644
--- a/source/slang/slang-options.cpp
+++ b/source/slang/slang-options.cpp
@@ -324,7 +324,8 @@ struct OptionsParser
}
SlangResult addInputPath(
- char const* inPath)
+ char const* inPath,
+ SourceLanguage langOverride = SourceLanguage::Unknown)
{
inputPathCount++;
@@ -332,7 +333,7 @@ struct OptionsParser
// how we should handle it.
String path = String(inPath);
- if( path.endsWith(".slang") )
+ if( path.endsWith(".slang") || langOverride == SourceLanguage::Slang)
{
// Plain old slang code
addInputSlangPath(path);
@@ -340,8 +341,8 @@ struct OptionsParser
}
Stage impliedStage = Stage::Unknown;
- SlangSourceLanguage sourceLanguage = findSourceLanguageFromPath(path, impliedStage);
-
+ SlangSourceLanguage sourceLanguage = langOverride == SourceLanguage::Unknown ? findSourceLanguageFromPath(path, impliedStage) : SlangSourceLanguage(langOverride);
+
if (sourceLanguage == SLANG_SOURCE_LANGUAGE_UNKNOWN)
{
requestImpl->getSink()->diagnose(SourceLoc(), Diagnostics::cannotDeduceSourceLanguage, inPath);
@@ -707,6 +708,26 @@ struct OptionsParser
rawEntryPoints.add(rawEntryPoint);
}
+ else if (argStr == "-lang")
+ {
+ String name;
+ SLANG_RETURN_ON_FAIL(tryReadCommandLineArgument(sink, arg, &argCursor, argEnd, name));
+
+ SourceLanguage sourceLanguage = findSourceLanguageByName(name);
+
+ if (sourceLanguage == SourceLanguage::Unknown)
+ {
+ sink->diagnose(SourceLoc(), Diagnostics::unknownSourceLanguage, name);
+ return SLANG_FAIL;
+ }
+ else
+ {
+ while ((*argCursor)[0] != '-' && argCursor != argEnd)
+ {
+ SLANG_RETURN_ON_FAIL(addInputPath(*argCursor++, sourceLanguage));
+ }
+ }
+ }
else if (argStr == "-pass-through")
{
String name;