News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

New Variable to support wx-config in MSys2 MinGW

Started by stahta01, May 18, 2022, 11:09:29 PM

Previous topic - Next topic

stahta01

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.


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

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


Extra setting entry example

`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

$(TARGET_COMPILER_DIR)../usr/bin
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

ollydbg

Hi, Tim, thanks, I am also interested on this usage.

But:

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?
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.

stahta01

Quote from: ollydbg on May 19, 2022, 07:10:00 AM
Hi, Tim, thanks, I am also interested on this usage.

But:

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.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

ollydbg

Quote from: stahta01 on May 19, 2022, 07:30:32 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.
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.

ollydbg

I just did some test:


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?
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.

ollydbg

There is a command named "cygpath", which can do such convert

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.
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.

ollydbg


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.
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.

stahta01

#7
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.

$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.

C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

stahta01

#8

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.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

ollydbg

Hi, Tim, you method works under C::B.

I just add the below line to the linker option:


`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?

Quote from: stahta01 on May 19, 2022, 09:36:32 AM

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.
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.

ollydbg

Another question:

Why do you need a custom variable like WX_CONFIG?

In my previous post, I don't use a custom variable.
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.

stahta01

#11
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.

Quote from: 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.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

stahta01

#12
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.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

ollydbg

Quote from: 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.

Quote from: 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.

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.
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.

ollydbg

Quote from: stahta01 on May 19, 2022, 03:47:00 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?
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.