Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: stahta01 on May 18, 2022, 11:09:29 pm

Title: New Variable to support wx-config in MSys2 MinGW
Post by: stahta01 on May 18, 2022, 11:09:29 pm
I am working on upgrading wxWidgets version to 3.1.6 in MSys2.

While doing that I tested how to use wx-config-3.1.

And, CB still needs a patch to make it easy to do.

Code
Index: src/sdk/macrosmanager.cpp
===================================================================
--- src/sdk/macrosmanager.cpp (revision 12814)
+++ src/sdk/macrosmanager.cpp (working copy)
@@ -394,6 +394,8 @@
             wxFileName MasterPath;
             MasterPath.SetPath(c->GetMasterPath(), wxPATH_NATIVE);
             m_Macros[_T("TARGET_COMPILER_DIR")] = MasterPath.GetPathWithSep(wxPATH_NATIVE);
+            m_Macros[_T("TARGET_COMPILER_UNIX_PATH")] = MasterPath.GetPath(wxPATH_GET_VOLUME, wxPATH_UNIX);
+            m_Macros[_T("TARGET_COMPILER_VOLUME")] = MasterPath.GetVolume();
         }
         m_Macros[_T("TARGET_OBJECT_DIR")] = target->GetObjectOutput();
     }

TARGET_COMPILER_UNIX_PATH is like TARGET_COMPILER_DIR but, it always uses forward slashes and does not have a slash at the end. And, it does not show the drive letter like I thought it would.

So, I also added TARGET_COMPILER_VOLUME which will be just the drive letter.

custom variable
Code
WX_CONFIG=wx-config-3.1 --prefix=$(TARGET_COMPILER_VOLUME):$(TARGET_COMPILER_UNIX_PATH)

Extra setting entry example
Code
`sh.exe -c '$(WX_CONFIG) --cflags'`

Global Compiler Additional paths; this may be needed with wxWidgets 3.1.6; might not be needed with 3.1.5 msys2 library
Code
$(TARGET_COMPILER_DIR)../usr/bin
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: ollydbg on May 19, 2022, 07:10:00 am
Hi, Tim, thanks, I am also interested on this usage.

But:

Code
WX_CONFIG=wx-config-3.1 --prefix=$(TARGET_COMPILER_VOLUME):$(TARGET_COMPILER_UNIX_PATH)

Do we need two variables? I mean maybe we only need one variable to handle this?
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: stahta01 on May 19, 2022, 07:30:32 am
Hi, Tim, thanks, I am also interested on this usage.

But:

Code
WX_CONFIG=wx-config-3.1 --prefix=$(TARGET_COMPILER_VOLUME):$(TARGET_COMPILER_UNIX_PATH)

Do we need two variables? I mean maybe we only need one variable to handle this?

The logic would need to be more complex to have only one variable and a few years back a posted a patch that used only one and it was never applied.

If you wish to do a more complex patch feel free. I thought that having an variable that was useful under Linux would help get the change applied.

Tim S.
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: ollydbg on May 19, 2022, 07:44:54 am
The logic would need to be more complex to have only one variable and a few years back a posted a patch that used only one and it was never applied.

Can you tell me where is the "posted patch", thanks!

I will have a look at that patch.
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: ollydbg on May 19, 2022, 08:21:38 am
I just did some test:

Code
F:\code>sh.exe -c 'wx-config-3.1 --prefix=F:/code/msys2-64/mingw64/ --libs all'
-LF:/code/msys2-64/mingw64//lib   -pipe -Wl,--dynamicbase,--high-entropy-va,--nxcompat,--default-image-base-high -Wl,--subsystem,windows -mwindows -lwx_mswu_xrc-3.1 -lwx_mswu_webview-3.1 -lwx_mswu_stc
-3.1 -lwx_mswu_richtext-3.1 -lwx_mswu_ribbon-3.1 -lwx_mswu_propgrid-3.1 -lwx_mswu_aui-3.1 -lwx_mswu_gl-3.1 -lwx_mswu_html-3.1 -lwx_mswu_qa-3.1 -lwx_mswu_core-3.1 -lwx_baseu_xml-3.1 -lwx_baseu_net-3.1
-lwx_baseu-3.1

F:\code>sh.exe -c 'wx-config-3.1 --prefix=F:\code\msys2-64\mingw64\ --libs all'


So, you can see, we only need the "/" (forward slash) path separator version of the TARGET_COMPILER_DIR?
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: ollydbg on May 19, 2022, 08:29:22 am
There is a command named "cygpath", which can do such convert

