diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-06-14 12:20:12 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-06-14 12:20:12 -0400 |
| commit | 8c56d83506ef92b15b15bdb5969008dd69c8d2a6 (patch) | |
| tree | b58218a85c108b49c2ce74f77e1f3de8c668ef21 /source/core/slang-cpp-compiler.h | |
| parent | 7461e95210e7420d0ddf681279813f394a6fd0d8 (diff) | |
CPPCompiler improvements (#984)
* Removed the need for VisualStudio specific CPPCompiler
Improved the version parsing for gcc/clang
Removed need for slang-unix-cpp-compiler-util.cpp/.h
Remove binary before compiling in the compile c tests
* Moved VisualStudio calcArgs into CPPCompilerUtil - as code is not windows specific.
* Set up compile time version for gcc and clang
* Fix compilation on OSX - use remove instead of unlink for file deletion.
* On OSX - clang uses different string format.
* Removed /bin/sh invoking as not required for OSX.
Diffstat (limited to 'source/core/slang-cpp-compiler.h')
| -rw-r--r-- | source/core/slang-cpp-compiler.h | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/source/core/slang-cpp-compiler.h b/source/core/slang-cpp-compiler.h index 8794463d1..82930afd6 100644 --- a/source/core/slang-cpp-compiler.h +++ b/source/core/slang-cpp-compiler.h @@ -109,12 +109,19 @@ public: GenericCPPCompiler(const Desc& desc, const String& exeName, CalcArgsFunc func) : Super(desc), - m_exeName(exeName), + m_func(func) + { + m_cmdLine.setExecutableFilename(exeName); + } + + GenericCPPCompiler(const Desc& desc, const CommandLine& cmdLine, CalcArgsFunc func) : + Super(desc), + m_cmdLine(cmdLine), m_func(func) {} CalcArgsFunc m_func; - String m_exeName; + CommandLine m_cmdLine; }; class CPPCompilerSet : public RefObject @@ -151,6 +158,11 @@ protected: struct CPPCompilerUtil { + typedef CPPCompiler::CompileOptions CompileOptions; + typedef CPPCompiler::OptimizationLevel OptimizationLevel; + typedef CPPCompiler::TargetType TargetType; + typedef CPPCompiler::DebugInfoType DebugInfoType; + enum class MatchType { MinGreaterEqual, @@ -158,11 +170,17 @@ struct CPPCompilerUtil Newest, }; - /// Extracts version number into desc from text (assumes gcc/slang type layout with a line with version starting with versionPrefix) - static SlangResult parseGccFamilyVersion(const UnownedStringSlice& text, const UnownedStringSlice& versionPrefix, CPPCompiler::Desc& outDesc); + /// Extracts version number into desc from text (assumes gcc/clang -v layout with a line with version) + static SlangResult parseGCCFamilyVersion(const UnownedStringSlice& text, const UnownedStringSlice& prefix, CPPCompiler::Desc& outDesc); /// Runs the exeName, and extracts the version info into outDesc - static SlangResult calcGccFamilyVersion(const String& exeName, const UnownedStringSlice& versionPrefix, CPPCompiler::Desc& outDesc); + static SlangResult calcGCCFamilyVersion(const String& exeName, CPPCompiler::Desc& outDesc); + + /// Calculate gcc family compilers (including clang) cmdLine arguments from options + static void calcGCCFamilyArgs(const CompileOptions& options, CommandLine& cmdLine); + + /// Calculate Visual Studio family compilers cmdLine arguments from options + static void calcVisualStudioArgs(const CompileOptions& options, CommandLine& cmdLine); /// Find a compiler static CPPCompiler* findCompiler(const CPPCompilerSet* set, MatchType matchType, const CPPCompiler::Desc& desc); |
