diff --git a/gui/wxmain.cpp b/gui/wxmain.cpp index 41ae4c1..1eebe28 100644 --- a/gui/wxmain.cpp +++ b/gui/wxmain.cpp @@ -337,24 +337,24 @@ wxString MainFrame::compileEditorCode() file.Write(wxString(file_text) + m_text_editor->GetText()); file.Close(); - wxFile makefile (m_temp_file_name + "make", wxFile::write); + wxFile makefile (m_temp_file_name + ".sh", wxFile::write); wxString make_text (m_device->get_platform() == stmdsp::platform::L4 ? makefile_text_l4 : makefile_text_h7); make_text.Replace("$0", m_temp_file_name); makefile.Write(make_text); makefile.Close(); - wxString make_output = m_temp_file_name + "make.log"; - if (wxFile::Exists(make_output)) - wxRemoveFile(make_output); - - wxString make_command = wxString("make -C ") + m_temp_file_name.BeforeLast('/') + - " -f " + m_temp_file_name + "make" + - " > " + make_output + " 2>&1"; + wxString make_output = m_temp_file_name + ".sh.log"; + wxString make_command = m_temp_file_name + ".sh > " + make_output + " 2>&1"; + system(wxString("chmod +x ") + m_temp_file_name + ".sh"); int result = system(make_command.ToAscii()); m_compile_output->LoadFile(make_output); + wxRemoveFile(m_temp_file_name); + wxRemoveFile(m_temp_file_name + ".sh"); + wxRemoveFile(make_output); + if (result == 0) { m_status_bar->SetStatusText("Compilation succeeded."); return m_temp_file_name + ".o"; @@ -373,8 +373,8 @@ void MainFrame::onToolbarSampleRate(wxCommandEvent& ce) void MainFrame::onCodeDisassemble(wxCommandEvent&) { + auto output = m_temp_file_name + ".asm.log"; if (!m_temp_file_name.IsEmpty()) { - auto output = m_temp_file_name + ".asm.log"; wxString command = wxString("arm-none-eabi-objdump -d --no-show-raw-insn ") + m_temp_file_name + ".orig.o" // + " > " + output + " 2>&1"; @@ -391,6 +391,8 @@ void MainFrame::onCodeDisassemble(wxCommandEvent&) m_compile_output->ChangeValue(""); m_status_bar->SetStatusText("Need to compile code before analyzing."); } + + wxRemoveFile(output); } wxMenu *MainFrame::loadTemplates() diff --git a/gui/wxmain_devdata.cpp b/gui/wxmain_devdata.cpp index 0e49e63..0862f63 100644 --- a/gui/wxmain_devdata.cpp +++ b/gui/wxmain_devdata.cpp @@ -17,36 +17,39 @@ const std::array srateNums { 96000 }; -const char *makefile_text_h7 = R"make( -all: - @arm-none-eabi-g++ -x c++ -Os -std=c++20 -fno-exceptions -fno-rtti \ - -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-d16 -mtune=cortex-m7 \ - -nostartfiles \ - -Wl,-Ttext-segment=0x00000000 -Wl,-zmax-page-size=512 -Wl,-eprocess_data_entry \ - $0 -o $0.o - @cp $0.o $0.orig.o - @arm-none-eabi-strip -s -S --strip-unneeded $0.o - @arm-none-eabi-objcopy --remove-section .ARM.attributes \ - --remove-section .comment \ - --remove-section .noinit \ - $0.o - arm-none-eabi-size $0.o -)make"; -const char *makefile_text_l4 = R"make( -all: - @arm-none-eabi-g++ -x c++ -Os -std=c++20 -fno-exceptions -fno-rtti \ - -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 \ - -nostartfiles \ - -Wl,-Ttext-segment=0x10000000 -Wl,-zmax-page-size=512 -Wl,-eprocess_data_entry \ - $0 -o $0.o - @cp $0.o $0.orig.o - @arm-none-eabi-strip -s -S --strip-unneeded $0.o - @arm-none-eabi-objcopy --remove-section .ARM.attributes \ - --remove-section .comment \ - --remove-section .noinit \ - $0.o - arm-none-eabi-size $0.o -)make"; +#ifdef WIN32 +#define NEWLINE "\r\n" +#else +#define NEWLINE "\n" +#endif + +// $0 = temp file name +const char *makefile_text_h7 = + "arm-none-eabi-g++ -x c++ -Os -std=c++20 -fno-exceptions -fno-rtti " + "-mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-d16 -mtune=cortex-m7 " + "-nostartfiles " + "-Wl,-Ttext-segment=0x00000000 -Wl,-zmax-page-size=512 -Wl,-eprocess_data_entry " + "$0 -o $0.o" NEWLINE + "cp $0.o $0.orig.o" NEWLINE + "arm-none-eabi-strip -s -S --strip-unneeded $0.o" NEWLINE + "arm-none-eabi-objcopy --remove-section .ARM.attributes " + "--remove-section .comment " + "--remove-section .noinit " + "$0.o" NEWLINE + "arm-none-eabi-size $0.o" NEWLINE; +const char *makefile_text_l4 = + "arm-none-eabi-g++ -x c++ -Os -std=c++20 -fno-exceptions -fno-rtti " + "-mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 " + "-nostartfiles " + "-Wl,-Ttext-segment=0x10000000 -Wl,-zmax-page-size=512 -Wl,-eprocess_data_entry " + "$0 -o $0.o" NEWLINE + "cp $0.o $0.orig.o" NEWLINE + "arm-none-eabi-strip -s -S --strip-unneeded $0.o" NEWLINE + "arm-none-eabi-objcopy --remove-section .ARM.attributes " + "--remove-section .comment " + "--remove-section .noinit " + "$0.o" NEWLINE + "arm-none-eabi-size $0.o" NEWLINE; // $0 = buffer size const char *file_header_h7 = R"cpp(