Author Topic: ClearCase Plug-In  (Read 22055 times)

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5193
ClearCase Plug-In
« on: October 26, 2005, 12:38:14 pm »
Dear all,

I am going to implement a plug-in for CodeBlocks adding support for several ClearCase commands.
As it is now, I still need to learn a few things.

To start out with I am providing an executable that allows also to do some ClearCase commands. You can find it at :
http://users.pandora.be/lieven.de.cock/CodeBlocks/ClearCase4Devcpp.zip

As the name suggests it was something I initially created for Dev-cpp, but it also works with CB.
How to install it : extract the exe somewhere on your PC (oh yes : windows only :-(   ) and then in CB go to "tools" menu and select "Configure Tools".
Next press the add Button, and fill in the fields as follows :

Name : ClearCase for CodeBlocks
Executable : browse for the exe you just put somewhere on your machine
Parameters : $(ACTIVE_EDITOR_FILENAME) $(PROJECT_DIR)
   --> not the space inbetween the 2 parameters.
Working Directory : select the directory where the exe is in

The exe might need to some MS runtimes since it was build with .NET 2003. Yeah, using M$ to use other IDE's. ;-)
Please look for them and ensure they are in your path.

When you are working on a project (cbp !!) whose sources are in ClearCase you can run the clearcase commands for the active editor by going to the Tools menu and selecting our newly added tool. The rest is pretty obvious on what to do.


Roadmap :
1) create a simple plug-in that calls the cleartool on the command line for everything, clearcase menu in the menubar, and the context menu. Does not allow yet to add comments (needs a gui for that, one of the things that I need to study ...)
2) the same as 1 but with a GUI that allows to add comments for the action you excute
3) Maybe ? : replace cleartool calls by using the api dll (windows only)
4) more to come ... ???


I already have a FIRST QUESTION : what's the counterpart for CreateProcess (from the windows API) on wxWindows ?
Since I don't want to just call system(...), sometimes we need to wait untill the action is finished before the code can continue.


kind regards,
Lieven


Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: ClearCase Plug-In
« Reply #1 on: October 26, 2005, 01:06:42 pm »
Quote
I already have a FIRST QUESTION : what's the counterpart for CreateProcess (from the windows API) on wxWindows ?
Since I don't want to just call system(...), sometimes we need to wait untill the action is finished before the code can continue.

Check the documentation for wxExecute...
Be patient!
This bug will be fixed soon...

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5193
Re: ClearCase Plug-In
« Reply #2 on: October 26, 2005, 02:08:49 pm »
Thanks for the information.
The documentation said it can only be called from the main thread, I suspect a plug-in call is not in the context of the main thread ?? I hope it is  8)

Another request : since other people are also working on plug-in for version control system (cvs, svn), maybe it might be a good idea that there's always a tab in the Messages pane, purely for version control systems.

Maybe each plug-in can create a new tab ? Does the sdk provide that ? But things might get clumbsy then.

What do you think ?

Cheers,
Lieven

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: ClearCase Plug-In
« Reply #3 on: October 26, 2005, 02:36:40 pm »
Quote
The documentation said it can only be called from the main thread, I suspect a plug-in call is not in the context of the main thread ??
Yes, plugins run in the main thread (unless they use threading, like the code-completion plugin).

Quote
Another request : since other people are also working on plug-in for version control system (cvs, svn), maybe it might be a good idea that there's always a tab in the Messages pane, purely for version control systems.
AFAIK, one plugin is in development and it creates its own tab.

Quote
Maybe each plug-in can create a new tab ? Does the sdk provide that ? But things might get clumbsy then
Yes, it is provided. Check sdk/messagemanager.h for info.
The way it's done now is subject to change but the functionality will remain.
Be patient!
This bug will be fixed soon...

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5193
Re: ClearCase Plug-In
« Reply #4 on: October 27, 2005, 12:43:18 pm »
Problem when using my very first dialog.

