Add build action for selectively compiling the C program
ADD
resources/icons/build.svg
+<svg height="512pt" viewBox="0 0 512 512.11954" width="512pt" xmlns="http://www.w3.org/2000/svg"><path d="m185.320312 262.367188 65.175782-71.980469c15.933594-16.054688 30.085937-33.789063 42.210937-52.886719 8.742188-13.160156 10.628907-29.722656 5.070313-44.511719-7.511719-15.792969-26.007813-25.148437-42.035156-29.714843-14.277344-3.714844-28.957032-5.644532-43.703126-5.746094-10.898437.761718-21.839843.574218-32.703124-.5625-4.785157-.664063-9.09375-3.25-11.929688-7.160156-7.296875-12.609376 9.40625-23.246094 18.65625-28.175782 16.40625-8.6875 34-14.910156 52.21875-18.472656 33.886719-7.441406 69.339844-1.609375 99.058594 16.292969 6.179687 3.898437 12.011718 8.324219 17.429687 13.226562l45.460938 41.167969c9.707031 7.125 16.265625 17.734375 18.304687 29.597656.890625 11.269532-.839844 21.675782 4.679688 32.132813 6.132812 11.203125 19.136718 16.753906 31.46875 13.4375l-28.945313 45.667969-42.15625 32.855468c4.070313-43.949218-45.1875-29.003906-68.886719-2.832031l-77.027343 85.070313-35.1875-15.042969zm0 0" fill="#a5a5a4"/><path d="m426.207031 277.089844-42.007812-37.085938c-1.734375-1.570312-2.773438-3.765625-2.890625-6.105468-.117188-2.335938.703125-4.625 2.273437-6.363282l71.101563-78.523437c3.273437-3.613281 8.855468-3.886719 12.46875-.617188l42.007812 37.085938c1.734375 1.570312 2.777344 3.765625 2.890625 6.105469.117188 2.339843-.699219 4.628906-2.273437 6.363281l-71.101563 78.523437c-3.273437 3.613282-8.855469 3.890625-12.46875.617188zm0 0" fill="#7f8284"/><path d="m234.964844 342.609375c-58.242188 41.753906-106.878906 95.480469-142.652344 157.574219-2.628906 6.070312-8.113281 10.425781-14.621094 11.613281-6.503906 1.1875-13.175781-.949219-17.777344-5.699219-17.480468-15.800781-34.871093-31.601562-52.347656-47.40625-5.183594-4.109375-7.972656-10.53125-7.441406-17.125s4.316406-12.484375 10.089844-15.710937c41.175781-29.488281 77.636718-65.058594 108.136718-105.492188 3.621094-4.765625 7.0625-9.53125 10.417969-14.300781 2.734375-3.792969 5.382813-7.679688 7.855469-11.652344 3.355469-4.941406 6.53125-9.972656 9.621094-15.003906 2.296875-3.707031 4.503906-7.417969 6.621094-11.125 2.652343-6.070312 8.152343-10.421875 14.667968-11.609375 6.519532-1.183594 13.199219.949219 17.820313 5.695313 17.386719 15.800781 34.835937 31.601562 52.347656 47.40625 5.167969 4.125 7.941406 10.554687 7.390625 17.148437-.546875 6.589844-4.347656 12.476563-10.128906 15.6875zm0 0" fill="#f29c1f"/><g fill="#e57e25"><path d="m178.910156 319.21875c-1.523437 1.777344-3.6875 2.878906-6.023437 3.0625-2.332031.183594-4.644531-.570312-6.425781-2.09375l-29.835938-25.777344c3.355469-4.941406 6.53125-9.972656 9.621094-15.003906.355468.261719.621094.527344.972656.792969l30.71875 26.570312c1.78125 1.523438 2.882812 3.6875 3.066406 6.023438.179688 2.335937-.574218 4.644531-2.09375 6.425781zm0 0"/><path d="m161.253906 345.699219c-1.683594 1.953125-4.128906 3.082031-6.707031 3.089843-2.105469.011719-4.144531-.742187-5.738281-2.117187l-30.457032-26.308594c3.621094-4.765625 7.0625-9.53125 10.417969-14.300781.226563.117188.433594.265625.617188.441406l30.898437 26.75c1.777344 1.519532 2.878906 3.6875 3.0625 6.023438.179688 2.332031-.570312 4.644531-2.09375 6.421875zm0 0"/></g></svg>
\ No newline at end of file

