From e6cf93e3e638cb981a9be392a2f48ea06acd4e3f Mon Sep 17 00:00:00 2001 From: Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> Date: Mon, 25 Nov 2024 21:57:48 -0500 Subject: Fix issue with slang-embed & include ordering (#5680) * Fix issue with slang-embed & include ordering * Update CMakeLists.txt --- tools/slang-embed/slang-embed.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/slang-embed/slang-embed.cpp b/tools/slang-embed/slang-embed.cpp index eb493be4b..8cba887f3 100644 --- a/tools/slang-embed/slang-embed.cpp +++ b/tools/slang-embed/slang-embed.cpp @@ -63,6 +63,7 @@ struct App { char const* appName = "slang-embed"; char const* inputPath = nullptr; + char const* includeDir = nullptr; char const* outputPath = nullptr; Slang::HashSet includedFiles; @@ -83,6 +84,12 @@ struct App argc--; } + if (argc > 0) + { + includeDir = *argv++; + argc--; + } + if (argc > 0) { outputPath = *argv++; @@ -91,7 +98,7 @@ struct App if (!inputPath || (argc != 0)) { - fprintf(stderr, "usage: %s inputPath [outputPath]\n", appName); + fprintf(stderr, "usage: %s inputPath includeDir [outputPath]\n", appName); exit(1); } } @@ -137,7 +144,13 @@ struct App auto path = Slang::Path::combine(Slang::Path::getParentDirectory(inputPath), fileName); if (!Slang::File::exists(path)) - goto normalProcess; + { + // Try looking in the include directory. + path = Slang::Path::combine(includeDir, fileName); + + if (!Slang::File::exists(path)) + goto normalProcess; + } processInputFile(outputFile, path.getUnownedSlice()); continue; } -- cgit v1.2.3