From d2ddc590601778f309c81f7d19d5e7fed34210de Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 17 Dec 2018 09:22:14 -0500 Subject: Feature/test tool shared libraries (#758) * Remove circular reference to renderer on Vk & D3D12 DescriptorSetImpl * Refactor Stbi image loading such that memory is correctly freed when goes out of scope. Added Crt memory dump at termination. Reduced erroneous reporting by scoping TestContext. * Used capitalized acronym for STBImage to keep Tim happy. * Split out TestReporter - to just handle reporting test results Split out Options Made TestContext hold options, and the reporter Removed remaining memory leaks. * Small optimization for rawWrite, such that it directly writes over print.. * Improve comments on TestCategorySet * Fix typos in TestCategorySet * Made slangc a cpp file as part of slang-test (removing need for separate project/shared library). * * Made all test tools only available as dlls. * Made possible to invoke test tool dll from command line slang-test slangc [--bindir xxx] options to slangc * Fix Visual Studio projects that are no longer needed. --- .../render-test/render-test-shared-library.vcxproj | 210 --------------------- .../render-test-shared-library.vcxproj.filters | 48 ----- tools/render-test/render-test-tool.vcxproj | 210 +++++++++++++++++++++ tools/render-test/render-test-tool.vcxproj.filters | 48 +++++ tools/render-test/render-test.vcxproj | 206 -------------------- tools/render-test/render-test.vcxproj.filters | 48 ----- .../slang-reflection-test-shared-library.vcxproj | 182 ------------------ ...-reflection-test-shared-library.vcxproj.filters | 13 -- .../slang-reflection-test-tool.vcxproj | 182 ++++++++++++++++++ .../slang-reflection-test-tool.vcxproj.filters | 13 ++ .../slang-reflection-test.vcxproj | 178 ----------------- .../slang-reflection-test.vcxproj.filters | 13 -- tools/slang-test/main.cpp | 94 ++++++++- tools/slang-test/slang-test.vcxproj | 2 + tools/slang-test/slang-test.vcxproj.filters | 6 + tools/slang-test/slangc-tool.cpp | 57 ++++++ tools/slang-test/slangc-tool.h | 15 ++ tools/slang-test/test-context.cpp | 32 +++- tools/slang-test/test-context.h | 4 +- 19 files changed, 658 insertions(+), 903 deletions(-) delete mode 100644 tools/render-test/render-test-shared-library.vcxproj delete mode 100644 tools/render-test/render-test-shared-library.vcxproj.filters create mode 100644 tools/render-test/render-test-tool.vcxproj create mode 100644 tools/render-test/render-test-tool.vcxproj.filters delete mode 100644 tools/render-test/render-test.vcxproj delete mode 100644 tools/render-test/render-test.vcxproj.filters delete mode 100644 tools/slang-reflection-test/slang-reflection-test-shared-library.vcxproj delete mode 100644 tools/slang-reflection-test/slang-reflection-test-shared-library.vcxproj.filters create mode 100644 tools/slang-reflection-test/slang-reflection-test-tool.vcxproj create mode 100644 tools/slang-reflection-test/slang-reflection-test-tool.vcxproj.filters delete mode 100644 tools/slang-reflection-test/slang-reflection-test.vcxproj delete mode 100644 tools/slang-reflection-test/slang-reflection-test.vcxproj.filters create mode 100644 tools/slang-test/slangc-tool.cpp create mode 100644 tools/slang-test/slangc-tool.h (limited to 'tools') diff --git a/tools/render-test/render-test-shared-library.vcxproj b/tools/render-test/render-test-shared-library.vcxproj deleted file mode 100644 index 359a35b80..000000000 --- a/tools/render-test/render-test-shared-library.vcxproj +++ /dev/null @@ -1,210 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {61F7EB00-7281-4BF3-9470-7C2EA92620C3} - true - Win32Proj - render-test-shared-library - 10.0.14393.0 - - - - DynamicLibrary - true - Unicode - v140 - - - DynamicLibrary - true - Unicode - v140 - - - DynamicLibrary - false - Unicode - v140 - - - DynamicLibrary - false - Unicode - v140 - - - - - - - - - - - - - - - - - - - true - ..\..\bin\windows-x86\debug\ - ..\..\intermediate\windows-x86\debug\render-test-shared-library\ - render-test-shared-library - .dll - - - true - ..\..\bin\windows-x64\debug\ - ..\..\intermediate\windows-x64\debug\render-test-shared-library\ - render-test-shared-library - .dll - - - false - ..\..\bin\windows-x86\release\ - ..\..\intermediate\windows-x86\release\render-test-shared-library\ - render-test-shared-library - .dll - - - false - ..\..\bin\windows-x64\release\ - ..\..\intermediate\windows-x64\release\render-test-shared-library\ - render-test-shared-library - .dll - - - - NotUsing - Level3 - _DEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) - ..\..;..\..\external;..\..\source;..\gfx;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Windows - true - ..\..\bin\windows-x86\debug\render-test-shared-library.lib - - - "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x86/" "../../bin/windows-x86/debug/" - - - - - NotUsing - Level3 - _DEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) - ..\..;..\..\external;..\..\source;..\gfx;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Windows - true - ..\..\bin\windows-x64\debug\render-test-shared-library.lib - - - "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x64/" "../../bin/windows-x64/debug/" - - - - - NotUsing - Level3 - NDEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) - ..\..;..\..\external;..\..\source;..\gfx;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Windows - true - true - ..\..\bin\windows-x86\release\render-test-shared-library.lib - - - "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x86/" "../../bin/windows-x86/release/" - - - - - NotUsing - Level3 - NDEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) - ..\..;..\..\external;..\..\source;..\gfx;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Windows - true - true - ..\..\bin\windows-x64\release\render-test-shared-library.lib - - - "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x64/" "../../bin/windows-x64/release/" - - - - - - - - - - - - - - - - - - - - {F9BE7957-8399-899E-0C49-E714FDDD4B65} - - - {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} - - - {222F7498-B40C-4F3F-A704-DDEB91A4484A} - - - - - - \ No newline at end of file diff --git a/tools/render-test/render-test-shared-library.vcxproj.filters b/tools/render-test/render-test-shared-library.vcxproj.filters deleted file mode 100644 index ff3d52a7e..000000000 --- a/tools/render-test/render-test-shared-library.vcxproj.filters +++ /dev/null @@ -1,48 +0,0 @@ - - - - - {21EB8090-0D4E-1035-B6D3-48EBA215DCB7} - - - {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/tools/render-test/render-test-tool.vcxproj b/tools/render-test/render-test-tool.vcxproj new file mode 100644 index 000000000..811ffa56d --- /dev/null +++ b/tools/render-test/render-test-tool.vcxproj @@ -0,0 +1,210 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {61F7EB00-7281-4BF3-9470-7C2EA92620C3} + true + Win32Proj + render-test-tool + 10.0.14393.0 + + + + DynamicLibrary + true + Unicode + v140 + + + DynamicLibrary + true + Unicode + v140 + + + DynamicLibrary + false + Unicode + v140 + + + DynamicLibrary + false + Unicode + v140 + + + + + + + + + + + + + + + + + + + true + ..\..\bin\windows-x86\debug\ + ..\..\intermediate\windows-x86\debug\render-test-tool\ + render-test-tool + .dll + + + true + ..\..\bin\windows-x64\debug\ + ..\..\intermediate\windows-x64\debug\render-test-tool\ + render-test-tool + .dll + + + false + ..\..\bin\windows-x86\release\ + ..\..\intermediate\windows-x86\release\render-test-tool\ + render-test-tool + .dll + + + false + ..\..\bin\windows-x64\release\ + ..\..\intermediate\windows-x64\release\render-test-tool\ + render-test-tool + .dll + + + + NotUsing + Level3 + _DEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) + ..\..;..\..\external;..\..\source;..\gfx;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Windows + true + ..\..\bin\windows-x86\debug\render-test-tool.lib + + + "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x86/" "../../bin/windows-x86/debug/" + + + + + NotUsing + Level3 + _DEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) + ..\..;..\..\external;..\..\source;..\gfx;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Windows + true + ..\..\bin\windows-x64\debug\render-test-tool.lib + + + "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x64/" "../../bin/windows-x64/debug/" + + + + + NotUsing + Level3 + NDEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) + ..\..;..\..\external;..\..\source;..\gfx;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Windows + true + true + ..\..\bin\windows-x86\release\render-test-tool.lib + + + "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x86/" "../../bin/windows-x86/release/" + + + + + NotUsing + Level3 + NDEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) + ..\..;..\..\external;..\..\source;..\gfx;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Windows + true + true + ..\..\bin\windows-x64\release\render-test-tool.lib + + + "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x64/" "../../bin/windows-x64/release/" + + + + + + + + + + + + + + + + + + + + {F9BE7957-8399-899E-0C49-E714FDDD4B65} + + + {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} + + + {222F7498-B40C-4F3F-A704-DDEB91A4484A} + + + + + + \ No newline at end of file diff --git a/tools/render-test/render-test-tool.vcxproj.filters b/tools/render-test/render-test-tool.vcxproj.filters new file mode 100644 index 000000000..ff3d52a7e --- /dev/null +++ b/tools/render-test/render-test-tool.vcxproj.filters @@ -0,0 +1,48 @@ + + + + + {21EB8090-0D4E-1035-B6D3-48EBA215DCB7} + + + {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/tools/render-test/render-test.vcxproj b/tools/render-test/render-test.vcxproj deleted file mode 100644 index 91c8bd997..000000000 --- a/tools/render-test/render-test.vcxproj +++ /dev/null @@ -1,206 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {96610759-07B9-4EEB-A974-5C634A2E742B} - true - Win32Proj - render-test - 10.0.14393.0 - - - - Application - true - Unicode - v140 - - - Application - true - Unicode - v140 - - - Application - false - Unicode - v140 - - - Application - false - Unicode - v140 - - - - - - - - - - - - - - - - - - - true - ..\..\bin\windows-x86\debug\ - ..\..\intermediate\windows-x86\debug\render-test\ - render-test - .exe - - - true - ..\..\bin\windows-x64\debug\ - ..\..\intermediate\windows-x64\debug\render-test\ - render-test - .exe - - - false - ..\..\bin\windows-x86\release\ - ..\..\intermediate\windows-x86\release\render-test\ - render-test - .exe - - - false - ..\..\bin\windows-x64\release\ - ..\..\intermediate\windows-x64\release\render-test\ - render-test - .exe - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - ..\..;..\..\external;..\..\source;..\gfx;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Console - true - - - "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x86/" "../../bin/windows-x86/debug/" - - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - ..\..;..\..\external;..\..\source;..\gfx;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Console - true - - - "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x64/" "../../bin/windows-x64/debug/" - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - ..\..;..\..\external;..\..\source;..\gfx;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Console - true - true - - - "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x86/" "../../bin/windows-x86/release/" - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - ..\..;..\..\external;..\..\source;..\gfx;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Console - true - true - - - "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x64/" "../../bin/windows-x64/release/" - - - - - - - - - - - - - - - - - - - - {F9BE7957-8399-899E-0C49-E714FDDD4B65} - - - {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} - - - {222F7498-B40C-4F3F-A704-DDEB91A4484A} - - - - - - \ No newline at end of file diff --git a/tools/render-test/render-test.vcxproj.filters b/tools/render-test/render-test.vcxproj.filters deleted file mode 100644 index ff3d52a7e..000000000 --- a/tools/render-test/render-test.vcxproj.filters +++ /dev/null @@ -1,48 +0,0 @@ - - - - - {21EB8090-0D4E-1035-B6D3-48EBA215DCB7} - - - {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/tools/slang-reflection-test/slang-reflection-test-shared-library.vcxproj b/tools/slang-reflection-test/slang-reflection-test-shared-library.vcxproj deleted file mode 100644 index 48d08b94e..000000000 --- a/tools/slang-reflection-test/slang-reflection-test-shared-library.vcxproj +++ /dev/null @@ -1,182 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {C5ACCA6E-C04D-4B36-8516-3752B3C13C2F} - true - Win32Proj - slang-reflection-test-shared-library - - - - DynamicLibrary - true - Unicode - v140 - - - DynamicLibrary - true - Unicode - v140 - - - DynamicLibrary - false - Unicode - v140 - - - DynamicLibrary - false - Unicode - v140 - - - - - - - - - - - - - - - - - - - true - ..\..\bin\windows-x86\debug\ - ..\..\intermediate\windows-x86\debug\slang-reflection-test-shared-library\ - slang-reflection-test-shared-library - .dll - - - true - ..\..\bin\windows-x64\debug\ - ..\..\intermediate\windows-x64\debug\slang-reflection-test-shared-library\ - slang-reflection-test-shared-library - .dll - - - false - ..\..\bin\windows-x86\release\ - ..\..\intermediate\windows-x86\release\slang-reflection-test-shared-library\ - slang-reflection-test-shared-library - .dll - - - false - ..\..\bin\windows-x64\release\ - ..\..\intermediate\windows-x64\release\slang-reflection-test-shared-library\ - slang-reflection-test-shared-library - .dll - - - - NotUsing - Level3 - _DEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) - ..\..;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Windows - true - ..\..\bin\windows-x86\debug\slang-reflection-test-shared-library.lib - - - - - NotUsing - Level3 - _DEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) - ..\..;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Windows - true - ..\..\bin\windows-x64\debug\slang-reflection-test-shared-library.lib - - - - - NotUsing - Level3 - NDEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) - ..\..;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Windows - true - true - ..\..\bin\windows-x86\release\slang-reflection-test-shared-library.lib - - - - - NotUsing - Level3 - NDEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) - ..\..;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Windows - true - true - ..\..\bin\windows-x64\release\slang-reflection-test-shared-library.lib - - - - - - - - {F9BE7957-8399-899E-0C49-E714FDDD4B65} - - - {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} - - - - - - \ No newline at end of file diff --git a/tools/slang-reflection-test/slang-reflection-test-shared-library.vcxproj.filters b/tools/slang-reflection-test/slang-reflection-test-shared-library.vcxproj.filters deleted file mode 100644 index e9ae1c092..000000000 --- a/tools/slang-reflection-test/slang-reflection-test-shared-library.vcxproj.filters +++ /dev/null @@ -1,13 +0,0 @@ - - - - - {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} - - - - - Source Files - - - \ No newline at end of file diff --git a/tools/slang-reflection-test/slang-reflection-test-tool.vcxproj b/tools/slang-reflection-test/slang-reflection-test-tool.vcxproj new file mode 100644 index 000000000..77efa33f0 --- /dev/null +++ b/tools/slang-reflection-test/slang-reflection-test-tool.vcxproj @@ -0,0 +1,182 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {C5ACCA6E-C04D-4B36-8516-3752B3C13C2F} + true + Win32Proj + slang-reflection-test-tool + + + + DynamicLibrary + true + Unicode + v140 + + + DynamicLibrary + true + Unicode + v140 + + + DynamicLibrary + false + Unicode + v140 + + + DynamicLibrary + false + Unicode + v140 + + + + + + + + + + + + + + + + + + + true + ..\..\bin\windows-x86\debug\ + ..\..\intermediate\windows-x86\debug\slang-reflection-test-tool\ + slang-reflection-test-tool + .dll + + + true + ..\..\bin\windows-x64\debug\ + ..\..\intermediate\windows-x64\debug\slang-reflection-test-tool\ + slang-reflection-test-tool + .dll + + + false + ..\..\bin\windows-x86\release\ + ..\..\intermediate\windows-x86\release\slang-reflection-test-tool\ + slang-reflection-test-tool + .dll + + + false + ..\..\bin\windows-x64\release\ + ..\..\intermediate\windows-x64\release\slang-reflection-test-tool\ + slang-reflection-test-tool + .dll + + + + NotUsing + Level3 + _DEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) + ..\..;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Windows + true + ..\..\bin\windows-x86\debug\slang-reflection-test-tool.lib + + + + + NotUsing + Level3 + _DEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) + ..\..;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Windows + true + ..\..\bin\windows-x64\debug\slang-reflection-test-tool.lib + + + + + NotUsing + Level3 + NDEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) + ..\..;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Windows + true + true + ..\..\bin\windows-x86\release\slang-reflection-test-tool.lib + + + + + NotUsing + Level3 + NDEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) + ..\..;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Windows + true + true + ..\..\bin\windows-x64\release\slang-reflection-test-tool.lib + + + + + + + + {F9BE7957-8399-899E-0C49-E714FDDD4B65} + + + {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} + + + + + + \ No newline at end of file diff --git a/tools/slang-reflection-test/slang-reflection-test-tool.vcxproj.filters b/tools/slang-reflection-test/slang-reflection-test-tool.vcxproj.filters new file mode 100644 index 000000000..e9ae1c092 --- /dev/null +++ b/tools/slang-reflection-test/slang-reflection-test-tool.vcxproj.filters @@ -0,0 +1,13 @@ + + + + + {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} + + + + + Source Files + + + \ No newline at end of file diff --git a/tools/slang-reflection-test/slang-reflection-test.vcxproj b/tools/slang-reflection-test/slang-reflection-test.vcxproj deleted file mode 100644 index 8a40290e6..000000000 --- a/tools/slang-reflection-test/slang-reflection-test.vcxproj +++ /dev/null @@ -1,178 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {22C45F4F-FB6B-4535-BED1-D3F5D0C71047} - true - Win32Proj - slang-reflection-test - - - - Application - true - Unicode - v140 - - - Application - true - Unicode - v140 - - - Application - false - Unicode - v140 - - - Application - false - Unicode - v140 - - - - - - - - - - - - - - - - - - - true - ..\..\bin\windows-x86\debug\ - ..\..\intermediate\windows-x86\debug\slang-reflection-test\ - slang-reflection-test - .exe - - - true - ..\..\bin\windows-x64\debug\ - ..\..\intermediate\windows-x64\debug\slang-reflection-test\ - slang-reflection-test - .exe - - - false - ..\..\bin\windows-x86\release\ - ..\..\intermediate\windows-x86\release\slang-reflection-test\ - slang-reflection-test - .exe - - - false - ..\..\bin\windows-x64\release\ - ..\..\intermediate\windows-x64\release\slang-reflection-test\ - slang-reflection-test - .exe - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - ..\..;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Console - true - - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - ..\..;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Console - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - ..\..;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Console - true - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - ..\..;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Console - true - true - - - - - - - - {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} - - - {F9BE7957-8399-899E-0C49-E714FDDD4B65} - - - - - - \ No newline at end of file diff --git a/tools/slang-reflection-test/slang-reflection-test.vcxproj.filters b/tools/slang-reflection-test/slang-reflection-test.vcxproj.filters deleted file mode 100644 index e9ae1c092..000000000 --- a/tools/slang-reflection-test/slang-reflection-test.vcxproj.filters +++ /dev/null @@ -1,13 +0,0 @@ - - - - - {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} - - - - - Source Files - - - \ No newline at end of file diff --git a/tools/slang-test/main.cpp b/tools/slang-test/main.cpp index 774fbd6e2..ec2ad03e8 100644 --- a/tools/slang-test/main.cpp +++ b/tools/slang-test/main.cpp @@ -15,11 +15,11 @@ using namespace Slang; #include "test-context.h" #include "test-reporter.h" #include "options.h" +#include "slangc-tool.h" #define STB_IMAGE_IMPLEMENTATION #include "external/stb/stb_image.h" - #ifdef _WIN32 #define SLANG_TEST_SUPPORT_HLSL 1 #include @@ -1745,12 +1745,88 @@ void runTestsInDirectory( } } +struct ToolInvoke +{ + /// Returns true if it is a tool invoke + bool parse(const char*const* argv, int argc) + { + m_args.Clear(); + + m_binDirectory = "."; + + if (argc < 2 || !_isToolName(argv[1])) + { + return false; + } + m_toolName = argv[1]; + + // Look for parameters that are for the slang-test, and should be skipped + int i = 2; + while (i < argc) + { + if (strcmp(argv[i], "-bindir") == 0 && i + 1 < argc) + { + m_binDirectory = argv[i + 1]; + i += 2; + } + // If nothing found, the rest must be parsed to the tool + break; + } + + m_args.Add(m_toolName.Buffer()); + m_args.AddRange(argv + i, argc - i); + return true; + } + + SlangResult invoke(AppContext* appContext, TestContext* testContext) + { + // Do I want to strip the -bindir directory that may be later + + // We will just parse everything onto the underlying tool + auto func = testContext->getInnerMainFunc(m_binDirectory, m_toolName); + if (!func) + { + AppContext::getStdError().print("error: Unable to launch tool '%s'\n", m_toolName.Buffer()); + return SLANG_FAIL; + } + + return func(AppContext::getSingleton(), testContext->getSession(), int(m_args.Count()), m_args.Buffer()); + } + + String m_binDirectory; + String m_toolName; + List m_args; + +private: + static bool _isToolName(const char* name) + { + static const char* toolNames[] = + { + "slangc", + "render-test", + "slang-reflection-test", + }; + + for (int i = 0; i < SLANG_COUNT_OF(toolNames); ++i) + { + if (::strcmp(toolNames[i], name) == 0) + { + return true; + } + } + return false; + } +}; + + SlangResult innerMain(int argc, char** argv) { AppContext::initDefault(); // The context holds useful things used during testing TestContext context; + SLANG_RETURN_ON_FAIL(SLANG_FAILED(context.init())) + auto& categorySet = context.categorySet; // Set up our test categories here @@ -1766,9 +1842,21 @@ SlangResult innerMain(int argc, char** argv) // An un-categorized test will always belong to the `full` category categorySet.defaultCategory = fullTestCategory; - SLANG_RETURN_ON_FAIL(Options::parse(argc, argv, &categorySet, AppContext::getStdError(), &context.options)); - SLANG_RETURN_ON_FAIL(SLANG_FAILED(context.init())) + { + // We can set the slangc command line tool, to just use the function defined here + context.setInnerMainFunc("slangc", &SlangCTool::innerMain); + } + + { + ToolInvoke toolInvoke; + if (toolInvoke.parse(argv, argc)) + { + return toolInvoke.invoke(AppContext::getSingleton(), &context); + } + } + SLANG_RETURN_ON_FAIL(Options::parse(argc, argv, &categorySet, AppContext::getStdError(), &context.options)); + Options& options = context.options; if( options.includeCategories.Count() == 0 ) { diff --git a/tools/slang-test/slang-test.vcxproj b/tools/slang-test/slang-test.vcxproj index 82c3e652a..cbd00ad0e 100644 --- a/tools/slang-test/slang-test.vcxproj +++ b/tools/slang-test/slang-test.vcxproj @@ -165,6 +165,7 @@ + @@ -173,6 +174,7 @@ + diff --git a/tools/slang-test/slang-test.vcxproj.filters b/tools/slang-test/slang-test.vcxproj.filters index 24ba365a7..6c1bdf941 100644 --- a/tools/slang-test/slang-test.vcxproj.filters +++ b/tools/slang-test/slang-test.vcxproj.filters @@ -18,6 +18,9 @@ Header Files + + Header Files + Header Files @@ -38,6 +41,9 @@ Source Files + + Source Files + Source Files diff --git a/tools/slang-test/slangc-tool.cpp b/tools/slang-test/slangc-tool.cpp new file mode 100644 index 000000000..3085e2ab5 --- /dev/null +++ b/tools/slang-test/slangc-tool.cpp @@ -0,0 +1,57 @@ +// test-context.cpp +#include "slangc-tool.h" + +using namespace Slang; + +SLANG_API void spSetCommandLineCompilerMode(SlangCompileRequest* request); + +static void _diagnosticCallback(char const* message, void* /*userData*/) +{ + auto stdError = AppContext::getStdError(); + stdError.put(message); + stdError.flush(); +} + +SlangResult SlangCTool::innerMain(AppContext* appContext, SlangSession* session, int argc, const char*const* argv) +{ + SlangCompileRequest* compileRequest = spCreateCompileRequest(session); + spSetDiagnosticCallback(compileRequest, &_diagnosticCallback, nullptr); + + spSetCommandLineCompilerMode(compileRequest); + // Do any app specific configuration + appContext->configureRequest(compileRequest); + + { + const SlangResult res = spProcessCommandLineArguments(compileRequest, &argv[1], argc - 1); + if (SLANG_FAILED(res)) + { + // TODO: print usage message + return res; + } + } + + SlangResult res = SLANG_OK; + +#ifndef _DEBUG + try +#endif + { + // 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) + { + AppContext::getStdOut().print("internal compiler error: %S\n", e.Message.ToWString().begin()); + res = SLANG_FAIL; + } +#endif + + // Now that we are done, clean up after ourselves + spDestroyCompileRequest(compileRequest); + return res; +} + diff --git a/tools/slang-test/slangc-tool.h b/tools/slang-test/slangc-tool.h new file mode 100644 index 000000000..dd6e1b977 --- /dev/null +++ b/tools/slang-test/slangc-tool.h @@ -0,0 +1,15 @@ +// slangc-tool.h + +#ifndef SLANGC_TOOL_H_INCLUDED +#define SLANGC_TOOL_H_INCLUDED + +#include "../../source/core/slang-app-context.h" + +/* The slangc 'tool' interface, such that slangc like functionality is available directly without invoking slangc command line tool, or +need for a dll/shared library. */ +struct SlangCTool +{ + static SlangResult innerMain(Slang::AppContext* appContext, SlangSession* session, int argc, const char*const* argv); +}; + +#endif // SLANGC_TOOL_H_INCLUDED diff --git a/tools/slang-test/test-context.cpp b/tools/slang-test/test-context.cpp index 06a9847bf..0030d6136 100644 --- a/tools/slang-test/test-context.cpp +++ b/tools/slang-test/test-context.cpp @@ -27,6 +27,15 @@ Result TestContext::init() TestContext::~TestContext() { + for (auto& pair : m_sharedLibTools) + { + const auto& tool = pair.Value; + if (tool.m_sharedLibrary) + { + SharedLibrary::unload(tool.m_sharedLibrary); + } + } + if (m_session) { spDestroySession(m_session); @@ -45,7 +54,7 @@ TestContext::InnerMainFunc TestContext::getInnerMainFunc(const String& dirPath, StringBuilder sharedLibToolBuilder; sharedLibToolBuilder.append(name); - sharedLibToolBuilder.append("-shared-library"); + sharedLibToolBuilder.append("-tool"); StringBuilder builder; SharedLibrary::appendPlatformFileName(sharedLibToolBuilder.getUnownedSlice(), builder); @@ -61,3 +70,24 @@ TestContext::InnerMainFunc TestContext::getInnerMainFunc(const String& dirPath, m_sharedLibTools.Add(name, tool); return tool.m_func; } + +void TestContext::setInnerMainFunc(const String& name, InnerMainFunc func) +{ + SharedLibraryTool* tool = m_sharedLibTools.TryGetValue(name); + if (tool) + { + if (tool->m_sharedLibrary) + { + SharedLibrary::unload(tool->m_sharedLibrary); + tool->m_sharedLibrary = nullptr; + } + + tool->m_func = func; + } + else + { + SharedLibraryTool tool = {}; + tool.m_func = func; + m_sharedLibTools.Add(name, tool); + } +} diff --git a/tools/slang-test/test-context.h b/tools/slang-test/test-context.h index 18034f4c7..cfa9837da 100644 --- a/tools/slang-test/test-context.h +++ b/tools/slang-test/test-context.h @@ -21,7 +21,9 @@ class TestContext SlangResult init(); /// Get the inner main function (from shared library) - TestContext::InnerMainFunc getInnerMainFunc(const Slang::String& dirPath, const Slang::String& name); + InnerMainFunc getInnerMainFunc(const Slang::String& dirPath, const Slang::String& name); + /// Set the function for the shared library + void setInnerMainFunc(const Slang::String& name, InnerMainFunc func); /// Ctor TestContext(); -- cgit v1.2.3