Author Topic: Compiler Plugin: Plan to add compiler for MSys2  (Read 3026 times)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5870
    • My Best Post
Compiler Plugin: Plan to add compiler for MSys2
« on: October 23, 2016, 05:34:18 pm »
I am planning to add a Compiler toolchain settings for the MSys2's GCC Compiler.

The planned name is "msys2-gcc". This is one of the things that will be hard to changed; so, I need to confirm the name is OK?
The planned title is "MSys2 GCC".

I plan to add an variable expansion of "$(TARGET_COMPILER_PREFIX)". http://wiki.codeblocks.org/index.php/Variable_expansion

I, also, plan to add variable expansion of "$(TARGET_WORKING_DIR)".

Both of the above variable expansions are going to use forward slashes instead of backslashes.

On my computer, "$(TARGET_COMPILER_DIR)" is "C:\Apps32\MSys2\mingw32\".
While the "$(TARGET_COMPILER_PREFIX)" will be "C:/Apps32/MSys2/mingw32". Notice the last slash is missing.

Tim S.

C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10118
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #1 on: October 23, 2016, 07:45:50 pm »
What is different with this compiler that it needs a separate entry?
Can't it be made as a copy of the original gcc compiler?
<debugger plugin maintainer>
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5870
    • My Best Post
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #2 on: October 23, 2016, 09:28:53 pm »
What is different with this compiler that it needs a separate entry?
Can't it be made as a copy of the original gcc compiler?

No; but, it might be able to be a copy of the CygWin compiler.
I am just planning on copying the three CygWin compiler files (cpp, h, and xml).
I could instead just edit the three CygWin files instead of copying them.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5870
    • My Best Post
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #3 on: October 23, 2016, 09:37:25 pm »
Ah, I think you mean I should try to create two xml files; instead of doing it the way the Cygwin compiler did it.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10118
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #4 on: October 23, 2016, 11:28:38 pm »
No, I mean exactly: why do we need to have this as a separate compiler in the list of compilers?
Isn't this just another gcc compiler? So a user will set it up just by adjusting the toolchain paths for a gcc compiler.
If we need to improve autodetection for it we should do so and not add another compiler in the already very long list of compilers most users have no idea what to do with!

Probably we should modify this dialog to make users add compilers in the list and not stick them by default there... but this is a bit more complex task...
<debugger plugin maintainer>
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5870
    • My Best Post
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #5 on: October 23, 2016, 11:51:34 pm »
OK, I now understand what you mean; so, I will just work on adding the two macros that I seem to need using the MSys2's GCC.

And, I will work on directions to edit the existing "GCC" or "CYGWIN" compiler to use the MSys2's GCC; the changes are NOT that great; so, I can see NOT having the compiler installed by default by the CB Dev installer.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5870
    • My Best Post
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #6 on: October 24, 2016, 12:01:17 am »
Probably we should modify this dialog to make users add compilers in the list and not stick them by default there... but this is a bit more complex task...

This does sound like the best newbie friendly way to solve the compiler list being so wrong long.

Any, ideas on the short list of compiler to have installed?
These two "null" and "gcc" are needed in the list; but, what others should default to being checked.
And, what is the name to be used to name this list? I feel compiler list is misleading.
CB Toolchain list?

Tim S.


C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10118
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #7 on: October 24, 2016, 12:23:22 am »
Any, ideas on the short list of compiler to have installed?
These two "null" and "gcc" are needed in the list; but, what others should default to being checked.
The list should be empty if the autodetector hasn't found a compiler.

And, what is the name to be used to name this list? I feel compiler list is misleading.
Why do you think it should be a list? It should be in a new dialog hidden behind an Add button in just below the selected compiler combo box we have now.
<debugger plugin maintainer>
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5870
    • My Best Post
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #8 on: October 24, 2016, 12:41:17 am »
Any, ideas on the short list of compiler to have installed?
These two "null" and "gcc" are needed in the list; but, what others should default to being checked.
The list should be empty if the autodetector hasn't found a compiler.

And, what is the name to be used to name this list? I feel compiler list is misleading.
Why do you think it should be a list? It should be in a new dialog hidden behind an Add button in just below the selected compiler combo box we have now.

Ah, you thinking a runtime GUI option, I was thinking Windows Installer option to select which ones to install.
But, your method would be better.

Tim S.

C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10118
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #9 on: October 24, 2016, 01:12:57 am »
Of course it will be a GUI option. We don't want to bundle more than one compiler in the installer.
<debugger plugin maintainer>
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5870
    • My Best Post
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #10 on: October 24, 2016, 01:14:55 am »
How about another check box on the "Global Compiler Setting" "Other Settings" ?
Right above or below the "Enable non-platform compilers".

Tim S.

C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5870
    • My Best Post
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #11 on: October 24, 2016, 01:25:18 am »
How about another check box on the "Global Compiler Setting" "Other Settings" ?
Right above or below the "Enable non-platform compilers".

