]> code.bitgloo.com Git - clyne/stmdsp.git/commitdiff
remove make dependency; delete tmp files after use
authorClyne Sullivan <clyne@bitgloo.com>
Sat, 10 Apr 2021 15:21:33 +0000 (11:21 -0400)
committerClyne Sullivan <clyne@bitgloo.com>
Sat, 10 Apr 2021 15:21:33 +0000 (11:21 -0400)
gui/wxmain.cpp
gui/wxmain_devdata.cpp

index 41ae4c113e9e50372eaa8819b986a76b620b60c2..1eebe28c4f2e05cf185ee765223d4fda2101ac28 100644 (file)
@@ -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()
index 0e49e632b76941ba30ff9257ab995131af96ebf7..0862f63288cf96bfb0dee758efca7f854da0ecb4 100644 (file)
@@ -17,36 +17,39 @@ const std::array<unsigned int, 6> 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(