Code
F:\code>cygpath -m F:\code\msys2-64\mingw64\
F:/code/msys2-64/mingw64/

So, either we can define a new variable like "TARGET_COMPILER_DIR_UNIX_SEP" or we may use the cygpath command some where.
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: ollydbg on May 19, 2022, 08:37:06 am
Code
F:\code>sh.exe -c 'wx-config-3.1 --prefix=`cygpath -m F:\code\msys2-64\mingw64\ ` --libs all'
-LF:codemsys2-64mingw64/lib   -pipe -Wl,--dynamicbase,--high-entropy-va,--nxcompat,--default-image-base-high -Wl,--subsystem,windows -mwindows -lwx_mswu_xrc-3.1 -lwx_mswu_webview-3.1 -lwx_mswu_stc-3.1
 -lwx_mswu_richtext-3.1 -lwx_mswu_ribbon-3.1 -lwx_mswu_propgrid-3.1 -lwx_mswu_aui-3.1 -lwx_mswu_gl-3.1 -lwx_mswu_html-3.1 -lwx_mswu_qa-3.1 -lwx_mswu_core-3.1 -lwx_baseu_xml-3.1 -lwx_baseu_net-3.1 -lwx
_baseu-3.1


This works, but please note that there is a space after the string "F:\code\msys2-64\mingw64\". Also, I don't know how to do this inside the C::B build option.
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: stahta01 on May 19, 2022, 08:53:23 am
Could not find what I thought I did.
But, I found a more complex solution.

Your stuff will likely fail to work; but, try doing it. Maybe you have better luck; I really do not know CB scripting and I think it might be simple using CB scripting.

If you want a better fix than fix the below so it works in setting a custom variable.
Code
$TO_UNIX_PATH{$(TARGET_COMPILER_DIR)}

Everything I try failed to work in setting a custom variable; the two lines work patch I posted yesterday.
I just recalled the changing of TARGET_COMPILER_DIR patch was posted by someone else.
I cannot remember who did it; but, it just changed the "\"  to "/" and I think it removed the trailing slash.

Tim S.

Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: stahta01 on May 19, 2022, 09:36:32 am
Code
Index: src/sdk/macrosmanager.cpp
===================================================================
--- src/sdk/macrosmanager.cpp (revision 12814)
+++ src/sdk/macrosmanager.cpp (working copy)
@@ -394,6 +394,8 @@
             wxFileName MasterPath;
             MasterPath.SetPath(c->GetMasterPath(), wxPATH_NATIVE);
             m_Macros[_T("TARGET_COMPILER_DIR")] = MasterPath.GetPathWithSep(wxPATH_NATIVE);
+            m_Macros[_T("TARGET_COMPILER_UNIX_PATH")] = MasterPath.GetVolume() +
+                     MasterPath.GetVolumeSeparator() + MasterPath.GetPath(wxPATH_GET_VOLUME, wxPATH_UNIX);
         }
         m_Macros[_T("TARGET_OBJECT_DIR")] = target->GetObjectOutput();
     }

I am building CB with the above patch; no idea if it will work; but, the wxWidgets directions implies it might.

Edit: It worked in the wx 3.1 minimal test project. No idea what it will do under wxWidgets 3.0 or under Linux.
Edit2: WX_CONFIG=wx-config-3.1 --prefix=$(TARGET_COMPILER_UNIX_PATH)

Tim S.
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: ollydbg on May 19, 2022, 02:22:03 pm
Hi, Tim, you method works under C::B.

I just add the below line to the linker option:

Code
`sh.exe -c 'wx-config-3.1 --prefix=$TO_UNIX_PATH{$(TARGET_COMPILER_DIR)} --libs all'`

and the linker works correctly(it link to the wx library supplied by msys2).

So, is the patch below still needed?

Code
Index: src/sdk/macrosmanager.cpp
===================================================================
--- src/sdk/macrosmanager.cpp (revision 12814)
+++ src/sdk/macrosmanager.cpp (working copy)
@@ -394,6 +394,8 @@
             wxFileName MasterPath;
             MasterPath.SetPath(c->GetMasterPath(), wxPATH_NATIVE);
             m_Macros[_T("TARGET_COMPILER_DIR")] = MasterPath.GetPathWithSep(wxPATH_NATIVE);