In my plug-in project I created a dialog by using the wxSmith.
So the project gets expanded with a header and a source file, an I choose to use an xrc file.
In my code at a given moment I try to do this (in the handler of a menu entry that was selected) :

   CcDialog Dialog(Manager::Get()->GetAppWindow());
   if(Dialog.ShowModal() == wxID_OK)
   {
      Manager::Get()->GetMessageManager()->Log("Ok pressed");
   }
   else
   {
      Manager::Get()->GetMessageManager()->Log("Cancel pressed");
   }

Everything compiles fine.
I place my plug-in dll in the share\CodeBlocks\plug-in subdur, and I even zipped my xrc file and putted it in share\CodeBlocks dir (dunno why yet, but looking at other plug-ins it might be needed).
I start CB, but I get an error like this :
The procedure entry point _ZN!wxDialog17MSWProcessMessageEPT6tagMSG could not be located in the dynamic link library wxmsw26_gcc_cb.dll.

Anyone any idea on what I did wrong ?

Many thanks,
Lieven


Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: ClearCase Plug-In
« Reply #5 on: October 27, 2005, 02:12:57 pm »
Quote
The procedure entry point _ZN!wxDialog17MSWProcessMessageEPT6tagMSG could not be located in the dynamic link library wxmsw26_gcc_cb.dll.

Are you sure you 're linking to the same DLL C::B uses?
Be patient!
This bug will be fixed soon...

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5193
Re: ClearCase Plug-In
« Reply #6 on: October 27, 2005, 02:18:01 pm »
Well, I saw that CB is using wx 2.6.1, but when downloading the sources at wxwidgets.org  I could either choose between 2.4.2 and 2.6.2. So I choose the 2.6.2.
This is part of my project file :
         <Environment>
            <Variable name="WX_VER" value="26"/>
            <Variable name="WX_DIR" value="E:\wxWidgets-2.6.2"/>
            <Variable name="WX_CFG" value="NonUnicode"/>
            <Variable name="CB_SDK" value="E:\Program Files\CodeBlocks"/>
         </Environment>

      <Linker>
         <Add library="wxmsw$(WX_VER)"/>
         <Add library="codeblocks"/>
         <Add directory="$(WX_DIR)\lib\gcc_dll\msw"/>
         <Add directory="$(WX_DIR)\lib\gcc_dll$(WX_CFG)"/>
         <Add directory="$(CB_SDK)\sdk\lib"/>
         <Add directory="$(CB_SDK)\devel"/>
         <Add directory="$(CB_SDK)\sdk\tinyxml"/>
         <Add directory="$(CB_SDK)\sdk\wxscintilla\include"/>
      </Linker>


So I guess I link with the dll of CB ? And in my sources of wx (where I builded as instructed in the wiki) I retrieve the header files and that setup.h ???

kind regards,
Lieven

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5193
Re: ClearCase Plug-In
« Reply #7 on: October 27, 2005, 02:25:00 pm »
Experiment : I replace in CB directory the wx dll, with the one resulting from my wx 2.6.2 build -> I seem toget a bit further (I can already see my menu entry) but then CB crashes :

-------------------

Error occured on Thursday, October 27, 2005 at 14:22:08.

E:\Program Files\CodeBlocks\codeblocks.exe caused an Access Violation at location 10060e63 in module E:\Program Files\CodeBlocks\wxmsw26_gcc_cb.dll Reading from location 002dfff8.

Registers:
eax=0023f1e0 ebx=01357ba8 ecx=104cfb9c edx=002e0004 esi=0023f1e0 edi=002d044e
eip=10060e63 esp=0023f150 ebp=0023f168 iopl=0         nv up ei pl zr na po nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010246

