Page 1 of 1

Compilation of RT-Win32-Simulator demo with Visual Studio

Posted: Sun Jul 05, 2020 5:10 pm
by dismirlian
Hi all, I attach a patch for the stable_20.3.x branch, with minor modifications:

- Adapt some sources to be able to compile with MSVC
- Add a Visual Studio project to the RT-Win32-Simulator demo (demos/various/RT-Win32-Simulator/visual-studio).

This enables compilation with Visual Studio (which is a great IDE, btw). Tested with Visual Studio Community Edition 2019.

Thanks!
Diego.

Re: Compilation of RT-Win32-Simulator demo with Visual Studio

Posted: Sun Jul 05, 2020 5:20 pm
by Giovanni
Hi,

Few problems:

1) Cannot put MSVC code in files under compilers/GCC, you need to split the directories, create a compilers/MSVC.

2) Do not make conditional changes that would also work with GCC. In general minimize conditionals.

3) XML based projects are going to break as soon there is a change in files structure. If possible use makefiles.

Giovanni

Re: Compilation of RT-Win32-Simulator demo with Visual Studio

Posted: Sun Jul 05, 2020 5:37 pm
by dismirlian
Hi Giovanni,

1) There are no new files under compilers/GCC, I effectively created compilers/MSVC; where do you see this problem?

2) Ok, I'll try to fix/minimize those.

3) I don't know any way of using makefiles with VS, keeping the Intellisense/IDE tools working well. Do you know how to do this?

Thanks,
Diego.

Re: Compilation of RT-Win32-Simulator demo with Visual Studio

Posted: Sun Jul 05, 2020 5:44 pm
by Giovanni
1) I looked at the patch, perhaps I am wrong.

2) OK.

3) No idea, I don't use it, this is why it would break unless it is maintained.

Giovanni

Re: Compilation of RT-Win32-Simulator demo with Visual Studio

Posted: Sun Jul 05, 2020 8:26 pm
by dismirlian
Hi Giovanni,

2) New patch attached.

3) IMHO there is no inherent benefit in compiling with MSVC instead of GCC. The only reason I wanted this is because Visual Studio is really great for development, especially for developing the application logic, and Visual Studio handles MSVC very "naturally". I know that the XML project is not great... Even if you don't merge it, maybe someone finds this useful.

Thanks!
Diego.

Re: Compilation of RT-Win32-Simulator demo with Visual Studio

Posted: Sun Jul 05, 2020 9:34 pm
by Giovanni
Hi,

Please don't misunderstand me, it is welcome, note that when I FIST ran ChibiOS it was in what then become the "Win32 simulator", it was in 2006 and I used Visual Studio.... then ported it to ARM.

Code compatibility is good, the only problem I can see is that the project is going to break like it happens (a lot) with Keil and IAR projects. Rebuild those after tree changes is a PITA.

Giovanni

Re: Compilation of RT-Win32-Simulator demo with Visual Studio

Posted: Mon Jul 06, 2020 6:03 pm
by dismirlian
Hi Giovanni, no problem, I know you welcome contributions!

What I meant is:
- The changes in os/... should not have a high maintenance impact; it only allows MSVC to compile the code.
- The project itself (under demos/), which may have maintenance impact, could go as a .zip in the forum or in the ChibiOS-Contrib repository.

What do you think?

Diego.

Re: Compilation of RT-Win32-Simulator demo with Visual Studio

Posted: Mon Jul 06, 2020 6:33 pm
by Giovanni
It is OK, I can also include the project knowing it may break.

Giovanni

Re: Compilation of RT-Win32-Simulator demo with Visual Studio

Posted: Mon Jul 06, 2020 8:17 pm
by dismirlian
Hi Giovanni,

I split the patch in two:
1. enable_compilation_with_msvc: fixes compilation with MSVC for IA32 architecture.
2. rt_win32_simulator_visual_studio_project: Visual Studio project for the RT-Win32-Simulator demo project.

Thanks!
Diego.