summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-12-03 11:45:01 -0500
committerGitHub <noreply@github.com>2021-12-03 11:45:01 -0500
commitda6be80f18014a3972eedf05099cd0066e9eae04 (patch)
tree687cb3853e1794b9478ee2a7b0503590f00f4669
parentf4b86ff23c825f5e776a401f89302bfcd358aae8 (diff)
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.
-rw-r--r--source/compiler-core/slang-downstream-compiler.h4
-rw-r--r--source/compiler-core/slang-gcc-compiler-util.cpp21
-rw-r--r--source/compiler-core/slang-gcc-compiler-util.h18
-rw-r--r--source/compiler-core/windows/slang-win-visual-studio-util.cpp18
-rw-r--r--source/core/slang-command-line.cpp90
-rw-r--r--source/core/slang-command-line.h75
-rw-r--r--source/core/slang-io.h5
-rw-r--r--source/core/unix/slang-unix-process.cpp17
-rw-r--r--source/core/windows/slang-win-process.cpp18
-rw-r--r--tools/slang-test/slang-test-main.cpp50
-rw-r--r--tools/slang-test/test-context.cpp2
-rw-r--r--tools/slang-test/test-reporter.cpp2
-rw-r--r--tools/slang-unit-test/unit-test-process.cpp2
13 files changed, 226 insertions, 96 deletions
diff --git a/source/compiler-core/slang-downstream-compiler.h b/source/compiler-core/slang-downstream-compiler.h
index 58b7c5be0..dc9e29185 100644
--- a/source/compiler-core/slang-downstream-compiler.h
+++ b/source/compiler-core/slang-downstream-compiler.h
@@ -419,10 +419,10 @@ public:
virtual SlangResult calcArgs(const CompileOptions& options, CommandLine& cmdLine) = 0;
virtual SlangResult parseOutput(const ExecuteResult& exeResult, DownstreamDiagnostics& output) = 0;
- CommandLineDownstreamCompiler(const Desc& desc, const String& exeName) :
+ CommandLineDownstreamCompiler(const Desc& desc, const ExecutableLocation& exe) :
Super(desc)
{
- m_cmdLine.setExecutableFilename(exeName);
+ m_cmdLine.setExecutableLocation(exe);
}
CommandLineDownstreamCompiler(const Desc& desc, const CommandLine& cmdLine) :
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<DownstreamCompiler>& outCompiler)
+/* static */SlangResult GCCDownstreamCompilerUtil::createCompiler(const ExecutableLocation& exe, RefPtr<DownstreamCompiler>& 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<CommandLineDownstreamCompiler> 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<DownstreamCompiler> 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<DownstreamCompiler> compiler;
- if (SLANG_SUCCEEDED(createCompiler(path, "clang", compiler)))
+ if (SLANG_SUCCEEDED(createCompiler(ExecutableLocation(path, "clang"), compiler)))
{
set->addCompiler(compiler);
}
diff --git a/source/compiler-core/slang-gcc-compiler-util.h b/source/compiler-core/slang-gcc-compiler-util.h
index b97144e35..b1ff791b0 100644
--- a/source/compiler-core/slang-gcc-compiler-util.h
+++ b/source/compiler-core/slang-gcc-compiler-util.h
@@ -12,28 +12,30 @@ struct GCCDownstreamCompilerUtil : public DownstreamCompilerBaseUtil
/// Extracts version number into desc from text (assumes gcc/clang -v layout with a line with version)
static SlangResult parseVersion(const UnownedStringSlice& text, const UnownedStringSlice& prefix, DownstreamCompiler::Desc& outDesc);
- /// Runs the exeName, and extracts the version info into outDesc
- static SlangResult calcVersion(const String& exeName, DownstreamCompiler::Desc& outDesc);
+ /// Runs the exe, and extracts the version info into outDesc
+ static SlangResult calcVersion(const ExecutableLocation& exe, DownstreamCompiler::Desc& outDesc);
/// Calculate gcc family compilers (including clang) cmdLine arguments from options
static SlangResult calcArgs(const CompileOptions& options, CommandLine& cmdLine);
- /// Parse ExecuteResult into Output
- static SlangResult parseOutput(const ExecuteResult& exeRes, DownstreamDiagnostics& outOutput);
+ /// Parse ExecuteResult into diagnostics
+ static SlangResult parseOutput(const ExecuteResult& exeRes, DownstreamDiagnostics& out);
/// Calculate the output module filename
static SlangResult calcModuleFilePath(const CompileOptions& options, StringBuilder& outPath);
- /// Given options, calculate paths to products produced for a compilation
+ /// Given options, calculate paths to products/files produced for a compilation
static SlangResult calcCompileProducts(const CompileOptions& options, ProductFlags flags, List<String>& outPaths);
- /// Given a path and an exe name, detects if compiler is present, and if so adds to compiler set.
- static SlangResult createCompiler(const String& path, const String& inExeName, RefPtr<DownstreamCompiler>& outCompiler);
+ /// Given the exe location, creates a DownstreamCompiler.
+ /// Note! Invoke/s the compiler to determine the compiler version number.
+ static SlangResult createCompiler(const ExecutableLocation& exe, RefPtr<DownstreamCompiler>& outCompiler);
+ /// Finds GCC compiler/s and adds them to the set
static SlangResult locateGCCCompilers(const String& path, ISlangSharedLibraryLoader* loader, DownstreamCompilerSet* set);
+ /// Finds clang compiler/s and adds them to the set
static SlangResult locateClangCompilers(const String& path, ISlangSharedLibraryLoader* loader, DownstreamCompilerSet* set);
-
};
class GCCDownstreamCompiler : public CommandLineDownstreamCompiler
diff --git a/source/compiler-core/windows/slang-win-visual-studio-util.cpp b/source/compiler-core/windows/slang-win-visual-studio-util.cpp
index dd9656c23..e1a0f6109 100644
--- a/source/compiler-core/windows/slang-win-visual-studio-util.cpp
+++ b/source/compiler-core/windows/slang-win-visual-studio-util.cpp
@@ -200,7 +200,7 @@ static SlangResult _find(int versionIndex, WinVisualStudioUtil::VersionPath& out
String vswherePath = programFilesPath;
vswherePath.append("\\Microsoft Visual Studio\\Installer\\vswhere");
- cmd.setExecutableFilename(vswherePath);
+ cmd.setExecutableLocation(ExecutableLocation(vswherePath));
StringBuilder versionName;
WinVisualStudioUtil::append(version, versionName);
@@ -305,22 +305,20 @@ static SlangResult _find(int versionIndex, WinVisualStudioUtil::VersionPath& out
// To invoke cl we need to run the suitable vcvars. In order to run this we have to have MS CommandLine.
// So here we build up a cl command line that is run by first running vcvars, and then executing cl with the parameters as passed to commandLine
- CommandLine cmdLine;
+ // https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa
+ // To run a batch file, you must start the command interpreter; set lpApplicationName to cmd.exe and set lpCommandLine to the
+ // following arguments: /c plus the name of the batch file.
- cmdLine.setExecutableFilename("cmd.exe");
+ CommandLine cmdLine;
+ cmdLine.setExecutableLocation(ExecutableLocation(ExecutableLocation::Type::Name, "cmd.exe"));
+
{
String options[] = { "/q", "/c", "@prompt", "$" };
cmdLine.addArgs(options, SLANG_COUNT_OF(options));
}
cmdLine.addArg("&&");
-
- {
- StringBuilder path;
- path << versionPath.vcvarsPath;
- path << "\\vcvarsall.bat";
- cmdLine.addArg(path);
- }
+ cmdLine.addArg(Path::combine(versionPath.vcvarsPath, "vcvarsall.bat"));
#if SLANG_PTR_IS_32
cmdLine.addArg("x86");
diff --git a/source/core/slang-command-line.cpp b/source/core/slang-command-line.cpp
index 419c031ab..973bb46d0 100644
--- a/source/core/slang-command-line.cpp
+++ b/source/core/slang-command-line.cpp
@@ -11,6 +11,63 @@
namespace Slang {
+/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ExecutableLocation !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
+
+void ExecutableLocation::set(const String& dir, const String& name)
+{
+ if (dir.getLength() == 0)
+ {
+ set(name);
+ }
+ else
+ {
+ set(Path::combine(dir, name));
+ }
+}
+
+void ExecutableLocation::set(const String& nameOrPath)
+{
+ // See if input looks like a path
+ if (Path::hasPath(nameOrPath))
+ {
+ // If it is a path we may want to add a suffix
+ const auto suffix = Process::getExecutableSuffix();
+
+ if (suffix.getLength() == 0 || nameOrPath.endsWith(suffix))
+ {
+ setPath(nameOrPath);
+ }
+ else
+ {
+ // If on target that has suffix make sure name has the suffix
+ StringBuilder builder;
+ builder << nameOrPath;
+ builder << suffix;
+ setPath(builder.ProduceString());
+ }
+ }
+ else
+ {
+ // If we don't have a parent, we assume it is just a naem
+ setName(nameOrPath);
+ }
+}
+
+void ExecutableLocation::append(StringBuilder& out) const
+{
+ if (m_type == Type::Unknown)
+ {
+ out << "(unknown)";
+ }
+ else
+ {
+ auto escapeHandler = Process::getEscapeHandler();
+ StringEscapeUtil::appendMaybeQuoted(escapeHandler, m_pathOrName.getUnownedSlice(), out);
+ }
+}
+
+/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CommandLine !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
+
void CommandLine::addPrefixPathArg(const char* prefix, const String& path, const char* pathPostfix)
{
StringBuilder builder;
@@ -23,23 +80,29 @@ void CommandLine::addPrefixPathArg(const char* prefix, const String& path, const
addArg(builder.ProduceString());
}
-void CommandLine::setExecutable(const String& dir, const String& name)
+void CommandLine::append(StringBuilder& out) const
{
- StringBuilder builder;
- Path::combineIntoBuilder(dir.getUnownedSlice(), name.getUnownedSlice(), builder);
- builder << Process::getExecutableSuffix();
- setExecutablePath(builder.ProduceString());
+ m_executableLocation.append(out);
+
+ if (m_args.getCount())
+ {
+ out << " ";
+ appendArgs(out);
+ }
}
-void CommandLine::append(StringBuilder& out) const
+void CommandLine::appendArgs(StringBuilder& out) const
{
auto escapeHandler = Process::getEscapeHandler();
- StringEscapeUtil::appendMaybeQuoted(escapeHandler, m_executable.getUnownedSlice(), out);
-
- for (const auto& arg : m_args)
+ const Int argCount = m_args.getCount();
+ for (Index i = 0; i < argCount; ++i)
{
- out << " ";
+ const auto& arg = m_args[i];
+ if (i > 0)
+ {
+ out << " ";
+ }
StringEscapeUtil::appendMaybeQuoted(escapeHandler, arg.getUnownedSlice(), out);
}
}
@@ -51,4 +114,11 @@ String CommandLine::toString() const
return buf.ProduceString();
}
+String CommandLine::toStringArgs() const
+{
+ StringBuilder buf;
+ appendArgs(buf);
+ return buf.ProduceString();
+}
+
} // namespace Slang
diff --git a/source/core/slang-command-line.h b/source/core/slang-command-line.h
index 85ba1a331..f2007865f 100644
--- a/source/core/slang-command-line.h
+++ b/source/core/slang-command-line.h
@@ -7,15 +7,57 @@
namespace Slang {
-struct CommandLine
+struct ExecutableLocation
{
- enum class ExecutableType
+ typedef ExecutableLocation ThisType;
+
+ enum Type
{
- Unknown, ///< The executable is not specified
+ Unknown, ///< Not specified
Path, ///< The executable is set as a path (ie won't be searched for)
- Filename, ///< The executable is set as a filename
+ Name, ///< The executable is passed as a name which will be searched for
};
+ /// Set the executable path.
+ /// NOTE! On some targets the executable path *must* include an extension to be able to start as a process
+ void setPath(const String& path) { m_type = Type::Path; m_pathOrName = path; }
+
+ /// Set a filename (such that the path will be looked up)
+ void setName(const String& filename) { m_type = Type::Name; m_pathOrName = filename; }
+
+ void set(Type type, const String& pathOrName) { m_type = type; m_pathOrName = pathOrName; }
+
+ /// Set the executable path from a base directory and an executable name (no suffix such as '.exe' needed)
+ void set(const String& dir, const String& name);
+
+ /// Determines if it's a name or a path when it sets
+ void set(const String& nameOrPath);
+
+ /// Append as text to out.
+ void append(StringBuilder& out) const;
+
+ /// Reset state to be same as ctor
+ void reset() { m_type = Type::Unknown; m_pathOrName = String(); }
+
+ /// Equality means exactly the same definition.
+ /// *NOT* that exactly the same executable is specified
+ bool operator==(const ThisType& rhs) const { return m_type == rhs.m_type && m_pathOrName == rhs.m_pathOrName; }
+ bool operator!=(const ThisType& rhs) const { return !(*this == rhs); }
+
+ ExecutableLocation() {}
+ ExecutableLocation(const String& dir, const String& name) { set(dir, name); }
+ ExecutableLocation(Type type, const String& pathOrName) : m_type(type), m_pathOrName(pathOrName) {}
+
+ explicit ExecutableLocation(const String& nameOrPath) { set(nameOrPath); }
+
+ Type m_type = Type::Unknown;
+ String m_pathOrName;
+};
+
+struct CommandLine
+{
+ typedef CommandLine ThisType;
+
/// Add args - assumed unescaped
void addArg(const String& in) { m_args.add(in); }
void addArgs(const String* args, Int argsCount) { for (Int i = 0; i < argsCount; ++i) addArg(args[i]); }
@@ -23,16 +65,6 @@ struct CommandLine
/// Find the index of an arg which is exact match for slice
SLANG_INLINE Index findArgIndex(const UnownedStringSlice& slice) const { return m_args.indexOf(slice); }
- /// Set the executable path.
- /// NOTE! On some targets the executable path *must* include an extension to be able to start as a process
- void setExecutablePath(const String& path) { m_executableType = ExecutableType::Path; m_executable = path; }
-
- /// Set the executable path from a base directory and an executable name (no suffix such as '.exe' needed)
- void setExecutable(const String& dir, const String& name);
-
- /// Set a filename (such that the path will be looked up
- void setExecutableFilename(const String& filename) { m_executableType = ExecutableType::Filename; m_executable = filename; }
-
/// For handling args where the switch is placed directly in front of the path
void addPrefixPathArg(const char* prefix, const String& path, const char* pathPostfix = nullptr);
@@ -42,17 +74,22 @@ struct CommandLine
/// Reset to the initial state
void reset() { *this = CommandLine(); }
+ /// Append the args
+ void appendArgs(StringBuilder& out) const;
+
/// Append the command line to out
void append(StringBuilder& out) const;
/// convert into a string
String toString() const;
- /// Ctor
- CommandLine():m_executableType(ExecutableType::Unknown) {}
+ /// Convert just the args to string
+ String toStringArgs() const;
+
+ /// Set an executable location
+ void setExecutableLocation(const ExecutableLocation& loc) { m_executableLocation = loc; }
- ExecutableType m_executableType; ///< How the executable is specified
- String m_executable; ///< Executable to run. Note that the executable is never escaped.
- List<String> m_args; ///< The arguments (Stored *unescaped*)
+ ExecutableLocation m_executableLocation; ///< The executable location
+ List<String> m_args; ///< The arguments (Stored *unescaped*)
};
}
diff --git a/source/core/slang-io.h b/source/core/slang-io.h
index 50ce67784..de761cf4b 100644
--- a/source/core/slang-io.h
+++ b/source/core/slang-io.h
@@ -74,6 +74,11 @@ namespace Slang
static Index findExtIndex(String const& path) { return findExtIndex(path.getUnownedSlice()); }
static Index findExtIndex(UnownedStringSlice const& path);
+ /// True if isn't just a name (ie has any path separator)
+ /// Note this is no the same as having a 'parent' as '/thing' 'has a path', but it doesn't have a parent.
+ static bool hasPath(const UnownedStringSlice& path) { return findLastSeparatorIndex(path) >= 0; }
+ static bool hasPath(const String& path) { return findLastSeparatorIndex(path) >= 0; }
+
static String replaceExt(const String& path, const char* newExt);
static String getFileName(const String& path);
static String getPathWithoutExt(const String& path);
diff --git a/source/core/unix/slang-unix-process.cpp b/source/core/unix/slang-unix-process.cpp
index 2c84ef08f..1f58f5725 100644
--- a/source/core/unix/slang-unix-process.cpp
+++ b/source/core/unix/slang-unix-process.cpp
@@ -355,8 +355,10 @@ static const int kCannotExecute = 126;
{
List<char const*> argPtrs;
+ const auto& exe = commandLine.m_executableLocation;
+
// Add the command
- argPtrs.add(commandLine.m_executable.getBuffer());
+ argPtrs.add(exe.m_pathOrName.getBuffer());
// Add all the args - they don't need any explicit escaping
for (auto arg : commandLine.m_args)
@@ -413,9 +415,16 @@ static const int kCannotExecute = 126;
// TODO(JS): Strictly speaking if m_executableType is 'Path' then we shouldn't be searching. Ie which
// exec we use here should be dependent on the executable type.
- // Path = execvp
- // Filename = execv
- ::execvp(argPtrs[0], (char* const*)&argPtrs[0]);
+ if (exe.m_type == ExecutableLocation::Type::Path)
+ {
+ // Use the specified path (ie don't search)
+ ::execv(argPtrs[0], (char* const*)&argPtrs[0]);
+ }
+ else
+ {
+ // Search for the executable
+ ::execvp(argPtrs[0], (char* const*)&argPtrs[0]);
+ }
// If we get here, then `exec` failed
diff --git a/source/core/windows/slang-win-process.cpp b/source/core/windows/slang-win-process.cpp
index e0e38f2d4..215904938 100644
--- a/source/core/windows/slang-win-process.cpp
+++ b/source/core/windows/slang-win-process.cpp
@@ -453,12 +453,12 @@ void WinProcess::kill(int32_t returnCode)
OSString pathBuffer;
LPCWSTR path = nullptr;
- if (commandLine.m_executableType == CommandLine::ExecutableType::Path)
+ const auto& exe = commandLine.m_executableLocation;
+ if (exe.m_type == ExecutableLocation::Type::Path)
{
- StringBuilder cmd;
- StringEscapeUtil::appendMaybeQuoted(getEscapeHandler(), commandLine.m_executable.getUnownedSlice(), cmd);
-
- pathBuffer = cmd.toWString();
+ // If it 'Path' specified we pass in as the lpApplicationName to limit
+ // searching.
+ pathBuffer = exe.m_pathOrName.toWString();
path = pathBuffer.begin();
}
@@ -479,6 +479,14 @@ void WinProcess::kill(int32_t returnCode)
createFlags |= CREATE_SUSPENDED;
}
+ // From docs:
+ // If both lpApplicationName and lpCommandLine are non-NULL, the null-terminated string pointed to by lpApplicationName
+ // specifies the module to execute, and the null-terminated string pointed to by lpCommandLine specifies the command line.
+
+ // JS:
+ // Somewhat confusingly this means that even if lpApplicationName is specified, it muse *ALSO* be included as the first
+ // whitespace delimited arg must *also* be the (possibly) quoted executable
+
// https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-createprocessa
// `CreateProcess` requires write access to this, for some reason...
BOOL success = CreateProcessW(
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp
index 68c7aeec7..f57fe22a1 100644
--- a/tools/slang-test/slang-test-main.cpp
+++ b/tools/slang-test/slang-test-main.cpp
@@ -553,13 +553,13 @@ Result spawnAndWaitExe(TestContext* context, const String& testPath, const Comma
Result spawnAndWaitSharedLibrary(TestContext* context, const String& testPath, const CommandLine& cmdLine, ExecuteResult& outRes)
{
const auto& options = context->options;
- String exeName = Path::getFileNameWithoutExt(cmdLine.m_executable);
+ String exeName = Path::getFileNameWithoutExt(cmdLine.m_executableLocation.m_pathOrName);
if (options.shouldBeVerbose)
{
CommandLine testCmdLine;
- testCmdLine.setExecutableFilename("slang-test");
+ testCmdLine.setExecutableLocation(ExecutableLocation("slang-test"));
if (options.binDir.getLength())
{
@@ -622,7 +622,7 @@ Result spawnAndWaitSharedLibrary(TestContext* context, const String& testPath, c
Result spawnAndWaitProxy(TestContext* context, const String& testPath, const CommandLine& inCmdLine, ExecuteResult& outRes)
{
// Get the name of the thing to execute
- String exeName = Path::getFileNameWithoutExt(inCmdLine.m_executable);
+ String exeName = Path::getFileNameWithoutExt(inCmdLine.m_executableLocation.m_pathOrName);
if (exeName == "slangc")
{
@@ -635,7 +635,7 @@ Result spawnAndWaitProxy(TestContext* context, const String& testPath, const Com
// Make the first arg the name of the tool to invoke
cmdLine.m_args.insert(0, exeName);
- cmdLine.setExecutable(context->exeDirectoryPath, "test-proxy");
+ cmdLine.setExecutableLocation(ExecutableLocation(context->exeDirectoryPath, "test-proxy"));
const auto& options = context->options;
if (options.shouldBeVerbose)
@@ -707,7 +707,7 @@ static Result _executeRPC(TestContext* context, SpawnType spawnType, const Unown
Result spawnAndWaitTestServer(TestContext* context, SpawnType spawnType, const String& testPath, const CommandLine& inCmdLine, ExecuteResult& outRes)
{
- String exeName = Path::getFileNameWithoutExt(inCmdLine.m_executable);
+ String exeName = Path::getFileNameWithoutExt(inCmdLine.m_executableLocation.m_pathOrName);
// This is a test tool execution
TestServerProtocol::ExecuteToolTestArgs args;
@@ -945,7 +945,7 @@ static SlangResult _extractReflectionTestRequirements(const CommandLine& cmdLine
static SlangResult _extractTestRequirements(const CommandLine& cmdLine, TestRequirements* ioInfo)
{
- String exeName = Path::getFileNameWithoutExt(cmdLine.m_executable);
+ String exeName = Path::getFileNameWithoutExt(cmdLine.m_executableLocation.m_pathOrName);
if (exeName == "render-test")
{
@@ -1002,7 +1002,7 @@ static RenderApiFlags _getAvailableRenderApiFlags(TestContext* context)
}
// Try starting up the device
CommandLine cmdLine;
- cmdLine.setExecutable(context->options.binDir, "render-test");
+ cmdLine.setExecutableLocation(ExecutableLocation(context->options.binDir, "render-test"));
_addRenderTestOptions(context->options, cmdLine);
// We just want to see if the device can be started up
cmdLine.addArg("-only-startup");
@@ -1150,7 +1150,7 @@ String findExpectedPath(const TestInput& input, const char* postFix)
static void _initSlangCompiler(TestContext* context, CommandLine& ioCmdLine)
{
- ioCmdLine.setExecutable(context->options.binDir, "slangc");
+ ioCmdLine.setExecutableLocation(ExecutableLocation(context->options.binDir, "slangc"));
if (context->options.verbosePaths)
{
@@ -1203,9 +1203,12 @@ static SlangResult _executeBinary(const UnownedStringSlice& hexDump, ExecuteResu
SLANG_RETURN_ON_FAIL(File::makeExecutable(fileName));
// Execute it
+ ExecutableLocation exe;
+ exe.setPath(fileName);
+
CommandLine cmdLine;
- cmdLine.m_executable = fileName;
- cmdLine.m_executableType = CommandLine::ExecutableType::Path;
+ cmdLine.setExecutableLocation(exe);
+
return ProcessUtil::execute(cmdLine, outExeRes);
}
@@ -1599,7 +1602,7 @@ TestResult runReflectionTest(TestContext* context, TestInput& input)
CommandLine cmdLine;
- cmdLine.setExecutable(options.binDir, "slang-reflection-test");
+ cmdLine.setExecutableLocation(ExecutableLocation(options.binDir, "slang-reflection-test"));
cmdLine.addArg(filePath);
for( auto arg : input.testOptions->args )
@@ -1881,13 +1884,17 @@ static TestResult runCPPCompilerExecute(TestContext* context, TestInput& input)
String modulePath = _calcModulePath(input);
// Remove the binary..
+ String moduleExePath;
{
- StringBuilder moduleExePath;
- moduleExePath << modulePath;
- moduleExePath << Process::getExecutableSuffix();
- File::remove(moduleExePath);
+ StringBuilder buf;
+ buf << modulePath;
+ buf << Process::getExecutableSuffix();
+ moduleExePath = buf;
}
+ // Remove the exe if it exists
+ File::remove(moduleExePath);
+
// Set up the compilation options
DownstreamCompiler::CompileOptions options;
@@ -1915,13 +1922,12 @@ static TestResult runCPPCompilerExecute(TestContext* context, TestInput& input)
else
{
// Execute the binary and see what we get
-
CommandLine cmdLine;
- StringBuilder exePath;
- exePath << modulePath << Process::getExecutableSuffix();
+ ExecutableLocation exe;
+ exe.setPath(moduleExePath);
- cmdLine.setExecutablePath(exePath);
+ cmdLine.setExecutableLocation(exe);
ExecuteResult exeRes;
if (SLANG_FAILED(ProcessUtil::execute(cmdLine, exeRes)))
@@ -2385,7 +2391,7 @@ TestResult runPerformanceProfile(TestContext* context, TestInput& input)
CommandLine cmdLine;
- cmdLine.setExecutable(context->options.binDir, "render-test");
+ cmdLine.setExecutableLocation(ExecutableLocation(context->options.binDir, "render-test"));
cmdLine.addArg(input.filePath);
cmdLine.addArg("-performance-profile");
@@ -2538,7 +2544,7 @@ TestResult runComputeComparisonImpl(TestContext* context, TestInput& input, cons
CommandLine cmdLine;
- cmdLine.setExecutable(context->options.binDir, "render-test");
+ cmdLine.setExecutableLocation(ExecutableLocation(context->options.binDir, "render-test"));
cmdLine.addArg(filePath999);
_addRenderTestOptions(context->options, cmdLine);
@@ -2647,7 +2653,7 @@ TestResult doRenderComparisonTestRun(TestContext* context, TestInput& input, cha
CommandLine cmdLine;
- cmdLine.setExecutable(context->options.binDir, "render-test");
+ cmdLine.setExecutableLocation(ExecutableLocation(context->options.binDir, "render-test"));
cmdLine.addArg(filePath);
_addRenderTestOptions(context->options, cmdLine);
diff --git a/tools/slang-test/test-context.cpp b/tools/slang-test/test-context.cpp
index acc680f24..2f0e23815 100644
--- a/tools/slang-test/test-context.cpp
+++ b/tools/slang-test/test-context.cpp
@@ -118,7 +118,7 @@ SlangResult TestContext::_createJSONRPCConnection(RefPtr<JSONRPCConnection>& out
{
CommandLine cmdLine;
- cmdLine.setExecutable(exeDirectoryPath.getBuffer(), "test-server");
+ cmdLine.setExecutableLocation(ExecutableLocation(exeDirectoryPath, "test-server"));
SLANG_RETURN_ON_FAIL(Process::create(cmdLine, Process::Flag::AttachDebugger, process));
}
diff --git a/tools/slang-test/test-reporter.cpp b/tools/slang-test/test-reporter.cpp
index 8000fd2a5..83df0fb0b 100644
--- a/tools/slang-test/test-reporter.cpp
+++ b/tools/slang-test/test-reporter.cpp
@@ -439,7 +439,7 @@ void TestReporter::_addResult(const TestInfo& info)
// https://www.appveyor.com/docs/build-worker-api/#add-tests
CommandLine cmdLine;
- cmdLine.setExecutableFilename("appveyor");
+ cmdLine.setExecutableLocation(ExecutableLocation("appveyor"));
cmdLine.addArg("AddTest");
cmdLine.addArg(info.name);
cmdLine.addArg("-FileName");
diff --git a/tools/slang-unit-test/unit-test-process.cpp b/tools/slang-unit-test/unit-test-process.cpp
index 559522769..839a19f5d 100644
--- a/tools/slang-unit-test/unit-test-process.cpp
+++ b/tools/slang-unit-test/unit-test-process.cpp
@@ -14,7 +14,7 @@ using namespace Slang;
static SlangResult _createProcess(UnitTestContext* context, const char* toolName, const List<String>* optArgs, RefPtr<Process>& outProcess)
{
CommandLine cmdLine;
- cmdLine.setExecutable(context->executableDirectory, "test-process");
+ cmdLine.setExecutableLocation(ExecutableLocation(context->executableDirectory, "test-process"));
cmdLine.addArg(toolName);
if (optArgs)
{