MODIFY
resources/icons/icons.qrc
resources/icons/icons.qrc
<file>delete.svg</file>
<file>analytics.svg</file>
<file>crosshair.svg</file>
+ <file>build.svg</file>
</qresource>
</RCC>

MODIFY
src/ccmanager.cpp
src/ccmanager.cpp
@@ -21,7 +21,7 @@ const static QString s_testprogram = "int main() { return 0; }";
* - %4: input source file
* - %5: output executable
*/
-const static QString s_baseCC = "%1 -march=%2 -mabi=%3 %4 -x c -s %5 -o %6";
+const static QString s_baseCC = "%1 -march=%2 -mabi=%3 %4 -x c %5 -o %6";
CCManager::CCManager() {
if (RipesSettings::value(RIPES_SETTING_CCPATH) == "") {

MODIFY
src/edittab.cpp
src/edittab.cpp
@@ -21,6 +21,14 @@ namespace Ripes {
EditTab::EditTab(QToolBar* toolbar, QWidget* parent) : RipesTab(toolbar, parent), m_ui(new Ui::EditTab) {
m_ui->setupUi(this);
+ m_buildAction = new QAction(this);
+ m_buildAction->setIcon(QIcon(":/icons/build.svg"));
+ m_buildAction->setText("Compile C program");
+ m_buildAction->setEnabled(false);
+ m_buildAction->setShortcut(QKeySequence("Ctrl+B"));
+ connect(m_buildAction, &QAction::triggered, this, &EditTab::compile);
+ m_toolbar->addAction(m_buildAction);
+
connect(m_ui->enableEditor, &QPushButton::clicked, this, &EditTab::enableAssemblyInput);
connect(m_ui->codeEditor, &CodeEditor::timedTextChanged, this, &EditTab::sourceCodeChanged);
@@ -103,6 +111,9 @@ void EditTab::updateProgramViewerHighlighting() {
}
void EditTab::sourceTypeChanged() {
+ // Convervatively always disable build action
+ m_buildAction->setEnabled(false);
+
if (!m_editorEnabled) {
// Do nothing; editor is currently disabled so we should not care about updating our source type being the code
// editor. sourceTypeChanged() will be re-executed once the editor is reenabled.
@@ -123,6 +134,7 @@ void EditTab::sourceTypeChanged() {
return;
} else {
m_currentSourceType = SourceType::C;
+ m_buildAction->setEnabled(true);
}
}
@@ -140,11 +152,9 @@ void EditTab::sourceCodeChanged() {
case SourceType::Assembly:
assemble();
break;
- case SourceType::C:
- compile();
- break;
default:
- // Do nothing, some external program is loaded
+ // Do nothing, either some external program is loaded or, if compiling from C, the user shall manually
+ // select to build
break;
}
}

MODIFY
src/edittab.h
src/edittab.h
@@ -80,6 +80,8 @@ private:
void enableEditor();
void disableEditor();
+ QAction* m_buildAction = nullptr;
+
Ui::EditTab* m_ui = nullptr;
std::unique_ptr<Assembler> m_assembler;

MODIFY
src/ripessettings.h
src/ripessettings.h
@@ -12,7 +12,7 @@ namespace Ripes {
// Definitions of all default settings within Ripes
const static std::map<QString, QVariant> s_defaultSettings = {{RIPES_SETTING_REWINDSTACKSIZE, 100},
{RIPES_SETTING_CCPATH, ""},
- {RIPES_SETTING_CCARGS, "-O3"}};
+ {RIPES_SETTING_CCARGS, "-O0"}};
/**
* @brief The SettingObserver class

Add build action for selectively compiling the C program