// slang-options.cpp // Implementation of options parsing for `slangc` command line, // and also for API interface that takes command-line argument strings. #include "slang-options.h" #include "../compiler-core/slang-artifact-desc-util.h" #include "../compiler-core/slang-artifact-impl.h" #include "../compiler-core/slang-artifact-representation-impl.h" #include "../compiler-core/slang-command-line-args.h" #include "../compiler-core/slang-core-diagnostics.h" #include "../compiler-core/slang-name-convention-util.h" #include "../compiler-core/slang-source-embed-util.h" #include "../core/slang-castable.h" #include "../core/slang-char-util.h" #include "../core/slang-command-options-writer.h" #include "../core/slang-file-system.h" #include "../core/slang-hex-dump-util.h" #include "../core/slang-name-value.h" #include "../core/slang-string-slice-pool.h" #include "../core/slang-type-text-util.h" #include "slang-compiler-options.h" #include "slang-compiler.h" #include "slang-hlsl-to-vulkan-layout-options.h" #include "slang-profile.h" #include "slang-repro.h" #include "slang-serialize-ir.h" #include "slang.h" #include namespace Slang { namespace { // anonymous // All of the options are given an unique enum typedef CompilerOptionName OptionKind; struct Option { OptionKind optionKind; const char* name; const char* usage = nullptr; const char* description = nullptr; }; enum class ValueCategory { Compiler, Target, Language, FloatingPointMode, FloatingPointDenormalMode, ArchiveType, Stage, LineDirectiveMode, DebugInfoFormat, HelpStyle, OptimizationLevel, DebugLevel, FileSystemType, VulkanShift, SourceEmbedStyle, LanguageVersion, CountOf, }; template struct GetValueCategory; #define SLANG_GET_VALUE_CATEGORY(cat, type) \ template<> \ struct GetValueCategory \ { \ enum \ { \ Value = Index(ValueCategory::cat) \ }; \ }; SLANG_GET_VALUE_CATEGORY(Compiler, SlangPassThrough) SLANG_GET_VALUE_CATEGORY(ArchiveType, SlangArchiveType) SLANG_GET_VALUE_CATEGORY(LineDirectiveMode, SlangLineDirectiveMode) SLANG_GET_VALUE_CATEGORY(FloatingPointMode, FloatingPointMode) SLANG_GET_VALUE_CATEGORY(FloatingPointDenormalMode, FloatingPointDenormalMode) SLANG_GET_VALUE_CATEGORY(FileSystemType, TypeTextUtil::FileSystemType) SLANG_GET_VALUE_CATEGORY(HelpStyle, CommandOptionsWriter::Style) SLANG_GET_VALUE_CATEGORY(OptimizationLevel, SlangOptimizationLevel) SLANG_GET_VALUE_CATEGORY(VulkanShift, HLSLToVulkanLayoutOptions::Kind) SLANG_GET_VALUE_CATEGORY(SourceEmbedStyle, SourceEmbedUtil::Style) SLANG_GET_VALUE_CATEGORY(Language, SourceLanguage) } // namespace static void _addOptions(const ConstArrayView