Author Topic: New Variable to support wx-config in MSys2 MinGW  (Read 27703 times)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7696
    • My Best Post
New Variable to support wx-config in MSys2 MinGW
« 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
« Last Edit: May 18, 2022, 11:11:21 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: New Variable to support wx-config in MSys2 MinGW
« Reply #1 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?
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 stahta01

  • Lives here!
  • ****
  • Posts: 7696
    • My Best Post
Re: New Variable to support wx-config in MSys2 MinGW
« Reply #2 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.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: New Variable to support wx-config in MSys2 MinGW
« Reply #3 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.
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: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: New Variable to support wx-config in MSys2 MinGW
« Reply #4 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?
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: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: New Variable to support wx-config in MSys2 MinGW
« Reply #5 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.
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: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: New Variable to support wx-config in MSys2 MinGW
« Reply #6 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.
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 stahta01

  • Lives here!
  • ****
  • Posts: 7696
    • My Best Post
Re: New Variable to support wx-config in MSys2 MinGW
« Reply #7 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.

« Last Edit: May 19, 2022, 09:16:13 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7696
    • My Best Post
Re: New Variable to support wx-config in MSys2 MinGW
« Reply #8 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.
« Last Edit: May 19, 2022, 09:50:32 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: New Variable to support wx-config in MSys2 MinGW
« Reply #9 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.
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: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: New Variable to support wx-config in MSys2 MinGW
« Reply #10 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.
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 stahta01

  • Lives here!
  • ****
  • Posts: 7696
    • My Best Post
Re: New Variable to support wx-config in MSys2 MinGW
« Reply #11 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.
« Last Edit: May 19, 2022, 03:48:14 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7696
    • My Best Post
Re: New Variable to support wx-config in MSys2 MinGW
« Reply #12 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.
« Last Edit: May 19, 2022, 03:53:30 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: New Variable to support wx-config in MSys2 MinGW
« Reply #13 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.
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: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: New Variable to support wx-config in MSys2 MinGW
« Reply #14 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?
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.