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 -1
View File
@@ -28,6 +28,7 @@
#include "utility/ResourcePaths.h"
#include "utility/ScopedFunctor.h"
#include "utility/UserPaths.h"
#include "utility/utilityApp.h"
#include "utility/utilityPathDetection.h"
#include "utility/Version.h"
#include "version.h"
@@ -169,7 +170,7 @@ int main(int argc, char *argv[])
{
QApplication::setApplicationName("Sourcetrail");
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
if (utility::getOsType() == OS_WINDOWS)
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
}
+1
View File
@@ -482,6 +482,7 @@ add_files(
utility/Cache.h
utility/ConfigManager.cpp
utility/ConfigManager.h
utility/OsType.h
utility/Property.h
utility/ResourcePaths.cpp
utility/ResourcePaths.h
+17 -1
View File
@@ -156,10 +156,18 @@ std::vector<std::shared_ptr<SourceGroupSettings>> ProjectSettings::getAllSourceG
{
cxxSettings->setCompilationDatabasePath(FilePath(getValue<std::string>(key + "/build_file_path/compilation_db_path", "")));
}
if (type == SOURCE_GROUP_C_EMPTY || type == SOURCE_GROUP_CPP_EMPTY)
{
cxxSettings->setTargetOptionsEnabled(getValue<bool>(key + "/cross_compilation/target_options_enabled", false));
cxxSettings->setTargetArch(getValue<std::string>(key + "/cross_compilation/target/arch", ""));
cxxSettings->setTargetVendor(getValue<std::string>(key + "/cross_compilation/target/vendor", ""));
cxxSettings->setTargetSys(getValue<std::string>(key + "/cross_compilation/target/sys", ""));
cxxSettings->setTargetAbi(getValue<std::string>(key + "/cross_compilation/target/abi", ""));
}
cxxSettings->setShouldApplyAnonymousTypedefTransformation(getValue<bool>(key + "/should_apply_anonymous_typedef_transformation", true));
settings = cxxSettings;
}
break;
break;
case SOURCE_GROUP_JAVA_EMPTY:
case SOURCE_GROUP_JAVA_MAVEN:
{
@@ -233,6 +241,14 @@ void ProjectSettings::setAllSourceGroupSettings(const std::vector<std::shared_pt
{
setValue(key + "/build_file_path/compilation_db_path", cxxSettings->getCompilationDatabasePath().str());
}
if (type == SOURCE_GROUP_C_EMPTY || type == SOURCE_GROUP_CPP_EMPTY)
{
setValue(key + "/cross_compilation/target_options_enabled", cxxSettings->getTargetOptionsEnabled());
setValue(key + "/cross_compilation/target/arch", cxxSettings->getTargetArch());
setValue(key + "/cross_compilation/target/vendor", cxxSettings->getTargetVendor());
setValue(key + "/cross_compilation/target/sys", cxxSettings->getTargetSys());
setValue(key + "/cross_compilation/target/abi", cxxSettings->getTargetAbi());
}
setValue(key + "/should_apply_anonymous_typedef_transformation", cxxSettings->getShouldApplyAnonymousTypedefTransformation());
}
break;
+208 -1
View File
@@ -1,6 +1,144 @@
#include "settings/SourceGroupSettingsCxx.h"
#include "utility/utility.h"
#include "utility/utilityApp.h"
std::vector<std::string> SourceGroupSettingsCxx::getAvailableArchTypes()
{
return {
"aarch64",
"aarch64_be",
"arm",
"armeb",
"avr",
"bpfel",
"bpfeb",
"hexagon",
"mips",
"mipsel",
"mips64",
"mips64el",
"msp430",
"powerpc64",
"powerpc64le",
"powerpc",
"r600",
"amdgcn",
"riscv32",
"riscv64",
"sparc",
"sparcv9",
"sparcel",
"s390x",
"tce",
"tcele",
"thumb",
"thumbeb",
"i386",
"x86_64",
"xcore",
"nvptx",
"nvptx64",
"le32",
"le64",
"amdil",
"amdil64",
"hsail",
"hsail64",
"spir",
"spir64",
"kalimba",
"lanai",
"shave",
"wasm32",
"wasm64",
"renderscript32",
"renderscript64",
};
}
std::vector<std::string> SourceGroupSettingsCxx::getAvailableVendorTypes()
{
return {
"unknown",
"apple",
"pc",
"scei",
"bgp",
"bgq",
"fsl",
"ibm",
"img",
"mti",
"nvidia",
"csr",
"myriad",
"amd",
"mesa"
};
}
std::vector<std::string> SourceGroupSettingsCxx::getAvailableOsTypes()
{
return {
"unknown",
"cloudabi",
"darwin",
"dragonfly",
"freebsd",
"fuchsia",
"ios",
"kfreebsd",
"linux",
"lv2",
"macosx",
"netbsd",
"openbsd",
"solaris",
"windows",
"haiku",
"minix",
"rtems",
"nacl",
"cnk",
"bitrig",
"aix",
"cuda",
"nvcl",
"amdhsa",
"ps4",
"elfiamcu",
"tvos",
"watchos",
"mesa3d",
"contiki"
};
}
std::vector<std::string> SourceGroupSettingsCxx::getAvailableEnvironmentTypes()
{
return {
"unknown",
"gnu",
"gnuabi64",
"gnueabihf",
"gnueabi",
"gnux32",
"code16",
"eabi",
"eabihf",
"android",
"musl",
"musleabi",
"musleabihf",
"msvc",
"itanium",
"cygnus",
"amdopencl",
"coreclr",
"opencl"
};
}
SourceGroupSettingsCxx::SourceGroupSettingsCxx(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings)
: SourceGroupSettings(id, type, projectSettings)
@@ -29,7 +167,8 @@ bool SourceGroupSettingsCxx::equals(std::shared_ptr<SourceGroupSettings> other)
utility::isPermutation(m_compilerFlags, otherCxx->m_compilerFlags) &&
m_useSourcePathsForHeaderSearch == otherCxx->m_useSourcePathsForHeaderSearch &&
m_hasDefinedUseSourcePathsForHeaderSearch == otherCxx->m_hasDefinedUseSourcePathsForHeaderSearch &&
m_compilationDatabasePath == otherCxx->m_compilationDatabasePath
m_compilationDatabasePath == otherCxx->m_compilationDatabasePath &&
getTargetFlag() == otherCxx->getTargetFlag()
);
}
@@ -126,6 +265,74 @@ void SourceGroupSettingsCxx::setFrameworkSearchPaths(const std::vector<FilePath>
m_frameworkSearchPaths = frameworkSearchPaths;
}
bool SourceGroupSettingsCxx::getTargetOptionsEnabled() const
{
return m_targetOptionsEnabled;
}
void SourceGroupSettingsCxx::setTargetOptionsEnabled(bool targetOptionsEnabled)
{
m_targetOptionsEnabled = targetOptionsEnabled;
}
std::string SourceGroupSettingsCxx::getTargetArch() const
{
return m_targetArch;
}
void SourceGroupSettingsCxx::setTargetArch(const std::string& arch)
{
m_targetArch = arch;
}
std::string SourceGroupSettingsCxx::getTargetVendor() const
{
return m_targetVendor;
}
void SourceGroupSettingsCxx::setTargetVendor(const std::string& vendor)
{
m_targetVendor = vendor;
}
std::string SourceGroupSettingsCxx::getTargetSys() const
{
return m_targetSys;
}
void SourceGroupSettingsCxx::setTargetSys(const std::string& sys)
{
m_targetSys = sys;
}
std::string SourceGroupSettingsCxx::getTargetAbi() const
{
return m_targetAbi;
}
void SourceGroupSettingsCxx::setTargetAbi(const std::string& abi)
{
m_targetAbi = abi;
}
std::string SourceGroupSettingsCxx::getTargetFlag() const
{
std::string targetFlag = "";
if (m_targetOptionsEnabled)
{
targetFlag = "--target=";
targetFlag += m_targetArch;
if (!m_targetSub.empty())
{
targetFlag += m_targetSub;
}
targetFlag += "-" + m_targetVendor;
targetFlag += "-" + m_targetSys;
targetFlag += "-" + m_targetAbi;
}
return targetFlag;
}
std::vector<std::string> SourceGroupSettingsCxx::getCompilerFlags() const
{
return m_compilerFlags;
+28
View File
@@ -7,6 +7,11 @@ class SourceGroupSettingsCxx
: public SourceGroupSettings
{
public:
static std::vector<std::string> getAvailableArchTypes();
static std::vector<std::string> getAvailableVendorTypes();
static std::vector<std::string> getAvailableOsTypes();
static std::vector<std::string> getAvailableEnvironmentTypes();
SourceGroupSettingsCxx(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings);
virtual ~SourceGroupSettingsCxx();
@@ -22,6 +27,23 @@ public:
std::vector<FilePath> getFrameworkSearchPathsExpandedAndAbsolute() const;
void setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths);
bool getTargetOptionsEnabled() const;
void setTargetOptionsEnabled(bool targetOptionsEnabled);
std::string getTargetArch() const;
void setTargetArch(const std::string& arch);
std::string getTargetVendor() const;
void setTargetVendor(const std::string& vendor);
std::string getTargetSys() const;
void setTargetSys(const std::string& sys);
std::string getTargetAbi() const;
void setTargetAbi(const std::string& abi);
std::string getTargetFlag() const;
std::vector<std::string> getCompilerFlags() const;
void setCompilerFlags(const std::vector<std::string>& compilerFlags);
@@ -45,6 +67,12 @@ private:
std::vector<FilePath> m_headerSearchPaths;
std::vector<FilePath> m_frameworkSearchPaths;
bool m_targetOptionsEnabled;
std::string m_targetArch;
std::string m_targetSub;
std::string m_targetVendor;
std::string m_targetSys;
std::string m_targetAbi;
std::vector<std::string> m_compilerFlags;
bool m_useSourcePathsForHeaderSearch;
bool m_hasDefinedUseSourcePathsForHeaderSearch;
+12
View File
@@ -0,0 +1,12 @@
#ifndef OS_TYPE
#define OS_TYPE
enum OsType
{
OS_UNKNOWN,
OS_LINUX,
OS_MAC,
OS_WINDOWS
};
#endif // OS_TYPE
+10 -1
View File
@@ -106,7 +106,16 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxx::getIndexerCommands(
utility::append(frameworkSearchPaths, m_settings->getFrameworkSearchPathsExpandedAndAbsolute());
utility::append(frameworkSearchPaths, appSettings->getFrameworkSearchPathsExpanded());
const std::vector<std::string> compilerFlags = m_settings->getCompilerFlags();
std::vector<std::string> compilerFlags;
{
const std::string targetFlag = m_settings->getTargetFlag();
if (!targetFlag.empty())
{
compilerFlags.push_back(targetFlag);
}
}
utility::append(compilerFlags, m_settings->getCompilerFlags());
std::set<FilePath> indexedPaths;
for (FilePath p: m_settings->getSourcePathsExpandedAndAbsolute())
+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;
@@ -154,6 +154,8 @@ private:
{
LOG_ERROR("parser with id " + std::to_string(parserId) + " not found");
}
return false;
}
static int s_nextParserId;