Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
New plugin to create Makefile project with existing code
christo:
https://github.com/josephch/CBMakefileProjectWithExistingCode
More details are available in README.md.
It is similar to the feature in eclipse CDT.
Pecan:
--- Quote from: christo on August 30, 2023, 06:19:30 am ---https://github.com/josephch/CBMakefileProjectWithExistingCode
More details are available in README.md.
It is similar to the feature in eclipse CDT.
--- End quote ---
I see, in the readme, that there is some problem with clangd_client.
Can you give me a 1,2,3 type steps to recreate the problem? I'd like to help resolve this if I can.
christo:
--- Quote from: Pecan on August 30, 2023, 06:52:54 am ---I see, in the readme, that there is some problem with clangd_client.
Can you give me a 1,2,3 type steps to recreate the problem? I'd like to help resolve this if I can.
--- End quote ---
1. Build and install MakefileProjectWithExistingCode plugin
2. Restart C::B and make sure no other projects are open.
3. In the File menu, select "Makefile Project With Existing Code" and add any directory which contains C++ files.
You can see that in the projects pane, project is not listed properly. you can see following print repeated in the console.
--- Quote ---GetLSPclient: No associated pClient in m_LSP_Clients[pProject]
--- End quote ---
Pecan:
@Christo
I've made some mods to clangd_client to more properly handle a custom makefile project.
Because a makefile project most likely does not contain all the info needed by clangd to properly parse a translation unit, it gets a large number of lines marked as errors.
I've adjusted clangd_client to pause parsing when the activated project is marked "custom makefile".
But the user can force parsing by unticking "Pause parsing (toggle)" for the project entry in the Projects tree.
Parsing can also be invoked by choosing "Reparse this project" in the Projects entry.
See the snapshot jpg below.
You might also consider adding ".cache" to the list of excluded files. Clangd keeps a lot of .idx files in that directory.
Just a thought to avoid confusing other plugins, you might consider the following (maybe overly cautious) changes:
The close will flush any status other plugins might be holding. And the new open will load a cleanly saved project that other plugins may have missed with just a "SetProject()" call.
To do this, I've commented some lines of your code. You may have to adjust as you see fit.
--- Code: --- else
{
//projectManager->BeginLoadingProject();
prj->SetMakefileCustom(true);
prj->AddBuildTarget("all");
wxArrayInt targets;
targets.Add(0);
projectManager->AddMultipleFilesToProject(filelist, prj, targets);
Manager::Get()->GetLogManager()->Log(wxString::Format(_("%s Added %d files!"), pluginName, (int)filelist.GetCount()));
prj->SetModified(true);
prj->CalculateCommonTopLevelPath();
prj->Save();
//projectManager->EndLoadingProject(prj);
if (!projectManager->IsLoadingWorkspace())
{
//- projectManager->SetProject(prj);
/** Close a project.
* @param project A pointer to the project to close.
* @param dontsave Force not (!) saving the project on close.
* @param refresh Force a refresh of the project tree after closing a project.
* @return True if project was closed, false if not.
*/
bool ok = projectManager->CloseProject(prj, /*bool dontsave =*/ true, /*bool refresh =*/ true);
/** Load a project from disk. This function, internally, uses IsOpen()
* so that the same project can't be loaded twice.
* @param filename The project file's filename.
* @param activateIt Active the project after loading.
* @return If the function succeeds, a pointer to the newly opened project
* is returned. Else the return value is NULL.
*/
//cbProject* LoadProject(const wxString& filename, bool activateIt = true);
cbProject* prj = projectManager->LoadProject(fileName, true);
}
projectManager->GetUI().RebuildTree();
ret = true;
}
return ret;
--- End code ---
Your plugin works well on Windows also with the following added target:
--- Code: --- <Target title="to_wn_wx32_64">
<Option output="bin/MakefileProjectWithExistingCode" prefix_auto="1" extension_auto="1" />
<Option object_output=".objs/to_codeblocks_wx32" />
<Option type="3" />
<Option compiler="gcc" />
<Option parameters="--debug-log --multiple-instance --no-splash-screen --verbose -p debug --no-dde --no-check-associations /p debug" />
<Option host_application="$(CODEBLOCKS)/../devel32_64/codeblocks.exe" />
<Option run_host_application_in_terminal="0" />
<Compiler>
<Add option="-g" />
<Add directory="$(#wx32.include)" />
<Add directory="$(#wx32.lib)/gcc_dll/mswu" />
<Add directory="$(#cb)/include" />
<Add directory="$(#cb)/sdk/wxscintilla/include" />
<Add directory="$(#cb)/include/tinyxml" />
</Compiler>
<Linker>
<Add library="wxmsw32u" />
<Add library="codeblocks" />
<Add directory="$(#wx32.lib)/gcc_dll" />
<Add directory="$(#cb)/devel32_64" />
<Add directory="$(#cb)/devel32" />
</Linker>
<ExtraCommands>
<Add before="cmd.exe /c echo CodeBlocks: $(codeblocks)" />
<Add before="cmd.exe /c echo cb: $(#cb)" />
<Add before="cmd.exe /c echo LinkFrom: $(#cb)\devel32_64" />
<Add after="zip -j9 .\bin\MakefileProjectWithExistingCode.zip manifest.xml" />
<Add after="cmd /c copy bin\MakefileProjectWithExistingCode.zip $(CODEBLOCKS)\..\devel32_64\share\codeblocks\" />
<Add after="cmd /c copy bin\MakefileProjectWithExistingCode.dll $(CODEBLOCKS)\..\devel32_64\share\codeblocks\plugins\" />
<Mode after="always" />
</ExtraCommands>
</Target>
--- End code ---
Thanks for your work.
christo:
@Pecan, thank you. Changed the plugin according to your suggestions.
Navigation
[0] Message Index
[#] Next page
Go to full version