Author Topic: Portable Code::Blocks  (Read 155491 times)

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Portable Code::Blocks
« on: April 05, 2009, 04:04:17 pm »
Hi All,

I've made a patch against current svn revision to make Code::Blocks portable. A slightly detailed write-up on this can be found from my blog (http://biplab.in/2009/04/creating-portable-version-of-codeblocks/).

With this patch anyone should be able to carry customised C::B settings by copying entire folder of Code::Blocks and plugins settings from %APPDATA%\codeblocks folder, place it to a folder and then pointing it by modifying APPDATA variable before launching C::B.

I've written a small utility which will create an folder structure AppData\codeblocks from the directory it is launched. Then it'll modify APPDATA variable before launching Code::Blocks from same folder.

Now you can copy your entire content of %APPDATA%\codeblocks to AppData\codeblocks folder and copy the folder to any portable drive. Everytime you run codeblocks through cblauncher, your settings will be saved to the folder you are running from. If you don't copy your settings and run C::B through cblauncher it will assume that it's a fresh install and will behave accordingly.

I've created a binary package from revision 5409 to try this out. You can download it from the following link.
Quote
http://files.filefront.com/Portable+CB+5409+bin7z/;13536157;/fileinfo.html
Edit 1: If you download this package, extract it to a folder and then double click on cblauncher.exe file.

I've not applied this patch to svn. However I intend to do so if other devs have no objection to this hack.

Patch is attached with this post. CbLauncher source and binary can be downloaded from my blog.

Please post your valuable feedback.

Regards,

Biplab

[attachment deleted by admin]
« Last Edit: April 05, 2009, 04:11:01 pm by Biplab »
Be a part of the solution, not a part of the problem.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Portable Code::Blocks
« Reply #1 on: April 06, 2009, 03:14:32 pm »
I have read your blog article, and I have two binary package in my system. One is nightly build version, the other is the version I build from the svn.

To let the two version work separately, I follow the wiki page:
http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_make_Code::Blocks_portable.3F

But as you said, some plug-in setting can't be work in full portable mode. :(

I download your binary package and unpack to my nightly build folder which is located in D:\program files\code blocks.

Then I just run CbLauncher.exe, it will create an empty folder in
D:\Program Files\CodeBlocks\AppData\codeblocks

