Author Topic: codeblocks cbp projects for wx samples  (Read 8652 times)

Offline AndrewCot

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 678
Re: codeblocks cbp projects for wx samples
« Reply #15 on: September 17, 2022, 02:15:38 am »
Good work. 

Sounds like the find/replace on CBP files could be similar to what I needed and I had to create a quick simple app for my find replace as the project options manager plugin did not do what I wanted. Attached is the source and project file for my find replace app. The app changes the windows path delimiter \ to unix / for certain lines in the project files as it then makes the files similar. You may not be able to use the app for all of the required changes, but for some you will be able modify it for what you want.
I have also used Agent ransack to search the CBP files and then open them in Notepad++ using the context menu option in the Agent Ransack file list context menu, then within Notepad++I can then perform a find replace on all of the openned files.


What is the messagebox that is shown?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: codeblocks cbp projects for wx samples
« Reply #16 on: September 17, 2022, 03:08:57 am »
What is the messagebox that is shown?

See the screen shot as attachment.

I guess the executing working dir is wrong.

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: codeblocks cbp projects for wx samples
« Reply #17 on: September 17, 2022, 03:36:13 am »
Good work. 

Sounds like the find/replace on CBP files could be similar to what I needed and I had to create a quick simple app for my find replace as the project options manager plugin did not do what I wanted. Attached is the source and project file for my find replace app. The app changes the windows path delimiter \ to unix / for certain lines in the project files as it then makes the files similar. You may not be able to use the app for all of the required changes, but for some you will be able modify it for what you want.
I have also used Agent ransack to search the CBP files and then open them in Notepad++ using the context menu option in the Agent Ransack file list context menu, then within Notepad++I can then perform a find replace on all of the openned files.


I now using find/replace tool in Notepad++ to tweak all the cbp files, and it looks the result cbp works correctly.
I can open the samples.workspace file, and active a single cbp project, and build that project.
I have push all my changes to my git repo now.

asmwarrior/cb_projects_for_wxWidgets: Code::Blocks projects for building wxWidgets sample code

BTW: where is your Attached file? I guess your forgot it.  :)
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 AndrewCot

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 678
Re: codeblocks cbp projects for wx samples
« Reply #18 on: September 17, 2022, 04:11:17 am »
Attach file.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: codeblocks cbp projects for wx samples
« Reply #19 on: September 17, 2022, 04:39:46 am »
What is the messagebox that is shown?

See the screen shot as attachment.

I guess the executing working dir is wrong.

About this issue, currently, there are two folders setting, for example, the caret.cbp file has such content:

Code
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="caret" />
<Option execution_dir="../minimal" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="win_gcc">
<Option output="bin/$(TARGET_NAME)/$(PROJECT_NAME)" prefix_auto="1" extension_auto="1" />
<Option working_dir="../../caret" />
<Option object_output=".objs/$(TARGET_NAME)" />
<Option type="0" />
<Option compiler="gcc" />
<Option projectLinkerOptionsRelation="2" />
<Compiler>
<Add option="-O2" />
<Add option="`$(#WX_CONFIG) --cflags`" />
</Compiler>
<Linker>
<Add option="-s" />
<Add option="`$(#WX_CONFIG) --libs base,core,adv`" />
</Linker>
</Target>
</Build>
<VirtualTargets>
<Add alias="All" targets="win_gcc;" />
</VirtualTargets>
<Unit filename="caret.cpp" />
<Extensions />
</Project>
</CodeBlocks_project_file>

What do you think about the correct value of "execution_dir" and "working_dir"?

The current dir where the cbp file locates? So, the value could be "../caret"?  or just "./" ?

EDIT

I choose the later one, I just use the notepad++'s search/replace feature

search this(with regex enabled)

Code
working_dir="(.*)"
and replace by this:
Code
working_dir="./"

I have pushed my changes to my repo.
« Last Edit: September 17, 2022, 05:21:20 am 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 AndrewCot

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 678
Re: codeblocks cbp projects for wx samples
« Reply #20 on: September 17, 2022, 05:38:26 am »
I have never seen or used the "execution_dir". As such I would delete it, unless it is really required. You can comment it out for the time being (<!-- Option execution_dir="../minimal" -->).

In the C::B plugin build project files some did not have an entry for the "working_dir", but where it did exist it was set to the same directory as the "output" where I looked. I would either remove it or set it to $(TARGET_OUTPUT_DIR) so that you do not have to update two lines in the project file going forward if you change the output directory.


Some other changes could be:
1. As they are sample apps I would change the compiler options to enable debugging and no optimisation (-g -O0 -ggdb) plus remove the linker "-s" option.
2. Add a "<Option default_target="TBA" />"
3. Remove the target "<Option compiler="gcc" />" option so that there is only one at the project level

I have not done this or tried this, but you could add a <ExtraCommands> before to check that the $(#WX_CONFIG) is defined and if not the use the script expansion facility to pop up a message dialog to indicate that they have to set the global variable. See https://wiki.codeblocks.org/index.php/Variable_expansion for the script expansion info/example.



BTW I should update my project files to change the working_dir to $(TARGET_OUTPUT_DIR). I will update my bulk CBP app to make the change in the next day or two.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: codeblocks cbp projects for wx samples
« Reply #21 on: September 17, 2022, 06:00:51 am »
I have never seen or used the "execution_dir". As such I would delete it, unless it is really required. You can comment it out for the time being (<!-- Option execution_dir="../minimal" -->).

In the C::B plugin build project files some did not have an entry for the "working_dir", but where it did exist it was set to the same directory as the "output" where I looked. I would either remove it or set it to $(TARGET_OUTPUT_DIR) so that you do not have to update two lines in the project file going forward if you change the output directory.


Some other changes could be:
1. As they are sample apps I would change the compiler options to enable debugging and no optimisation (-g -O0 -ggdb) plus remove the linker "-s" option.
2. Add a "<Option default_target="TBA" />"
3. Remove the target "<Option compiler="gcc" />" option so that there is only one at the project level

I have not done this or tried this, but you could add a <ExtraCommands> before to check that the $(#WX_CONFIG) is defined and if not the use the script expansion facility to pop up a message dialog to indicate that they have to set the global variable. See https://wiki.codeblocks.org/index.php/Variable_expansion for the script expansion info/example.



BTW I should update my project files to change the working_dir to $(TARGET_OUTPUT_DIR). I will update my bulk CBP app to make the change in the next day or two.

Thanks for the suggestion, I will do what I believe is simple and make some find/replace operation.  ;)
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: codeblocks cbp projects for wx samples
« Reply #22 on: September 17, 2022, 12:27:44 pm »
Now, I see there are about 100 sample folders in the wx, and most of the samples can be built and run by opening the cbp(or the toplevel samples.workspace) and C::B now.

 :)

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: codeblocks cbp projects for wx samples
« Reply #23 on: October 09, 2022, 10:11:21 am »
Some good news:

The cbp projects also works under the self build wx library.

For example, you local build wx library is in F:/code/wxWidgets-3.2.1, and you build command could be:

Code
mingw32-make -f makefile.gcc SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1 VENDOR=cb


You need the "wx-config.exe" from https://github.com/eranif/wx-config-msys2

What I need to do is:

Open the C::B's Menu->Settings->Global variables

Change the wx_config's base value to something like:

Code
wx-config.exe --prefix=F:/code/wxWidgets-3.2.1 --wxcfg=gcc_dll/mswu

Then, you can build those samples linking to you local build wx.
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.