summaryrefslogtreecommitdiffstats
path: root/source/slang
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2021-01-07 13:16:18 -0800
committerGitHub <noreply@github.com>2021-01-07 13:16:18 -0800
commitd84f4582c0caa656e7d0ca0e619651f8b4e5ed16 (patch)
tree9c2311eef71873dddda407360ff0c96e9802cd4b /source/slang
parent66d4466d680bcd97b7eb561f08bd6da80a1d6c4e (diff)
Add a -capability command-line option (#1651)
This provides a stand-alone option distinct from `-profile` that can be used to add capabilities to a target. A test has been added to confirm that `-profile X -capability Y` works the same as `-profile X+Y`. The intention is that this option could be used in applications that use the API to set up their target but then use the options-parsing logic to handle things like capabilities. Note: that latter bit has not been confirmed, so it is possible that this approach does not actually suffice for hybrid API + options usage. That will need to be confirmed in follow-up work.
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/slang-options.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp
index c3db39773..a89818c4f 100644
--- a/source/slang/slang-options.cpp
+++ b/source/slang/slang-options.cpp
@@ -717,6 +717,35 @@ struct OptionsParser
addCapabilityAtom(getCurrentTarget(), atom);
}
}
+ else if( argStr == "-capability" )
+ {
+ // The `-capability` option is similar to `-profile` but does not set the actual profile
+ // for a target (it just adds capabilities).
+ //
+ // TODO: Once profiles are treated as capabilities themselves, it might be possible
+ // to treat `-profile` and `-capability` as aliases, although there might still be
+ // value in only allowing a single `-profile` option per target while still allowing
+ // zero or more `-capability` options.
+
+ String operand;
+ SLANG_RETURN_ON_FAIL(tryReadCommandLineArgument(sink, arg, &argCursor, argEnd, operand));
+
+ List<UnownedStringSlice> slices;
+ StringUtil::split(operand.getUnownedSlice(), '+', slices);
+ Index sliceCount = slices.getCount();
+ for(Index i = 0; i < sliceCount; ++i)
+ {
+ UnownedStringSlice atomName = slices[i];
+ CapabilityAtom atom = findCapabilityAtom(atomName);
+ if( atom == CapabilityAtom::Invalid )
+ {
+ sink->diagnose(SourceLoc(), Diagnostics::unknownProfile, atomName);
+ return SLANG_FAIL;
+ }
+
+ addCapabilityAtom(getCurrentTarget(), atom);
+ }
+ }
else if (argStr == "-stage")
{
String name;