diff options
Diffstat (limited to 'source')
28 files changed, 913 insertions, 115 deletions
diff --git a/source/core/core.vcxproj b/source/core/core.vcxproj index 97dc19d66..5dad716fb 100644 --- a/source/core/core.vcxproj +++ b/source/core/core.vcxproj @@ -182,6 +182,7 @@ <ClInclude Include="list.h" /> <ClInclude Include="platform.h" /> <ClInclude Include="secure-crt.h" /> + <ClInclude Include="slang-app-context.h" /> <ClInclude Include="slang-byte-encode-util.h" /> <ClInclude Include="slang-cpu-defines.h" /> <ClInclude Include="slang-free-list.h" /> @@ -194,6 +195,7 @@ <ClInclude Include="slang-string-slice-pool.h" /> <ClInclude Include="slang-string-util.h" /> <ClInclude Include="slang-string.h" /> + <ClInclude Include="slang-writer.h" /> <ClInclude Include="smart-pointer.h" /> <ClInclude Include="stream.h" /> <ClInclude Include="text-io.h" /> @@ -202,6 +204,7 @@ </ItemGroup> <ItemGroup> <ClCompile Include="platform.cpp" /> + <ClCompile Include="slang-app-context.cpp" /> <ClCompile Include="slang-byte-encode-util.cpp" /> <ClCompile Include="slang-free-list.cpp" /> <ClCompile Include="slang-io.cpp" /> @@ -212,6 +215,7 @@ <ClCompile Include="slang-string-slice-pool.cpp" /> <ClCompile Include="slang-string-util.cpp" /> <ClCompile Include="slang-string.cpp" /> + <ClCompile Include="slang-writer.cpp" /> <ClCompile Include="stream.cpp" /> <ClCompile Include="text-io.cpp" /> <ClCompile Include="token-reader.cpp" /> diff --git a/source/core/core.vcxproj.filters b/source/core/core.vcxproj.filters index b470f9b43..c5c1fc733 100644 --- a/source/core/core.vcxproj.filters +++ b/source/core/core.vcxproj.filters @@ -45,6 +45,9 @@ <ClInclude Include="secure-crt.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="slang-app-context.h"> + <Filter>Header Files</Filter> + </ClInclude> <ClInclude Include="slang-byte-encode-util.h"> <Filter>Header Files</Filter> </ClInclude> @@ -81,6 +84,9 @@ <ClInclude Include="slang-string.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="slang-writer.h"> + <Filter>Header Files</Filter> + </ClInclude> <ClInclude Include="smart-pointer.h"> <Filter>Header Files</Filter> </ClInclude> @@ -101,6 +107,9 @@ <ClCompile Include="platform.cpp"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="slang-app-context.cpp"> + <Filter>Source Files</Filter> + </ClCompile> <ClCompile Include="slang-byte-encode-util.cpp"> <Filter>Source Files</Filter> </ClCompile> @@ -131,6 +140,9 @@ <ClCompile Include="slang-string.cpp"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="slang-writer.cpp"> + <Filter>Source Files</Filter> + </ClCompile> <ClCompile Include="stream.cpp"> <Filter>Source Files</Filter> </ClCompile> diff --git a/source/core/slang-app-context.cpp b/source/core/slang-app-context.cpp new file mode 100644 index 000000000..2b3f32cbc --- /dev/null +++ b/source/core/slang-app-context.cpp @@ -0,0 +1,67 @@ + +#include "slang-app-context.h" + +#include "slang-writer.h" + +namespace Slang +{ + +/* static */AppContext* AppContext::s_singleton = nullptr; + + +/* static */AppContext* AppContext::getDefault() +{ + static AppContext* s_context = nullptr; + + if (!s_context) + { + static FileWriter s_stdError(stderr, WriterFlag::IsStatic | WriterFlag::IsUnowned | WriterFlag::AutoFlush); + static FileWriter s_stdOut(stdout, WriterFlag::IsStatic | WriterFlag::IsUnowned | WriterFlag::AutoFlush); + + static AppContext s_contextVar; + s_context = &s_contextVar; + + s_context->setWriter(SLANG_WRITER_CHANNEL_STD_ERROR, &s_stdError); + s_context->setWriter(SLANG_WRITER_CHANNEL_STD_OUTPUT, &s_stdOut); + } + return s_context; +} + +/* static */AppContext* AppContext::initDefault() +{ + AppContext* context = getDefault(); + setSingleton(context); + return context; +} + +/* static */int AppContext::getReturnCode(SlangResult res) +{ + if (SLANG_SUCCEEDED(res)) + { + return 0; + } + else if (res == SLANG_E_INTERNAL_FAIL) + { + return -1; + } + return 1; +} + +void AppContext::setRequestWriters(SlangCompileRequest* request) +{ + for (int i = 0; i < SLANG_WRITER_CHANNEL_COUNT_OF; ++i) + { + if (m_replaceWriterFlags & (1 << i)) + { + spSetWriter(request, SlangWriterChannel(i), m_writers[i]); + } + } +} + +void AppContext::configureRequest(SlangCompileRequest* request) +{ + setRequestWriters(request); +} + +} + diff --git a/source/core/slang-app-context.h b/source/core/slang-app-context.h new file mode 100644 index 000000000..9f1eb306c --- /dev/null +++ b/source/core/slang-app-context.h @@ -0,0 +1,60 @@ +#ifndef SLANG_APP_CONTEXT_H +#define SLANG_APP_CONTEXT_H + +#include "slang-writer.h" +#include "../../slang-com-ptr.h" + +namespace Slang +{ + +#ifdef SLANG_SHARED_LIBRARY_TOOL +# define SLANG_SHARED_LIBRARY_TOOL_API SLANG_EXTERN_C SLANG_DLL_EXPORT +#else +# define SLANG_SHARED_LIBRARY_TOOL_API +#endif + +/* A structure to hold general state shared across an application */ +class AppContext +{ +public: + + ISlangWriter * getWriter(SlangWriterChannel chan) const { return m_writers[chan]; } + void setWriter(SlangWriterChannel chan, ISlangWriter* writer) { m_writers[chan] = writer; } + + /// Make modifications to the request + void configureRequest(SlangCompileRequest* request); + + void setRequestWriters(SlangCompileRequest* request); + + void setReplaceWriterFlagsAll() { setReplaceWriterFlags((1 << SLANG_WRITER_CHANNEL_COUNT_OF) - 1); } + void setReplaceWriterFlags(int flags) { m_replaceWriterFlags = flags; } + int getReplaceWriterFlags() const { return m_replaceWriterFlags; } + + /// Ctor + AppContext() : m_replaceWriterFlags(0) {} + + /// Initialize a default context + static AppContext* initDefault(); + + static AppContext* getDefault(); + + static AppContext* getSingleton() { return s_singleton; } + static void setSingleton(AppContext* context) { s_singleton = context; } + + static WriterHelper getStdError() { return getSingleton()->getWriter(SLANG_WRITER_CHANNEL_STD_ERROR); } + static WriterHelper getStdOut() { return getSingleton()->getWriter(SLANG_WRITER_CHANNEL_STD_OUTPUT); } + static WriterHelper getDiagnostic() { return getSingleton()->getWriter(SLANG_WRITER_CHANNEL_DIAGNOSTIC); } + + static int getReturnCode(SlangResult res); + +protected: + + ComPtr<ISlangWriter> m_writers[SLANG_WRITER_CHANNEL_COUNT_OF]; + int m_replaceWriterFlags; ///< Bit for each writer + + static AppContext* s_singleton; +}; + +} + +#endif diff --git a/source/core/slang-string-util.cpp b/source/core/slang-string-util.cpp index 6d0d896a1..cb5709759 100644 --- a/source/core/slang-string-util.cpp +++ b/source/core/slang-string-util.cpp @@ -39,32 +39,39 @@ static const Guid IID_ISlangBlob = SLANG_UUID_ISlangBlob; } } - -/* static */void StringUtil::append(const char* format, va_list args, StringBuilder& buf) +/* static */size_t StringUtil::calcFormattedSize(const char* format, va_list args) { - int numChars = 0; +#if SLANG_WINDOWS_FAMILY + return _vscprintf(format, args); +#else + return vsnprintf(nullptr, 0, format, args); +#endif +} +/* static */void StringUtil::calcFormatted(const char* format, va_list args, size_t numChars, char* dst) +{ #if SLANG_WINDOWS_FAMILY - numChars = _vscprintf(format, args); + vsnprintf_s(dst, numChars + 1, _TRUNCATE, format, args); #else + vsnprintf(dst, numChars + 1, format, args); +#endif +} + +/* static */void StringUtil::append(const char* format, va_list args, StringBuilder& buf) +{ + // Calculate the size + size_t numChars; { + // Create a copy of args, as will be consumed by calcFormattedSize va_list argsCopy; va_copy(argsCopy, args); - numChars = vsnprintf(nullptr, 0, format, argsCopy); + numChars = calcFormattedSize(format, argsCopy); va_end(argsCopy); } -#endif - - List<char> chars; - chars.SetSize(numChars + 1); - -#if SLANG_WINDOWS_FAMILY - vsnprintf_s(chars.Buffer(), numChars + 1, _TRUNCATE, format, args); -#else - vsnprintf(chars.Buffer(), numChars + 1, format, args); -#endif - buf.Append(chars.Buffer(), numChars); + char* dst = buf.prepareForAppend(numChars + 1); + calcFormatted(format, args, numChars, dst); + buf.appendInPlace(dst, numChars); } /* static */void StringUtil::appendFormat(StringBuilder& buf, const char* format, ...) diff --git a/source/core/slang-string-util.h b/source/core/slang-string-util.h index b365b6cf5..0579dd057 100644 --- a/source/core/slang-string-util.h +++ b/source/core/slang-string-util.h @@ -41,6 +41,15 @@ struct StringUtil /// Slices contents will directly address into in, so contents will only stay valid as long as in does. static void split(const UnownedStringSlice& in, char splitChar, List<UnownedStringSlice>& slicesOut); + /// Returns the size in bytes needed to hold the formatted string using the specified args, NOT including a terminating 0 + /// NOTE! The caller *should* assume this will consume the va_list (use va_copy to make a copy to be consumed) + static size_t calcFormattedSize(const char* format, va_list args); + + /// Calculate the formatted string using the specified args. + /// NOTE! The caller *should* assume this will consume the va_list + /// The buffer should be at least calcFormattedSize + 1 bytes. The +1 is needed because a terminating 0 is written. + static void calcFormatted(const char* format, va_list args, size_t numChars, char* dst); + /// Appends formatted string with args into buf static void append(const char* format, va_list args, StringBuilder& buf); diff --git a/source/core/slang-string.cpp b/source/core/slang-string.cpp index b195e12d5..648249b2c 100644 --- a/source/core/slang-string.cpp +++ b/source/core/slang-string.cpp @@ -253,7 +253,31 @@ namespace Slang ensureUniqueStorageWithCapacity(newLength); return getData() + oldLength; } + void String::appendInPlace(const char* chars, UInt count) + { + SLANG_UNUSED(chars); + + if (count > 0) + { + SLANG_ASSERT(buffer && buffer->isUniquelyReferenced()); + + auto oldLength = getLength(); + auto newLength = oldLength + count; + + char* dst = buffer->getData(); + // Make sure the input buffer is the same one returned from prepareForAppend + SLANG_ASSERT(chars == dst + oldLength); + // It has to fit within the capacity + SLANG_ASSERT(newLength <= buffer->capacity); + + // We just need to modify the length + buffer->length = newLength; + + // And mark with a terminating 0 + dst[newLength] = 0; + } + } void String::append(const char* textBegin, char const* textEnd) { diff --git a/source/core/slang-string.h b/source/core/slang-string.h index fb60ef562..435e2b29b 100644 --- a/source/core/slang-string.h +++ b/source/core/slang-string.h @@ -329,8 +329,7 @@ namespace Slang } void ensureUniqueStorageWithCapacity(UInt capacity); - char* prepareForAppend(UInt count); - + RefPtr<StringRepresentation> buffer; public: @@ -347,6 +346,11 @@ namespace Slang { } + /// Returns a buffer which can hold at least count chars + char* prepareForAppend(UInt count); + /// Append data written to buffer output via 'prepareForAppend' directly written 'inplace' + void appendInPlace(const char* chars, UInt count); + SLANG_FORCE_INLINE StringRepresentation* getStringRepresentation() const { return buffer; } const char * begin() const diff --git a/source/core/slang-writer.cpp b/source/core/slang-writer.cpp new file mode 100644 index 000000000..4c5df0c8a --- /dev/null +++ b/source/core/slang-writer.cpp @@ -0,0 +1,152 @@ +#include "slang-writer.h" + +#include "platform.h" +#include "slang-string-util.h" + +// Includes to allow us to control console +// output when writing assembly dumps. +#include <fcntl.h> +#ifdef _WIN32 +# include <io.h> +#else +# include <unistd.h> +#endif + +#include <stdarg.h> + +namespace Slang +{ +static const Guid IID_ISlangWriter = SLANG_UUID_ISlangWriter; +static const Guid IID_ISlangUnknown = SLANG_UUID_ISlangUnknown; + +/* !!!!!!!!!!!!!!!!!!!!!!!!! WriterHelper !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ + +SlangResult WriterHelper::print(const char* format, ...) +{ + va_list args; + va_start(args, format); + SlangResult res = m_writer->writeVaList(format, args); + + if (res == SLANG_E_NOT_IMPLEMENTED) + { + StringBuilder builder; + StringUtil::append(format, args, builder); + + // Write if there is anything to write + res = (builder.Length()) ? m_writer->write(builder.Buffer(), builder.Length()) : SLANG_OK; + } + + va_end(args); + return res; +} + +SlangResult WriterHelper::put(const char* text) +{ + return m_writer->write(text, ::strlen(text)); +} + +/* !!!!!!!!!!!!!!!!!!!!!!!!! BaseWriter !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ + +ISlangUnknown* BaseWriter::getInterface(const Guid& guid) +{ + return (guid == IID_ISlangUnknown || guid == IID_ISlangWriter) ? static_cast<ISlangWriter*>(this) : nullptr; +} + +/* !!!!!!!!!!!!!!!!!!!!!!!!! CallbackWriter !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ + +SlangResult CallbackWriter::write(const char* chars, size_t numChars) +{ + if (numChars > 0) + { + // Make sure zero terminated + StringBuilder builder; + builder.Append(chars, numChars); + + m_callback(builder.Buffer(), (void*)m_data); + } + + return SLANG_OK; +} + +/* !!!!!!!!!!!!!!!!!!!!!!!!! FileWriter !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ + +FileWriter::~FileWriter() +{ + if ((m_flags & WriterFlag::IsUnowned) == 0) + { + fclose(m_file); + } +} + +SlangResult FileWriter::writeVaList(const char* format, va_list args) +{ + // http://www.cplusplus.com/reference/cstdio/vfprintf/ + ::vfprintf(m_file, format, args); + + if (m_flags & WriterFlag::AutoFlush) + { + ::fflush(m_file); + } + + return SLANG_OK; +} + +SlangResult FileWriter::write(const char* text, size_t numChars) +{ + const size_t numWritten = ::fwrite(text, sizeof(char), numChars, m_file); + if (m_flags & WriterFlag::AutoFlush) + { + ::fflush(m_file); + } + return numChars == numWritten ? SLANG_OK : SLANG_FAIL; +} + +void FileWriter::flush() +{ + ::fflush(m_file); +} + +/* static */bool FileWriter::isConsole(FILE* file) +{ + const int stdoutFileDesc = _fileno(file); + return _isatty(stdoutFileDesc) != 0; +} + +SlangResult FileWriter::setMode(SlangWriterMode mode) +{ + switch (mode) + { + case SLANG_WRITER_MODE_BINARY: + { +#ifdef _WIN32 + int stdoutFileDesc = _fileno(m_file); + _setmode(stdoutFileDesc, _O_BINARY); + return SLANG_OK; +#else + break; +#endif + } + default: break; + } + return SLANG_FAIL; +} + +/* !!!!!!!!!!!!!!!!!!!!!!!!! StringWriter !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ + +SlangResult StringWriter::writeVaList(const char* format, va_list args) +{ + StringUtil::append(format, args, *m_builder); + return SLANG_OK; +} + +SlangResult StringWriter::write(const char* chars, size_t numChars) +{ + if (numChars > 0) + { + m_builder->Append(chars, numChars); + } + return SLANG_OK; +} + +} + diff --git a/source/core/slang-writer.h b/source/core/slang-writer.h new file mode 100644 index 000000000..0fa336d6e --- /dev/null +++ b/source/core/slang-writer.h @@ -0,0 +1,145 @@ +#ifndef SLANG_WRITER_H +#define SLANG_WRITER_H + +#include "slang-string.h" + +#include "../../slang-com-helper.h" + +namespace Slang +{ + + +class WriterHelper +{ +public: + SlangResult print(const char* format, ...); + SlangResult put(const char* text); + + SLANG_FORCE_INLINE void flush() { m_writer->flush(); } + + ISlangWriter* getWriter() const { return m_writer; } + + WriterHelper(ISlangWriter* writer) :m_writer(writer) {} + +protected: + ISlangWriter* m_writer; +}; + +struct WriterFlag +{ + enum Enum :uint32_t + { + IsStatic = 0x1, ///< Means non ref counted + IsConsole = 0x2, ///< True if console + IsUnowned = 0x4, ///< True if doesn't own contained type + AutoFlush = 0x8, ///< Automatically flushes after every call + }; +private: + WriterFlag() = delete; +}; +typedef uint32_t WriterFlags; + +class BaseWriter : public ISlangWriter, public RefObject +{ +public: + // ISlangUnknown + SLANG_REF_OBJECT_IUNKNOWN_QUERY_INTERFACE + SLANG_REF_OBJECT_IUNKNOWN_ADD_REF + SLANG_NO_THROW uint32_t SLANG_MCALL release() { return (m_flags & WriterFlag::IsStatic) ? 1 : (uint32_t)releaseReference(); } + + // ISlangWriter - default impl + SLANG_NO_THROW virtual SlangResult SLANG_MCALL writeVaList(const char* format, va_list args) { SLANG_UNUSED(args); SLANG_UNUSED(format); return SLANG_E_NOT_IMPLEMENTED; } + SLANG_NO_THROW virtual void SLANG_MCALL flush() SLANG_OVERRIDE {} + SLANG_NO_THROW virtual bool SLANG_MCALL isConsole() SLANG_OVERRIDE { return (m_flags & WriterFlag::IsConsole) != 0; } + SLANG_NO_THROW virtual SlangResult SLANG_MCALL setMode(SlangWriterMode mode) SLANG_OVERRIDE { SLANG_UNUSED(mode); return SLANG_FAIL; } + + BaseWriter(WriterFlags flags) : + m_flags(flags) + { + } + +protected: + ISlangUnknown * getInterface(const Guid& guid); + WriterFlags m_flags; +}; + +class CallbackWriter : public BaseWriter +{ +public: + typedef BaseWriter Parent; + // ISlangWriter + SLANG_NO_THROW virtual SlangResult SLANG_MCALL write(const char* chars, size_t numChars) SLANG_OVERRIDE; + + CallbackWriter(SlangDiagnosticCallback callback, const void* data, WriterFlags flags) : + Parent(flags), + m_callback(callback), + m_data(data) + {} + +protected: + + SlangDiagnosticCallback m_callback; + const void* m_data; +}; + +class FileWriter : public BaseWriter +{ +public: + typedef BaseWriter Parent; + // ISlangWriter + SLANG_NO_THROW virtual SlangResult SLANG_MCALL writeVaList(const char* format, va_list args) SLANG_OVERRIDE; + SLANG_NO_THROW virtual SlangResult SLANG_MCALL write(const char* chars, size_t numChars) SLANG_OVERRIDE; + SLANG_NO_THROW virtual void SLANG_MCALL flush() SLANG_OVERRIDE; + SLANG_NO_THROW virtual SlangResult SLANG_MCALL setMode(SlangWriterMode mode) SLANG_OVERRIDE; + + static bool isConsole(FILE* file); + static WriterFlags getDefaultFlags(FILE* file) { return isConsole(file) ? WriterFlags(WriterFlag::IsConsole) : 0; } + + /// Ctor + FileWriter(FILE* file, WriterFlags flags) : + Parent(flags | getDefaultFlags(file)), + m_file(file) + {} + + /// Dtor + ~FileWriter(); + +protected: + FILE* m_file; +}; + +class StringWriter : public BaseWriter +{ +public: + typedef BaseWriter Parent; + // ISlangWriter + SLANG_NO_THROW virtual SlangResult SLANG_MCALL writeVaList(const char* format, va_list args) SLANG_OVERRIDE; + SLANG_NO_THROW virtual SlangResult SLANG_MCALL write(const char* chars, size_t numChars) SLANG_OVERRIDE; + + /// Ctor + StringWriter(StringBuilder* builder, WriterFlags flags) : + Parent(flags), + m_builder(builder) + {} + +protected: + StringBuilder* m_builder; +}; + +class NullWriter : public BaseWriter +{ +public: + typedef BaseWriter Parent; + // ISlangWriter + SLANG_NO_THROW virtual SlangResult SLANG_MCALL writeVaList(const char* format, va_list args) SLANG_OVERRIDE { SLANG_UNUSED(format); SLANG_UNUSED(args); return SLANG_OK; } + SLANG_NO_THROW virtual SlangResult SLANG_MCALL write(const char* chars, size_t numChars) SLANG_OVERRIDE { SLANG_UNUSED(chars); SLANG_UNUSED(numChars); return SLANG_OK; } + + /// Ctor + NullWriter(WriterFlags flags) : + Parent(flags) + {} +}; + +} + +#endif // SLANG_TEXT_WRITER_H diff --git a/source/slang/check.cpp b/source/slang/check.cpp index 21e3b894b..4f914ee1f 100644 --- a/source/slang/check.cpp +++ b/source/slang/check.cpp @@ -1006,6 +1006,15 @@ namespace Slang } } + if (!type) + { + if (outProperType) + { + *outProperType = nullptr; + } + return false; + } + if (auto genericDeclRefType = type->As<GenericDeclRefType>()) { // We are using a reference to a generic declaration as a concrete @@ -1034,7 +1043,7 @@ namespace Slang } // TODO: this is one place where syntax should get cloned! - if(outProperType) + if (outProperType) args.Add(typeParam->initType.exp); } else if (auto valParam = member.As<GenericValueParamDecl>()) @@ -1050,7 +1059,7 @@ namespace Slang } // TODO: this is one place where syntax should get cloned! - if(outProperType) + if (outProperType) args.Add(valParam->initExpr); } else @@ -1065,15 +1074,13 @@ namespace Slang } return true; } - else + + // default case: we expect this to already be a proper type + if (outProperType) { - // default case: we expect this to already be a proper type - if (outProperType) - { - *outProperType = type; - } - return true; + *outProperType = type; } + return true; } @@ -1147,7 +1154,7 @@ namespace Slang { // TODO: we may want other cases here... - if (auto errorType = expr->type->As<ErrorType>()) + if (auto errorType = expr->type.As<ErrorType>()) return true; return false; @@ -7229,7 +7236,7 @@ namespace Slang // for anything applicable. AddDeclRefOverloadCandidates(LookupResultItem(declRefExpr->declRef), context); } - else if (auto funcType = funcExprType->As<FuncType>()) + else if (auto funcType = funcExprType.As<FuncType>()) { // TODO(tfoley): deprecate this path... AddFuncOverloadCandidate(funcType, context); @@ -7250,7 +7257,7 @@ namespace Slang AddOverloadCandidates(item, context); } } - else if (auto typeType = funcExprType->As<TypeType>()) + else if (auto typeType = funcExprType.As<TypeType>()) { // If none of the above cases matched, but we are // looking at a type, then I suppose we have diff --git a/source/slang/compiler.cpp b/source/slang/compiler.cpp index 0f333aa3d..172bc33b9 100644 --- a/source/slang/compiler.cpp +++ b/source/slang/compiler.cpp @@ -864,6 +864,23 @@ SlangResult dissassembleDXILUsingDXC( static void writeOutputFile( CompileRequest* compileRequest, + ISlangWriter* writer, + String const& path, + void const* data, + size_t size) + { + + if (SLANG_FAILED(writer->write((const char*)data, size))) + { + compileRequest->mSink.diagnose( + SourceLoc(), + Diagnostics::cannotWriteOutputFile, + path); + } + } + + static void writeOutputFile( + CompileRequest* compileRequest, String const& path, void const* data, size_t size, @@ -924,14 +941,10 @@ SlangResult dissassembleDXILUsingDXC( } static void writeOutputToConsole( - CompileRequest*, + ISlangWriter* writer, String const& text) { - fwrite( - text.begin(), - text.end() - text.begin(), - 1, - stdout); + writer->write(text.Buffer(), text.Length()); } static void writeEntryPointResultToStandardOutput( @@ -941,17 +954,19 @@ SlangResult dissassembleDXILUsingDXC( { auto compileRequest = entryPoint->compileRequest; + ISlangWriter* writer = compileRequest->getWriter(WriterChannel::StdOutput); + switch (result.format) { case ResultFormat::Text: - writeOutputToConsole(compileRequest, result.outputString); + writeOutputToConsole(writer, result.outputString); break; case ResultFormat::Binary: { auto& data = result.outputBinary; - int stdoutFileDesc = _fileno(stdout); - if (_isatty(stdoutFileDesc)) + + if (writer->isConsole()) { // Writing to console, so we need to generate text output. @@ -964,7 +979,7 @@ SlangResult dissassembleDXILUsingDXC( dissassembleDXBC(compileRequest, data.begin(), data.end() - data.begin(), assembly); - writeOutputToConsole(compileRequest, assembly); + writeOutputToConsole(writer, assembly); } break; #endif @@ -977,7 +992,7 @@ SlangResult dissassembleDXILUsingDXC( data.begin(), data.end() - data.begin(), assembly); - writeOutputToConsole(compileRequest, assembly); + writeOutputToConsole(writer, assembly); } break; #endif @@ -988,7 +1003,7 @@ SlangResult dissassembleDXILUsingDXC( dissassembleSPIRV(compileRequest, data.begin(), data.end() - data.begin(), assembly); - writeOutputToConsole(compileRequest, assembly); + writeOutputToConsole(writer, assembly); } break; @@ -1000,12 +1015,11 @@ SlangResult dissassembleDXILUsingDXC( else { // Redirecting stdout to a file, so do the usual thing - #ifdef _WIN32 - _setmode(stdoutFileDesc, _O_BINARY); - #endif + writer->setMode(SLANG_WRITER_MODE_BINARY); + writeOutputFile( compileRequest, - stdout, + writer, "stdout", data.begin(), data.end() - data.begin()); diff --git a/source/slang/compiler.h b/source/slang/compiler.h index fbd6b3f15..2a9b60d9b 100644 --- a/source/slang/compiler.h +++ b/source/slang/compiler.h @@ -212,6 +212,20 @@ namespace Slang Precise = SLANG_FLOATING_POINT_MODE_PRECISE, }; + enum class WriterChannel : SlangWriterChannel + { + Diagnostic = SLANG_WRITER_CHANNEL_DIAGNOSTIC, + StdOutput = SLANG_WRITER_CHANNEL_STD_OUTPUT, + StdError = SLANG_WRITER_CHANNEL_STD_ERROR, + CountOf = SLANG_WRITER_CHANNEL_COUNT_OF, + }; + + enum class WriterMode : SlangWriterMode + { + Text = SLANG_WRITER_MODE_TEXT, + Binary = SLANG_WRITER_MODE_BINARY, + }; + // A request to generate output in some target format class TargetRequest : public RefObject { @@ -401,6 +415,12 @@ namespace Slang /// or a wrapped impl that makes fileSystem operate as fileSystemExt ComPtr<ISlangFileSystemExt> fileSystemExt; + // For output + ComPtr<ISlangWriter> m_writers[SLANG_WRITER_CHANNEL_COUNT_OF]; + + void setWriter(WriterChannel chan, ISlangWriter* writer); + ISlangWriter* getWriter(WriterChannel chan) const { return m_writers[int(chan)]; } + /// Load a file into memory using the configured file system. /// /// @param path The path to attempt to load from diff --git a/source/slang/diagnostics.cpp b/source/slang/diagnostics.cpp index f1d0b63f9..4000fd967 100644 --- a/source/slang/diagnostics.cpp +++ b/source/slang/diagnostics.cpp @@ -237,13 +237,13 @@ void DiagnosticSink::diagnoseImpl(SourceLoc const& pos, DiagnosticInfo const& in } // Did the client supply a callback for us to use? - if( callback ) + if( writer ) { // If so, pass the error string along to them StringBuilder messageBuilder; formatDiagnostic(this, messageBuilder, diagnostic); - callback(messageBuilder.ProduceString().begin(), callbackUserData); + writer->write(messageBuilder.Buffer(), messageBuilder.Length()); } else { @@ -269,10 +269,10 @@ void DiagnosticSink::diagnoseRaw( } // Did the client supply a callback for us to use? - if( callback ) + if(writer) { // If so, pass the error string along to them - callback(message, callbackUserData); + writer->write(message, ::strlen(message)); } else { diff --git a/source/slang/diagnostics.h b/source/slang/diagnostics.h index 945dc6c73..420b936a3 100644 --- a/source/slang/diagnostics.h +++ b/source/slang/diagnostics.h @@ -143,8 +143,7 @@ namespace Slang // List<Diagnostic> diagnostics; int errorCount = 0; - SlangDiagnosticCallback callback = nullptr; - void* callbackUserData = nullptr; + ISlangWriter* writer = nullptr; /* void Error(int id, const String & msg, const SourceLoc & pos) diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp index d7abbff24..f83ea894a 100644 --- a/source/slang/emit.cpp +++ b/source/slang/emit.cpp @@ -6434,7 +6434,9 @@ String emitEntryPoint( // un-specialized IR. if (translationUnit->compileRequest->shouldDumpIR) { - dumpIR(irModule); + ISlangWriter* writer = translationUnit->compileRequest->getWriter(WriterChannel::StdError); + + dumpIR(irModule, writer); } // Next, we need to ensure that the code we emit for diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp index bc33527cf..784c5034d 100644 --- a/source/slang/ir.cpp +++ b/source/slang/ir.cpp @@ -3239,7 +3239,7 @@ namespace Slang dumpIRModule(&context, module); } - void dumpIR(IRGlobalValue* globalVal) + void dumpIR(IRGlobalValue* globalVal, ISlangWriter* writer) { StringBuilder sb; @@ -3249,8 +3249,11 @@ namespace Slang dumpInst(&context, globalVal); - fprintf(stderr, "%s\n", sb.Buffer()); - fflush(stderr); + writer->write(sb.Buffer(), sb.Length()); + char cr[] = "\n"; + writer->write(cr, 1); + + writer->flush(); } String getSlangIRAssembly(IRModule* module) @@ -3260,13 +3263,16 @@ namespace Slang return sb; } - void dumpIR(IRModule* module) + void dumpIR(IRModule* module, ISlangWriter* writer) { String ir = getSlangIRAssembly(module); - fprintf(stderr, "%s\n", ir.Buffer()); - fflush(stderr); - } + writer->write(ir.Buffer(), ir.Length()); + char cr[] = "\n"; + writer->write(cr, 1); + + writer->flush(); + } // // diff --git a/source/slang/ir.h b/source/slang/ir.h index 8183e038a..6fb0ff728 100644 --- a/source/slang/ir.h +++ b/source/slang/ir.h @@ -1105,8 +1105,8 @@ struct IRModule : RefObject void printSlangIRAssembly(StringBuilder& builder, IRModule* module); String getSlangIRAssembly(IRModule* module); -void dumpIR(IRModule* module); -void dumpIR(IRGlobalValue* globalVal); +void dumpIR(IRModule* module, ISlangWriter* writer); +void dumpIR(IRGlobalValue* globalVal, ISlangWriter* writer); String dumpIRFunc(IRFunc* func); diff --git a/source/slang/lookup.cpp b/source/slang/lookup.cpp index e4ae3c8bb..f74e11016 100644 --- a/source/slang/lookup.cpp +++ b/source/slang/lookup.cpp @@ -177,6 +177,11 @@ void DoMemberLookupImpl( LookupResult& ioResult, BreadcrumbInfo* breadcrumbs) { + if (!baseType) + { + return; + } + // If the type was pointer-like, then dereference it // automatically here. if (auto pointerLikeType = baseType->As<PointerLikeType>()) @@ -482,11 +487,14 @@ void DoLookupImpl( // in the target decl we are extending if (auto extDeclRef = containerDeclRef.As<ExtensionDecl>()) { - if (auto targetDeclRef = extDeclRef.getDecl()->targetType->AsDeclRefType()) + if (extDeclRef.getDecl()->targetType) { - if (auto aggDeclRef = targetDeclRef->declRef.As<AggTypeDecl>()) + if (auto targetDeclRef = extDeclRef.getDecl()->targetType->AsDeclRefType()) { - containerDeclRef = extDeclRef.Substitute(aggDeclRef); + if (auto aggDeclRef = targetDeclRef->declRef.As<AggTypeDecl>()) + { + containerDeclRef = extDeclRef.Substitute(aggDeclRef); + } } } } @@ -703,4 +711,4 @@ LookupResult lookUpMember( return result; } -}
\ No newline at end of file +} diff --git a/source/slang/lower-to-ir.cpp b/source/slang/lower-to-ir.cpp index 8af6292e6..2804854b7 100644 --- a/source/slang/lower-to-ir.cpp +++ b/source/slang/lower-to-ir.cpp @@ -5608,7 +5608,9 @@ IRModule* generateIRForTranslationUnit( // then we can dump the initial IR for the module here. if(compileRequest->shouldDumpIR) { - dumpIR(module); + ISlangWriter* writer = translationUnit->compileRequest->getWriter(WriterChannel::StdError); + + dumpIR(module, writer); } return module; diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 8fe08884e..b0adb2025 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -13,6 +13,7 @@ #include "../slang/type-layout.h" #include "slang-file-system.h" +#include "../core/slang-writer.h" #include "ir-serialize.h" @@ -305,6 +306,12 @@ CompileRequest::CompileRequest(Session* session) sourceManager->initialize(session->getBuiltinSourceManager()); + // Set all the default writers + for (int i = 0; i < int(WriterChannel::CountOf); ++i) + { + setWriter(WriterChannel(i), nullptr); + } + // Set up the default file system SLANG_ASSERT(fileSystem == nullptr); fileSystemExt = new CacheFileSystem(DefaultFileSystem::getSingleton()); @@ -368,9 +375,38 @@ MatrixLayoutMode TargetRequest::getDefaultMatrixLayoutMode() } - // +static ISlangWriter* _getDefaultWriter(WriterChannel chan) +{ + static FileWriter stdOut(stdout, WriterFlag::IsStatic | WriterFlag::IsUnowned); + static FileWriter stdError(stderr, WriterFlag::IsStatic | WriterFlag::IsUnowned); + static NullWriter nullWriter(WriterFlag::IsStatic | WriterFlag::IsConsole); + + switch (chan) + { + case WriterChannel::StdError: return &stdError; + case WriterChannel::StdOutput: return &stdOut; + case WriterChannel::Diagnostic: return &nullWriter; + default: + { + SLANG_ASSERT(!"Unknown type"); + return &stdError; + } + } +} + +void CompileRequest::setWriter(WriterChannel chan, ISlangWriter* writer) +{ + writer = writer ? writer : _getDefaultWriter(chan); + m_writers[int(chan)] = writer; + + if (chan == WriterChannel::Diagnostic) + { + mSink.writer = writer; + } +} + SlangResult CompileRequest::loadFile(String const& path, ISlangBlob** outBlob) { return fileSystemExt->loadFile(path.Buffer(), outBlob); @@ -1205,7 +1241,6 @@ SLANG_API void spSetFileSystem( } } - SLANG_API void spSetCompileFlags( SlangCompileRequest* request, SlangCompileFlags flags) @@ -1319,11 +1354,33 @@ SLANG_API void spSetDiagnosticCallback( SlangDiagnosticCallback callback, void const* userData) { + using namespace Slang; + if(!request) return; auto req = REQ(request); - req->mSink.callback = callback; - req->mSink.callbackUserData = (void*) userData; + ComPtr<ISlangWriter> writer(new CallbackWriter(callback, userData, WriterFlag::IsConsole)); + req->setWriter(WriterChannel::Diagnostic, writer); +} + +SLANG_API void spSetWriter( + SlangCompileRequest* request, + SlangWriterChannel chan, + ISlangWriter* writer) +{ + if (!request) return; + auto req = REQ(request); + + req->setWriter(Slang::WriterChannel(chan), writer); +} + +SLANG_API ISlangWriter* spGetWriter( + SlangCompileRequest* request, + SlangWriterChannel chan) +{ + if (!request) return nullptr; + auto req = REQ(request); + return req->getWriter(Slang::WriterChannel(chan)); } SLANG_API void spAddSearchPath( diff --git a/source/slang/syntax-base-defs.h b/source/slang/syntax-base-defs.h index acc795d8b..81f03d43f 100644 --- a/source/slang/syntax-base-defs.h +++ b/source/slang/syntax-base-defs.h @@ -22,6 +22,7 @@ ABSTRACT_SYNTAX_CLASS(SyntaxNodeBase, NodeBase) template<typename T> T* As() { + SLANG_ASSERT(this); return dynamic_cast<T*>(this); } ) diff --git a/source/slang/syntax.cpp b/source/slang/syntax.cpp index c1585a51a..d354057b2 100644 --- a/source/slang/syntax.cpp +++ b/source/slang/syntax.cpp @@ -153,7 +153,8 @@ void Type::accept(IValVisitor* visitor, void* extra) Type* Type::GetCanonicalType() { - if (!this) return nullptr; + SLANG_ASSERT(this); + Type* et = const_cast<Type*>(this); if (!et->canonicalType) { @@ -1314,7 +1315,7 @@ void Type::accept(IValVisitor* visitor, void* extra) RefPtr<Substitutions> GenericSubstitution::applySubstitutionsShallow(SubstitutionSet substSet, RefPtr<Substitutions> substOuter, int* ioDiff) { - if (!this) return nullptr; + SLANG_ASSERT(this); int diff = 0; @@ -1366,7 +1367,7 @@ void Type::accept(IValVisitor* visitor, void* extra) RefPtr<Substitutions> ThisTypeSubstitution::applySubstitutionsShallow(SubstitutionSet substSet, RefPtr<Substitutions> substOuter, int* ioDiff) { - if (!this) return nullptr; + SLANG_ASSERT(this); int diff = 0; @@ -1385,8 +1386,10 @@ void Type::accept(IValVisitor* visitor, void* extra) bool ThisTypeSubstitution::Equals(Substitutions* subst) { + SLANG_ASSERT(this); if (!subst) - return this == nullptr; + return false; + if (auto thisTypeSubst = dynamic_cast<ThisTypeSubstitution*>(subst)) { return witness->EqualsVal(thisTypeSubst->witness); @@ -1914,7 +1917,7 @@ void Type::accept(IValVisitor* visitor, void* extra) RefPtr<Val> Val::Substitute(SubstitutionSet subst) { - if (!this) return nullptr; + SLANG_ASSERT(this); if (!subst) return this; int diff = 0; return SubstituteImpl(subst, &diff); diff --git a/source/slang/syntax.h b/source/slang/syntax.h index 7bd2afc12..5eb40fefb 100644 --- a/source/slang/syntax.h +++ b/source/slang/syntax.h @@ -293,6 +293,9 @@ namespace Slang RefPtr<Type> type; bool IsLeftValue; + template <typename T> + T* As(); + QualType() : IsLeftValue(false) {} @@ -1108,6 +1111,13 @@ namespace Slang #include "object-meta-end.h" + + template <typename T> + SLANG_FORCE_INLINE T* QualType::As() + { + return type ? type->As<T>() : nullptr; + } + inline RefPtr<Type> GetSub(DeclRef<GenericTypeConstraintDecl> const& declRef) { return declRef.Substitute(declRef.getDecl()->sub.Ptr()); @@ -1314,4 +1324,4 @@ namespace Slang RefPtr<GenericSubstitution> findInnerMostGenericSubstitution(Substitutions* subst); } // namespace Slang -#endif
\ No newline at end of file +#endif diff --git a/source/slang/type-layout.cpp b/source/slang/type-layout.cpp index 2d21d7aef..4281829be 100644 --- a/source/slang/type-layout.cpp +++ b/source/slang/type-layout.cpp @@ -1099,12 +1099,13 @@ createParameterGroupTypeLayout( // There are several different cases that need to be handled here, // depending on whether we have a `ParameterBlock`, a `ConstantBuffer`, // or some other kind of parameter group. Furthermore, in the - // `ParameterBlock` case, we need to deal with differnet layout + // `ParameterBlock` case, we need to deal with different layout // rules depending on whether a block should map to a register `space` // in HLSL or not. // Check if we are working with a parameter block... - auto parameterBlockType = parameterGroupType->As<ParameterBlockType>(); + auto parameterBlockType = parameterGroupType ? parameterGroupType->As<ParameterBlockType>() : nullptr; + // Check if we have a parameter block *and* it should be // allocated into its own register space(s) diff --git a/source/slangc/main.cpp b/source/slangc/main.cpp index ba83a9bdf..e65ce6aa0 100644 --- a/source/slangc/main.cpp +++ b/source/slangc/main.cpp @@ -1,23 +1,24 @@ -// main.cpp +// main.cpp #include "../../slang.h" SLANG_API void spSetCommandLineCompilerMode(SlangCompileRequest* request); #include "../core/slang-io.h" +#include "../core/slang-app-context.h" +#include "../core/slang-writer.h" using namespace Slang; #include <assert.h> -// Try to read an argument for a command-line option. - static void diagnosticCallback( char const* message, void* /*userData*/) { - fputs(message, stderr); - fflush(stderr); + auto stdError = AppContext::getStdError(); + stdError.put(message); + stdError.flush(); } #ifdef _WIN32 @@ -26,14 +27,10 @@ static void diagnosticCallback( #define MAIN main #endif -// Used to identify that compilation was the failure - with a unique 'internal' code -#define SLANG_E_INTERNAL_COMPILE_FAILED SLANG_MAKE_ERROR(SLANG_FACILITY_INTERNAL, 0x7fab) - -static SlangResult innerMain(int argc, char** argv) +SLANG_SHARED_LIBRARY_TOOL_API SlangResult innerMain(AppContext* appContext, SlangSession* session, int argc, const char*const* argv) { - // Parse any command-line options + AppContext::setSingleton(appContext); - SlangSession* session = spCreateSession(nullptr); SlangCompileRequest* compileRequest = spCreateCompileRequest(session); spSetDiagnosticCallback( @@ -43,6 +40,9 @@ static SlangResult innerMain(int argc, char** argv) spSetCommandLineCompilerMode(compileRequest); + // Do any app specific configuration + appContext->configureRequest(compileRequest); + char const* appName = "slangc"; if (argc > 0) appName = argv[0]; @@ -55,47 +55,40 @@ static SlangResult innerMain(int argc, char** argv) } } + SlangResult res = SLANG_OK; + #ifndef _DEBUG try #endif { - // Run the compiler (this will produce any diagnostics through - // our callback above). - if (SLANG_FAILED(spCompile(compileRequest))) - { - // If the compilation failed, then get out of here... - // Turn into an internal Result -> such that return code can be used to vary result to match previous behavior - return SLANG_E_INTERNAL_COMPILE_FAILED; - } - - // Now that we are done, clean up after ourselves - - spDestroyCompileRequest(compileRequest); - spDestroySession(session); + // Run the compiler (this will produce any diagnostics through SLANG_WRITER_TARGET_TYPE_DIAGNOSTIC). + res = spCompile(compileRequest); + // If the compilation failed, then get out of here... + // Turn into an internal Result -> such that return code can be used to vary result to match previous behavior + res = SLANG_FAILED(res) ? SLANG_E_INTERNAL_FAIL : res; } #ifndef _DEBUG catch (Exception & e) { - printf("internal compiler error: %S\n", e.Message.ToWString().begin()); - return SLANG_FAIL; + AppContext::getStdOut().print("internal compiler error: %S\n", e.Message.ToWString().begin()); + res = SLANG_FAIL; } #endif - return SLANG_OK; + + // Now that we are done, clean up after ourselves + spDestroyCompileRequest(compileRequest); + return res; } int MAIN(int argc, char** argv) { - SlangResult res = innerMain(argc, argv); - - if (SLANG_SUCCEEDED(res)) + SlangResult res; { - return 0; - } - else if (res == SLANG_E_INTERNAL_COMPILE_FAILED) - { - return -1; + SlangSession* session = spCreateSession(nullptr); + res = innerMain(AppContext::initDefault(), session, argc, argv); + spDestroySession(session); } - return 1; + return AppContext::getReturnCode(res); } #ifdef _WIN32 diff --git a/source/slangc/slangc-shared-library.vcxproj b/source/slangc/slangc-shared-library.vcxproj new file mode 100644 index 000000000..1e36c1751 --- /dev/null +++ b/source/slangc/slangc-shared-library.vcxproj @@ -0,0 +1,178 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{644921BF-D228-4EEF-8CDA-11716DB06989}</ProjectGuid> + <IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename> + <Keyword>Win32Proj</Keyword> + <RootNamespace>slangc-shared-library</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v140</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v140</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v140</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v140</PlatformToolset> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <LinkIncremental>true</LinkIncremental> + <OutDir>..\..\bin\windows-x86\debug\</OutDir> + <IntDir>..\..\intermediate\windows-x86\debug\slangc-shared-library\</IntDir> + <TargetName>slangc-shared-library</TargetName> + <TargetExt>.dll</TargetExt> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <LinkIncremental>true</LinkIncremental> + <OutDir>..\..\bin\windows-x64\debug\</OutDir> + <IntDir>..\..\intermediate\windows-x64\debug\slangc-shared-library\</IntDir> + <TargetName>slangc-shared-library</TargetName> + <TargetExt>.dll</TargetExt> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <LinkIncremental>false</LinkIncremental> + <OutDir>..\..\bin\windows-x86\release\</OutDir> + <IntDir>..\..\intermediate\windows-x86\release\slangc-shared-library\</IntDir> + <TargetName>slangc-shared-library</TargetName> + <TargetExt>.dll</TargetExt> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <LinkIncremental>false</LinkIncremental> + <OutDir>..\..\bin\windows-x64\release\</OutDir> + <IntDir>..\..\intermediate\windows-x64\release\slangc-shared-library\</IntDir> + <TargetName>slangc-shared-library</TargetName> + <TargetExt>.dll</TargetExt> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PrecompiledHeader>NotUsing</PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <PreprocessorDefinitions>_DEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <DebugInformationFormat>EditAndContinue</DebugInformationFormat> + <Optimization>Disabled</Optimization> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ImportLibrary>..\..\bin\windows-x86\debug\slangc-shared-library.lib</ImportLibrary> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <ClCompile> + <PrecompiledHeader>NotUsing</PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <PreprocessorDefinitions>_DEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <DebugInformationFormat>EditAndContinue</DebugInformationFormat> + <Optimization>Disabled</Optimization> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ImportLibrary>..\..\bin\windows-x64\debug\slangc-shared-library.lib</ImportLibrary> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <PrecompiledHeader>NotUsing</PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <PreprocessorDefinitions>NDEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Optimization>Full</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <MinimalRebuild>false</MinimalRebuild> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + <ImportLibrary>..\..\bin\windows-x86\release\slangc-shared-library.lib</ImportLibrary> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <ClCompile> + <PrecompiledHeader>NotUsing</PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <PreprocessorDefinitions>NDEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Optimization>Full</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <MinimalRebuild>false</MinimalRebuild> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + <ImportLibrary>..\..\bin\windows-x64\release\slangc-shared-library.lib</ImportLibrary> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="main.cpp" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\core\core.vcxproj"> + <Project>{F9BE7957-8399-899E-0C49-E714FDDD4B65}</Project> + </ProjectReference> + <ProjectReference Include="..\slang\slang.vcxproj"> + <Project>{DB00DA62-0533-4AFD-B59F-A67D5B3A0808}</Project> + </ProjectReference> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/source/slangc/slangc-shared-library.vcxproj.filters b/source/slangc/slangc-shared-library.vcxproj.filters new file mode 100644 index 000000000..e9ae1c092 --- /dev/null +++ b/source/slangc/slangc-shared-library.vcxproj.filters @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6}</UniqueIdentifier> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="main.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> +</Project>
\ No newline at end of file |
