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

[SDL2] Build a fake SDL2 library #10889

Closed
wants to merge 1 commit into from
Closed

Conversation

madebr
Copy link
Contributor

@madebr madebr commented Sep 17, 2024

This is useful on CI to quickly build a library from scratch where we don't care about the internals.

This is related to #9580, but is not a header-only library:
it creates a shared SDL2 library that looks identical to the original, but aborts immediately when you try to run it.

I first tried plumbing this in src/dynapi/SDL_dynapi.c so it does not abort and forwards the calls to a "real" SDL2 library, like sdl2-compat does.
Perhaps @icculus has more success ;)

I'd like to use this for creating binary releases of the SDL2 satellite libraries such that they do not need to rebuild SDL2 for every VC/mingw architecture.

Description

Existing Issue(s)

This is useful on CI to quickly build a library from scratch where we don't care about the internals
@madebr madebr marked this pull request as draft September 17, 2024 21:12
@madebr madebr requested a review from icculus September 17, 2024 21:14
@slouken
Copy link
Collaborator

slouken commented Sep 17, 2024

Does it make sense to have CI download the last SDL2 release artifacts instead?

@icculus
Copy link
Collaborator

icculus commented Sep 17, 2024

Yeah, this was more or less what I was envisioning in that previous discussion. I also think it would be massively beneficial to setup-sdl's build times to have a mode like this, when the CI just needs to link against something but doesn't plan to distribute it.

@madebr
Copy link
Contributor Author

madebr commented Sep 17, 2024

Does it make sense to have CI download the last SDL2 release artifacts instead?

I did not know an easy way to get them in a reliable way, but I think I found one.
This command echos the tag of the latest SDL2 release:

RELEASE_TAG=$(gh -R libsdl-org/SDL release list  --json tagName,createdAt,name --jq '[.[]|select(.name|startswith("2."))]|max_by(.createdAt)|.tagName)
echo $RELEASE_TAG

Then download the latest release:

gh -R libsdl-org/SDL release download $RELEASE_TAG -p '*mingw*

I'll try to use that approach now.

@madebr
Copy link
Contributor Author

madebr commented Sep 17, 2024

Yeah, this was more or less what I was envisioning in that previous discussion. I also think it would be massively beneficial to setup-sdl's build times to have a mode like this, when the CI just needs to link against something but doesn't plan to distribute it.

I think dynapi forwarding can be greatly simplified if the SDL API would include va_list ap alternatives of the vararg functions.
Then,

  • normal functions can simply forward (as they do now), and
  • vararg functions can simply forward to their va_list equivalent (this code should move into the SDL source tree)

A header-only SDL would then not need to worry about vararg functions.

@icculus
Copy link
Collaborator

icculus commented Sep 18, 2024

That's an interesting idea. We should try this before the ABI locks down. If nothing else, it would remove some ugliness in dynapi.

@smcv
Copy link
Contributor

smcv commented Sep 18, 2024

Language binding authors would perhaps also appreciate it if there was always a way to get equivalent functionality without varargs, for example:

/* equivalent to SDL_SetError("%s", message) */
SDL_bool SDL_SetErrorLiteral(const char *message);

@madebr madebr closed this Oct 30, 2024
@madebr madebr deleted the fake-SDL2 branch October 30, 2024 02:15
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.

4 participants