Call stack:
10060E63  E:\Program Files\CodeBlocks\wxmsw26_gcc_cb.dll:10060E63  _onexit  d:/src/mingw/build/runtime/../../runtime/dllcrt1.c:183
1012B986  E:\Program Files\CodeBlocks\wxmsw26_gcc_cb.dll:1012B986  _onexit  d:/src/mingw/build/runtime/../../runtime/dllcrt1.c:183
1010A7D0  E:\Program Files\CodeBlocks\wxmsw26_gcc_cb.dll:1010A7D0  _onexit  d:/src/mingw/build/runtime/../../runtime/dllcrt1.c:183
77D48734  C:\WINDOWS\system32\USER32.dll:77D48734  GetDC
77D48816  C:\WINDOWS\system32\USER32.dll:77D48816  GetDC
77D4B89B  C:\WINDOWS\system32\USER32.dll:77D4B89B  GetParent
77D5F3E3  C:\WINDOWS\system32\USER32.dll:77D5F3E3  SendMessageA
101299ED  E:\Program Files\CodeBlocks\wxmsw26_gcc_cb.dll:101299ED  _onexit  d:/src/mingw/build/runtime/../../runtime/dllcrt1.c:183
10193586  E:\Program Files\CodeBlocks\wxmsw26_gcc_cb.dll:10193586  _onexit  d:/src/mingw/build/runtime/../../runtime/dllcrt1.c:183
6A7C6676  E:\Program Files\CodeBlocks\share\codeblocks\plugins\todo.dll:6A7C6676  GetSDKVersionMinor
6A7C6942  E:\Program Files\CodeBlocks\share\codeblocks\plugins\todo.dll:6A7C6942  GetSDKVersionMinor
6A7C6F9B  E:\Program Files\CodeBlocks\share\codeblocks\plugins\todo.dll:6A7C6F9B  GetSDKVersionMinor
6A7C4191  E:\Program Files\CodeBlocks\share\codeblocks\plugins\todo.dll:6A7C4191  GetSDKVersionMinor
100A86D8  E:\Program Files\CodeBlocks\wxmsw26_gcc_cb.dll:100A86D8  _onexit  d:/src/mingw/build/runtime/../../runtime/dllcrt1.c:183
100A8A9C  E:\Program Files\CodeBlocks\wxmsw26_gcc_cb.dll:100A8A9C  _onexit  d:/src/mingw/build/runtime/../../runtime/dllcrt1.c:183
100A9A79  E:\Program Files\CodeBlocks\wxmsw26_gcc_cb.dll:100A9A79  _onexit  d:/src/mingw/build/runtime/../../runtime/dllcrt1.c:183
100A9A19  E:\Program Files\CodeBlocks\wxmsw26_gcc_cb.dll:100A9A19  _onexit  d:/src/mingw/build/runtime/../../runtime/dllcrt1.c:183
100A9A19  E:\Program Files\CodeBlocks\wxmsw26_gcc_cb.dll:100A9A19  _onexit  d:/src/mingw/build/runtime/../../runtime/dllcrt1.c:183
60549C38  E:\Program Files\CodeBlocks\codeblocks.dll:60549C38  _ZN13PluginManager13NotifyPluginsER15CodeBlocksEvent
6055B23F  E:\Program Files\CodeBlocks\codeblocks.dll:6055B23F  _ZN14ProjectManager10SetProjectEP9cbProjectb
6055D66F  E:\Program Files\CodeBlocks\codeblocks.dll:6055D66F  _ZN14ProjectManager11LoadProjectERK8wxString
6057E3B9  E:\Program Files\CodeBlocks\codeblocks.dll:6057E3B9  _ZN15WorkspaceLoader4OpenERK8wxString
604DA46D  E:\Program Files\CodeBlocks\codeblocks.dll:604DA46D  _ZN11cbWorkspace4LoadEv
604DA049  E:\Program Files\CodeBlocks\codeblocks.dll:604DA049  _ZN11cbWorkspaceC1ERK8wxString
6055E5F4  E:\Program Files\CodeBlocks\codeblocks.dll:6055E5F4  _ZN14ProjectManager13LoadWorkspaceERK8wxString
004029EC  E:\Program Files\CodeBlocks\codeblocks.exe:004029EC
0040386D  E:\Program Files\CodeBlocks\codeblocks.exe:0040386D
0044D608  E:\Program Files\CodeBlocks\codeblocks.exe:0044D608
10043179  E:\Program Files\CodeBlocks\wxmsw26_gcc_cb.dll:10043179  _onexit  d:/src/mingw/build/runtime/../../runtime/dllcrt1.c:183
100B187C  E:\Program Files\CodeBlocks\wxmsw26_gcc_cb.dll:100B187C  _onexit  d:/src/mingw/build/runtime/../../runtime/dllcrt1.c:183
0040148A  E:\Program Files\CodeBlocks\codeblocks.exe:0040148A
00447ADA  E:\Program Files\CodeBlocks\codeblocks.exe:00447ADA
004011E7  E:\Program Files\CodeBlocks\codeblocks.exe:004011E7
00401238  E:\Program Files\CodeBlocks\codeblocks.exe:00401238
7C816D4F  C:\WINDOWS\system32\kernel32.dll:7C816D4F  RegisterWaitForInputIdle