Tim S.

I would like a option to disable auto compiler detection and this sounds like a good place to add this, also.

I will see how hard it is to add this feature(s).

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5870
    • My Best Post
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #12 on: October 24, 2016, 01:37:43 am »
How about another check box on the "Global Compiler Setting" "Other Settings" ?
Right above or below the "Enable non-platform compilers".

Tim S.

I have thought about it and I think the new options should go with the "Enable non-platform compilers"; but, it seems that the location of "Enable non-platform compilers" might be in the wrong place.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5870
    • My Best Post
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #13 on: October 24, 2016, 02:16:31 am »
Looks like check box needed could be called
Show only Detected or user-defined Compilers.

Problem seems to be that the information is NOT currently saved.
I am thinking adding two bools to the Compiler class.
one is set to true if compiler is detected.
The second set to true if compiler is user-defined.

Tim S.
 
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10118
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #14 on: October 24, 2016, 03:12:22 am »
Why do you want to introduce this complexity instead of just adding a field if the compiler is enabled? You'll have to add such field anyway. And then add the simple dialog where the user can select the needed compilers. And lastly add some logic to show this dialog if C::B detects if the user has old config.

Is the default GCC compiler user-defined using your logic? Will it be removed from everybody's list of compilers if this change is added to C::B?
<debugger plugin maintainer>
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5870
    • My Best Post
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #15 on: October 24, 2016, 04:06:54 am »
Why do you want to introduce this complexity instead of just adding a field if the compiler is enabled? You'll have to add such field anyway. And then add the simple dialog where the user can select the needed compilers. And lastly add some logic to show this dialog if C::B detects if the user has old config.

Is the default GCC compiler user-defined using your logic? Will it be removed from everybody's list of compilers if this change is added to C::B?

user-defined is what the auto detect window calls it; me I would throw out the auto detect and just add a field like you suggest. But, that does NOT seem to match the autodetect windows that is displayed on startup when it detects new/missing compilers.

Tim S.

C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5870
    • My Best Post
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #16 on: October 24, 2016, 05:22:46 am »
Why do you want to introduce this complexity instead of just adding a field if the compiler is enabled? You'll have to add such field anyway. And then add the simple dialog where the user can select the needed compilers. And lastly add some logic to show this dialog if C::B detects if the user has old config.

Is the default GCC compiler user-defined using your logic? Will it be removed from everybody's list of compilers if this change is added to C::B?

user-defined is what the auto detect window calls it; me I would throw out the auto detect and just add a field like you suggest. But, that does NOT seem to match the autodetect windows that is displayed on startup when it detects new/missing compilers.

Tim S.

Decided on a less GUI change method.
Add a checkbox called "Do not show missing compilers" which are the ones marked Not-Found by the auto detect window.

I can do most of the code changes in a single function called by DoRegisterCompilers, by verifying the compiler installation directory exists.
If it does NOT exist remove it from the list of compilers.

Edit: Decided to change
 void CompilerFactory::RegisterCompiler(Compiler* compiler)
to
 void CompilerFactory::RegisterCompiler(Compiler* compiler, bool found = false)

When found equals true it only Registers the Compiler if the master path of the compiler exists.

Tim S.
« Last Edit: October 24, 2016, 05:45:32 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5870
    • My Best Post
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #17 on: October 24, 2016, 07:48:11 am »
Link to the patch that still needs a lot of work https://github.com/stahta01/cb_misc/blob/master/Patches/svn/reduceList.patch

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10118
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #18 on: October 24, 2016, 09:55:08 am »
1. How do I enable not found compiler? I've installed one in non-default location and want to use it for example.
2. How do I disable found compiler I don't care for?
3. Why are you mixing addition of msys2-mingw and the autodetection changes in this patch?
4. Can you install this new compiler on linux? I doubt, but just want to ask.
5. Default parameter values is better to not be used.
<debugger plugin maintainer>
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5870
    • My Best Post
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #19 on: October 24, 2016, 02:19:58 pm »
1. How do I enable not found compiler? I've installed one in non-default location and want to use it for example.

I have yet to do the GUI changes; at current time I am using the "Enable non-platform compilers".

2. How do I disable found compiler I don't care for?

Set the master path to an invalid path will do it.

3. Why are you mixing addition of msys2-mingw and the autodetection changes in this patch?

Speed, the final patch will split those two xml files out.

4. Can you install this new compiler on linux? I doubt, but just want to ask.

Not likely.

5. Default parameter values is better to not be used.

Should I make a second function with the same name; but, two parameters or use a different name?
I think using the same name is better.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5870
    • My Best Post
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #20 on: October 24, 2016, 03:34:37 pm »
Decided to add a second checked box named something like "Do not show disabled Compilers" to add the feature you want.

Will use new name for the method I edited called something like "conditionalRegisterCompiler".
And, move the reading of the GUI setting inside it.

