logic: Added cross-compilation UI to CXX source group setup (issue #370)

Allows for defining specific target triple of architecture, vendor, OS and environment as set of dropdown lists
in CXX source group setup.

bug id = 370
This commit is contained in:
Eberhard Graether
2017-08-08 16:00:32 +02:00
parent 4f74235ca1
commit 2305a74e6c
22 changed files with 611 additions and 64 deletions
+2
View File
@@ -166,6 +166,8 @@ add_files(
qt/window/project_wizzard/QtProjectWizzardContent.h
qt/window/project_wizzard/QtProjectWizzardContentCDBSource.cpp
qt/window/project_wizzard/QtProjectWizzardContentCDBSource.h
qt/window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.cpp
qt/window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.h
qt/window/project_wizzard/QtProjectWizzardContentExtensions.cpp
qt/window/project_wizzard/QtProjectWizzardContentExtensions.h
qt/window/project_wizzard/QtProjectWizzardContentFlags.cpp
@@ -4,16 +4,15 @@
#include <QFileDialog>
#include <QMimeData>
#include <QScrollBar>
#include <QSysInfo>
#include <QTimer>
#include <QTreeView>
#include "utility/ResourcePaths.h"
#include "utility/utilityString.h"
#include "qt/element/QtIconButton.h"
#include "qt/utility/utilityQt.h"
#include "qt/window/QtTextEditDialog.h"
#include "utility/ResourcePaths.h"
#include "utility/utilityApp.h"
#include "utility/utilityString.h"
QtListItemWidget::QtListItemWidget(QtDirectoryListBox* list, QListWidgetItem* item, QWidget *parent)
: QWidget(parent)
@@ -80,7 +79,7 @@ void QtListItemWidget::handleButtonPress()
{
QFileDialog dialog(this);
if (QSysInfo::macVersion() == QSysInfo::MV_None)
if (utility::getOsType() != OS_MAC)
{
dialog.setFileMode(QFileDialog::Directory);
}
+2 -2
View File
@@ -3,7 +3,6 @@
#include <QFileDialog>
#include <QMouseEvent>
#include <QScrollBar>
#include <QSysInfo>
#include <QTimer>
#include <QApplication>
@@ -18,6 +17,7 @@
#include "qt/utility/utilityQt.h"
#include "settings/ApplicationSettings.h"
#include "utility/messaging/type/MessageDisplayBookmarkCreator.h"
#include "utility/utilityApp.h"
#include "utility/ResourcePaths.h"
QtGraphicsView::QtGraphicsView(QWidget* parent)
@@ -32,7 +32,7 @@ QtGraphicsView::QtGraphicsView(QWidget* parent)
, m_zoomInButtonSpeed(20.0f)
, m_zoomOutButtonSpeed(-20.0f)
{
QString modifierName = QSysInfo::macVersion() == QSysInfo::MV_None ? "Ctrl" : "Cmd";
QString modifierName = utility::getOsType() == OS_MAC ? "Cmd" : "Ctrl";
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
+13 -10
View File
@@ -11,6 +11,7 @@
#include "settings/ApplicationSettings.h"
#include "utility/Version.h"
#include "utility/utility.h"
#include "utility/utilityApp.h"
#include "utility/utilityUuid.h"
void QtUpdateChecker::check(bool force)
@@ -30,17 +31,19 @@ void QtUpdateChecker::check(bool force)
// OS
std::string osString;
#if defined(Q_OS_WIN)
osString = "windows";
#elif defined(Q_OS_MACOS)
osString = "macOS";
#elif defined(Q_OS_LINUX)
osString = "linux";
#endif
if (!osString.size())
switch (utility::getOsType())
{
return;
case OS_WINDOWS:
osString = "windows";
break;
case OS_MAC:
osString = "macOS";
break;
case OS_LINUX:
osString = "linux";
break;
default:
return;
}
urlString += ("?os=" + osString).c_str();
+4 -4
View File
@@ -1,9 +1,9 @@
#include "qt/view/QtGraphViewStyleImpl.h"
#include <QFontMetrics>
#include <QSysInfo>
#include "qt/view/graphElements/QtGraphNode.h"
#include "utility/utilityApp.h"
QtGraphViewStyleImpl::~QtGraphViewStyleImpl()
{
@@ -21,10 +21,10 @@ float QtGraphViewStyleImpl::getCharHeightForNodeType(Node::NodeType type)
float QtGraphViewStyleImpl::getGraphViewZoomDifferenceForPlatform()
{
if (QSysInfo::macVersion() == QSysInfo::MV_None)
if (utility::getOsType() == OS_MAC)
{
return 1.25;
return 1;
}
return 1;
return 1.25;
}
+2 -2
View File
@@ -7,7 +7,6 @@
#include <QMenuBar>
#include <QMessageBox>
#include <QSettings>
#include <QSysInfo>
#include <QTimer>
#include "Application.h"
@@ -50,6 +49,7 @@
#include "utility/ResourcePaths.h"
#include "utility/tracing.h"
#include "utility/UserPaths.h"
#include "utility/utilityApp.h"
#include "utility/utilityString.h"
@@ -752,7 +752,7 @@ void QtMainWindow::setupEditMenu()
menuBar()->addMenu(menu);
m_trialDisabledActions.push_back(menu->addAction(tr("&Refresh"), this, &QtMainWindow::refresh, QKeySequence::Refresh));
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
if (utility::getOsType() == OS_WINDOWS)
{
m_trialDisabledActions.push_back(
menu->addAction(tr("&Full Refresh"), this, &QtMainWindow::forceRefresh, QKeySequence(Qt::SHIFT + Qt::Key_F5))
@@ -9,6 +9,7 @@
#include "qt/window/project_wizzard/QtProjectWizzardContentPaths.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentPreferences.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentSummary.h"
#include "utility/utilityApp.h"
QtPreferencesWindow::QtPreferencesWindow(QWidget* parent)
: QtProjectWizzardWindow(parent)
@@ -27,7 +28,7 @@ QtPreferencesWindow::QtPreferencesWindow(QWidget* parent)
summary->addContent(new QtProjectWizzardContentPreferences(this));
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(this));
if (QSysInfo::macVersion() != QSysInfo::MV_None)
if (utility::getOsType() == OS_MAC)
{
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearchGlobal(this));
}
@@ -8,6 +8,7 @@
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentCDBSource.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentExtensions.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentFlags.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentLanguageAndStandard.h"
@@ -25,6 +26,7 @@
#include "utility/messaging/type/MessageStatus.h"
#include "utility/ResourcePaths.h"
#include "utility/utility.h"
#include "utility/utilityApp.h"
#include "utility/utilityPathDetection.h"
#include "utility/utilityString.h"
#include "utility/utilityUuid.h"
@@ -419,7 +421,7 @@ void QtProjectWizzard::selectedSourceGroupChanged(int index)
}
else
{
const bool isCDB = group->getType() == SOURCE_GROUP_CXX_CDB || group->getType() == SOURCE_GROUP_CXX_CDB;
const bool isCDB = group->getType() == SOURCE_GROUP_CXX_CDB;
if (isCDB)
{
@@ -434,6 +436,8 @@ void QtProjectWizzard::selectedSourceGroupChanged(int index)
{
summary->addContent(new QtProjectWizzardContentLanguageAndStandard(group, this));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentCrossCompilationOptions(group, this));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentPathsSource(group, this));
summary->addContent(new QtProjectWizzardContentExtensions(group, this));
@@ -452,7 +456,7 @@ void QtProjectWizzard::selectedSourceGroupChanged(int index)
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(this));
summary->addSpace();
if (QSysInfo::macVersion() != QSysInfo::MV_None)
if (utility::getOsType() == OS_MAC)
{
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearch(group, this, isCDB));
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearchGlobal(this));
@@ -644,11 +648,20 @@ void QtProjectWizzard::selectedProjectType(SourceGroupType sourceGroupType)
void QtProjectWizzard::emptySourceGroup()
{
QtProjectWizzardWindow* window = createWindowWithContent(
[this](QtProjectWizzardWindow* window)
QtProjectWizzardWindow* window = createWindowWithSummary(
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary)
{
window->setPreferredSize(QSize(470, 230));
return new QtProjectWizzardContentLanguageAndStandard(m_newSourceGroupSettings, window);
summary->addContent(new QtProjectWizzardContentLanguageAndStandard(m_newSourceGroupSettings, window));
if (m_newSourceGroupSettings->getType() == SOURCE_GROUP_C_EMPTY||
m_newSourceGroupSettings->getType() == SOURCE_GROUP_CPP_EMPTY)
{
summary->addContent(new QtProjectWizzardContentCrossCompilationOptions(m_newSourceGroupSettings, window));
window->setPreferredSize(QSize(470, 460));
}
else
{
window->setPreferredSize(QSize(470, 230));
}
}
);
@@ -731,7 +744,7 @@ void QtProjectWizzard::headerSearchPaths()
void QtProjectWizzard::headerSearchPathsDone()
{
if (QSysInfo::macVersion() != QSysInfo::MV_None)
if (utility::getOsType() == OS_MAC)
{
frameworkSearchPaths();
}
@@ -0,0 +1,173 @@
#include "qt/window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.h"
#include <QCheckBox>
#include <QComboBox>
#include <QLabel>
#include "settings/SourceGroupSettings.h"
#include "settings/SourceGroupSettingsCxx.h"
#include "utility/logging/logging.h"
QtProjectWizzardContentCrossCompilationOptions::QtProjectWizzardContentCrossCompilationOptions(
std::shared_ptr<SourceGroupSettings> sourceGroupSettings,
QtProjectWizzardWindow* window
)
: QtProjectWizzardContent(window)
, m_sourceGroupSettings(sourceGroupSettings)
, m_useTargetOptions(nullptr)
, m_arch(nullptr)
, m_vendor(nullptr)
, m_sys(nullptr)
, m_abi(nullptr)
{
}
void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layout, int& row)
{
if (!isInForm())
{
layout->setRowMinimumHeight(row, 15);
row++;
}
layout->addWidget(createFormLabel("Cross-Compilation"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
addHelpButton(
"<p>Use these options to specify the target architecture for the provided source code. Even though Sourcetrail will "
"not generate a target binary, providing these options will affect which headers the indexer will be looking for "
"while analyzing your source code.</p>"
"<p>If you are not sure which value to pick for a certain option just choose \"unknown\" and Sourcetrail will try "
"to guess the correct value.</p>",
layout, row
);
{
m_useTargetOptions = new QCheckBox("Use specific target");
connect(m_useTargetOptions, &QCheckBox::stateChanged, this, &QtProjectWizzardContentCrossCompilationOptions::onUseTargetOptionsChanged);
QHBoxLayout* rowLayout = new QHBoxLayout();
rowLayout->setContentsMargins(0, 0, 0, 0);
rowLayout->addWidget(m_useTargetOptions);
QWidget* rowWidget = new QWidget();
rowWidget->setLayout(rowLayout);
layout->addWidget(rowWidget, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop);
row++;
}
QGridLayout* gridLayout = new QGridLayout();
{
QLabel* label = new QLabel("Architecture:");
m_arch = new QComboBox();
std::vector<std::string> archTypes = SourceGroupSettingsCxx::getAvailableArchTypes();
std::sort(archTypes.begin(), archTypes.end());
for (size_t i = 0; i < archTypes.size(); i++)
{
m_arch->insertItem(i, archTypes[i].c_str());
}
m_arch->setCurrentIndex(m_arch->findText("x86_64"));
gridLayout->addWidget(label, 0, 0, Qt::AlignRight);
gridLayout->addWidget(m_arch, 0, 1, Qt::AlignLeft);
}
{
QLabel* label = new QLabel("Vendor:");
m_vendor = new QComboBox();
std::vector<std::string> vendorTypes = SourceGroupSettingsCxx::getAvailableVendorTypes();
std::sort(vendorTypes.begin() + 1, vendorTypes.end());
for (size_t i = 0; i < vendorTypes.size(); i++)
{
m_vendor->insertItem(i, vendorTypes[i].c_str());
}
gridLayout->addWidget(label, 1, 0, Qt::AlignRight);
gridLayout->addWidget(m_vendor, 1, 1, Qt::AlignLeft);
}
{
QLabel* label = new QLabel("OS:");
m_sys = new QComboBox();
std::vector<std::string> osTypes = SourceGroupSettingsCxx::getAvailableOsTypes();
std::sort(osTypes.begin() + 1, osTypes.end());
for (size_t i = 0; i < osTypes.size(); i++)
{
m_sys->insertItem(i, osTypes[i].c_str());
}
gridLayout->addWidget(label, 2, 0, Qt::AlignRight);
gridLayout->addWidget(m_sys, 2, 1, Qt::AlignLeft);
}
{
QLabel* label = new QLabel("Environment:");
m_abi = new QComboBox();
std::vector<std::string> environmentTypes = SourceGroupSettingsCxx::getAvailableEnvironmentTypes();
std::sort(environmentTypes.begin() + 1, environmentTypes.end());
for (size_t i = 0; i < environmentTypes.size(); i++)
{
m_abi->insertItem(i, environmentTypes[i].c_str());
}
gridLayout->addWidget(label, 3, 0, Qt::AlignRight);
gridLayout->addWidget(m_abi, 3, 1, Qt::AlignLeft);
}
layout->addLayout(gridLayout, row++, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop);
if (!isInForm())
{
layout->setRowMinimumHeight(row, 15);
layout->setRowStretch(row, 1);
}
}
void QtProjectWizzardContentCrossCompilationOptions::load()
{
if (std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(m_sourceGroupSettings))
{
m_useTargetOptions->setChecked(cxxSettings->getTargetOptionsEnabled());
m_arch->setCurrentText(QString::fromStdString(cxxSettings->getTargetArch()));
m_vendor->setCurrentText(QString::fromStdString(cxxSettings->getTargetVendor()));
m_sys->setCurrentText(QString::fromStdString(cxxSettings->getTargetSys()));
m_abi->setCurrentText(QString::fromStdString(cxxSettings->getTargetAbi()));
}
updateTargetOptionsEnabled();
}
void QtProjectWizzardContentCrossCompilationOptions::save()
{
if (std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(m_sourceGroupSettings))
{
cxxSettings->setTargetOptionsEnabled(m_useTargetOptions->isChecked());
cxxSettings->setTargetArch(m_arch->currentText().toStdString());
cxxSettings->setTargetVendor(m_vendor->currentText().toStdString());
cxxSettings->setTargetSys(m_sys->currentText().toStdString());
cxxSettings->setTargetAbi(m_abi->currentText().toStdString());
}
}
bool QtProjectWizzardContentCrossCompilationOptions::check()
{
return true;
}
void QtProjectWizzardContentCrossCompilationOptions::onUseTargetOptionsChanged()
{
updateTargetOptionsEnabled();
}
void QtProjectWizzardContentCrossCompilationOptions::updateTargetOptionsEnabled()
{
const bool useTargetOptions = m_useTargetOptions->isChecked();
m_arch->setEnabled(useTargetOptions);
m_vendor->setEnabled(useTargetOptions);
m_sys->setEnabled(useTargetOptions);
m_abi->setEnabled(useTargetOptions);
}
@@ -0,0 +1,41 @@
#ifndef QT_PROJECT_WIZZARD_CONTENT_CROSS_COMPILATION_OPTIONS
#define QT_PROJECT_WIZZARD_CONTENT_CROSS_COMPILATION_OPTIONS
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
class QCheckBox;
class QComboBox;
class QLabel;
class SourceGroupSettings;
class QtProjectWizzardContentCrossCompilationOptions
: public QtProjectWizzardContent
{
Q_OBJECT
public:
QtProjectWizzardContentCrossCompilationOptions(
std::shared_ptr<SourceGroupSettings> sourceGroupSettings,
QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
virtual void populate(QGridLayout* layout, int& row) override;
virtual void load() override;
virtual void save() override;
virtual bool check() override;
private:
void onUseTargetOptionsChanged();
void updateTargetOptionsEnabled();
std::shared_ptr<SourceGroupSettings> m_sourceGroupSettings;
QCheckBox* m_useTargetOptions;
QComboBox* m_arch;
QComboBox* m_vendor;
QComboBox* m_sys;
QComboBox* m_abi;
};
#endif // QT_PROJECT_WIZZARD_CONTENT_CROSS_COMPILATION_OPTIONS
@@ -88,7 +88,7 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row)
);
// graph zooming
QString modifierName = QSysInfo::macVersion() == QSysInfo::MV_None ? "Ctrl" : "Cmd";
QString modifierName =utility::getOsType() == OS_MAC ? "Cmd" : "Ctrl";
m_graphZooming = addCheckBox(
"Graph Zoom",
"Zoom on mouse wheel",
@@ -159,20 +159,23 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row)
// jvm library path
m_javaPath = new QtLocationPicker(this);
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
switch (utility::getOsType())
{
case OS_WINDOWS:
m_javaPath->setFileFilter("JVM Library (jvm.dll)");
m_javaPath->setPlaceholderText("<jre_path>/bin/client/jvm.dll");
}
else if (QSysInfo::macVersion() != QSysInfo::MV_None)
{
break;
case OS_MAC:
m_javaPath->setFileFilter("JLI or JVM Library (libjli.dylib libjvm.dylib)");
m_javaPath->setPlaceholderText("<jre_path>/Contents/Home/jre/lib/jli/libjli.dylib");
}
else
{
break;
case OS_LINUX:
m_javaPath->setFileFilter("JVM Library (libjvm.so)");
m_javaPath->setPlaceholderText("<jre_path>/bin/<arch>/server/libjvm.so");
break;
default:
LOG_WARNING("No placeholders and filters set for Java path selection");
break;
}
addLabelAndWidget("Java Path", m_javaPath, layout, row);
+18 -2
View File
@@ -1,13 +1,12 @@
#include "utility/utilityApp.h"
#include <QProcess>
#include <QSysInfo>
#include <QThread>
#include <qprocessordetection.h>
#include "utility/utilityString.h"
#include <iostream>
namespace utility
{
std::mutex s_runningProcessesMutex;
@@ -78,6 +77,23 @@ void utility::killRunningProcesses()
}
}
OsType utility::getOsType()
{
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
{
return OS_WINDOWS;
}
else if (QSysInfo::macVersion() != QSysInfo::MV_None)
{
return OS_MAC;
}
else
{
return OS_LINUX;
}
return OS_UNKNOWN;
}
int utility::getIdealThreadCount()
{
return QThread::idealThreadCount();
+4
View File
@@ -5,6 +5,8 @@
#include <set>
#include <string>
#include "utility/OsType.h"
namespace utility
{
std::string executeProcess(const std::string& command, const std::string& workingDirectory = "", int timeout = 30000);
@@ -13,6 +15,8 @@ namespace utility
void killRunningProcesses();
int getIdealThreadCount();
OsType getOsType();
}
#endif // UTILITY_APP_H
+35 -19
View File
@@ -1,6 +1,6 @@
#include "utility/utilityPathDetection.h"
#include <QSysInfo>
#include "utility/logging/logging.h"
#include "utility/path_detector/java_runtime/JavaPathDetectorLinux.h"
#include "utility/path_detector/java_runtime/JavaPathDetectorMac.h"
@@ -17,20 +17,26 @@
#include "utility/path_detector/cxx_header/CxxHeaderPathDetector.h"
#include "utility/path_detector/cxx_header/CxxVsHeaderPathDetector.h"
#include "utility/utilityApp.h"
std::shared_ptr<CombinedPathDetector> utility::getJavaRuntimePathDetector()
{
std::shared_ptr<CombinedPathDetector> combinedDetector = std::make_shared<CombinedPathDetector>();
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
switch (utility::getOsType())
{
case OS_WINDOWS:
combinedDetector->addDetector(std::make_shared<JavaPathDetectorWindows>("1.8"));
}
else if (QSysInfo::macVersion() != QSysInfo::MV_None)
{
break;
case OS_MAC:
combinedDetector->addDetector(std::make_shared<JavaPathDetectorMac>("1.8"));
}
else
{
break;
case OS_LINUX:
combinedDetector->addDetector(std::make_shared<JavaPathDetectorLinux>("1.8"));
break;
default:
LOG_WARNING("No suitable Java Runtime path detector found");
break;
}
return combinedDetector;
@@ -39,17 +45,21 @@ std::shared_ptr<CombinedPathDetector> utility::getJavaRuntimePathDetector()
std::shared_ptr<CombinedPathDetector> utility::getJreSystemLibraryPathsDetector()
{
std::shared_ptr<CombinedPathDetector> combinedDetector = std::make_shared<CombinedPathDetector>();
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
switch (utility::getOsType())
{
case OS_WINDOWS:
combinedDetector->addDetector(std::make_shared<JreSystemLibraryPathDetectorWindows>("1.8"));
}
else if (QSysInfo::macVersion() != QSysInfo::MV_None)
{
break;
case OS_MAC:
combinedDetector->addDetector(std::make_shared<JreSystemLibraryPathDetectorMac>("1.8"));
}
else
{
break;
case OS_LINUX:
combinedDetector->addDetector(std::make_shared<JreSystemLibraryPathDetectorLinux>("1.8"));
break;
default:
LOG_WARNING("No suitable JRE system library path detector found");
break;
}
return combinedDetector;
@@ -58,13 +68,19 @@ std::shared_ptr<CombinedPathDetector> utility::getJreSystemLibraryPathsDetector(
std::shared_ptr<CombinedPathDetector> utility::getMavenExecutablePathDetector()
{
std::shared_ptr<CombinedPathDetector> combinedDetector = std::make_shared<CombinedPathDetector>();
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
switch (utility::getOsType())
{
case OS_WINDOWS:
combinedDetector->addDetector(std::make_shared<MavenPathDetectorWindows>());
}
else
{
break;
case OS_MAC:
case OS_LINUX:
combinedDetector->addDetector(std::make_shared<MavenPathDetectorUnix>());
break;
default:
LOG_WARNING("No suitable Maven path detector found");
break;
}
return combinedDetector;