Seems like I am definitely doing something wrong :-( , but what ?

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5193
Re: ClearCase Plug-In
« Reply #8 on: October 27, 2005, 03:04:07 pm »
I found the sources for wx 2.6.1, and build them, and accordingly changed my plug-in project.
Also here I get the crash now :

Error occured on Thursday, October 27, 2005 at 15:02:48.

E:\Program Files\CodeBlocks\codeblocks.exe caused an Access Violation at location 1014fa2f in module E:\Program Files\CodeBlocks\wxmsw26_gcc_cb.dll Reading from location 0000006c.

Registers:
eax=00c18080 ebx=00000008 ecx=1053a548 edx=0023f4c0 esi=01337cb8 edi=0132cd88
eip=1014fa2f esp=0023f3b0 ebp=0023f3d8 iopl=0         nv up ei pl nz na pe nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010202

Call stack:
1014FA2F  E:\Program Files\CodeBlocks\wxmsw26_gcc_cb.dll:1014FA2F  _ZN9wxMenuBar6AppendEP6wxMenuRK8wxString
014A1AA2  E:\Program Files\CodeBlocks\share\codeblocks\plugins\ClearCase.dll:014A1AA2  GetSDKVersionMinor
00418124  E:\Program Files\CodeBlocks\codeblocks.exe:00418124
0042132B  E:\Program Files\CodeBlocks\codeblocks.exe:0042132B
100A77E8  E:\Program Files\CodeBlocks\wxmsw26_gcc_cb.dll:100A77E8  _ZN12wxEvtHandler21ProcessEventIfMatchesERK21wxEventTableEntryBasePS_R7wxEvent
100A7BAC  E:\Program Files\CodeBlocks\wxmsw26_gcc_cb.dll:100A7BAC  _ZN16wxEventHashTable11HandleEventER7wxEventP12wxEvtHandler
100A8B89  E:\Program Files\CodeBlocks\wxmsw26_gcc_cb.dll:100A8B89  _ZN12wxEvtHandler12ProcessEventER7wxEvent
100A89C6  E:\Program Files\CodeBlocks\wxmsw26_gcc_cb.dll:100A89C6  _ZN12wxEvtHandler20ProcessPendingEventsEv
10001C44  E:\Program Files\CodeBlocks\wxmsw26_gcc_cb.dll:10001C44  _ZN12wxAppConsole20ProcessPendingEventsEv
100C8D01  E:\Program Files\CodeBlocks\wxmsw26_gcc_cb.dll:100C8D01  _ZN5wxApp5YieldEb
6052F54E  E:\Program Files\CodeBlocks\codeblocks.dll:6052F54E  _ZN14MessageManager9AppendLogEPKcz
60548DD9  E:\Program Files\CodeBlocks\codeblocks.dll:60548DD9  _ZN13PluginManager14LoadAllPluginsEv
0041630F  E:\Program Files\CodeBlocks\codeblocks.exe:0041630F
0041278C  E:\Program Files\CodeBlocks\codeblocks.exe:0041278C
00402832  E:\Program Files\CodeBlocks\codeblocks.exe:00402832
0040386D  E:\Program Files\CodeBlocks\codeblocks.exe:0040386D
0044D608  E:\Program Files\CodeBlocks\codeblocks.exe:0044D608
10043161  E:\Program Files\CodeBlocks\wxmsw26_gcc_cb.dll:10043161  _Z14wxUninitializev
100B07BC  E:\Program Files\CodeBlocks\wxmsw26_gcc_cb.dll:100B07BC  _Z7wxEntryP11HINSTANCE__S0_Pci
0040148A  E:\Program Files\CodeBlocks\codeblocks.exe:0040148A
00447ADA  E:\Program Files\CodeBlocks\codeblocks.exe:00447ADA
004011E7  E:\Program Files\CodeBlocks\codeblocks.exe:004011E7
00401238  E:\Program Files\CodeBlocks\codeblocks.exe:00401238
7C816D4F  C:\WINDOWS\system32\kernel32.dll:7C816D4F  RegisterWaitForInputIdle


Any help ?
Lieven

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: ClearCase Plug-In
« Reply #9 on: October 27, 2005, 03:53:49 pm »
You need the exact same wxWidgets C::B was built with.
If you build C::B yourself that's easy because you 'll be using the same wx.
If not, download the C::B SDK. It contains, among other things, the import library for wxmsw26_gcc_cb.dll (libwxmsw26.a). Link with it and everything will be fine.
Be patient!
This bug will be fixed soon...

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5193
Re: ClearCase Plug-In
« Reply #10 on: October 27, 2005, 04:35:25 pm »
I linke with the lib from cb itself, still get the crash. searching searching ....

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5193
Re: ClearCase Plug-In
« Reply #11 on: October 30, 2005, 04:43:10 pm »

Hi folks,

The crash problem is gone, the reason and solution can be found at :
http://forums.codeblocks.org/index.php/topic,1224.0.html

So I could continue my programming on the clearcase plug-in. I am close to an alpha release.

One minor problem I have is that I created 2 access points for the functionality : a menu in the menubar( that one is ok), and a submenu in the context menu of the editor, and in there I have a problem. When you start up, the context menu is OK, but once a selection has been made out of my submenu, the next time you right click -> my submenu has disappeared.

Thus I am tackling this problem for the moment, any ideas are more then welcome ;-)

