Refactoring multi-platform .travis.yml

I’ve recently tried using Travis CI for Windows to build and test a C++ project.
While I got it to work, I’m struggling a bit with cleaning up the configuration and would appreciate help.

Here’s my current .yml file:

Here’s the things I don’t like about it:

  • The script section is trying to combine two different scripts in one and looks horrible. I don’t want to use multi-line bash blocks because then Travis will consider each block as an atomic unit of execution and will, for example, time them separately. Is there a way to more cleanly split two different script invocations? I tried using conditional stages but couldn’t get them to work for some reason.

  • I’m forced to use language: sh instead of cpp because Windows doesn’t support cpp. Is there a way to still use language: cpp for Linux/macOS?

  • The build matrix specification is weird. I need to exclude the default “windows” job to be able to add two new ones with custom macros. Can I just specify the matrix manually without having to remove default jobs?

The most important point I’d like help on is the first one. I tried defining stages like “script_unix” and “script_win” and conditionally including them based on the value of os but I couldn’t get it to work with no errors and I’m not sure how to debug this.

edit: After reading documentation a few more times I now understand that I was confusing phases and stages. Phases don’t seem configurable in any way that is per OS or job. I could replicate the scripts in job setup but then I have to copy & paste their contents (if I still want Travis to individually execute and time separate lines). I’m beginning to think that this problem doesn’t have a solution, sadly.

Iam just a user, so this is no official statement.

for the cpp language support see: C++ Support on Windows
I expect at some point all languages supported in Linux/macOS will also be supported in windows.

For the other things. Personally I think this looks still ok. If it would be more complex I would recommend to extract it into own scripts, which then handle the if windows part.
And it seems your current approach is, what the community is using usually to solve this kind of problems.

My question would be, why do you split by os and not by make vs cmake I understand you probably still want to test with make on linux, but you can also use cmake on linux if I did read up correctly.