From c0733be56dc24ef0eb67b26fe0c49d3419e75773 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 9 Aug 2022 10:31:22 -0400 Subject: Support for Items on IArtifact (#2347) * #include an absolute path didn't work - because paths were taken to always be relative. * WIP with hierarchical enums. * Some small fixes and improvements around artifact desc related types. * Improvements around hierarchical enum. * Fixes to get Artifact types refactor to be able to execute tests. * Attempt to better categorize PTX. * Work around for potentially unused function warning. * Typo fix. * Simplify Artifact header. * Small improvements around Artifact kind/payload/style. * Added IDestroyable/ICastable * Add IArtifactList. * First impl of IArtifactUtil. * Use the ICastable interface for IArtifactRepresentation. * Added IArtifactRepresentation & IArtifactAssociated. * Add SLANG_OVERRIDE to avoid gcc/clang warning. * Fix calling convention issue on win32. * Fix missing SLANG_OVERRIDE. * First attempt at file abstraction around Artifact. * Added creation of lock file. * Move functionality for determining file paths to the IArtifactUtil. Add casting to ICastable. * Added some casting/finding mechanisms. * Simplify IArtifact interface, and use Items for file reps. * Fix problem with libraries on DXIL. --- source/slang/slang-compiler.cpp | 4 ++++ source/slang/slang-options.cpp | 22 ++++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) (limited to 'source/slang') diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp index 8a9c322b2..8205bcf36 100644 --- a/source/slang/slang-compiler.cpp +++ b/source/slang/slang-compiler.cpp @@ -1313,8 +1313,12 @@ void printDiagnosticArg(StringBuilder& sb, CodeGenTarget val) if (_isCPUHostTarget(target)) { options.libraryPaths.add(Path::getParentDirectory(Path::getExecutablePath())); + // Set up the library artifact ComPtr artifact(new Artifact(ArtifactDesc::make(ArtifactKind::Library, Artifact::Payload::HostCPU), "slang-rt")); + ComPtr fileRep(new FileArtifactRepresentation(IFileArtifactRepresentation::Kind::NameOnly, "slang-rt", nullptr, nullptr)); + artifact->addItem(fileRep); + options.libraries.add(artifact); } } diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index f56395f5b..ab658fe18 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -1488,17 +1488,23 @@ struct OptionsParser // Seeing as on all targets the baseName doesn't have an extension, and all library types do // if the name doesn't have an extension we can assume there is no path to it. - if (Path::getPathExt(path).getLength() > 0) + ComPtr fileRep; + if (Path::getPathExt(path).getLength() <= 0) { - // Set the path - artifact->setPath(Artifact::PathType::Existing, path.getBuffer()); + // If there is no extension *assume* it is the name of a system level library + fileRep = new FileArtifactRepresentation(IFileArtifactRepresentation::Kind::NameOnly, path, nullptr, nullptr); } + else + { + fileRep = new FileArtifactRepresentation(IFileArtifactRepresentation::Kind::Reference, path, nullptr, nullptr); + if (!fileRep->exists()) + { + sink->diagnose(referenceModuleName.loc, Diagnostics::libraryDoesNotExist, path); + return SLANG_FAIL; + } + } + artifact->addItem(fileRep); - // TODO(JS): We might want to check if the artifact exists. - // If the artifact is a CPU (or downstream compiler) library - // it may be findable by some other mechanism, so we probably don't want to check existance and just let the - // downstream compiler handle. - SLANG_RETURN_ON_FAIL(_addLibraryReference(requestImpl, artifact)); } else if (argValue == "-v" || argValue == "-version") -- cgit v1.2.3