Utils: Introduce a FilePath::withNewPath() convenience method

It's effectively the mirrored version of onDevice() with an
equally odd name which is a bit more straightforward to use
in some cases.

Change-Id: I0cfedeb58871a857c93144e2a0d734bad1bcd887
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2021-07-14 13:01:28 +02:00
parent 842770b6b5
commit d06c670504
6 changed files with 28 additions and 11 deletions

View File

@@ -60,8 +60,7 @@ static QString emSdkEnvOutput(const FilePath &sdkRoot)
emSdkEnv.setCommand(CommandLine(scriptFile));
} else {
// File needs to be source'd, not executed.
emSdkEnv.setCommand({FilePath::fromString("bash").onDevice(sdkRoot),
{"-c", ". " + scriptFile}});
emSdkEnv.setCommand({sdkRoot.withNewPath("bash"), {"-c", ". " + scriptFile}});
}
emSdkEnv.runBlocking();
const QString output = emSdkEnv.allOutput();
@@ -108,8 +107,7 @@ QVersionNumber WebAssemblyEmSdk::version(const FilePath &sdkRoot)
Environment env;
WebAssemblyEmSdk::addToEnvironment(sdkRoot, env);
QLatin1String scriptFile{sdkRoot.osType() == OsType::OsTypeWindows ? "emcc.bat" : "emcc"};
FilePath script =
FilePath::fromString(scriptFile).onDevice(sdkRoot).searchOnDevice(env.path());
FilePath script = sdkRoot.withNewPath(scriptFile).searchOnDevice(env.path());
const CommandLine command(script, {"-dumpversion"});
QtcProcess emcc;
emcc.setCommand(command);