Infrastructure: add include search paths (-I, etc.).
diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp
index 40110e3..0b8b8f4 100644
--- a/StandAlone/StandAlone.cpp
+++ b/StandAlone/StandAlone.cpp
@@ -167,6 +167,7 @@
const char* sourceEntryPointName = nullptr;
const char* shaderStageName = nullptr;
const char* variableName = nullptr;
+std::vector<std::string> IncludeDirectoryList;
std::array<unsigned int, EShLangCount> baseSamplerBinding;
std::array<unsigned int, EShLangCount> baseTextureBinding;
@@ -407,6 +408,13 @@
Options |= EOptionLinkProgram;
}
break;
+ case 'I':
+ if (argv[0][2] == 0) {
+ printf("include path must immediately follow (no spaces) -I\n");
+ exit(EFailUsage);
+ }
+ IncludeDirectoryList.push_back(argv[0]+2);
+ break;
case 'V':
Options |= EOptionSpv;
Options |= EOptionVulkanRules;
@@ -668,6 +676,8 @@
const int defaultVersion = Options & EOptionDefaultDesktop? 110: 100;
DirStackFileIncluder includer;
+ std::for_each(IncludeDirectoryList.rbegin(), IncludeDirectoryList.rend(), [&includer](const std::string& dir) {
+ includer.pushExternalLocalDirectory(dir); });
if (Options & EOptionOutputPreprocessed) {
std::string str;
if (shader->preprocess(&Resources, defaultVersion, ENoProfile, false, false,
@@ -1031,6 +1041,8 @@
" -G create SPIR-V binary, under OpenGL semantics; turns on -l;\n"
" default file name is <stage>.spv (-o overrides this)\n"
" -H print human readable form of SPIR-V; turns on -V\n"
+ " -I<dir> add dir to the include search path; includer's directory\n"
+ " is searched first, followed by left-to-right order of -I\n"
" -E print pre-processed GLSL; cannot be used with -l;\n"
" errors will appear on stderr.\n"
" -S <stage> uses specified stage rather than parsing the file extension\n"