forked from qt-creator/qt-creator
Qnx: Fix discovery of host and target for remote build devices
Change-Id: I9fa65f0e2a0708888d1fc4ca19c932560ee4af68 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -358,11 +358,11 @@ void QnxConfiguration::setDefaultConfiguration(const FilePath &envScript)
|
|||||||
m_qnxEnv = QnxUtils::qnxEnvironmentFromEnvFile(m_envFile);
|
m_qnxEnv = QnxUtils::qnxEnvironmentFromEnvFile(m_envFile);
|
||||||
for (const EnvironmentItem &item : std::as_const(m_qnxEnv)) {
|
for (const EnvironmentItem &item : std::as_const(m_qnxEnv)) {
|
||||||
if (item.name == QNXConfiguration)
|
if (item.name == QNXConfiguration)
|
||||||
m_qnxConfiguration = FilePath::fromString(item.value).canonicalPath();
|
m_qnxConfiguration = envScript.withNewPath(item.value).canonicalPath();
|
||||||
else if (item.name == QNXTarget)
|
else if (item.name == QNXTarget)
|
||||||
m_qnxTarget = FilePath::fromString(item.value).canonicalPath();
|
m_qnxTarget = envScript.withNewPath(item.value).canonicalPath();
|
||||||
else if (item.name == QNXHost)
|
else if (item.name == QNXHost)
|
||||||
m_qnxHost = FilePath::fromString(item.value).canonicalPath();
|
m_qnxHost = envScript.withNewPath(item.value).canonicalPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
const FilePath qccPath = m_qnxHost.pathAppended("usr/bin/qcc").withExecutableSuffix();
|
const FilePath qccPath = m_qnxHost.pathAppended("usr/bin/qcc").withExecutableSuffix();
|
||||||
@@ -383,9 +383,9 @@ void QnxConfiguration::setDefaultConfiguration(const FilePath &envScript)
|
|||||||
EnvironmentItems QnxConfiguration::qnxEnvironmentItems() const
|
EnvironmentItems QnxConfiguration::qnxEnvironmentItems() const
|
||||||
{
|
{
|
||||||
Utils::EnvironmentItems envList;
|
Utils::EnvironmentItems envList;
|
||||||
envList.push_back(EnvironmentItem(QNXConfiguration, m_qnxConfiguration.toString()));
|
envList.push_back(EnvironmentItem(QNXConfiguration, m_qnxConfiguration.path()));
|
||||||
envList.push_back(EnvironmentItem(QNXTarget, m_qnxTarget.toString()));
|
envList.push_back(EnvironmentItem(QNXTarget, m_qnxTarget.path()));
|
||||||
envList.push_back(EnvironmentItem(QNXHost, m_qnxHost.toString()));
|
envList.push_back(EnvironmentItem(QNXHost, m_qnxHost.path()));
|
||||||
|
|
||||||
return envList;
|
return envList;
|
||||||
}
|
}
|
||||||
@@ -401,17 +401,20 @@ const QnxConfiguration::Target *QnxConfiguration::findTargetByDebuggerPath(
|
|||||||
void QnxConfiguration::updateTargets()
|
void QnxConfiguration::updateTargets()
|
||||||
{
|
{
|
||||||
m_targets.clear();
|
m_targets.clear();
|
||||||
QList<QnxTarget> targets = QnxUtils::findTargets(m_qnxTarget);
|
const QList<QnxTarget> targets = QnxUtils::findTargets(m_qnxTarget);
|
||||||
for (const auto &target : targets)
|
for (const QnxTarget &target : targets)
|
||||||
m_targets.append(Target(target.m_abi, target.m_path));
|
m_targets.append(Target(target.m_abi, target.m_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
void QnxConfiguration::assignDebuggersToTargets()
|
void QnxConfiguration::assignDebuggersToTargets()
|
||||||
{
|
{
|
||||||
const FilePath hostUsrBinDir = m_qnxHost.pathAppended("usr/bin");
|
const FilePath hostUsrBinDir = m_qnxHost.pathAppended("usr/bin");
|
||||||
const FilePaths debuggerNames = hostUsrBinDir.dirEntries(
|
QString pattern = "nto*-gdb";
|
||||||
{{HostOsInfo::withExecutableSuffix("nto*-gdb")}, QDir::Files});
|
if (m_qnxHost.osType() == Utils::OsTypeWindows)
|
||||||
Environment sysEnv = Environment::systemEnvironment();
|
pattern += ".exe";
|
||||||
|
|
||||||
|
const FilePaths debuggerNames = hostUsrBinDir.dirEntries({{pattern}, QDir::Files});
|
||||||
|
Environment sysEnv = m_qnxHost.deviceEnvironment();
|
||||||
sysEnv.modify(qnxEnvironmentItems());
|
sysEnv.modify(qnxEnvironmentItems());
|
||||||
|
|
||||||
for (const FilePath &debuggerPath : debuggerNames) {
|
for (const FilePath &debuggerPath : debuggerNames) {
|
||||||
|
@@ -21,11 +21,6 @@ using namespace Utils;
|
|||||||
|
|
||||||
namespace Qnx::Internal {
|
namespace Qnx::Internal {
|
||||||
|
|
||||||
const char *EVAL_ENV_VARS[] = {
|
|
||||||
"QNX_TARGET", "QNX_HOST", "QNX_CONFIGURATION", "QNX_CONFIGURATION_EXCLUSIVE",
|
|
||||||
"MAKEFLAGS", "LD_LIBRARY_PATH", "PATH", "QDE", "CPUVARDIR", "PYTHONPATH"
|
|
||||||
};
|
|
||||||
|
|
||||||
QString QnxUtils::cpuDirFromAbi(const Abi &abi)
|
QString QnxUtils::cpuDirFromAbi(const Abi &abi)
|
||||||
{
|
{
|
||||||
if (abi.os() != Abi::OS::QnxOS)
|
if (abi.os() != Abi::OS::QnxOS)
|
||||||
@@ -64,30 +59,46 @@ EnvironmentItems QnxUtils::qnxEnvironmentFromEnvFile(const FilePath &filePath)
|
|||||||
const bool isWindows = filePath.osType() == Utils::OsTypeWindows;
|
const bool isWindows = filePath.osType() == Utils::OsTypeWindows;
|
||||||
|
|
||||||
// locking creating sdp-env file wrapper script
|
// locking creating sdp-env file wrapper script
|
||||||
TemporaryFile tmpFile("sdp-env-eval-XXXXXX" + QString::fromLatin1(isWindows ? ".bat" : ".sh"));
|
const expected_str<FilePath> tmpPath = filePath.tmpDir();
|
||||||
if (!tmpFile.open())
|
if (!tmpPath)
|
||||||
return items;
|
return {}; // make_unexpected(tmpPath.error());
|
||||||
tmpFile.setTextModeEnabled(true);
|
|
||||||
|
|
||||||
// writing content to wrapper script
|
const QString tmpName = "sdp-env-eval-XXXXXX" + QLatin1String(isWindows ? ".bat" : "");
|
||||||
QTextStream fileContent(&tmpFile);
|
const FilePath pattern = *tmpPath / tmpName;
|
||||||
|
|
||||||
|
const expected_str<FilePath> tmpFile = pattern.createTempFile();
|
||||||
|
if (!tmpFile)
|
||||||
|
return {}; // make_unexpected(tmpFile.error());
|
||||||
|
|
||||||
|
QStringList fileContent;
|
||||||
|
|
||||||
|
// writing content to wrapper script.
|
||||||
|
// this has to use bash as qnxsdp-env.sh requires this
|
||||||
if (isWindows)
|
if (isWindows)
|
||||||
fileContent << "@echo off\n"
|
fileContent << "@echo off" << "call " + filePath.path();
|
||||||
<< "call " << filePath.path() << '\n';
|
|
||||||
else
|
else
|
||||||
fileContent << "#!/bin/bash\n"
|
fileContent << "#!/bin/bash" << ". " + filePath.path();
|
||||||
<< ". " << filePath.path() << '\n';
|
|
||||||
QString linePattern = QString::fromLatin1(isWindows ? "echo %1=%%1%" : "echo %1=$%1");
|
QLatin1String linePattern(isWindows ? "echo %1=%%1%" : "echo %1=$%1");
|
||||||
for (int i = 0, len = sizeof(EVAL_ENV_VARS) / sizeof(const char *); i < len; ++i)
|
|
||||||
fileContent << linePattern.arg(QLatin1String(EVAL_ENV_VARS[i])) << QLatin1Char('\n');
|
static const char *envVars[] = {
|
||||||
tmpFile.close();
|
"QNX_TARGET", "QNX_HOST", "QNX_CONFIGURATION", "QNX_CONFIGURATION_EXCLUSIVE",
|
||||||
|
"MAKEFLAGS", "LD_LIBRARY_PATH", "PATH", "QDE", "CPUVARDIR", "PYTHONPATH"
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const char *envVar : envVars)
|
||||||
|
fileContent << linePattern.arg(QLatin1String(envVar));
|
||||||
|
|
||||||
|
QString content = fileContent.join(QLatin1String(isWindows ? "\r\n" : "\n"));
|
||||||
|
|
||||||
|
tmpFile->writeFileContents(content.toUtf8());
|
||||||
|
|
||||||
// running wrapper script
|
// running wrapper script
|
||||||
QtcProcess process;
|
QtcProcess process;
|
||||||
if (isWindows)
|
if (isWindows)
|
||||||
process.setCommand({"cmd.exe", {"/C", tmpFile.fileName()}});
|
process.setCommand({filePath.withNewPath("cmd.exe"), {"/C", tmpFile->path()}});
|
||||||
else
|
else
|
||||||
process.setCommand({"/bin/bash", {tmpFile.fileName()}});
|
process.setCommand({filePath.withNewPath("/bin/bash"), {tmpFile->path()}});
|
||||||
process.start();
|
process.start();
|
||||||
|
|
||||||
// waiting for finish
|
// waiting for finish
|
||||||
@@ -190,25 +201,25 @@ QList<QnxTarget> QnxUtils::findTargets(const FilePath &basePath)
|
|||||||
{
|
{
|
||||||
QList<QnxTarget> result;
|
QList<QnxTarget> result;
|
||||||
|
|
||||||
QDirIterator iterator(basePath.toString());
|
basePath.iterateDirectory(
|
||||||
while (iterator.hasNext()) {
|
[&result](const FilePath &filePath) {
|
||||||
iterator.next();
|
const FilePath libc = filePath / "lib/libc.so";
|
||||||
const FilePath libc = FilePath::fromString(iterator.filePath()).pathAppended("lib/libc.so");
|
|
||||||
if (libc.exists()) {
|
if (libc.exists()) {
|
||||||
auto abis = Abi::abisOfBinary(libc);
|
const Abis abis = Abi::abisOfBinary(libc);
|
||||||
if (abis.isEmpty()) {
|
if (abis.isEmpty()) {
|
||||||
qWarning() << libc << "has no ABIs ... discarded";
|
qWarning() << libc << "has no ABIs ... discarded";
|
||||||
continue;
|
return IterationPolicy::Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (abis.count() > 1)
|
if (abis.count() > 1)
|
||||||
qWarning() << libc << "has more than one ABI ... processing all";
|
qWarning() << libc << "has more than one ABI ... processing all";
|
||||||
|
|
||||||
FilePath path = FilePath::fromString(iterator.filePath());
|
|
||||||
for (const Abi &abi : abis)
|
for (const Abi &abi : abis)
|
||||||
result.append(QnxTarget(path, QnxUtils::convertAbi(abi)));
|
result.append(QnxTarget(filePath, QnxUtils::convertAbi(abi)));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return IterationPolicy::Continue;
|
||||||
|
},
|
||||||
|
{{}, QDir::Dirs});
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user