From d4316c88457a32f1169b2d7d82053ccbc05fa7ed Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 14 May 2021 17:50:00 -0400 Subject: FXC as DownstreamCompiler (#1844) * #include an absolute path didn't work - because paths were taken to always be relative. * WIP Fxc as downstream compiler. * First pass FXC downstream compiler working. * GCC compile fix. * Fix FXC parsing issue. * Special case filesystem access. * Use StringUtil getSlice. * Fix isses with not emitting source for FXC. * Small fixes for DXBC handling. --- source/core/slang-string-util.cpp | 13 +++++++++---- source/core/slang-string-util.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'source/core') diff --git a/source/core/slang-string-util.cpp b/source/core/slang-string-util.cpp index cddee4bc4..7a142f643 100644 --- a/source/core/slang-string-util.cpp +++ b/source/core/slang-string-util.cpp @@ -293,7 +293,7 @@ UnownedStringSlice StringUtil::getAtInSplit(const UnownedStringSlice& in, char s return builder; } -/* static */String StringUtil::getString(ISlangBlob* blob) +/* static */UnownedStringSlice StringUtil::getSlice(ISlangBlob* blob) { if (blob) { @@ -301,15 +301,20 @@ UnownedStringSlice StringUtil::getAtInSplit(const UnownedStringSlice& in, char s if (size > 0) { const char* contents = (const char*)blob->getBufferPointer(); - // Check it has terminating 0, if not we must construct as if it does + // Check it has terminating 0, if it has we skip it, because slices do not need zero termination if (contents[size - 1] == 0) { size--; } - return String(contents, contents + size); + return UnownedStringSlice(contents, contents + size); } } - return String(); + return UnownedStringSlice(); +} + +/* static */String StringUtil::getString(ISlangBlob* blob) +{ + return getSlice(blob); } ComPtr StringUtil::createStringBlob(const String& string) diff --git a/source/core/slang-string-util.h b/source/core/slang-string-util.h index 5b375a09e..2b30120b7 100644 --- a/source/core/slang-string-util.h +++ b/source/core/slang-string-util.h @@ -69,6 +69,7 @@ struct StringUtil /// Given a string held in a blob, returns as a String /// Returns an empty string if blob is nullptr static String getString(ISlangBlob* blob); + static UnownedStringSlice getSlice(ISlangBlob* blob); /// Given a string or slice, replaces all instances of fromChar with toChar static String calcCharReplaced(const UnownedStringSlice& slice, char fromChar, char toChar); -- cgit v1.2.3