libsdl-org / setup-sdl

GitHub action for providing SDL.
The Unlicense
26 stars 3 forks source link

Configured headers #15

Closed icculus closed 1 year ago

icculus commented 1 year ago

I'm not sure what the correct solution is here, but here's the situation I'm seeing:

I've got a little SDL app at https://github.com/icculus/DirkSimple

I've hooked up setup-sdl, it currently looks like this:

https://github.com/icculus/DirkSimple/blob/08651f838e05be377ad74ff16c39939f2f45f912/.github/workflows/main.yml

When the workflow runs, it'll build SDL or pull it from cache, using gcc.

But then my app builds with Visual Studio, and fails...

https://github.com/icculus/DirkSimple/actions/runs/5427630645/jobs/9871079268#step:5:109

The installed SDL headers have HAVE_STRINGS_H defined in their generated SDL_config.h, but Visual Studio doesn't have strings.h, so it panics here.

I guess the question is:

I could probably build the app with the same compiler that setup-sdl is using, but I suspect a lot of workflows on GitHub look just like this one. :/

madebr commented 1 year ago

By default, setup-sdl uses ninja on all platforms. This speeds up builds considerably.

This has consequences for Windows: the Ninja CMake backend uses CC and CXX to configure the compiler. These are usually set by MSVC's vcvars.bat. See this ci run: instead of msvc, it chose a pre-installed gcc toolchain.

I'll look into making cmake-generator an optional input and use the cmake default if not set.

madebr commented 1 year ago

I think I addressed this in https://github.com/libsdl-org/setup-sdl/commit/70a811d08f0205970d31688445bc2ff964175c4c The action does not select any generator, unless you pass something into the cmake-generator input. I think this plays better with other actions.

icculus commented 1 year ago

I think this plays better with other actions.

Yeah, I think this is the right call.

Also, DirkSimple now builds correctly with this action!

https://github.com/icculus/DirkSimple/actions/runs/5428367307/

This is so great, it's going to be a huge help to lots of people!

madebr commented 1 year ago

Awesome!

You can speed-up the cmake configuration on Windows by using vcvars + ninja. Configuration is so slow because for every test, CMake generates a temporary Visual Studio project, and builds it with msbuild.

About adoption, I think #6 and #9 are the main issues people will grapple with.