- fix: when run/debug the executable, add current compiler set's bin folders to path
- fix: when open in shell, add current compiler set's bin folders to path
This commit is contained in:
parent
c4ca944a15
commit
3d6d3c5210
3
NEWS.md
3
NEWS.md
|
@ -4,6 +4,9 @@ Red Panda C++ Version 1.1.1
|
|||
- enhancement: when problem case panel is positioned at right, problem case's input, output and expected controls is layouted vertically
|
||||
- enhancement: add ignore spaces checkbox in problem cases panel
|
||||
- fix: can't paste contents copied from Clion/IDEA/PyCharm
|
||||
- fix: project don't have compiler set bin folder setting
|
||||
- fix: when run/debug the executable, add current compiler set's bin folders to path
|
||||
- fix: when open in shell, add current compiler set's bin folders to path
|
||||
|
||||
Red Panda C++ Version 1.1.0
|
||||
- enhancement: when ctrl+mouse cursor hovered an identifier or header name, use underline to highlight it
|
||||
|
|
|
@ -4927,6 +4927,10 @@
|
|||
<source>Resources</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Binaries</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProjectFilesWidget</name>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -4927,6 +4927,10 @@
|
|||
<source>Resources</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Binaries</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProjectFilesWidget</name>
|
||||
|
|
|
@ -422,7 +422,7 @@ QString Compiler::getProjectIncludeArguments()
|
|||
{
|
||||
QString result;
|
||||
if (mProject) {
|
||||
foreach (const QString& folder,mProject->options().includes) {
|
||||
foreach (const QString& folder,mProject->options().includeDirs) {
|
||||
result += QString(" -I\"%1\"").arg(folder);
|
||||
}
|
||||
// result += QString(" -I\"%1\"").arg(extractFilePath(mProject->filename()));
|
||||
|
@ -450,7 +450,7 @@ QString Compiler::getLibraryArguments(FileType fileType)
|
|||
|
||||
//add libs added via project
|
||||
if (mProject) {
|
||||
foreach (const QString& folder, mProject->options().libs){
|
||||
foreach (const QString& folder, mProject->options().libDirs){
|
||||
result += QString(" -L\"%1\"").arg(folder);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -206,7 +206,11 @@ void CompilerManager::checkSyntax(const QString &filename, const QByteArray& enc
|
|||
}
|
||||
}
|
||||
|
||||
void CompilerManager::run(const QString &filename, const QString &arguments, const QString &workDir)
|
||||
void CompilerManager::run(
|
||||
const QString &filename,
|
||||
const QString &arguments,
|
||||
const QString &workDir,
|
||||
const QStringList& binDirs)
|
||||
{
|
||||
QMutexLocker locker(&mRunnerMutex);
|
||||
if (mRunner!=nullptr && !mRunner->pausing()) {
|
||||
|
@ -279,7 +283,12 @@ void CompilerManager::run(const QString &filename, const QString &arguments, con
|
|||
execRunner->setRedirectInput(true);
|
||||
execRunner->setRedirectInputFilename(redirectInputFilename);
|
||||
}
|
||||
execRunner->addBinDirs(binDirs);
|
||||
|
||||
execRunner->addBinDir(pSettings->dirs().appDir());
|
||||
|
||||
mRunner = execRunner;
|
||||
|
||||
connect(mRunner, &Runner::finished, this ,&CompilerManager::onRunnerTerminated);
|
||||
connect(mRunner, &Runner::finished, mRunner ,&Runner::deleteLater);
|
||||
connect(mRunner, &Runner::finished, pMainWindow ,&MainWindow::onRunFinished);
|
||||
|
|
|
@ -42,7 +42,11 @@ public:
|
|||
void cleanProject(std::shared_ptr<Project> project);
|
||||
void buildProjectMakefile(std::shared_ptr<Project> project);
|
||||
void checkSyntax(const QString&filename, const QByteArray& encoding, const QString& content, std::shared_ptr<Project> project);
|
||||
void run(const QString& filename, const QString& arguments, const QString& workDir);
|
||||
void run(
|
||||
const QString& filename,
|
||||
const QString& arguments,
|
||||
const QString& workDir,
|
||||
const QStringList& extraBinDir);
|
||||
void runProblem(const QString& filename, const QString& arguments, const QString& workDir, POJProblemCase problemCase);
|
||||
void runProblem(const QString& filename, const QString& arguments, const QString& workDir, const QVector<POJProblemCase> &problemCases);
|
||||
void stopRun();
|
||||
|
|
|
@ -62,6 +62,21 @@ void ExecutableRunner::setShareMemoryId(const QString &newShareMemoryId)
|
|||
mShareMemoryId = newShareMemoryId;
|
||||
}
|
||||
|
||||
const QStringList &ExecutableRunner::binDirs() const
|
||||
{
|
||||
return mBinDirs;
|
||||
}
|
||||
|
||||
void ExecutableRunner::addBinDirs(const QStringList &binDirs)
|
||||
{
|
||||
mBinDirs.append(binDirs);
|
||||
}
|
||||
|
||||
void ExecutableRunner::addBinDir(const QString &binDir)
|
||||
{
|
||||
mBinDirs.append(binDir);
|
||||
}
|
||||
|
||||
bool ExecutableRunner::redirectInput() const
|
||||
{
|
||||
return mRedirectInput;
|
||||
|
@ -100,15 +115,9 @@ void ExecutableRunner::run()
|
|||
mProcess->setWorkingDirectory(mWorkDir);
|
||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||
QString path = env.value("PATH");
|
||||
QStringList pathAdded;
|
||||
if (pSettings->compilerSets().defaultSet()) {
|
||||
foreach(const QString& dir, pSettings->compilerSets().defaultSet()->binDirs()) {
|
||||
pathAdded.append(dir);
|
||||
}
|
||||
}
|
||||
pathAdded.append(pSettings->dirs().appDir());
|
||||
QStringList pathAdded = mBinDirs;
|
||||
if (!path.isEmpty()) {
|
||||
path= pathAdded.join(PATH_SEPARATOR) + PATH_SEPARATOR + path;
|
||||
path = pathAdded.join(PATH_SEPARATOR) + PATH_SEPARATOR + path;
|
||||
} else {
|
||||
path = pathAdded.join(PATH_SEPARATOR);
|
||||
}
|
||||
|
|
|
@ -41,6 +41,10 @@ public:
|
|||
|
||||
void setShareMemoryId(const QString &newShareMemoryId);
|
||||
|
||||
const QStringList &binDirs() const;
|
||||
void addBinDirs(const QStringList &binDirs);
|
||||
void addBinDir(const QString &binDir);
|
||||
|
||||
private:
|
||||
QString mRedirectInputFilename;
|
||||
QString mShareMemoryId;
|
||||
|
@ -48,6 +52,7 @@ private:
|
|||
bool mStartConsole;
|
||||
std::shared_ptr<QProcess> mProcess;
|
||||
QSemaphore mQuitSemaphore;
|
||||
QStringList mBinDirs;
|
||||
|
||||
// QThread interface
|
||||
protected:
|
||||
|
|
|
@ -55,7 +55,7 @@ Debugger::Debugger(QObject *parent) : QObject(parent),
|
|||
this, &Debugger::fetchVarChildren);
|
||||
}
|
||||
|
||||
bool Debugger::start(int compilerSetIndex, const QString& inferior)
|
||||
bool Debugger::start(int compilerSetIndex, const QString& inferior, const QStringList& binDirs)
|
||||
{
|
||||
|
||||
Settings::PCompilerSet compilerSet = pSettings->compilerSets().getSet(compilerSetIndex);
|
||||
|
@ -126,6 +126,8 @@ bool Debugger::start(int compilerSetIndex, const QString& inferior)
|
|||
mTarget->waitStart();
|
||||
}
|
||||
mReader = new DebugReader(this);
|
||||
mReader->addBinDirs(binDirs);
|
||||
mReader->addBinDir(pSettings->dirs().appDir());
|
||||
mReader->setDebuggerPath(debuggerPath);
|
||||
connect(mReader, &QThread::finished,this,&Debugger::cleanUpReader);
|
||||
connect(mReader, &QThread::finished,mMemoryModel,&MemoryModel::reset);
|
||||
|
@ -1327,6 +1329,21 @@ void DebugReader::asyncUpdate()
|
|||
mAsyncUpdated = false;
|
||||
}
|
||||
|
||||
const QStringList &DebugReader::binDirs() const
|
||||
{
|
||||
return mBinDirs;
|
||||
}
|
||||
|
||||
void DebugReader::addBinDirs(const QStringList &binDirs)
|
||||
{
|
||||
mBinDirs.append(binDirs);
|
||||
}
|
||||
|
||||
void DebugReader::addBinDir(const QString &binDir)
|
||||
{
|
||||
mBinDirs.append(binDir);
|
||||
}
|
||||
|
||||
const QString &DebugReader::signalMeaning() const
|
||||
{
|
||||
return mSignalMeaning;
|
||||
|
@ -1420,19 +1437,22 @@ void DebugReader::run()
|
|||
mProcess->setProgram(cmd);
|
||||
mProcess->setArguments(splitProcessCommand(arguments));
|
||||
mProcess->setProcessChannelMode(QProcess::MergedChannels);
|
||||
|
||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||
QString path = env.value("PATH");
|
||||
QStringList pathAdded = mBinDirs;
|
||||
if (!path.isEmpty()) {
|
||||
path = pathAdded.join(PATH_SEPARATOR) + PATH_SEPARATOR + path;
|
||||
} else {
|
||||
path = pathAdded.join(PATH_SEPARATOR);
|
||||
}
|
||||
QString cmdDir = extractFileDir(cmd);
|
||||
if (!cmdDir.isEmpty()) {
|
||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||
QString path = env.value("PATH");
|
||||
cmdDir.replace("/",QDir::separator());
|
||||
if (path.isEmpty()) {
|
||||
path = cmdDir;
|
||||
} else {
|
||||
path = cmdDir + PATH_SEPARATOR + path;
|
||||
}
|
||||
env.insert("PATH",path);
|
||||
mProcess->setProcessEnvironment(env);
|
||||
path = cmdDir + PATH_SEPARATOR + path;
|
||||
}
|
||||
env.insert("PATH",path);
|
||||
mProcess->setProcessEnvironment(env);
|
||||
|
||||
mProcess->setWorkingDirectory(workingDir);
|
||||
|
||||
connect(mProcess.get(), &QProcess::errorOccurred,
|
||||
|
|
|
@ -259,7 +259,7 @@ class Debugger : public QObject
|
|||
public:
|
||||
explicit Debugger(QObject *parent = nullptr);
|
||||
// Play/pause
|
||||
bool start(int compilerSetIndex, const QString& inferior);
|
||||
bool start(int compilerSetIndex, const QString& inferior, const QStringList& binDirs);
|
||||
void sendCommand(const QString& command, const QString& params,
|
||||
DebugCommandSource source = DebugCommandSource::Other);
|
||||
bool commandRunning();
|
||||
|
@ -428,6 +428,10 @@ public:
|
|||
|
||||
const QString &signalMeaning() const;
|
||||
|
||||
const QStringList &binDirs() const;
|
||||
void addBinDirs(const QStringList &binDirs);
|
||||
void addBinDir(const QString &binDir);
|
||||
|
||||
signals:
|
||||
void parseStarted();
|
||||
void invalidateAllVars();
|
||||
|
@ -463,6 +467,7 @@ signals:
|
|||
const QString& newType, int newNumChildren,
|
||||
bool hasMore);
|
||||
void varsValueUpdated();
|
||||
|
||||
private:
|
||||
void clearCmdQueue();
|
||||
|
||||
|
@ -502,6 +507,7 @@ private:
|
|||
bool mCmdRunning;
|
||||
PDebugCommand mCurrentCmd;
|
||||
std::shared_ptr<QProcess> mProcess;
|
||||
QStringList mBinDirs;
|
||||
|
||||
//fWatchView: TTreeView;
|
||||
|
||||
|
|
|
@ -1550,7 +1550,7 @@ bool MainWindow::compile(bool rebuild)
|
|||
}
|
||||
mProject->buildPrivateResource();
|
||||
if (mCompileSuccessionTask) {
|
||||
mCompileSuccessionTask->filename = mProject->executable();
|
||||
mCompileSuccessionTask->execName = mProject->executable();
|
||||
}
|
||||
stretchMessagesPanel(true);
|
||||
ui->tabMessages->setCurrentWidget(ui->tabToolsOutput);
|
||||
|
@ -1566,7 +1566,7 @@ bool MainWindow::compile(bool rebuild)
|
|||
return false;
|
||||
}
|
||||
if (mCompileSuccessionTask) {
|
||||
mCompileSuccessionTask->filename = getCompiledExecutableName(editor->filename());
|
||||
mCompileSuccessionTask->execName = getCompiledExecutableName(editor->filename());
|
||||
}
|
||||
stretchMessagesPanel(true);
|
||||
ui->tabMessages->setCurrentWidget(ui->tabToolsOutput);
|
||||
|
@ -1579,7 +1579,11 @@ bool MainWindow::compile(bool rebuild)
|
|||
return false;
|
||||
}
|
||||
|
||||
void MainWindow::runExecutable(const QString &exeName,const QString &filename,RunType runType)
|
||||
void MainWindow::runExecutable(
|
||||
const QString &exeName,
|
||||
const QString &filename,
|
||||
RunType runType,
|
||||
const QStringList& binDirs)
|
||||
{
|
||||
mCompilerManager->stopPausing();
|
||||
// Check if it exists
|
||||
|
@ -1622,7 +1626,7 @@ void MainWindow::runExecutable(const QString &exeName,const QString &filename,Ru
|
|||
if (pSettings->executor().minimizeOnRun()) {
|
||||
showMinimized();
|
||||
}
|
||||
mCompilerManager->run(exeName,params,QFileInfo(exeName).absolutePath());
|
||||
mCompilerManager->run(exeName,params,QFileInfo(exeName).absolutePath(),binDirs);
|
||||
} else if (runType == RunType::ProblemCases) {
|
||||
POJProblem problem = mOJProblemModel.problem();
|
||||
if (problem) {
|
||||
|
@ -1649,6 +1653,7 @@ void MainWindow::runExecutable(RunType runType)
|
|||
{
|
||||
CompileTarget target =getCompileTarget();
|
||||
if (target == CompileTarget::Project) {
|
||||
QStringList binDirs = mProject->binDirs();
|
||||
if (mProject->modified() &&
|
||||
QMessageBox::question(
|
||||
this,
|
||||
|
@ -1658,10 +1663,14 @@ void MainWindow::runExecutable(RunType runType)
|
|||
mProject->saveAll();
|
||||
mCompileSuccessionTask=std::make_shared<CompileSuccessionTask>();
|
||||
mCompileSuccessionTask->type = CompileSuccessionTaskType::RunNormal;
|
||||
mCompileSuccessionTask->execName=mProject->executable();
|
||||
mCompileSuccessionTask->binDirs=binDirs;
|
||||
compile();
|
||||
return;
|
||||
}
|
||||
runExecutable(mProject->executable(),mProject->filename(),runType);
|
||||
|
||||
runExecutable(mProject->executable(),mProject->filename(),runType,
|
||||
binDirs);
|
||||
} else {
|
||||
Editor * editor = mEditorList->getEditor();
|
||||
if (editor != NULL ) {
|
||||
|
@ -1669,8 +1678,9 @@ void MainWindow::runExecutable(RunType runType)
|
|||
if (!editor->save(false,false))
|
||||
return;
|
||||
}
|
||||
QStringList binDirs = getDefaultCompilerSetBinDirs();
|
||||
QString exeName= getCompiledExecutableName(editor->filename());
|
||||
runExecutable(exeName,editor->filename(),runType);
|
||||
runExecutable(exeName,editor->filename(),runType,binDirs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1691,8 +1701,10 @@ void MainWindow::debug()
|
|||
bool stripEnabled;
|
||||
QString filePath;
|
||||
QFileInfo debugFile;
|
||||
QStringList binDirs;
|
||||
switch(getCompileTarget()) {
|
||||
case CompileTarget::Project:
|
||||
binDirs = mProject->binDirs();
|
||||
// Check if we enabled proper options
|
||||
debugEnabled = mProject->getCompileOption(CC_CMD_OPT_DEBUG_INFO) == COMPILER_OPTION_ON;
|
||||
stripEnabled = mProject->getCompileOption(LINK_CMD_OPT_STRIP_EXE) == COMPILER_OPTION_ON;
|
||||
|
@ -1711,6 +1723,8 @@ void MainWindow::debug()
|
|||
|
||||
mCompileSuccessionTask=std::make_shared<CompileSuccessionTask>();
|
||||
mCompileSuccessionTask->type = CompileSuccessionTaskType::Debug;
|
||||
mCompileSuccessionTask->execName = mProject->executable();
|
||||
mCompileSuccessionTask->binDirs = binDirs;
|
||||
|
||||
compile();
|
||||
return;
|
||||
|
@ -1725,7 +1739,8 @@ void MainWindow::debug()
|
|||
QMessageBox::Yes) == QMessageBox::Yes) {
|
||||
mCompileSuccessionTask=std::make_shared<CompileSuccessionTask>();
|
||||
mCompileSuccessionTask->type = CompileSuccessionTaskType::Debug;
|
||||
|
||||
mCompileSuccessionTask->execName = mProject->executable();
|
||||
mCompileSuccessionTask->binDirs = binDirs;
|
||||
compile();
|
||||
}
|
||||
return;
|
||||
|
@ -1738,6 +1753,8 @@ void MainWindow::debug()
|
|||
) == QMessageBox::Yes) {
|
||||
mCompileSuccessionTask=std::make_shared<CompileSuccessionTask>();
|
||||
mCompileSuccessionTask->type = CompileSuccessionTaskType::Debug;
|
||||
mCompileSuccessionTask->execName = mProject->executable();
|
||||
mCompileSuccessionTask->binDirs = binDirs;
|
||||
compile();
|
||||
return;
|
||||
}
|
||||
|
@ -1766,7 +1783,7 @@ void MainWindow::debug()
|
|||
|
||||
// mDebugger->setUseUTF8(e->fileEncoding() == ENCODING_UTF8 || e->fileEncoding() == ENCODING_UTF8_BOM);
|
||||
|
||||
if (!mDebugger->start(mProject->options().compilerSet, filePath))
|
||||
if (!mDebugger->start(mProject->options().compilerSet, filePath, binDirs))
|
||||
return;
|
||||
filePath.replace('\\','/');
|
||||
mDebugger->sendCommand("-file-exec-and-symbols", '"' + filePath + '"');
|
||||
|
@ -1777,12 +1794,16 @@ void MainWindow::debug()
|
|||
mDebugger->sendCommand("-file-exec-file", '"' + host + '"');
|
||||
}
|
||||
|
||||
includeOrSkipDirs(mProject->options().includes,
|
||||
includeOrSkipDirs(mProject->options().includeDirs,
|
||||
pSettings->debugger().skipProjectLibraries());
|
||||
includeOrSkipDirs(mProject->options().libs,
|
||||
includeOrSkipDirs(mProject->options().libDirs,
|
||||
pSettings->debugger().skipProjectLibraries());
|
||||
break;
|
||||
case CompileTarget::File: {
|
||||
if (pSettings->compilerSets().defaultSet()) {
|
||||
binDirs = pSettings->compilerSets().defaultSet()->binDirs();
|
||||
}
|
||||
|
||||
// Check if we enabled proper options
|
||||
debugEnabled = compilerSet->getCompileOptionValue(CC_CMD_OPT_DEBUG_INFO) == COMPILER_OPTION_ON;
|
||||
stripEnabled = compilerSet->getCompileOptionValue(LINK_CMD_OPT_STRIP_EXE) == COMPILER_OPTION_ON;
|
||||
|
@ -1801,7 +1822,7 @@ void MainWindow::debug()
|
|||
|
||||
mCompileSuccessionTask=std::make_shared<CompileSuccessionTask>();
|
||||
mCompileSuccessionTask->type = CompileSuccessionTaskType::Debug;
|
||||
|
||||
mCompileSuccessionTask->binDirs = binDirs;
|
||||
compile();
|
||||
return;
|
||||
}
|
||||
|
@ -1825,6 +1846,7 @@ void MainWindow::debug()
|
|||
QMessageBox::Yes) == QMessageBox::Yes) {
|
||||
mCompileSuccessionTask=std::make_shared<CompileSuccessionTask>();
|
||||
mCompileSuccessionTask->type = CompileSuccessionTaskType::Debug;
|
||||
mCompileSuccessionTask->binDirs = binDirs;
|
||||
compile();
|
||||
return;
|
||||
}
|
||||
|
@ -1836,6 +1858,7 @@ void MainWindow::debug()
|
|||
QMessageBox::Yes) == QMessageBox::Yes) {
|
||||
mCompileSuccessionTask=std::make_shared<CompileSuccessionTask>();
|
||||
mCompileSuccessionTask->type = CompileSuccessionTaskType::Debug;
|
||||
mCompileSuccessionTask->binDirs = binDirs;
|
||||
compile();
|
||||
return;
|
||||
}
|
||||
|
@ -1844,7 +1867,7 @@ void MainWindow::debug()
|
|||
|
||||
prepareDebugger();
|
||||
QString filePath = debugFile.filePath().replace('\\','/');
|
||||
if (!mDebugger->start(pSettings->compilerSets().defaultIndex(),filePath))
|
||||
if (!mDebugger->start(pSettings->compilerSets().defaultIndex(),filePath, binDirs))
|
||||
return;
|
||||
mDebugger->sendCommand("-file-exec-and-symbols", QString("\"%1\"").arg(filePath));
|
||||
}
|
||||
|
@ -2746,7 +2769,29 @@ void MainWindow::maximizeEditor()
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::openShell(const QString &folder, const QString &shellCommand)
|
||||
QStringList MainWindow::getBinDirsForCurrentEditor()
|
||||
{
|
||||
Editor * e=mEditorList->getEditor();
|
||||
if (e) {
|
||||
if (e->inProject() && mProject) {
|
||||
return mProject->binDirs();
|
||||
} else {
|
||||
return getDefaultCompilerSetBinDirs();
|
||||
}
|
||||
} else if (mProject) {
|
||||
return mProject->binDirs();
|
||||
}
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
QStringList MainWindow::getDefaultCompilerSetBinDirs()
|
||||
{
|
||||
if (pSettings->compilerSets().defaultSet())
|
||||
return pSettings->compilerSets().defaultSet()->binDirs();
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
void MainWindow::openShell(const QString &folder, const QString &shellCommand, const QStringList& binDirs)
|
||||
{
|
||||
QProcess process;
|
||||
process.setWorkingDirectory(folder);
|
||||
|
@ -2760,11 +2805,7 @@ void MainWindow::openShell(const QString &folder, const QString &shellCommand)
|
|||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||
QString path = env.value("PATH");
|
||||
QStringList pathAdded;
|
||||
if (pSettings->compilerSets().defaultSet()) {
|
||||
foreach(const QString& dir, pSettings->compilerSets().defaultSet()->binDirs()) {
|
||||
pathAdded.append(dir);
|
||||
}
|
||||
}
|
||||
pathAdded.append(binDirs);
|
||||
pathAdded.append(pSettings->dirs().appDir());
|
||||
if (!path.isEmpty()) {
|
||||
path= pathAdded.join(PATH_SEPARATOR) + PATH_SEPARATOR + path;
|
||||
|
@ -3702,9 +3743,9 @@ void MainWindow::onFilesViewOpenInTerminal()
|
|||
if (!path.isEmpty()) {
|
||||
QFileInfo fileInfo(path);
|
||||
#ifdef Q_OS_WIN
|
||||
openShell(fileInfo.path(),"cmd.exe");
|
||||
openShell(fileInfo.path(),"cmd.exe",getDefaultCompilerSetBinDirs());
|
||||
#else
|
||||
openShell(fileInfo.path(),pSettings->environment().terminalPath());
|
||||
openShell(fileInfo.path(),pSettings->environment().terminalPath(),getDefaultCompilerSetBinDirs());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -4656,13 +4697,13 @@ void MainWindow::onCompileFinished(bool isCheckSyntax)
|
|||
if (mCompileSuccessionTask && mCompilerManager->compileErrorCount()==0) {
|
||||
switch (mCompileSuccessionTask->type) {
|
||||
case MainWindow::CompileSuccessionTaskType::RunNormal:
|
||||
runExecutable(mCompileSuccessionTask->filename);
|
||||
runExecutable(mCompileSuccessionTask->execName,QString(),RunType::Normal, mCompileSuccessionTask->binDirs);
|
||||
break;
|
||||
case MainWindow::CompileSuccessionTaskType::RunProblemCases:
|
||||
runExecutable(mCompileSuccessionTask->filename,QString(),RunType::ProblemCases);
|
||||
runExecutable(mCompileSuccessionTask->execName,QString(),RunType::ProblemCases, mCompileSuccessionTask->binDirs);
|
||||
break;
|
||||
case MainWindow::CompileSuccessionTaskType::RunCurrentProblemCase:
|
||||
runExecutable(mCompileSuccessionTask->filename,QString(),RunType::CurrentProblemCase);
|
||||
runExecutable(mCompileSuccessionTask->execName,QString(),RunType::CurrentProblemCase, mCompileSuccessionTask->binDirs);
|
||||
break;
|
||||
case MainWindow::CompileSuccessionTaskType::Debug:
|
||||
debug();
|
||||
|
@ -5566,9 +5607,9 @@ void MainWindow::on_actionOpen_Terminal_triggered()
|
|||
QFileInfo info(editor->filename());
|
||||
if (!info.path().isEmpty()) {
|
||||
#ifdef Q_OS_WIN
|
||||
openShell(info.path(),"cmd.exe");
|
||||
openShell(info.path(),"cmd.exe",getBinDirsForCurrentEditor());
|
||||
#else
|
||||
openShell(info.path(),pSettings->environment().terminalPath());
|
||||
openShell(info.path(),pSettings->environment().terminalPath(),getBinDirsForCurrentEditor());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -5889,9 +5930,9 @@ void MainWindow::on_actionProject_Open_In_Terminal_triggered()
|
|||
if (!mProject)
|
||||
return;
|
||||
#ifdef Q_OS_WIN
|
||||
openShell(mProject->directory(),"cmd.exe");
|
||||
openShell(mProject->directory(),"cmd.exe",mProject->binDirs());
|
||||
#else
|
||||
openShell(mProject->directory(),pSettings->environment().terminalPath());
|
||||
openShell(mProject->directory(),pSettings->environment().terminalPath(),mProject->binDirs());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -6489,7 +6530,17 @@ void MainWindow::clearIssues()
|
|||
|
||||
void MainWindow::doCompileRun(RunType runType)
|
||||
{
|
||||
CompileTarget target =getCompileTarget();
|
||||
QStringList binDirs;
|
||||
QString execName;
|
||||
if (target == CompileTarget::Project) {
|
||||
binDirs = mProject->binDirs();
|
||||
execName = mProject->executable();
|
||||
} else {
|
||||
binDirs = getDefaultCompilerSetBinDirs();
|
||||
}
|
||||
mCompileSuccessionTask = std::make_shared<CompileSuccessionTask>();
|
||||
mCompileSuccessionTask->binDirs=binDirs;
|
||||
switch (runType) {
|
||||
case RunType::CurrentProblemCase:
|
||||
mCompileSuccessionTask->type = CompileSuccessionTaskType::RunCurrentProblemCase;
|
||||
|
|
|
@ -56,6 +56,7 @@ enum class RunType {
|
|||
ProblemCases
|
||||
};
|
||||
|
||||
|
||||
class EditorList;
|
||||
class QLabel;
|
||||
class QComboBox;
|
||||
|
@ -85,8 +86,10 @@ class MainWindow : public QMainWindow
|
|||
|
||||
struct CompileSuccessionTask {
|
||||
CompileSuccessionTaskType type;
|
||||
QString filename;
|
||||
QString execName;
|
||||
QStringList binDirs;
|
||||
};
|
||||
|
||||
using PCompileSuccessionTask = std::shared_ptr<CompileSuccessionTask>;
|
||||
|
||||
struct TabWidgetInfo {
|
||||
|
@ -114,7 +117,11 @@ public:
|
|||
void updateActionIcons();
|
||||
void checkSyntaxInBack(Editor* e);
|
||||
bool compile(bool rebuild=false);
|
||||
void runExecutable(const QString& exeName, const QString& filename=QString(),RunType runType = RunType::Normal);
|
||||
void runExecutable(
|
||||
const QString& exeName,
|
||||
const QString& filename,
|
||||
RunType runType,
|
||||
const QStringList& binDirs);
|
||||
void runExecutable(RunType runType = RunType::Normal);
|
||||
void debug();
|
||||
void showSearchPanel(bool showReplace = false);
|
||||
|
@ -241,7 +248,9 @@ private:
|
|||
void buildContextMenus();
|
||||
void buildEncodingMenu();
|
||||
void maximizeEditor();
|
||||
void openShell(const QString& folder, const QString& shellCommand);
|
||||
QStringList getBinDirsForCurrentEditor();
|
||||
QStringList getDefaultCompilerSetBinDirs();
|
||||
void openShell(const QString& folder, const QString& shellCommand, const QStringList& binDirs);
|
||||
QAction* createActionFor(const QString& text,
|
||||
QWidget* parent,
|
||||
QKeySequence shortcut=QKeySequence());
|
||||
|
|
|
@ -463,7 +463,7 @@ void Project::resetParserProjectFiles()
|
|||
foreach (const PProjectUnit& unit, mUnits) {
|
||||
mParser->addFileToScan(unit->fileName());
|
||||
}
|
||||
foreach (const QString& s, mOptions.includes) {
|
||||
foreach (const QString& s, mOptions.includeDirs) {
|
||||
mParser->addProjectIncludePath(s);
|
||||
}
|
||||
}
|
||||
|
@ -876,8 +876,9 @@ void Project::saveOptions()
|
|||
ini.SetLongValue("Project","Type", static_cast<int>(mOptions.type));
|
||||
ini.SetLongValue("Project","Ver", 3); // Is 3 as of Red Panda C++.0
|
||||
ini.SetValue("Project","ObjFiles", toByteArray(mOptions.objFiles.join(";")));
|
||||
ini.SetValue("Project","Includes", toByteArray(mOptions.includes.join(";")));
|
||||
ini.SetValue("Project","Libs", toByteArray(mOptions.libs.join(";")));
|
||||
ini.SetValue("Project","Includes", toByteArray(mOptions.includeDirs.join(";")));
|
||||
ini.SetValue("Project","Libs", toByteArray(mOptions.libDirs.join(";")));
|
||||
ini.SetValue("Project","Bins", toByteArray(mOptions.binDirs.join(";")));
|
||||
ini.SetValue("Project","PrivateResource", toByteArray(mOptions.privateResource));
|
||||
ini.SetValue("Project","ResourceIncludes", toByteArray(mOptions.resourceIncludes.join(";")));
|
||||
ini.SetValue("Project","MakeIncludes", toByteArray(mOptions.makeIncludes.join(";")));
|
||||
|
@ -1589,8 +1590,9 @@ void Project::loadOptions(SimpleIni& ini)
|
|||
mOptions.cppCompilerCmd = fromByteArray(ini.GetValue("Project", "CppCompiler", ""));
|
||||
mOptions.linkerCmd = fromByteArray(ini.GetValue("Project", "Linker", ""));
|
||||
mOptions.objFiles = fromByteArray(ini.GetValue("Project", "ObjFiles", "")).split(";",QString::SkipEmptyParts);
|
||||
mOptions.libs = fromByteArray(ini.GetValue("Project", "Libs", "")).split(";",QString::SkipEmptyParts);
|
||||
mOptions.includes = fromByteArray(ini.GetValue("Project", "Includes", "")).split(";",QString::SkipEmptyParts);
|
||||
mOptions.binDirs = fromByteArray(ini.GetValue("Project", "Bins", "")).split(";",QString::SkipEmptyParts);
|
||||
mOptions.libDirs = fromByteArray(ini.GetValue("Project", "Libs", "")).split(";",QString::SkipEmptyParts);
|
||||
mOptions.includeDirs = fromByteArray(ini.GetValue("Project", "Includes", "")).split(";",QString::SkipEmptyParts);
|
||||
mOptions.privateResource = fromByteArray(ini.GetValue("Project", "PrivateResource", ""));
|
||||
mOptions.resourceIncludes = fromByteArray(ini.GetValue("Project", "ResourceIncludes", "")).split(";",QString::SkipEmptyParts);
|
||||
mOptions.makeIncludes = fromByteArray(ini.GetValue("Project", "MakeIncludes", "")).split(";",QString::SkipEmptyParts);
|
||||
|
@ -1708,7 +1710,7 @@ void Project::loadOptions(SimpleIni& ini)
|
|||
mOptions.privateResource = fromByteArray(ini.GetValue("Project", "PrivateResource", ""));
|
||||
mOptions.resourceIncludes = fromByteArray(ini.GetValue("Project", "ResourceIncludes", "")).split(";",QString::SkipEmptyParts);
|
||||
mOptions.objFiles = fromByteArray(ini.GetValue("Project", "ObjFiles", "")).split(";",QString::SkipEmptyParts);
|
||||
mOptions.includes = fromByteArray(ini.GetValue("Project", "IncludeDirs", "")).split(";",QString::SkipEmptyParts);
|
||||
mOptions.includeDirs = fromByteArray(ini.GetValue("Project", "IncludeDirs", "")).split(";",QString::SkipEmptyParts);
|
||||
mOptions.compilerCmd = fromByteArray(ini.GetValue("Project", "CompilerOptions", ""));
|
||||
mOptions.isCpp = ini.GetBoolValue("Project", "Use_GPP", false);
|
||||
mOptions.exeOutput = fromByteArray(ini.GetValue("Project", "ExeOutput", ""));
|
||||
|
@ -1826,6 +1828,16 @@ QString Project::fileSystemNodeFolderPath(const PProjectModelNode &node)
|
|||
return result;
|
||||
}
|
||||
|
||||
QStringList Project::binDirs()
|
||||
{
|
||||
QStringList lst = options().binDirs;
|
||||
Settings::PCompilerSet compilerSet = pSettings->compilerSets().getSet(options().compilerSet);
|
||||
if (compilerSet) {
|
||||
lst.append(compilerSet->binDirs());
|
||||
}
|
||||
return lst;
|
||||
}
|
||||
|
||||
EditorList *Project::editorList() const
|
||||
{
|
||||
return mEditorList;
|
||||
|
|
|
@ -245,6 +245,8 @@ public:
|
|||
|
||||
QString fileSystemNodeFolderPath(const PProjectModelNode& node);
|
||||
|
||||
QStringList binDirs();
|
||||
|
||||
signals:
|
||||
void nodesChanged();
|
||||
void modifyChanged(bool value);
|
||||
|
|
|
@ -61,8 +61,9 @@ struct ProjectOptions{
|
|||
QString compilerCmd;
|
||||
QString cppCompilerCmd;
|
||||
QString linkerCmd;
|
||||
QStringList includes;
|
||||
QStringList libs;
|
||||
QStringList binDirs;
|
||||
QStringList includeDirs;
|
||||
QStringList libDirs;
|
||||
QString privateResource;
|
||||
QStringList resourceIncludes;
|
||||
QStringList makeIncludes;
|
||||
|
|
|
@ -130,8 +130,9 @@ void ProjectTemplate::readTemplateFile(const QString &fileName)
|
|||
mOptions.icon = mIni->GetValue("Project", "Icon", "");
|
||||
mOptions.type = static_cast<ProjectType>(mIni->GetLongValue("Project", "Type", 0)); // default = gui
|
||||
mOptions.objFiles = fromByteArray(mIni->GetValue("Project", "ObjFiles", "")).split(";",QString::SkipEmptyParts);
|
||||
mOptions.includes = fromByteArray(mIni->GetValue("Project", "Includes", "")).split(";",QString::SkipEmptyParts);
|
||||
mOptions.libs = fromByteArray(mIni->GetValue("Project", "Libs", "")).split(";",QString::SkipEmptyParts);
|
||||
mOptions.includeDirs = fromByteArray(mIni->GetValue("Project", "Includes", "")).split(";",QString::SkipEmptyParts);
|
||||
mOptions.binDirs = fromByteArray(mIni->GetValue("Project", "Bins", "")).split(";",QString::SkipEmptyParts);
|
||||
mOptions.libDirs = fromByteArray(mIni->GetValue("Project", "Libs", "")).split(";",QString::SkipEmptyParts);
|
||||
mOptions.resourceIncludes = fromByteArray(mIni->GetValue("Project", "ResourceIncludes", "")).split(";",QString::SkipEmptyParts);
|
||||
mOptions.compilerCmd = fromByteArray(mIni->GetValue("Project", "Compiler", ""));
|
||||
mOptions.cppCompilerCmd = fromByteArray(mIni->GetValue("Project", "CppCompiler", ""));
|
||||
|
|
|
@ -26,6 +26,8 @@ ProjectDirectoriesWidget::ProjectDirectoriesWidget(const QString &name, const QS
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
mBinDirWidget = new CompilerSetDirectoriesWidget();
|
||||
ui->tabDirs->addTab(mBinDirWidget,tr("Binaries"));
|
||||
mLibDirWidget = new CompilerSetDirectoriesWidget();
|
||||
ui->tabDirs->addTab(mLibDirWidget,tr("Libraries"));
|
||||
mIncludeDirWidget = new CompilerSetDirectoriesWidget();
|
||||
|
@ -42,16 +44,18 @@ ProjectDirectoriesWidget::~ProjectDirectoriesWidget()
|
|||
|
||||
void ProjectDirectoriesWidget::doLoad()
|
||||
{
|
||||
mLibDirWidget->setDirList(pMainWindow->project()->options().libs);
|
||||
mIncludeDirWidget->setDirList(pMainWindow->project()->options().includes);
|
||||
mBinDirWidget->setDirList(pMainWindow->project()->options().binDirs);
|
||||
mLibDirWidget->setDirList(pMainWindow->project()->options().libDirs);
|
||||
mIncludeDirWidget->setDirList(pMainWindow->project()->options().includeDirs);
|
||||
mResourceDirWidget->setDirList(pMainWindow->project()->options().resourceIncludes);
|
||||
|
||||
}
|
||||
|
||||
void ProjectDirectoriesWidget::doSave()
|
||||
{
|
||||
pMainWindow->project()->options().libs = mLibDirWidget->dirList();
|
||||
pMainWindow->project()->options().includes = mIncludeDirWidget->dirList();
|
||||
pMainWindow->project()->options().binDirs = mBinDirWidget->dirList();
|
||||
pMainWindow->project()->options().libDirs = mLibDirWidget->dirList();
|
||||
pMainWindow->project()->options().includeDirs = mIncludeDirWidget->dirList();
|
||||
pMainWindow->project()->options().resourceIncludes = mResourceDirWidget->dirList();
|
||||
pMainWindow->project()->saveOptions();
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ public:
|
|||
|
||||
private:
|
||||
Ui::ProjectDirectoriesWidget *ui;
|
||||
CompilerSetDirectoriesWidget *mBinDirWidget;
|
||||
CompilerSetDirectoriesWidget *mLibDirWidget;
|
||||
CompilerSetDirectoriesWidget *mIncludeDirWidget;
|
||||
CompilerSetDirectoriesWidget *mResourceDirWidget;
|
||||
|
|
Loading…
Reference in New Issue