remove make dependency; delete tmp files after use

master
Clyne 4 years ago
parent 692f172321
commit cf20e4aceb

@ -337,24 +337,24 @@ wxString MainFrame::compileEditorCode()
file.Write(wxString(file_text) + m_text_editor->GetText()); file.Write(wxString(file_text) + m_text_editor->GetText());
file.Close(); 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 wxString make_text (m_device->get_platform() == stmdsp::platform::L4 ? makefile_text_l4
: makefile_text_h7); : makefile_text_h7);
make_text.Replace("$0", m_temp_file_name); make_text.Replace("$0", m_temp_file_name);
makefile.Write(make_text); makefile.Write(make_text);
makefile.Close(); makefile.Close();
wxString make_output = m_temp_file_name + "make.log"; wxString make_output = m_temp_file_name + ".sh.log";
if (wxFile::Exists(make_output)) wxString make_command = m_temp_file_name + ".sh > " + make_output + " 2>&1";
wxRemoveFile(make_output);
wxString make_command = wxString("make -C ") + m_temp_file_name.BeforeLast('/') +
" -f " + m_temp_file_name + "make" +
" > " + make_output + " 2>&1";
system(wxString("chmod +x ") + m_temp_file_name + ".sh");
int result = system(make_command.ToAscii()); int result = system(make_command.ToAscii());
m_compile_output->LoadFile(make_output); m_compile_output->LoadFile(make_output);
wxRemoveFile(m_temp_file_name);
wxRemoveFile(m_temp_file_name + ".sh");
wxRemoveFile(make_output);
if (result == 0) { if (result == 0) {
m_status_bar->SetStatusText("Compilation succeeded."); m_status_bar->SetStatusText("Compilation succeeded.");
return m_temp_file_name + ".o"; return m_temp_file_name + ".o";
@ -373,8 +373,8 @@ void MainFrame::onToolbarSampleRate(wxCommandEvent& ce)
void MainFrame::onCodeDisassemble(wxCommandEvent&) void MainFrame::onCodeDisassemble(wxCommandEvent&)
{ {
auto output = m_temp_file_name + ".asm.log";
if (!m_temp_file_name.IsEmpty()) { 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 ") + wxString command = wxString("arm-none-eabi-objdump -d --no-show-raw-insn ") +
m_temp_file_name + ".orig.o" // + m_temp_file_name + ".orig.o" // +
" > " + output + " 2>&1"; " > " + output + " 2>&1";
@ -391,6 +391,8 @@ void MainFrame::onCodeDisassemble(wxCommandEvent&)
m_compile_output->ChangeValue(""); m_compile_output->ChangeValue("");
m_status_bar->SetStatusText("Need to compile code before analyzing."); m_status_bar->SetStatusText("Need to compile code before analyzing.");
} }
wxRemoveFile(output);
} }
wxMenu *MainFrame::loadTemplates() wxMenu *MainFrame::loadTemplates()

@ -17,36 +17,39 @@ const std::array<unsigned int, 6> srateNums {
96000 96000
}; };
const char *makefile_text_h7 = R"make( #ifdef WIN32
all: #define NEWLINE "\r\n"
@arm-none-eabi-g++ -x c++ -Os -std=c++20 -fno-exceptions -fno-rtti \ #else
-mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-d16 -mtune=cortex-m7 \ #define NEWLINE "\n"
-nostartfiles \ #endif
-Wl,-Ttext-segment=0x00000000 -Wl,-zmax-page-size=512 -Wl,-eprocess_data_entry \
$0 -o $0.o // $0 = temp file name
@cp $0.o $0.orig.o const char *makefile_text_h7 =
@arm-none-eabi-strip -s -S --strip-unneeded $0.o "arm-none-eabi-g++ -x c++ -Os -std=c++20 -fno-exceptions -fno-rtti "
@arm-none-eabi-objcopy --remove-section .ARM.attributes \ "-mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-d16 -mtune=cortex-m7 "
--remove-section .comment \ "-nostartfiles "
--remove-section .noinit \ "-Wl,-Ttext-segment=0x00000000 -Wl,-zmax-page-size=512 -Wl,-eprocess_data_entry "
$0.o "$0 -o $0.o" NEWLINE
arm-none-eabi-size $0.o "cp $0.o $0.orig.o" NEWLINE
)make"; "arm-none-eabi-strip -s -S --strip-unneeded $0.o" NEWLINE
const char *makefile_text_l4 = R"make( "arm-none-eabi-objcopy --remove-section .ARM.attributes "
all: "--remove-section .comment "
@arm-none-eabi-g++ -x c++ -Os -std=c++20 -fno-exceptions -fno-rtti \ "--remove-section .noinit "
-mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 \ "$0.o" NEWLINE
-nostartfiles \ "arm-none-eabi-size $0.o" NEWLINE;
-Wl,-Ttext-segment=0x10000000 -Wl,-zmax-page-size=512 -Wl,-eprocess_data_entry \ const char *makefile_text_l4 =
$0 -o $0.o "arm-none-eabi-g++ -x c++ -Os -std=c++20 -fno-exceptions -fno-rtti "
@cp $0.o $0.orig.o "-mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 "
@arm-none-eabi-strip -s -S --strip-unneeded $0.o "-nostartfiles "
@arm-none-eabi-objcopy --remove-section .ARM.attributes \ "-Wl,-Ttext-segment=0x10000000 -Wl,-zmax-page-size=512 -Wl,-eprocess_data_entry "
--remove-section .comment \ "$0 -o $0.o" NEWLINE
--remove-section .noinit \ "cp $0.o $0.orig.o" NEWLINE
$0.o "arm-none-eabi-strip -s -S --strip-unneeded $0.o" NEWLINE
arm-none-eabi-size $0.o "arm-none-eabi-objcopy --remove-section .ARM.attributes "
)make"; "--remove-section .comment "
"--remove-section .noinit "
"$0.o" NEWLINE
"arm-none-eabi-size $0.o" NEWLINE;
// $0 = buffer size // $0 = buffer size
const char *file_header_h7 = R"cpp( const char *file_header_h7 = R"cpp(

Loading…
Cancel
Save