Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable VT code based highlighting on Windows if supported #1146

Merged
merged 4 commits into from
Aug 25, 2024

Conversation

seanmcleod
Copy link
Member

No description provided.

Copy link

codecov bot commented Aug 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 25.13%. Comparing base (dbf2eec) to head (e0f465c).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1146   +/-   ##
=======================================
  Coverage   25.13%   25.13%           
=======================================
  Files         170      170           
  Lines       18325    18325           
=======================================
  Hits         4606     4606           
  Misses      13719    13719           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bcoconni
Copy link
Member

The compilation fails on MinGW. It seems the constant ENABLE_VIRTUAL_TERMINAL_PROCESSING is not recognized.

@seanmcleod
Copy link
Member Author

Yep, busy looking at it. Bit weird. Not sure if MinGW is making use of some other set, possibly older set of Windows header files compared to the MSVC builds.

I never made any changes to the set of Windows specific header files to get this code to build on MSVC. So suspecting MinGW may be using an older set before this define was included.

jsbsim/src/JSBSim.cpp

Lines 60 to 69 in dbf2eec

#if defined(__BORLANDC__) || defined(_MSC_VER) || defined(__MINGW32__)
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# include <mmsystem.h>
# include <regstr.h>
# include <sys/types.h>
# include <sys/timeb.h>
#else
# include <sys/time.h>
#endif

@seanmcleod
Copy link
Member Author

The define was added to the Windows 10 SDK around 2017.

@seanmcleod
Copy link
Member Author

Where and how do we install MinGW?

I thought it might be pre-installed in the windows-2019 runner that we use, but don't see it listed here:

https://github.com/actions/runner-images/blob/main/images/windows/Windows2019-Readme.md

No immediate, obvious section in here that I spot in terms of installing MinGW.

https://github.com/JSBSim-Team/jsbsim/blob/master/.github/workflows/cpp-python-build.yml

@bcoconni
Copy link
Member

bcoconni commented Aug 24, 2024

I thought it might be pre-installed in the windows-2019 runner that we use, but don't see it listed here

Well, MinGW is also a name for "compiling with the gcc compiler on Windows". So in the document you mentioned, the windows-2019 runner is using gcc 8.1.0. And according to godotengine/godot#58595 (comment), the flag ENABLE_VIRTUAL_TERMINAL_PROCESSING is supported since 7.0.0.

@bcoconni
Copy link
Member

In the link I mentioned above they say that ENABLE_VIRTUAL_TERMINAL_PROCESSING was introduced by commit mirror/mingw-w64@1b29d1b. So it seems that ENABLE_VIRTUAL_TERMINAL_PROCESSING is defined in the header <wincon.h> for MinGW/gcc.

@bcoconni
Copy link
Member

OK I think I've found the issue. Still in the link I mentioned previously they say:

GCC version is irrelevant, but GCC 8.x is 4 years old and might be shipped with the old MinGW headers 6.0.0.

ENABLE_VIRTUAL_TERMINAL_PROCESSING should be available in the MinGW headers 7.0.0+ (current version is 9.0.0).

And since the windows-2019 runner is using gcc 8.1.0 it means that it is using a version of MinGW older than 7.0.0 i.e. which does not define ENABLE_VIRTUAL_TERMINAL_PROCESSING.

@seanmcleod
Copy link
Member Author

Talking of windows-2019 runner, I've been wondering if we should switch to windows-2022 to move from Visual Studio 2019 to Visual Studio 2022, or whether there is a specific or good reason to stick with 2019.

@bcoconni
Copy link
Member

Talking of windows-2019 runner, I've been wondering if we should switch to windows-2022 to move from Visual Studio 2019 to Visual Studio 2022, or whether there is a specific or good reason to stick with 2019.

Well, the idea is to support the oldest platform available to support users that cannot upgrade their platform for whatever reason. It's the same idea that makes the script support all versions of Python since 3.8.

@seanmcleod
Copy link
Member Author

Well, the idea is to support the oldest platform available to support users that cannot upgrade their platform for whatever reason.

What sort of support are we thinking of? If we compile JSBSim on github using VS2022 that doesn't mean a user can't compile JSBSim on their own PC using VS2019. Unless we specifically switch to say assuming and using C++20 features and VS2019 (I haven't double-checked) only supports say C++17.

@bcoconni
Copy link
Member

Well, the idea is to support the oldest platform available to support users that cannot upgrade their platform for whatever reason.

What sort of support are we thinking of? If we compile JSBSim on github using VS2022 that doesn't mean a user can't compile JSBSim on their own PC using VS2019. Unless we specifically switch to say assuming and using C++20 features and VS2019 (I haven't double-checked) only supports say C++17.

Well, according to PR #1020 successfully compiling on MSVC 2019 does not mean a successful compilation on VS 2015... I'm no specialist in this area but just acknowledging the user feedback.

@bcoconni
Copy link
Member

I've a pushed a commit and rebased this PR so it is now successfully compiling on MinGW. However the unit test FGLogTest.h fails because it assumes that MSVC would not use escape sequences:

#ifdef _MSC_VER
TS_ASSERT_EQUALS(buffer.str(), "Hello, World!");
#else
TS_ASSERT_EQUALS(buffer.str(), "\033[31mHello, World!\033[0m");
#endif

and at some other places.

@seanmcleod
Copy link
Member Author

Yep, so as long as the unit tests are executed on Windows 10 or later then they'll pass if you remove the ifdefs.

@bcoconni
Copy link
Member

Yep, so as long as the unit tests are executed on Windows 10 or later then they'll pass if you remove the ifdefs.

Done ! The PR now compiles successfully on all platforms and I have gorgeous colors in my terminal on Windows as well 😄 Thanks for the PR.

@seanmcleod
Copy link
Member Author

You'll have to spend more time on Windows then to enjoy it 😉

@bcoconni bcoconni merged commit f33f20e into JSBSim-Team:master Aug 25, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants