From 77fe3dd74446fb07dd0de31114f7033f111ef868 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 15 Aug 2019 18:38:59 -0400 Subject: A more convoluted #pragma once file identity test, using relative paths. (#1021) * A more convoluted #pragma once file identity test, using relative paths. * Fix bug with passing - to slang as a command line option causes a crash. Ability to set file-system to use on command line. #pragma once tests try with 'normal' and 'read-file' only versions * OSFileSystem -> OSFileSystemExt LoadFileOSFileSystem -> OSFileSystem Implemented OSFileSystem like OSFileSystemExt as as singleton. Fixes to comments. --- source/slang/slang-options.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'source/slang/slang-options.cpp') diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index 81fb468eb..5918f1551 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -8,6 +8,8 @@ #include "slang-compiler.h" #include "slang-profile.h" +#include "slang-file-system.h" + #include namespace Slang { @@ -632,7 +634,7 @@ struct OptionsParser SLANG_RETURN_ON_FAIL(tryReadCommandLineArgument(sink, arg, &argCursor, argEnd, name)); addSharedLibraryPath(SharedLibraryType::Fxc, name); } - else if (argStr[1] == 'D') + else if (argStr.getLength() >= 2 && argStr[1] == 'D') { // The value to be defined might be part of the same option, as in: // -DFOO @@ -677,7 +679,7 @@ struct OptionsParser ""); } } - else if (argStr[1] == 'I') + else if (argStr.getLength() >= 2 && argStr[1] == 'I') { // The value to be defined might be part of the same option, as in: // -IFOO @@ -803,6 +805,25 @@ struct OptionsParser { requestImpl->getBackEndReq()->useUnknownImageFormatAsDefault = true; } + else if (argStr == "-file-system") + { + String name; + SLANG_RETURN_ON_FAIL(tryReadCommandLineArgument(sink, arg, &argCursor, argEnd, name)); + + if (name == "default") + { + spSetFileSystem(compileRequest, nullptr); + } + else if (name == "load-file") + { + spSetFileSystem(compileRequest, OSFileSystem::getSingleton()); + } + else + { + sink->diagnose(SourceLoc(), Diagnostics::unknownFileSystemOption, name); + return SLANG_FAIL; + } + } else if (argStr == "--") { // The `--` option causes us to stop trying to parse options, -- cgit v1.2.3