yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f65d756bf
master
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) 14static SlangResult parseVersion ( 15const UnownedStringSlice & text , 16const UnownedStringSlice & prefix , 17DownstreamCompilerDesc & outDesc ); 18 19/// Runs the exe, and extracts the version info into outDesc 20static SlangResult calcVersion (const ExecutableLocation & exe ,DownstreamCompilerDesc & outDesc ); 21 22/// Calculate gcc family compilers (including clang) cmdLine arguments from options 23static SlangResult calcArgs (const CompileOptions & options ,CommandLine & cmdLine ); 24 25/// Parse ExecuteResult into diagnostics 26static SlangResult parseOutput (const ExecuteResult & exeRes ,IArtifactDiagnostics * diagnostics ); 27 28/// Given options, calculate paths to products/files produced for a compilation 29static SlangResult calcCompileProducts ( 30const CompileOptions & options , 31ProductFlags flags , 32IOSFileArtifactRepresentation * lockFile , 33List < ComPtr < IArtifact >>& outArtifacts ); 34 35/// Given the exe location, creates a DownstreamCompiler. 36/// Note! Invoke/s the compiler to determine the compiler version number. 37static SlangResult createCompiler ( 38const ExecutableLocation & exe , 39ComPtr < IDownstreamCompiler >& outCompiler ); 40 41/// Finds GCC compiler/s and adds them to the set 42static SlangResult locateGCCCompilers ( 43const String & path , 44ISlangSharedLibraryLoader * loader , 45DownstreamCompilerSet * set ); 46 47/// Finds clang compiler/s and adds them to the set 48static SlangResult locateClangCompilers ( 49const String & path , 50ISlangSharedLibraryLoader * loader , 51DownstreamCompilerSet * set ); 52}; 53 54class GCCDownstreamCompiler :public CommandLineDownstreamCompiler 55{ 56public : 57typedef CommandLineDownstreamCompiler Super ; 58typedef GCCDownstreamCompilerUtil Util ; 59 60// CommandLineCPPCompiler impl - just forwards to the Util 61virtual SlangResult calcArgs (const CompileOptions & options ,CommandLine & cmdLine )SLANG_OVERRIDE 62 { 63return Util ::calcArgs (options ,cmdLine ); 64 } 65virtual SlangResult parseOutput ( 66const ExecuteResult & exeResult , 67IArtifactDiagnostics * diagnostics )SLANG_OVERRIDE 68 { 69return Util ::parseOutput (exeResult ,diagnostics ); 70 } 71virtual SlangResult calcCompileProducts ( 72const CompileOptions & options , 73DownstreamProductFlags flags , 74IOSFileArtifactRepresentation * lockFile , 75List < ComPtr < IArtifact >>& outArtifacts )SLANG_OVERRIDE 76 { 77return Util ::calcCompileProducts (options ,flags ,lockFile ,outArtifacts ); 78 } 79 80GCCDownstreamCompiler (const Desc & desc ) 81 :Super (desc ) 82 { 83 } 84}; 85 86}// namespace Slang 87 88#endif