yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Ellie Hermaszewskaformatf65d756bf

master
3.0 KiB88 linesraw
1#ifndef SLANG_GCC_COMPILER_UTIL_H
2#define SLANG_GCC_COMPILER_UTIL_H
3
4#include "slang-downstream-compiler-util.h"
5
6namespace Slang
7{
8
9/* Utility for processing input and output of gcc-like compilers, including clang */
10struct GCCDownstreamCompilerUtil : public DownstreamCompilerUtilBase
11{
12    /// Extracts version number into desc from text (assumes gcc/clang -v layout with a line with
13    /// version)
14    static SlangResult parseVersion(
15        const UnownedStringSlice& text,
16        const UnownedStringSlice& prefix,
17        DownstreamCompilerDesc& outDesc);
18
19    /// Runs the exe, and extracts the version info into outDesc
20    static SlangResult calcVersion(const ExecutableLocation& exe, DownstreamCompilerDesc& outDesc);
21
22    /// Calculate gcc family compilers (including clang) cmdLine arguments from options
23    static SlangResult calcArgs(const CompileOptions& options, CommandLine& cmdLine);
24
25    /// Parse ExecuteResult into diagnostics
26    static SlangResult parseOutput(const ExecuteResult& exeRes, IArtifactDiagnostics* diagnostics);
27
28    /// Given options, calculate paths to products/files produced for a compilation
29    static SlangResult calcCompileProducts(
30        const CompileOptions& options,
31        ProductFlags flags,
32        IOSFileArtifactRepresentation* lockFile,
33        List<ComPtr<IArtifact>>& outArtifacts);
34
35    /// Given the exe location, creates a DownstreamCompiler.
36    /// Note! Invoke/s the compiler  to determine the compiler version number.
37    static SlangResult createCompiler(
38        const ExecutableLocation& exe,
39        ComPtr<IDownstreamCompiler>& outCompiler);
40
41    /// Finds GCC compiler/s and adds them to the set
42    static SlangResult locateGCCCompilers(
43        const String& path,
44        ISlangSharedLibraryLoader* loader,
45        DownstreamCompilerSet* set);
46
47    /// Finds clang compiler/s and adds them to the set
48    static SlangResult locateClangCompilers(
49        const String& path,
50        ISlangSharedLibraryLoader* loader,
51        DownstreamCompilerSet* set);
52};
53
54class GCCDownstreamCompiler : public CommandLineDownstreamCompiler
55{
56public:
57    typedef CommandLineDownstreamCompiler Super;
58    typedef GCCDownstreamCompilerUtil Util;
59
60    // CommandLineCPPCompiler impl  - just forwards to the Util
61    virtual SlangResult calcArgs(const CompileOptions& options, CommandLine& cmdLine) SLANG_OVERRIDE
62    {
63        return Util::calcArgs(options, cmdLine);
64    }
65    virtual SlangResult parseOutput(
66        const ExecuteResult& exeResult,
67        IArtifactDiagnostics* diagnostics) SLANG_OVERRIDE
68    {
69        return Util::parseOutput(exeResult, diagnostics);
70    }
71    virtual SlangResult calcCompileProducts(
72        const CompileOptions& options,
73        DownstreamProductFlags flags,
74        IOSFileArtifactRepresentation* lockFile,
75        List<ComPtr<IArtifact>>& outArtifacts) SLANG_OVERRIDE
76    {
77        return Util::calcCompileProducts(options, flags, lockFile, outArtifacts);
78    }
79
80    GCCDownstreamCompiler(const Desc& desc)
81        : Super(desc)
82    {
83    }
84};
85
86} // namespace Slang
87
88#endif