+            m_Macros[_T("TARGET_COMPILER_UNIX_PATH")] = MasterPath.GetVolume() +
+                     MasterPath.GetVolumeSeparator() + MasterPath.GetPath(wxPATH_GET_VOLUME, wxPATH_UNIX);
         }
         m_Macros[_T("TARGET_OBJECT_DIR")] = target->GetObjectOutput();
     }

I am building CB with the above patch; no idea if it will work; but, the wxWidgets directions implies it might.

Edit: It worked in the wx 3.1 minimal test project. No idea what it will do under wxWidgets 3.0 or under Linux.
Edit2: WX_CONFIG=wx-config-3.1 --prefix=$(TARGET_COMPILER_UNIX_PATH)

Tim S.
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: ollydbg on May 19, 2022, 02:35:46 pm
Another question:

Why do you need a custom variable like WX_CONFIG?

In my previous post, I don't use a custom variable.
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: stahta01 on May 19, 2022, 03:45:32 pm
It makes it easy and it is closer to the Linux projects that way.
This should make it easy to change the CB wizards.

Tim S.

Another question:

Why do you need a custom variable like WX_CONFIG?

In my previous post, I don't use a custom variable.
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: stahta01 on May 19, 2022, 03:47:00 pm
But, if the devs ignore my patch I will likely use your way without the custom variable.

I expect them to ignore my patch; so, thanks for testing the project file way only.
I likely would have tried in a month or so. But, I am really have too make to do for my time and energy.
I think I have gotten the wxWidgets 3.1.6 PR to MSys2 MinGW done, but each prior time, either, I or someone else thinks of a new thing to change. I just did the CB stuff to verify that the wxWidgets change did not break this CB stuff.

Tim S.
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: ollydbg on May 19, 2022, 04:22:03 pm
It makes it easy and it is closer to the Linux projects that way.
This should make it easy to change the CB wizards.

Tim S.

Another question:

Why do you need a custom variable like WX_CONFIG?

In my previous post, I don't use a custom variable.

OK, for me, I think adding a "TARGET_COMPILER_UNIX_PATH" macro is simple and indeed has benefit. We can use either way. A simple wx wizard is very important from my point of view.

If other devs don't have objections, I will apply your patch about "TARGET_COMPILER_UNIX_PATH". Thanks.
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: ollydbg on May 19, 2022, 04:24:05 pm

I think I have gotten the wxWidgets 3.1.6 PR to MSys2 MinGW done...

Do you have the direct2D enabled wx 3.1.6 for your PR?
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: ollydbg on May 19, 2022, 04:28:23 pm

I think I have gotten the wxWidgets 3.1.6 PR to MSys2 MinGW done...

Do you have the direct2D enabled wx 3.1.6 for your PR?
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: stahta01 on May 19, 2022, 04:50:14 pm

I think I have gotten the wxWidgets 3.1.6 PR to MSys2 MinGW done...

Do you have the direct2D enabled wx 3.1.6 for your PR?

Yep, that was one of the changes I added after the first time I did the PR.
https://github.com/msys2/MINGW-packages/pull/11631 (https://github.com/msys2/MINGW-packages/pull/11631)

Quote
Summary of the current changes

wxWidgets3.1: Update to version 3.1.6; and,

Removed MSYSTEM guard in "wx-config.in".
Redo manifest filename logic in "wx/msw/wx.rc".
The prior manifest logic failed to work under Clang64.
Add replaces "wxmsw3.1-git" package.
Add "enable-graphics-d2d" to help support Code::Blocks IDE.

Tim S.
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: PB on May 20, 2022, 11:52:17 pm

Summary of the current changes
Redo manifest filename logic in "wx/msw/wx.rc".
The prior manifest logic failed to work under Clang64.

I know virtually nothing about MSYS2 packages but I wonder why are those changes necessary?

I have tried not that long ago and wxWidgets with the unmodified wx.rc builds just fine not only with GCC (package mingw-w64-x86_64-toolchain) but also clang (package mingw-w64-clang-x86_64-toolchain)?

Is there another clang package? I admit I have no idea if that package i listed uses its own resource compiler (llvm-rc) or mingw one (windres).
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: ollydbg on May 21, 2022, 05:20:03 am
Hi, tim, I add this macro in rev12816. Thanks!
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: stahta01 on May 22, 2022, 05:20:05 pm

Summary of the current changes
Redo manifest filename logic in "wx/msw/wx.rc".
The prior manifest logic failed to work under Clang64.

I know virtually nothing about MSYS2 packages but I wonder why are those changes necessary?