And even I close C::B, no setting files were saved in these folders. This is a little strange. :(. Should I need to clear the setting file in:
"C:\Documents and Settings\[your_user_name]\Application Data\codeblocks"?

By the way, I suggest when the portable version was running, the console window should be closed.
And another issue it the about dialog shows that it is SVN 0.  :D

See the screen shot.



[attachment deleted by admin]
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Portable Code::Blocks
« Reply #2 on: April 06, 2009, 03:44:03 pm »
I upzip your binary package to D:\PortableCB.

The First time I run CbLauncher.exe, it seems no C::B was running, only an empty folder named AppData was generated.

The second time I run CbLauncher.exe, it will initialize C::B, then after I close C::B, some configuration files were saved in D:\portableCB\AppData\XXX, also, two sub folders were generated.

Here is the folder tree. Is it right?
Code
D:\portableCB

├─AppData
│  ├─codeblocks
│  └─share
│      └─codeblocks
│          ├─plugins
│          └─scripts
└─share
    └─CodeBlocks
        ├─images
        │  ├─16x16
        │  ├─codecompletion
        │  ├─codesnippets
        │  ├─settings
        │  ├─ThreadSearch
        │  └─wxsmith
        ├─lexers
        ├─lib_finder
        ├─plugins
        ├─scripts
        └─templates
        ......
        ......

Thanks!
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Portable Code::Blocks
« Reply #3 on: April 06, 2009, 04:39:00 pm »
By the way, I have found the way to hide the console window.

Add this statement:

Code
#define _WIN32_WINNT 0x0500
......
......


HWND hwnd = GetConsoleWindow();
ShowWindow(hwnd,SW_HIDE);


Thanks
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Portable Code::Blocks
« Reply #4 on: April 06, 2009, 04:53:26 pm »
I download your binary package and unpack to my nightly build folder which is located in D:\program files\code blocks.

Then I just run CbLauncher.exe, it will create an empty folder in
D:\Program Files\CodeBlocks\AppData\codeblocks

And even I close C::B, no setting files were saved in these folders. This is a little strange. :(. Should I need to clear the setting file in:
"C:\Documents and Settings\[your_user_name]\Application Data\codeblocks"?

It's a bug in CbLauncher. I've fixed it. You can replace your cblauncher.exe file with the attached one. I'll reupload binary package with new cblauncher.exe file.

But as you said, some plug-in setting can't be work in full portable mode. :(

I have tried with few plugins (DevPak, DragScroll). They are saving their settings to APPDATA pointed directory. But honestly I haven't checked all.

By the way, I suggest when the portable version was running, the console window should be closed.
And another issue it the about dialog shows that it is SVN 0.  :D

Noted. I'll make this change. Don't worry about SVN 0. It's built from rev 5409. I built this build from source tarball and therefore svn failed to generate any revision number.

Code
D:\portableCB

├─AppData
│  ├─codeblocks
│  └─share
│      └─codeblocks
│          ├─plugins
│          └─scripts
└─share
    └─CodeBlocks
        ├─images
        │  ├─16x16
        │  ├─codecompletion
        │  ├─codesnippets
        │  ├─settings
        │  ├─ThreadSearch
        │  └─wxsmith
        ├─lexers
        ├─lib_finder
        ├─plugins
        ├─scripts
        └─templates
        ......
        ......

Folder structure is correct. Your settings will be saved under AppData folder. Share folder is being used to load various resources.

Thanks a lot for your feedback. :)


[attachment deleted by admin]
Be a part of the solution, not a part of the problem.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Portable Code::Blocks
« Reply #5 on: April 06, 2009, 05:12:57 pm »
You are welcome!

I just downloaded the new CbLauncher.exe in the previous post.

Before testing, I delete the folder
C:\Documents and Settings\My name\Application Data\codeblocks

But once the CbLauncher.exe runs, the folder will be automatically generated again.  :(.

By the way, I also find another folder here, ( I just deleted it, maybe, it is related to the bug you have fixed. :D)
C:\Documents and Settings\My name\AppData\codeblocks

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Portable Code::Blocks
« Reply #6 on: April 06, 2009, 05:24:28 pm »
Before testing, I delete the folder
C:\Documents and Settings\My name\Application Data\codeblocks

But once the CbLauncher.exe runs, the folder will be automatically generated again.  :(.

By the way, I also find another folder here, ( I just deleted it, maybe, it is related to the bug you have fixed. :D)
C:\Documents and Settings\My name\AppData\codeblocks

I noticed this too. It's strange that C::B is still generating a folder inside C:\Documents and Settings folder. Need to investigate further.

By the way, I have found the way to hide the console window.

Add this statement:

Code
#define _WIN32_WINNT 0x0500
......
......


HWND hwnd = GetConsoleWindow();
ShowWindow(hwnd,SW_HIDE);


Please feel free to download the source of CbLauncher and tweak it as you like. At the moment need to go to bed. I will apply your modification later. :)
Be a part of the solution, not a part of the problem.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2750
Re: Portable Code::Blocks
« Reply #7 on: April 07, 2009, 04:33:16 pm »
Before testing, I delete the folder
C:\Documents and Settings\My name\Application Data\codeblocks

But once the CbLauncher.exe runs, the folder will be automatically generated again.  :(.

By the way, I also find another folder here, ( I just deleted it, maybe, it is related to the bug you have fixed. :D)
C:\Documents and Settings\My name\AppData\codeblocks

I noticed this too. It's strange that C::B is still generating a folder inside C:\Documents and Settings folder. Need to investigate further.

...
[/quote]

CodeSnippets may be doing that. In the old days, it used to crash on first run of Codeblocks because the config folder was not created yet.

I'll have a look.

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Portable Code::Blocks
« Reply #8 on: April 07, 2009, 05:20:50 pm »
Before testing, I delete the folder
C:\Documents and Settings\My name\Application Data\codeblocks

But once the CbLauncher.exe runs, the folder will be automatically generated again.  :(.

By the way, I also find another folder here, ( I just deleted it, maybe, it is related to the bug you have fixed. :D)
C:\Documents and Settings\My name\AppData\codeblocks

I noticed this too. It's strange that C::B is still generating a folder inside C:\Documents and Settings folder. Need to investigate further.

...

CodeSnippets may be doing that. In the old days, it used to crash on first run of Codeblocks because the config folder was not created yet.

I'll have a look.

Thanks a lot Pecan. Hope to hear from you soon. :)
Be a part of the solution, not a part of the problem.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Portable Code::Blocks
« Reply #9 on: April 08, 2009, 03:44:52 pm »
I meet a bug in portable c::b.

I just click Menu->Settings->Editor, then c::B will crash. :(

Edit:

I revert to "nightly build version" and no crash there :D
« Last Edit: April 08, 2009, 05:13:03 pm by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Portable Code::Blocks
« Reply #10 on: April 08, 2009, 06:05:48 pm »
I meet a bug in portable c::b.

I just click Menu->Settings->Editor, then c::B will crash. :(

Edit:

I revert to "nightly build version" and no crash there :D

This was due to a make dist bug. As I generated source tarball and then compiled it, and in generated source tarball one resource file was missing. That was causing this crash.

I'm attaching a new resource file. Download & Paste it inside share\codeblocks folder and crash will vanish.

At the moment I don't have time to reupload a new binary (It's almost midnight here). Tomorrow I'll try to make a clean build and reupload it. :)

[attachment deleted by admin]
Be a part of the solution, not a part of the problem.

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Portable Code::Blocks
« Reply #11 on: April 11, 2009, 05:32:55 pm »
I've uploaded a new binary to the following link.

Quote
http://files.filefront.com/Portable+CB+5526+bin7z/;13582845;/fileinfo.html

Package comes with an updated launcher. New launcher is tagged as v0.1.1. Previous bug reported by OllyDbg have been fixed. Also now console window will be closed after launching C::B.
Be a part of the solution, not a part of the problem.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Portable Code::Blocks
« Reply #12 on: April 11, 2009, 05:48:04 pm »
I've uploaded a new binary to the following link.

Quote
http://files.filefront.com/Portable+CB+5526+bin7z/;13582845;/fileinfo.html

Package comes with an updated launcher. New launcher is tagged as v0.1.1. Previous bug reported by OllyDbg have been fixed. Also now console window will be closed after launching C::B.

Thanks for your effort. I will download and test it. :D

Edit:
I'm not sure you encountered the problem: dragging the toolbar vertically will make CB crash. :( This bug exists for many months.
« Last Edit: April 11, 2009, 06:18:01 pm by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Portable Code::Blocks
« Reply #13 on: April 13, 2009, 05:39:58 pm »
Edit:
I'm not sure you encountered the problem: dragging the toolbar vertically will make CB crash. :( This bug exists for many months.

I didn't experience this crash.

I've committed this patch to trunk. You'll be able to download next nightly and use CbLauncher to run Code::Blocks in a portable manner.
Be a part of the solution, not a part of the problem.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Portable Code::Blocks
« Reply #14 on: April 14, 2009, 03:36:35 am »
I think the CbLauncher.exe 0.11 version should be uploaded so the people don't need to download the whole package from:

http://files.filefront.com/Portable+CB+5526+bin7z/;13582845;/fileinfo.html

About the dragging toolbar crash:
I still meet this crash every time :(. So frustrated.

In the post, mmkider suggested using an old wxWidgets DLL, but this crash still exists in wxWidgets DLL 2.8.10. :(
http://forums.codeblocks.org/index.php/topic,9648.msg67823.html#msg67823

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.