cheers,
Lieven

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: ClearCase Plug-In
« Reply #12 on: October 30, 2005, 05:19:20 pm »
The correct way is to add a menu item (or a submenu) from the BuildModuleMenu function. You re-create whatever you need every time the menu is popped up this way.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5193
Re: ClearCase Plug-In
« Reply #13 on: October 30, 2005, 05:36:40 pm »
Well that's what I am doing, but it seems not enough.

Okay, while I was pasting the code in here (already removed it again), I saw the problem. I allocated my menu in this function but only when it was not allocated, and doing so I only added the entries .... in the case that ... it was not allocated yet... tssss

stupid stupid stupid ...... me

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5193
Re: ClearCase Plug-In
« Reply #14 on: October 30, 2005, 05:54:38 pm »
You fix 1 thing you break another it seems.

I allocate my wxMenu (for the submenu) now at constructor time, and add it to the context menu during the BuildModuleMenu, but for some reason it is interfering now with the entries in the folding submenu.
And at the second activation it crashes the entire cb.

1) I allocate submenu at constructor, and at BuildModuleMenu I add it to context menu and add also all the entries in my submenu -------> second time context menu is shown both folding and my menu have the entries of both submenus, and crash
2) I allocate submenu at constructor and already add all it's entries, at BuildModuleMenu I add the submenu itself to the context menu ---> second time context menu is shown both folding and my menu have the entries of the folding menu, and crash