I have tried not that long ago and wxWidgets with the unmodified wx.rc builds just fine not only with GCC (package mingw-w64-x86_64-toolchain) but also clang (package mingw-w64-clang-x86_64-toolchain)?

Is there another clang package? I admit I have no idea if that package i listed uses its own resource compiler (llvm-rc) or mingw one (windres).

The library builds without the change; but, some sample(s) will error without the change!
Edit: The UCRT64 use its own resource compiler (llvm-rc)

Tim S.
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: stahta01 on August 13, 2022, 04:50:15 am
Attached CB Project used to test building Code::Blocks using TARGET_COMPILER_UNIX_PATH macro.

The project started off as a copy of "CodeBlocks_wx30-unix.cbp" and was renamed to "CodeBlocks_wx32-msys2.cbp"
The primary purpose was to verify my msys2 mingw64 package had what was needed to build Code::Blocks.
Edit2: My only testing was running the built Code::Blocks and seeing if it could load all the core plugins without any errors.
Edit3: https://packages.msys2.org/base/mingw-w64-wxwidgets3.2 (https://packages.msys2.org/base/mingw-w64-wxwidgets3.2)

Contents of "updatemsys2.sh"
Code
#!/bin/sh
./update msys2

Tim S.
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: ollydbg on August 13, 2022, 09:58:11 am
Hi, Tim, thanks for your work on the msys2 and wx library.

One question:

Static libraries and headers for wxWidgets 3.2 (mingw-w64)

What is the word "static" means? Do they mean the library is not dll?

EDIT:
My guess is not correct, see this page: https://packages.msys2.org/package/mingw-w64-x86_64-wxwidgets3.2-msw-libs?repo=mingw64
It contains many dll files.
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: ollydbg on August 13, 2022, 04:00:53 pm
What is the msys2 package do we need to use this cbp?

Code
# pacman -S mingw-w64-x86_64-wxwidgets3.2-msw
# pacman -S mingw-w64-x86_64-wxwidgets3.2-msw-cb_headers

Those two packages?

EDIT:

Where is the "updatemsys2.sh"?
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: stahta01 on August 13, 2022, 05:15:56 pm
What is the msys2 package do we need to use this cbp?

Code
# pacman -S mingw-w64-x86_64-wxwidgets3.2-msw
# pacman -S mingw-w64-x86_64-wxwidgets3.2-msw-cb_headers

Those two packages?

Those and the depends of them should be enough.
You also need rsync

Quote
EDIT:

Where is the "updatemsys2.sh"?

I pasted the entire file ( 2 lines ) in code tags.

I use below to run the script file from the proper MINGW prompt
Code
./updatemsys2.sh

Edit it might make more sense just to run.
Code
./update msys2

Tim S.
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: ollydbg on August 14, 2022, 05:17:44 am
Here are some steps I need to use Tim's cbp file:

0, use pacman to install wx library (3.2)

Code
pacman -S mingw-w64-x86_64-wxwidgets3.2-msw
pacman -S mingw-w64-x86_64-wxwidgets3.2-msw-cb_headers

1, Set the compiler path to msys2's mingw 64 bit comipler, in my PC, it is

Code
F:\msys2\mingw64

and put the string

Code
$(TARGET_COMPILER_DIR)../usr/bin

In the "Additional Paths" option in the global Compiler setting.


2, open the cbp file(CodeBlocks_wx32-msys2.cbp), build.


3, in the msys2 mingw64's shell, run the command

Code
./update msys2

Note that those tools are needed to used by the "update" script

Code
pacman -S zip
pacman -S rsync


The result C::B(in the outputmsys2 folder) looks OK  :)

Note this only contains the core plugins.

BTW: it takes about 12 minutes to build the CodeBlocks_wx32-msys2.cbp on my PC, while it takes more than about 35 minutes to let the "Clangd_client" to parse all the 457 source files on my PC.  :(
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: stahta01 on August 14, 2022, 08:40:23 am
Thanks for putting the directions needed together. And, one more person confirms the wxWidgets 3.2 package works.

Tim S.
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: BlueHazzard on August 14, 2022, 06:20:35 pm
Can you put this in the wiki?
Title: Re: New Variable to support wx-config in MSys2 MinGW
Post by: stahta01 on August 14, 2022, 06:59:13 pm
Can you put this in the wiki?

I am creating more CB projects; once I am done will see if I still can edit the wiki.

Tim S.