From 5ca446888656da91165b7bf90b7b2195d1e1afac Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 21 Oct 2019 15:32:13 -0400 Subject: `Repro` functionality (#1085) * WIP on serialize/save state. * Relative string encoding. * Added RelativeContainer unit test. Split out RelativeContainer into core. * Fix bug in RelativeString encoding. * More work around relative container. * Fix checks. * Use RelativeBase for safe access. Use malloc/free/realloc instead of List. * Add natvis support for relative types. * Setting up of state (not includes) writing of repro state. * Capture after spCompile. * Writing SourceFile and file system files. Added -dump-repo * First pass at loading state. * First pass at reading repro. * Small optimization around Safe32Ptr * Refactor how repro data is stored - to make saving off the files more simple, by having all all backed by 'files'. Make file loading always set up PathInfo so we get uniqueIdentifier info. * Generate unique file names. * Added RelativeFileSystem Added saveFile to ISlangFileSystemExt and implemented for interfaces Added mechanism to save of files (and manifest) * Added ability to replace files in repo with directory holding their contents. * Add support for entry points. * Fix problem compiling on linux. * Added SIMPLE_EX option, where everything on command line must be specified. * Fix typo in unit test for relative container. * Fix another typo in unit test for RelativeContainer. * Fix small bugs. * Fix release unused variable issue in slang-state-serialize.cpp * Fix checking for SIMPLE_EX in testing, else broke COMMAND_LINE_SIMPLE. * Fix warnings on 32 bit debug build. * Added import-subdir-search-path-repro.slang test. Although disabled for now as writes to root of slang project. * Remove wrong version of import-subdir-search-path-repro.slang * Added import-subdir-search-path-repro.slang --- slang.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'slang.h') diff --git a/slang.h b/slang.h index 00957227a..970150edf 100644 --- a/slang.h +++ b/slang.h @@ -1005,6 +1005,20 @@ extern "C" /** Clears any cached information */ virtual SLANG_NO_THROW void SLANG_MCALL clearCache() = 0; + + /** Write the data specified with data and size to the specified path. + + Note that for normal slang operation it doesn't write files so this can return SLANG_E_NOT_IMPLEMENTED. + + @param path The path for data to be saved to + @param data The data to be saved + @param size The size of the data + @returns SLANG_OK if successful (SLANG_E_NOT_IMPLEMENTED if not implemented, or some other error code) + */ + virtual SLANG_NO_THROW SlangResult SLANG_MCALL saveFile( + const char* path, + const void* data, + size_t size) = 0; }; #define SLANG_UUID_ISlangFileSystemExt { 0x5fb632d2, 0x979d, 0x4481, { 0x9f, 0xee, 0x66, 0x3c, 0x3f, 0x14, 0x49, 0xe1 } } @@ -1601,6 +1615,34 @@ extern "C" size_t* outSize); + + /** Load repro from memory specified. + + Should only be performed on a newly created request. + + @param request The request + @param fileSystem An (optional) filesystem. If non null, files from repro will be loaded (by unique names) from the file system + @param data The data to load from. + @param size The size of the data to load from. + @returns A `SlangResult` to indicate success or failure. + */ + SLANG_API SlangResult spLoadRepro( + SlangCompileRequest* request, + ISlangFileSystem* fileSystem, + const void* data, + size_t size); + + /** Save repro state. Should *typically* be performed after spCompile, so that everything + that is needed for a compilation is available. + + @param request The request + @param outBlob Blob that will hold the serialized state + @returns A `SlangResult` to indicate success or failure. + */ + SLANG_API SlangResult spSaveRepro( + SlangCompileRequest* request, + ISlangBlob** outBlob + ); /* Forward declarations of types used in the reflection interface; -- cgit v1.2.3