From da6be80f18014a3972eedf05099cd0066e9eae04 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 3 Dec 2021 11:45:01 -0500 Subject: Split out ExecutableLocation (#2041) * #include an absolute path didn't work - because paths were taken to always be relative. * Split out ExecutableLocation. * Fixes for changes to ExecutableLocation. * Fix issues around Process on windows. * Improve comments. Kick CI. --- source/compiler-core/slang-gcc-compiler-util.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'source/compiler-core/slang-gcc-compiler-util.cpp') diff --git a/source/compiler-core/slang-gcc-compiler-util.cpp b/source/compiler-core/slang-gcc-compiler-util.cpp index 034f349e0..5d72e675a 100644 --- a/source/compiler-core/slang-gcc-compiler-util.cpp +++ b/source/compiler-core/slang-gcc-compiler-util.cpp @@ -86,10 +86,10 @@ static Index _findVersionEnd(const UnownedStringSlice& in) return SLANG_FAIL; } -SlangResult GCCDownstreamCompilerUtil::calcVersion(const String& exeName, DownstreamCompiler::Desc& outDesc) +SlangResult GCCDownstreamCompilerUtil::calcVersion(const ExecutableLocation& exe, DownstreamCompiler::Desc& outDesc) { CommandLine cmdLine; - cmdLine.setExecutableFilename(exeName); + cmdLine.setExecutableLocation(exe); cmdLine.addArg("-v"); ExecuteResult exeRes; @@ -635,19 +635,13 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse return SLANG_OK; } -/* static */SlangResult GCCDownstreamCompilerUtil::createCompiler(const String& path, const String& inExeName, RefPtr& outCompiler) +/* static */SlangResult GCCDownstreamCompilerUtil::createCompiler(const ExecutableLocation& exe, RefPtr& outCompiler) { - String exeName(inExeName); - if (path.getLength() > 0) - { - exeName = Path::combine(path, inExeName); - } - DownstreamCompiler::Desc desc; - SLANG_RETURN_ON_FAIL(GCCDownstreamCompilerUtil::calcVersion(exeName, desc)); + SLANG_RETURN_ON_FAIL(GCCDownstreamCompilerUtil::calcVersion(exe, desc)); RefPtr compiler(new GCCDownstreamCompiler(desc)); - compiler->m_cmdLine.setExecutableFilename(exeName); + compiler->m_cmdLine.setExecutableLocation(exe); outCompiler = compiler; return SLANG_OK; @@ -656,8 +650,9 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse /* static */SlangResult GCCDownstreamCompilerUtil::locateGCCCompilers(const String& path, ISlangSharedLibraryLoader* loader, DownstreamCompilerSet* set) { SLANG_UNUSED(loader); + RefPtr compiler; - if (SLANG_SUCCEEDED(createCompiler(path, "g++", compiler))) + if (SLANG_SUCCEEDED(createCompiler(ExecutableLocation(path, "g++"), compiler))) { set->addCompiler(compiler); } @@ -669,7 +664,7 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse SLANG_UNUSED(loader); RefPtr compiler; - if (SLANG_SUCCEEDED(createCompiler(path, "clang", compiler))) + if (SLANG_SUCCEEDED(createCompiler(ExecutableLocation(path, "clang"), compiler))) { set->addCompiler(compiler); } -- cgit v1.2.3