So, my patch will need to be changed a lot.

I will be working on the GUI changes and then do the code changes.

Edit: For some unknown reason the "GNU GCC Compiler for ARM" is still being displayed in the list.
I would guess it has a broken IsValid method.

Tim S.
« Last Edit: October 24, 2016, 06:01:55 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5870
    • My Best Post
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #21 on: October 24, 2016, 06:09:07 pm »
Attached patch that still needs work.

It is missing any GUI button to disable a Compiler. That is the next thing for me to add.
Button called "Disable"? I will look back at your posts to see where you wanted the button.

And, it has commented out code in it.

Please verify my changes to compiler.h file?
And, I edited compiler_options.xrc directly, is there an wxSmith file I should edit instead?

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5870
    • My Best Post
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #22 on: October 24, 2016, 06:16:14 pm »
It should be in a new dialog hidden behind an Add button in just below the selected compiler combo box we have now.

Adding a Dialog is beyond what I feel up to doing at this time; but, it does make more sense than an "Disable" button like I was thinking of doing.

I am a C Programming who does almost no GUI programming.

I will see if any of the wx Dialogs I know about can be adapted to do what you want; but, I will NOT have time for a few weeks.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5870
    • My Best Post
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #23 on: October 24, 2016, 06:28:04 pm »
It should be in a new dialog hidden behind an Add button in just below the selected compiler combo box we have now.

Adding a Dialog is beyond what I feel up to doing at this time; but, it does make more sense than an "Disable" button like I was thinking of doing.

I am a C Programming who does almost no GUI programming.

I will see if any of the wx Dialogs I know about can be adapted to do what you want; but, I will NOT have time for a few weeks.

Tim S.

Would it look OK if I moved the "selected compiler combo box" a little to the right and have the button to the left of it?
I think the dialog will be used to "adjust the compilers listed" for the hint; no idea about the button name.

I will have to look at the code behind the  "selected compiler combo box" and do research on wx combo boxes.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10118
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #24 on: October 24, 2016, 09:08:45 pm »
I don't like the idea of the checkboxes at all as already mentioned.

About default parameters - just make it non-default and pass the correct value at every call site. There is no need for a separate function.
<debugger plugin maintainer>
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5870
    • My Best Post
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #25 on: October 25, 2016, 03:18:47 pm »
I will research some of the C++ and wx Classes that can be used to replace the class used under CompilerFactory.
I think it will be easier to add the feature you want by changing that class; and, I can then add the feature I want to the new class.

So, I will be planning on changing this line below; and doing other stuff needed to add your feature.

Code: [Select]
WX_DEFINE_ARRAY(Compiler*, CompilersArray);

Looks like I will need to create an wxChoice box that only holds the compilers to be displayed in the compiler list.
And, I will create an wxList to display all the registered compilers; and use that list to select the compilers to be displayed.

I know almost nothing about how to use the wx classes wxChoice, wxList, and wxComboBox.

Files that I need to remember to edit or verify they still work right after my changes include:
src\plugins\compilergcc\compileroptionsdlg.cpp
src\plugins\scriptedwizard\compilerpanel.cpp     I have no idea where the compiler list in scripted wizard gets its data.


I have decided to add an new GUI entry in the "Compiler Settings" windows either above or below "Batch Builds" called "Compiler List" to do the GUI stuff for this feature. The "Global Compiler Settings"/"Project build Options" is just to busy to add anything to it.

I will likely move or remove the option "Enable non-platform Compiler" from the "Other settings Tab".

Tim S.


C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5870
    • My Best Post
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #26 on: October 25, 2016, 03:39:23 pm »
I am going to create an class called "CompilerList" or "cbCompilerList" and fill that with the registered compiler list and then give options to delete compilers from the list. This will be my next attempt at coding the feature you want.

Buttons likely to be on the Compiler List GUI include
Add  All              to add all the registered compilers to the list.
Auto Remove     to remove invalid compilers from the list using the compiler class isValid method
Remove             to delete the selected compilers from the list.
Save                 save the compiler in the list to external location on harddrive
Cancel/Load      to load list from external location on the harddrive

Will post a link to my Git repo in which I am going the work when I make progress; likely be a few days.
My Linux partition was broken by Windows 10; so, I need to either fix Linux or figure out a safe way to update Git repo on Windows.
Edit: Fixed Linux; was able to do apt upgrade and that fixed the no GUI on Linux (I had thought it was NOT booting at all).

Tim S.
« Last Edit: October 26, 2016, 11:56:17 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5870
    • My Best Post
Re: Compiler Plugin: Plan to add compiler for MSys2
« Reply #27 on: November 17, 2016, 10:59:54 pm »
I edited the CompilerFactory adding what I thought was good code; but, it does nothing.

I am going to try again in a few weeks; but, I think the issue is user error.

Looks like I need to learn more C++ and wxWidgets events.
And, how to use CB to debug CB plugins.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org