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

Mac Universal Binary #658

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

halprin
Copy link
Contributor

@halprin halprin commented Dec 22, 2024

Pull Request Type

  • GitHub Workflow changes
  • Documentation or Wiki changes
  • Build and Dependency changes
  • Runtime changes
    • Render changes
    • Audio changes
    • Input changes
    • Network changes
    • Other changes

Description

Related Issues

Screenshots (if applicable)

Checklist

  • I have tested my changes locally and verified that they work as intended.
  • I have documented any new or modified functionality.
  • I have reviewed the changes to ensure they do not introduce any unnecessary complexity or duplicate code.
  • I understand that by submitting this pull request, I am agreeing to license my contributions under the project's license.

Additional Comments

@Lgt2x
Copy link
Member

Lgt2x commented Dec 25, 2024

How do you intend to make d3-osx.hog work with a universal binary? Can we also get universal binaries for the level script modules?

@halprin
Copy link
Contributor Author

halprin commented Dec 31, 2024

Yes, I intend to make everything as a universal binary. Albeit, if I can do this in smaller, incremental steps, I'll do that.

I don't have much experience compiling complex C and C++ projects with CMake (like this project), so I expect this PR to take a while before it's ready for review.

@Lgt2x
Copy link
Member

Lgt2x commented Jan 1, 2025

Hey @halprin , I was curious about this whole universal binary thing, so I fired up a MacOS emulator and tried your branch. I faced the same compilation issues as CI when installing third-parties through Homebrew, which seemingly does not use universal libraries, so I used my WIP SDL3 branch that has SDL3 as a git submodule, so SDL is compiled as part of the project instead of externally. I did not try using VCPKG however. The build succeeded this way.

The Descent3 executable is indeed multi-arch:

file ./builds/mac/build/Debug/Descent3.app/Contents/MacOS/Descent3
./builds/mac/build/Debug/Descent3.app/Contents/MacOS/Descent3: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64]
./builds/mac/build/Debug/Descent3.app/Contents/MacOS/Descent3 (for architecture x86_64):	Mach-O 64-bit executable x86_64
./builds/mac/build/Debug/Descent3.app/Contents/MacOS/Descent3 (for architecture arm64):	Mach-O 64-bit executable arm64

and to answer my question above, level scripts bundled d3-osx.hog are also universal dynamic modules/libraries:

file ./builds/mac/scripts/Debug/LEVEL0.dylib
./builds/mac/scripts/Debug/LEVEL0.dylib: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit bundle x86_64] [arm64:Mach-O 64-bit bundle arm64]
./builds/mac/scripts/Debug/LEVEL0.dylib (for architecture x86_64):	Mach-O 64-bit bundle x86_64
./builds/mac/scripts/Debug/LEVEL0.dylib (for architecture arm64):	Mach-O 64-bit bundle arm64

Running the game just... works! Level scripts do too (you can check that using the training level, that should constrain controls if the script is loaded properly)

Honestly this is a pretty impressive feat from Apple, I'm not an Apple fanboy at all but I have to admit that this is really nice, and makes me wish we could do the same on Linux.

@halprin
Copy link
Contributor Author

halprin commented Jan 10, 2025

Oh, that's super cool! How far away do you think your SDL3 branch is from merging?

I've never used VCPKG. It looks like it works for Mac. I'll need to explore how it could install a universal version or both versions of the dependencies.

@Lgt2x
Copy link
Member

Lgt2x commented Jan 11, 2025

I had packaging issues with VCPKG builds for SDL3, so it still needs some work. Meanwhile it can be a good idea to use VCPKG for the universal mac builds, since it builds all requirements from source instead of using brew.

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