Skip to content

Commit 9849b61

Browse files
committed
[cleanup] Pass wxString directly to avoid to use StdToWX::ToArrayString (and wxJoin)
1 parent d4a352b commit 9849b61

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

CMakePlugin/CMakePlugin.cpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
#include "AsyncProcess/processreaderthread.h"
5757
#include "CMakeBuilder.h"
5858
#include "ICompilerLocator.h"
59-
#include "StdToWX.h"
6059
#include "StringUtils.h"
6160
#include "build_config.h"
6261
#include "environmentconfig.h"
@@ -515,11 +514,10 @@ bool CMakePlugin::IsCMakeListsExists() const
515514
return false;
516515
}
517516

518-
wxString CMakePlugin::WriteCMakeListsAndOpenIt(const std::vector<wxString>& lines) const
517+
wxString CMakePlugin::WriteCMakeListsAndOpenIt(const wxString& lines) const
519518
{
520519
wxFileName cmakelists_txt{::wxGetCwd(), "CMakeLists.txt"};
521-
const wxArrayString wx_lines = StdToWX::ToArrayString(lines);
522-
FileUtils::WriteFileContent(cmakelists_txt, wxJoin(wx_lines, '\n'));
520+
FileUtils::WriteFileContent(cmakelists_txt, lines);
523521
clGetManager()->OpenFile(cmakelists_txt.GetFullPath());
524522
return cmakelists_txt.GetFullPath();
525523
}
@@ -552,28 +550,30 @@ clStatusOr<wxString> CMakePlugin::CreateCMakeListsFile(CMakePlugin::TargetType t
552550
return StatusOther("User cancelled");
553551
}
554552

555-
wxString cmakelists_txt = WriteCMakeListsAndOpenIt({
556-
"cmake_minimum_required(VERSION 3.16)",
557-
wxString::Format("project(%s)", name),
558-
wxEmptyString,
559-
wxEmptyString,
560-
"set(CMAKE_EXPORT_COMPILE_COMMANDS 1)",
561-
"set(CMAKE_CXX_STANDARD 17)",
562-
"set(CMAKE_CXX_STANDARD_REQUIRED ON)",
563-
wxEmptyString,
564-
"file(GLOB CXX_SRCS \"*.cpp\")",
565-
"file(GLOB C_SRCS \"*.c\")",
566-
wxEmptyString,
567-
target_line,
568-
"if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})",
569-
" add_custom_command(",
570-
wxString::Format(" TARGET %s", name),
571-
" POST_BUILD",
572-
" COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/compile_commands.json",
573-
" ${CMAKE_SOURCE_DIR}/compile_commands.json)",
574-
"endif()",
575-
wxEmptyString,
576-
});
553+
wxString cmakelists_txt = WriteCMakeListsAndOpenIt(
554+
wxString::Format("cmake_minimum_required(VERSION 3.16)\n"
555+
"project(%s)\n"
556+
"\n"
557+
"\n"
558+
"set(CMAKE_EXPORT_COMPILE_COMMANDS 1)\n"
559+
"set(CMAKE_CXX_STANDARD 17)\n"
560+
"set(CMAKE_CXX_STANDARD_REQUIRED ON)\n"
561+
"\n"
562+
"file(GLOB CXX_SRCS \"*.cpp\")\n"
563+
"file(GLOB C_SRCS \"*.c\")\n"
564+
"\n"
565+
"%s\n"
566+
"if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})\n"
567+
" add_custom_command(\n"
568+
" TARGET %s\n"
569+
" POST_BUILD\n"
570+
" COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/compile_commands.json\n"
571+
" ${CMAKE_SOURCE_DIR}/compile_commands.json)\n"
572+
"endif()\n"
573+
"\n",
574+
name,
575+
target_line,
576+
name));
577577
return cmakelists_txt;
578578
}
579579

CMakePlugin/CMakePlugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ class CMakePlugin : public IPlugin
249249
void OnCreateCMakeListsDll(wxCommandEvent& event);
250250
void OnCreateCMakeListsLib(wxCommandEvent& event);
251251
bool IsCMakeListsExists() const;
252-
wxString WriteCMakeListsAndOpenIt(const std::vector<wxString>& lines) const;
252+
wxString WriteCMakeListsAndOpenIt(const wxString& lines) const;
253253
clStatusOr<wxString> CreateCMakeListsFile(TargetType type) const;
254254
void FireCMakeListsFileCreatedEvent(const wxString& cmakelists_txt) const;
255255

0 commit comments

Comments
 (0)