From 6fc2c37d9a4c408331db1b33deb3b46e74d2a7d2 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 12 Aug 2019 15:41:41 -0400 Subject: Callable CPU code support (#1014) * First pass support for compiling to a loaded shared library. * Improve documentation for cpu target. * Removed the SLANG_COMPILE_FLAG_LOAD_SHARED_LIBRARY flag. Use the SLANG_HOST_CALLABLE code target Document mechanism. * Fix typo in cpp-resource.slang In test code if the target is 'callable' we don't need to compile (indeed there is no source file). * Small refactor using CommandLineCPPCompiler as base class to implement VisualStudioCPPCompiler and GCCCPPCompiler. * Improvements around CPPCompiler. Mechanism to know products produced. Cleaning up products after execution. * Fix multiple definition of 'SourceType' --- source/core/slang-shared-library.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'source/core/slang-shared-library.cpp') diff --git a/source/core/slang-shared-library.cpp b/source/core/slang-shared-library.cpp index 9932db0b5..fd61ba0a0 100644 --- a/source/core/slang-shared-library.cpp +++ b/source/core/slang-shared-library.cpp @@ -56,6 +56,18 @@ SlangResult DefaultSharedLibraryLoader::loadSharedLibrary(const char* path, ISla /* !!!!!!!!!!!!!!!!!!!!!!!!!! DefaultSharedLibrary !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ +TemporarySharedLibrary::~TemporarySharedLibrary() +{ + if (m_sharedLibraryHandle) + { + // We have to unload if we want to be able to remove + SharedLibrary::unload(m_sharedLibraryHandle); + m_sharedLibraryHandle = nullptr; + } +} + +/* !!!!!!!!!!!!!!!!!!!!!!!!!! DefaultSharedLibrary !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ + ISlangUnknown* DefaultSharedLibrary::getInterface(const Guid& guid) { return (guid == IID_ISlangUnknown || guid == IID_ISlangSharedLibrary) ? static_cast(this) : nullptr; @@ -63,7 +75,10 @@ ISlangUnknown* DefaultSharedLibrary::getInterface(const Guid& guid) DefaultSharedLibrary::~DefaultSharedLibrary() { - SharedLibrary::unload(m_sharedLibraryHandle); + if (m_sharedLibraryHandle) + { + SharedLibrary::unload(m_sharedLibraryHandle); + } } SlangFuncPtr DefaultSharedLibrary::findFuncByName(char const* name) -- cgit v1.2.3