Commit 974a0fd5 by Mārtiņš Možeiko

Better detection of VS CRT source folders

Using also Visual Studio 2015 and Universal CRT sources locations.
parent 9ddfb5d9
......@@ -5,6 +5,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(UI
MainWindow.ui
NewDialog.ui
Preferences.ui
RunningDialog.ui
SymbolWidget.ui
)
......@@ -14,6 +15,7 @@ set(MOC
SyntaxHighlighter.h
MainWindow.h
NewDialog.h
Preferences.h
RunningDialog.h
SymbolWidget.h
SourceWidget.h
......@@ -31,6 +33,7 @@ set(SOURCE
SyntaxHighlighter.cpp
MainWindow.cpp
NewDialog.cpp
Preferences.cpp
RunningDialog.cpp
SymbolWidget.cpp
SourceWidget.cpp
......
#include "MainWindow.h"
#include "NewDialog.h"
#include "Preferences.h"
#include "RunningDialog.h"
#include "Profiler.h"
#include "SymbolWidget.h"
#include "Symbols.h"
#include "Utils.h"
#include "Version.h"
MainWindow::MainWindow()
......@@ -16,6 +18,10 @@ MainWindow::MainWindow()
{
restoreGeometry(settings.value("MainWindow/geometry").toByteArray());
}
if (!settings.contains("Preferences/VS2013"))
{
DetectVSLocations(settings);
}
}
ui.actFileSave->setDisabled(true);
......@@ -357,6 +363,11 @@ MainWindow::MainWindow()
}
});
QObject::connect(ui.actFilePreferences, &QAction::triggered, this, [this]()
{
Preferences(this).exec();
});
QObject::connect(ui.actFileSave, &QAction::triggered, this, &MainWindow::saveData);
QObject::connect(ui.actFileQuit, &QAction::triggered, this, &QWidget::close);
......
......@@ -45,6 +45,8 @@
<addaction name="actFileOpen"/>
<addaction name="actFileSave"/>
<addaction name="separator"/>
<addaction name="actFilePreferences"/>
<addaction name="separator"/>
<addaction name="actFileQuit"/>
</widget>
<widget class="QMenu" name="menu_Help">
......@@ -109,6 +111,14 @@
<enum>QAction::QuitRole</enum>
</property>
</action>
<action name="actFilePreferences">
<property name="text">
<string>Preferences...</string>
</property>
<property name="shortcut">
<string>Ctrl+P</string>
</property>
</action>
</widget>
<resources/>
<connections/>
......
#include "Preferences.h"
#include "Utils.h"
Preferences::Preferences(QWidget* parent)
: QDialog(parent)
{
ui.setupUi(this);
QSettings settings(GetSettingsFile(), QSettings::IniFormat);
if (settings.contains("Preferences/VS2013"))
{
QString path = settings.value("Preferences/VS2013").toString();
ui.txtLocation2013->setText(QDir::toNativeSeparators(path));
}
if (settings.contains("Preferences/VS2015"))
{
QString path = settings.value("Preferences/VS2015").toString();
ui.txtLocation2015->setText(QDir::toNativeSeparators(path));
}
if (settings.contains("Preferences/SDK10"))
{
QString path = settings.value("Preferences/SDK10").toString();
ui.txtLocationSdk10->setText(QDir::toNativeSeparators(path));
}
QObject::connect(ui.btnLocation2013, &QPushButton::clicked, this, [this]()
{
QString dir = ui.txtLocation2013->text();
if (dir.isEmpty())
{
dir = "C:\\";
}
dir = QFileDialog::getExistingDirectory(this, "Choose VS2013 location (VC folder)", dir);
if (!dir.isNull())
{
dir = QDir::toNativeSeparators(dir);
if (QFileInfo(dir + "\\crt\\src").isDir())
{
ui.txtLocation2013->setText(dir);
}
else
{
QMessageBox::warning(this, "Error", QString("'%1' location does not seem to be VS2013 VC folder. Please try again!").arg(dir));
}
}
});
QObject::connect(ui.btnLocation2015, &QPushButton::clicked, this, [this]()
{
QString dir = ui.txtLocation2015->text();
if (dir.isEmpty())
{
dir = "C:\\";
}
dir = QFileDialog::getExistingDirectory(this, "Choose VS2015 location (VC folder)", dir);
if (!dir.isNull())
{
dir = QDir::toNativeSeparators(dir);
if (QFileInfo(dir + "\\crt\\src").isDir())
{
ui.txtLocation2015->setText(dir);
}
else
{
QMessageBox::warning(this, "Error", QString("'%1' location does not seem to be VS2015 VC folder. Please try again!").arg(dir));
}
}
});
QObject::connect(ui.btnLocationSdk10, &QPushButton::clicked, this, [this]()
{
QString dir = ui.txtLocationSdk10->text();
if (dir.isEmpty())
{
dir = "C:\\";
}
dir = QFileDialog::getExistingDirectory(this, "Choose Windows 10 SDK source location (10.0.xxxxx.0 folder)", dir);
if (!dir.isNull())
{
dir = QDir::toNativeSeparators(dir);
if (QFileInfo(dir + "\\ucrt").isDir())
{
ui.txtLocationSdk10->setText(dir);
}
else
{
QMessageBox::warning(this, "Error", QString("'%1' location does not seem to be Windows SDK source folder. Please try again!").arg(dir));
}
}
});
QObject::connect(this, &QDialog::accepted, this, [this]()
{
QSettings settings(GetSettingsFile(), QSettings::IniFormat);
settings.setValue("Preferences/VS2013", QDir::fromNativeSeparators(ui.txtLocation2013->text()));
settings.setValue("Preferences/VS2015", QDir::fromNativeSeparators(ui.txtLocation2015->text()));
settings.setValue("Preferences/SDK10", QDir::fromNativeSeparators(ui.txtLocationSdk10->text()));
});
}
Preferences::~Preferences()
{
}
#pragma once
#include "Precompiled.h"
#include "ui_Preferences.h"
class Preferences : public QDialog
{
Q_OBJECT
public:
explicit Preferences(QWidget* parent);
~Preferences();
private:
Ui::Preferences ui;
};
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Preferences</class>
<widget class="QDialog" name="Preferences">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>680</width>
<height>158</height>
</rect>
</property>
<property name="windowTitle">
<string>Preferences</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="grpSource">
<property name="title">
<string>Source Location</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QLabel" name="lblLocationSdk10">
<property name="text">
<string>Windows SDK 10 CRT:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QToolButton" name="btnLocation2013">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblLocation2015">
<property name="text">
<string>Visual Studio 2015:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblLocation2013">
<property name="text">
<string>Visual Studio 2013:</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="txtLocation2015"/>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="txtLocation2013"/>
</item>
<item row="1" column="3">
<widget class="QToolButton" name="btnLocation2015">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="txtLocationSdk10"/>
</item>
<item row="2" column="3">
<widget class="QToolButton" name="btnLocationSdk10">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>txtLocation2013</tabstop>
<tabstop>btnLocation2013</tabstop>
<tabstop>txtLocation2015</tabstop>
<tabstop>btnLocation2015</tabstop>
<tabstop>txtLocationSdk10</tabstop>
<tabstop>btnLocationSdk10</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Preferences</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Preferences</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
#include "SourceLoader.h"
#include "Utils.h"
#include <limits.h>
enum
......@@ -11,6 +12,10 @@ SourceLoader::SourceLoader(uint32_t totalSamples, const FileProfile& fileProfile
: totalSamples(totalSamples)
, fileProfile(fileProfile)
{
QSettings settings(GetSettingsFile(), QSettings::IniFormat);
vs2013 = QDir::toNativeSeparators(settings.value("Preferences/VS2013", QString()).toString());
vs2015 = QDir::toNativeSeparators(settings.value("Preferences/VS2015", QString()).toString());
sdk10 = QDir::toNativeSeparators(settings.value("Preferences/SDK10", QString()).toString());
}
SourceLoader::~SourceLoader()
......@@ -45,23 +50,38 @@ QFuture<LoadResult> SourceLoader::load(const QString& fname, int lineFrom, int l
}
QString fname2 = fname;
if (fname.startsWith("f:\\dd\\vctools\\crt\\crtw32\\"))
if (fname.startsWith("f:\\dd\\vctools\\crt\\crtw32\\") && !vs2013.isEmpty())
{
QString vcRoot = "C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\";
QString path = vcRoot + "crt\\src\\";
QString path = vs2013 + "\\crt\\src\\";
if (QFileInfo(path + QFileInfo(fname).fileName()).isFile())
{
fname2 = path + QFileInfo(fname).fileName();
}
else
{
path = vcRoot + "crt\\src\\intel\\";
path = vs2013 + "\\crt\\src\\intel\\";
if (QFileInfo(path + QFileInfo(fname).fileName()).isFile())
{
fname2 = path + QFileInfo(fname).fileName();
}
}
}
else if (fname.startsWith("f:\\dd\\vctools\\crt\\vcstartup\\src\\startup\\") && !vs2015.isEmpty())
{
QString path = vs2015 + "\\crt\\src\\vcruntime\\";
if (QFileInfo(path + QFileInfo(fname).fileName()).isFile())
{
fname2 = path + QFileInfo(fname).fileName();
}
}
else if (fname.startsWith("d:\\th\\minkernel\\crts\\ucrt\\src\\appcrt\\") && !sdk10.isEmpty())
{
QString path = sdk10 + "\\ucrt\\" + fname.right(fname.length() - QLatin1String("d:\\th\\minkernel\\crts\\ucrt\\src\\appcrt\\").size());
if (QFileInfo(path).isFile())
{
fname2 = path;
}
}
QFile file(fname2);
if (!file.exists())
......
......@@ -26,6 +26,10 @@ public:
private:
uint32_t totalSamples;
FileProfile fileProfile;
QString vs2013;
QString vs2015;
QString sdk10;
};
typedef QSharedPointer<SourceLoader> SourceLoaderPtr;
......@@ -168,3 +168,32 @@ QString GetSettingsFile()
{
return QDir(qApp->applicationDirPath()).filePath("config.ini");
}
void DetectVSLocations(QSettings& settings)
{
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
QString vs2013 = env.value("VS120COMNTOOLS", "C:\\Program Files(x86)\\Microsoft Visual Studio 12.0\\Common7\\Tools\\");
vs2013 += "..\\..\\VC";
if (!QFileInfo(vs2013).isDir())
{
vs2013.clear();
}
QString vs2015 = env.value("VS140COMNTOOLS", "C:\\Program Files(x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools\\");
vs2015 += "..\\..\\VC";
if (!QFileInfo(vs2015).isDir())
{
vs2015.clear();
}
QString sdk10 = "C:\\Program Files (x86)\\Windows Kits\\10\\Source\\10.0.10586.0";
if (!QFileInfo(sdk10).isDir())
{
sdk10.clear();
}
settings.setValue("Preferences/VS2013", QDir::cleanPath(vs2013));
settings.setValue("Preferences/VS2015", QDir::cleanPath(vs2015));
settings.setValue("Preferences/SDK10", QDir::cleanPath(sdk10));
}
......@@ -26,3 +26,4 @@ void OpenInExplorer(const QString& file);
void OpenInEditor(const QString& file);
QString GetSettingsFile();
void DetectVSLocations(QSettings& settings);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment