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

macOS universal binary #42

Open
wants to merge 41 commits into
base: urt
Choose a base branch
from
Open

Conversation

danielepantaleone
Copy link
Collaborator

This PR add the ability to build an universal binary for macOS that works with Apple M1

timangus and others added 30 commits October 29, 2023 13:31
- Reorganized Xcode project
- Added missionpack support to Xcode project
- Incorporated changes from MaddTheSane for Apple Silicon support https://github.com/maddthesane/ioq3
- Built SDL 2.0.14 for Apple Siicon, added to existing SDL dylib
- Built SDLMain for Apple Silicon, added to existing libSDL2main.a

# Conflicts:
#	make-macosx-app.sh
#	make-macosx.sh
#	misc/xcode/botlib.xcodeproj/project.pbxproj
#	misc/xcode/cgame.xcodeproj/project.pbxproj
#	misc/xcode/game.xcodeproj/project.pbxproj
#	misc/xcode/ioquake3-Info.plist
#	misc/xcode/ioquake3.xcodeproj/project.pbxproj
#	misc/xcode/ioquake3.xcworkspace/contents.xcworkspacedata
#	misc/xcode/ioquake3.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
#	misc/xcode/ioquake3.xcworkspace/xcshareddata/xcschemes/all game.xcscheme
#	misc/xcode/ioquake3.xcworkspace/xcshareddata/xcschemes/all ioquake3.xcscheme
#	misc/xcode/jpeg8.xcodeproj/project.pbxproj
#	misc/xcode/opus.xcodeproj/project.pbxproj
#	misc/xcode/renderer_opengl1.xcodeproj/project.pbxproj
#	misc/xcode/renderer_opengl2.xcodeproj/project.pbxproj
#	misc/xcode/ui.xcodeproj/project.pbxproj
#	misc/xcode/xcode-readme.txt
# Conflicts:
#	code/libs/win32/SDL2.lib
#	code/libs/win32/SDL2main.lib
#	code/libs/win64/SDL264.lib
#	code/libs/win64/SDL264main.lib
#	external/SDL2/include/SDL_config_macosx.h.orig
#	external/SDL2/include/SDL_locale.h
#	external/SDL2/include/SDL_metal.h
#	external/SDL2/include/SDL_misc.h
#	external/SDL2/include/SDL_sensor.h
# Conflicts:
#	code/SDL2/include/SDL_config.h
#	code/SDL2/include/SDL_cpuinfo.h
#	code/SDL2/include/SDL_revision.h
#	external/SDL2/include/SDL_config.h.cmake
#	external/SDL2/include/SDL_config.h.in
#	external/SDL2/include/SDL_config_android.h
#	external/SDL2/include/SDL_config_iphoneos.h
#	external/SDL2/include/SDL_config_macosx.h
#	external/SDL2/include/SDL_config_minimal.h
#	external/SDL2/include/SDL_config_os2.h
#	external/SDL2/include/SDL_config_pandora.h
#	external/SDL2/include/SDL_config_psp.h
#	external/SDL2/include/SDL_config_windows.h
#	external/SDL2/include/SDL_config_winrt.h
#	external/SDL2/include/SDL_config_wiz.h
#	external/SDL2/include/SDL_locale.h
#	external/SDL2/include/SDL_metal.h
#	external/SDL2/include/SDL_misc.h
#	external/SDL2/include/SDL_sensor.h
# Conflicts:
#	external/SDL2/include/SDL_config_macosx.h.orig
#	external/SDL2/include/SDL_config_os2.h
Also added line break in script for consistency, thanks @zturtleman

# Conflicts:
#	misc/xcode/ioquake3.xcodeproj/project.pbxproj
#	misc/xcode/opus.xcodeproj/project.pbxproj
Until I can find a way to branch around this in a way Xcode 3 is cool with we'll just have to use the deprecated version
KMOD_RESERVED was replaced with KMOD_SCROLL.
Also works on Apple Silicon. Specific signing values are in a non-committed file, and the ub2 script only notarizes if a "notarize" flag is passed in on the command line.

NOTE: the SDL dylib currently only has x86_64 and arm64, will need extra work to graft those back in and keep the Notary service happy.

# Conflicts:
#	external/SDL2/include/SDL_mutex.h
#	external/SDL2/include/SDL_platform.h
#	misc/xcode/ioquake3.xcodeproj/project.pbxproj
The ppc arch is the 2.0.1 that was there originaly.
The i386 arch is 2.0.16, now compiled with an SDK later than 10.9 so the Notarization process is cool with it.
So now all post-ppc SDL libraries are 2.0.16.
# Conflicts:
#	code/SDL2/include/SDL_audio.h
#	code/SDL2/include/SDL_cpuinfo.h
#	code/SDL2/include/SDL_gamecontroller.h
#	code/SDL2/include/SDL_joystick.h
#	code/SDL2/include/SDL_mutex.h
#	code/SDL2/include/SDL_render.h
#	code/SDL2/include/SDL_revision.h
#	code/SDL2/include/SDL_surface.h
#	code/SDL2/include/SDL_system.h
#	code/SDL2/include/SDL_thread.h
#	code/SDL2/include/SDL_version.h
#	code/SDL2/include/SDL_video.h
#	external/SDL2/include/SDL_config.h.cmake
#	external/SDL2/include/SDL_config.h.in
#	external/SDL2/include/SDL_config_android.h
#	external/SDL2/include/SDL_config_iphoneos.h
#	external/SDL2/include/SDL_config_macosx.h
#	external/SDL2/include/SDL_config_pandora.h
#	external/SDL2/include/SDL_config_windows.h
#	external/SDL2/include/SDL_config_winrt.h
#	external/SDL2/include/SDL_config_wiz.h
… actions

# Conflicts:
#	code/libs/macosx/libSDL2-2.0.0.dylib
# Conflicts:
#	make-macosx.sh
#	misc/xcode/xcode-readme.txt
Using LUMINANCE with OpenGL 3.2 Core contex results in all images being
solid black (in the menu, world, and the console). In the end the whole
screen was solid black except the intro video.

Store images in RGB and RGBA instead. This doesn't affect r_grayscale
visually. If there is issues with it now possibly using compressed
formats, then it would already be an issue for r_grayscale 0.9.
Printing GL_EXTENSIONS list might be cut off for OpenGL contexts
before 3.0 due to glConfig.extensions_string being a limited length.
Instead get the full extensions list directly.

This was already fixed for OpenGL 3.0 and later contexts.
GL_DEPTH_TEXTURE_MODE defaults to GL_LUMINANCE. Code sets it here as
part of a workaround old nvidia drivers (apparently? the URL in comment
is dead). GL_DEPTH_TEXTURE_MODE was removed in OpenGL 3.0 / 3.2 Core
contexts and may be treated as an error.
Fix "Architecture arm64 is not supported when cross compiling" and
also be more be more flexible for manually specifying CC or the
osxcross darwin version (which corresponds with a macOS SDK version
to build against).
The engine function pointer to vmMain used variadic arguments but
the vmMain function in the dylib has explicit arguments. Evidently
the arguments are stored on the stack and/or registers differently.

Found by fretn.
ranlib errors on older macOS because of arm64 arch in code/libs/macosx/-
libSDL2main.a. Use lipo to extract the library for the specific arch
that is being linked.
kungfooman and others added 11 commits October 29, 2023 13:32
This fixes the additional buttons triggering binds for ioq3 left
and right joystick direction keys.
When in_restart is called or SDL controller added/remove event is
received, IN_InitJoystick() tried to update the list but instead
of updating the cvar Cvar_Get() just printed a developer message:

  Warning: cvar "in_availableJoysticks" given initial values:
  "first joystick
  ", "first joystick
  second joystick
  "
The first chunk of Wavelet sound was decoded as ADPCM and then
following chunks were decoded as Wavelet. It played as static
noise.

Using Wavelet compression requires engine code changes to enable.
Update mingw and macOS SDL libraries to 2.24.0. (MSVC .lib files and
Xcode project haven't been updated.)

There is now a separate SDL dylib for macOS Universal Binary 1 and 2
because SDL 2.24.0 dropped support for macOS 10.6 (which is last to
support x86). Documentation says SDL 2.24.0 also dropped macOS 10.7
and 10.8 too. So UB2 is now 10.9 or later while 10.5 to 10.8 live in
UB1.

Compiled using osxcross with macOS 11.3 SDK. Ran "strip -x" on Windows
and macOS libraries. Ad-hoc signed dylib using PyOxidizer rcodesign to
fix digest checksums after strip.

# Conflicts:
#	README.md
#	code/SDL2/include-2.0.16/SDL_config_psp.h
#	code/SDL2/include-2.0.16/SDL_config_wiz.h
#	code/SDL2/include/SDL_config_psp.h
#	code/SDL2/include/SDL_config_wiz.h
#	code/libs/macosx-ub/libSDL2main.a
#	code/libs/macosx/libSDL2main.a
#	external/SDL2/include/SDL_config_emscripten.h
#	external/SDL2/include/SDL_config_ngage.h
#	external/SDL2/include/SDL_config_psp.h
#	external/SDL2/include/SDL_config_wingdk.h
#	external/SDL2/include/SDL_config_wiz.h
#	external/SDL2/include/SDL_config_xbox.h
#	external/SDL2/include/SDL_guid.h
#	external/SDL2/include/SDL_hidapi.h
#	external/SDL2/include/SDL_revision.h.cmake
#	libs/macosx/libSDL2main.a
#	make-macosx-app.sh
#	make-macosx.sh
Fix crash when scrolling using touchpad on macOS 10.6 (I fixed it
in SDL 2.0.18) and fix failing to start on x86 due to ioq3 SDL dylib
having absolute path instead of "@executable_path/libSDL2-2.0.0.dylib".

SDL 2.24.0 removed macOS 10.6 support (last with x86). Offically at
least, they also dropped x86_64 on macOS 10.7 and 10.8. So ioq3 UB1
is limited to SDL 2.0.22.

- Update x86 and x86_64 to SDL 2.0.22. Compiled with 10.13 SDK as
  10.14 SDK dropped running on older than macOS 10.9 and I ran
  "strip -x" on the libraries. Ad-hoc signed with PyOxidizer rcodesign.
- PPC is still MAN-AT-ARMS' SDL 2.0.1 build but I ran "strip -x"
  on it to reduce the file size.
- ARM64 build was removed from UB1 as UB2 with SDL 2.24.0 should
  be used instead.
osxcross doesn't support ppc so it's not possible to compile Universal
Binary 1.

# Conflicts:
#	make-macosx-ub.sh
#	make-macosx.sh
The macOS client and server were completely unusable when run from a
terminal. They blocked forever in `[NSApp run];` which was called by
Sys_InitProtocolHandler(). `applicationDidFinishLaunching` was never
called to exit the NSApp run loop.

Use SDL's SDL_DROPFILE event to receive URLs to handle on macOS instead.
This also handles URLs while the game is running (connect to new server)
instead of nothing happening when clicking a link while the game is
running.

# Conflicts:
#	code/sys/sys_local.h
#	code/sys/sys_main.c
The mod list on Windows would search the root of the drive if
fs_basepath, fs_homepath, fs_steampath, or fs_gogpath are blank ("")
(which is usually the case).

The issue is in the low-level Sys_ListFiles() but it only affects the
mod menu, on Windows. It cannot be abused by console commands to
list system files outside of the virtual filesystem.

---

If a directory at the root of the drive of the working directory
contained a pk3 file, the directory was listed in the mods menu. The
virtual filesystem doesn't add blank directory names to the search path
so it cannot load mods from the drive root. (Unless of course you set a
fs_*path cvar to "C:\".)

Sys_ListFiles() with blank directory caused Windows to use "\*" for the
search path and "\" prefix means root of drive. Unix opendir("") failed
so nothing was listed for blank directory.

Sys_ListFilteredFiles() with blank directory _and_ specifying subdirs
could access any directory (on Windows and Unix-like) but no code uses
this or makes it accessible.

These functions are only used for initializing the virtual filesystem
and listing mods. They are not accessible by anything else such as a
console command. Only the mods menu, on Windows, is affected.
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.

None yet

8 participants