dxx-rebirth / dxx-rebirth

Descent-Rebirth and Descent II-Rebirth
Other
501 stars 117 forks source link

Mac OS X build notes #561

Open raptor opened 3 years ago

raptor commented 3 years ago

This isn't a bug/issue, rather a success:

I have built the latest version of d2x (revision 0d70c3831c31700ca1ad6edb73f6d3bce1d58a84) on macOS 10.13 using the following steps:

1. Get the dxx-rebirth source code and put it somewhere:

   git clone https://github.com/dxx-rebirth/dxx-rebirth.git

2. Install brew:

   /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

3. Install dependencies:

   brew install scons sdl sdl_image sdl_mixer physfs

4. Make earlier macOS compatible (if wanted):

   export MACOSX_DEPLOYMENT_TARGET=10.11

5. Run scons in the dxx-rebirth dir:

   scons opengl=1 sdlmixer=1 d2x=1 macos_add_frameworks=0

This builds the D2X-Rebirth.app (Xcode command line tools required:  xcode-select --install)

6. Fix up the executable and libraries in the .app to make it self-contained by getting the following tool:

   git clone https://github.com/auriamg/macdylibbundler.git
   cd macdylibbundler
   make

7. Then run the command against the .app:

   cd /path/to/dxx-rebirth
   /path/to/dylibbundler -od -b -x D2X-Rebirth.app/Contents/MacOS/d2x-rebirth -d D2X-Rebirth.app/Contents/Frameworks

The .app now has the .dylib files contained therein to run on any macOS system.

8. Copy descent 2 resources into:  

   D2X-Rebirth.app/Contents/Resources/

9. PLAY

Attached is the .app created using the above steps, but without the game data files (step 8).

Steps 6 and 7 were key to getting friends to run it without requiring extra dependencies. Should be compatible with macOS 10.11 and later.

D2X-Rebirth.app.zip

Thanks for your efforts. This game is great!

vLKp commented 3 years ago

Well done. Would you be interested in writing this up and submitting a pull request to improve the documentation, so that other users can readily find how to do this? If not, I can write something from the steps you posted here, but I won't be able to test it.

raptor commented 3 years ago

I think I can do that. The INSTALL.markdown file can be slimmed down and simplified. Would it be better to split out the macOS stuff into it's own file, like INSTALL.macos.md?

vLKp commented 3 years ago

I think that would be fine. A short note in INSTALL.markdown could direct readers to the platform-specific instructions, in case they do not notice it in the directory listing.

MaddTheSane commented 3 years ago

Have you had any luck building with SDL2?

EvanDorsky commented 3 years ago

These instructions work for me on Big Sur (11.0.1). Also with d1x. Thanks @raptor !

However, d1x doesn't play any sound or music. d2x plays sound fine.

@MaddTheSane I have attempted to build with SDL2. All seems fine until linking, then this:

LD  d2x d2x-rebirth/d2x-rebirth
Undefined symbols for architecture x86_64:
  "_SDL_main", referenced from:
      -[SDLMain applicationDidFinishLaunching:] in SDLMain.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
scons: *** [d2x-rebirth/d2x-rebirth] Error 1
scons: building terminated because of errors.
Failed target count: total=1; targets with enable_build_failure_summary=1: 1
Failed node list:
    d2x-rebirth/d2x-rebirth
Failed command list:
 g++ -g -O2 -ftabstop=4 -Wall -Werror=extra -Werror=format=2 -Werror=missing-braces -Werror=missing-include-dirs -Werror=uninitialized -Werror=undef -Werror=pointer-arith -Werror=cast-qual -Werror=missing-declarations -Werror=vla -funsigned-char -std=gnu++17 -Werror=unused -Wno-implicit-fallthrough -Wno-unused-lambda-capture -Wno-gnu-string-literal-operator-template -fvisibility=hidden -Wold-style-cast -Wredundant-decls -Wl,-rpath,@loader_path/../Frameworks "common/2d/2dsline.o" "common/2d/bitblt.o" "common/2d/bitmap.o" "common/2d/box.o" "common/2d/canvas.o" "common/2d/circle.o" "common/2d/disc.o" "common/2d/gpixel.o" "common/2d/line.o" "common/2d/pixel.o" "common/2d/rect.o" "common/2d/rle.o" "common/2d/scalec.o" "common/3d/draw.o" "common/3d/globvars.o" "common/3d/instance.o" "common/3d/matrix.o" "common/3d/points.o" "common/3d/rod.o" "common/3d/setup.o" "common/arch/sdl/event.o" "common/arch/sdl/joy.o" "common/arch/sdl/key.o" "common/arch/sdl/mouse.o" "common/arch/sdl/timer.o" "common/arch/sdl/window.o" "common/main/cli.o" "common/main/cmd.o" "common/main/cvar.o" "common/maths/fixc.o" "common/maths/rand.o" "common/maths/tables.o" "common/maths/vecmat.o" "common/mem/mem.o" "common/misc/error.o" "common/misc/hash.o" "common/misc/hmp.o" "common/misc/ignorecase.o" "common/misc/physfsrwops.o" "common/misc/strutil.o" "common/misc/vgrphys.o" "common/misc/vgwphys.o" "common/arch/cocoa/messagebox.o" "common/arch/cocoa/SDLMain.o" "similar/2d/.d2x-rebirth.font.o" "similar/2d/.d2x-rebirth.palette.o" "similar/2d/.d2x-rebirth.pcx.o" "similar/3d/.d2x-rebirth.interp.o" "similar/arch/sdl/.d2x-rebirth.digi.o" "similar/arch/sdl/.d2x-rebirth.digi_audio.o" "similar/arch/sdl/.d2x-rebirth.init.o" "similar/main/.d2x-rebirth.ai.o" "similar/main/.d2x-rebirth.aipath.o" "similar/main/.d2x-rebirth.automap.o" "similar/main/.d2x-rebirth.bm.o" "similar/main/.d2x-rebirth.cntrlcen.o" "similar/main/.d2x-rebirth.collide.o" "similar/main/.d2x-rebirth.config.o" "similar/main/.d2x-rebirth.console.o" "similar/main/.d2x-rebirth.controls.o" "similar/main/.d2x-rebirth.credits.o" "similar/main/.d2x-rebirth.digiobj.o" "similar/main/.d2x-rebirth.effects.o" "similar/main/.d2x-rebirth.endlevel.o" "similar/main/.d2x-rebirth.fireball.o" "similar/main/.d2x-rebirth.fuelcen.o" "similar/main/.d2x-rebirth.fvi.o" "similar/main/.d2x-rebirth.game.o" "similar/main/.d2x-rebirth.gamecntl.o" "similar/main/.d2x-rebirth.gamefont.o" "similar/main/.d2x-rebirth.gamemine.o" "similar/main/.d2x-rebirth.gamerend.o" "similar/main/.d2x-rebirth.gamesave.o" "similar/main/.d2x-rebirth.gameseg.o" "similar/main/.d2x-rebirth.gameseq.o" "similar/main/.d2x-rebirth.gauges.o" "similar/main/.d2x-rebirth.hostage.o" "similar/main/.d2x-rebirth.hud.o" "similar/main/.d2x-rebirth.iff.o" "similar/main/.d2x-rebirth.kmatrix.o" "similar/main/.d2x-rebirth.laser.o" "similar/main/.d2x-rebirth.lighting.o" "similar/main/.d2x-rebirth.menu.o" "similar/main/.d2x-rebirth.mglobal.o" "similar/main/.d2x-rebirth.mission.o" "similar/main/.d2x-rebirth.morph.o" "similar/main/.d2x-rebirth.multi.o" "similar/main/.d2x-rebirth.multibot.o" "similar/main/.d2x-rebirth.newdemo.o" "similar/main/.d2x-rebirth.newmenu.o" "similar/main/.d2x-rebirth.object.o" "similar/main/.d2x-rebirth.paging.o" "similar/main/.d2x-rebirth.physics.o" "similar/main/.d2x-rebirth.piggy.o" "similar/main/.d2x-rebirth.player.o" "similar/main/.d2x-rebirth.polyobj.o" "similar/main/.d2x-rebirth.powerup.o" "similar/main/.d2x-rebirth.render.o" "similar/main/.d2x-rebirth.robot.o" "similar/main/.d2x-rebirth.scores.o" "similar/main/.d2x-rebirth.segment.o" "similar/main/.d2x-rebirth.slew.o" "similar/main/.d2x-rebirth.songs.o" "similar/main/.d2x-rebirth.state.o" "similar/main/.d2x-rebirth.switch.o" "similar/main/.d2x-rebirth.terrain.o" "similar/main/.d2x-rebirth.texmerge.o" "similar/main/.d2x-rebirth.text.o" "similar/main/.d2x-rebirth.titles.o" "similar/main/.d2x-rebirth.vclip.o" "similar/main/.d2x-rebirth.wall.o" "similar/main/.d2x-rebirth.weapon.o" "similar/misc/.d2x-rebirth.args.o" "similar/main/.d2x-rebirth.inferno.o" "similar/main/.d2x-rebirth.kconfig.o" "similar/misc/.d2x-rebirth.physfsx.o" "similar/main/.d2x-rebirth.playsave.o" "similar/main/.d2x-rebirth.net_udp.o" "d2x-rebirth/libmve/decoder8.o" "d2x-rebirth/libmve/decoder16.o" "d2x-rebirth/libmve/mve_audio.o" "d2x-rebirth/libmve/mvelib.o" "d2x-rebirth/libmve/mveplay.o" "d2x-rebirth/main/escort.o" "d2x-rebirth/main/gamepal.o" "d2x-rebirth/main/movie.o" "common/arch/sdl/digi_mixer_music.o" "similar/arch/sdl/.d2x-rebirth.digi_mixer.o" "similar/arch/sdl/.d2x-rebirth.jukebox.o" "common/arch/ogl/ogl_extensions.o" "common/arch/ogl/ogl_sync.o" "similar/arch/ogl/.d2x-rebirth.gr.o" "similar/arch/ogl/.d2x-rebirth.ogl.o" "similar/main/.d2x-rebirth.vers_id.o" -L/usr/local/Cellar/libpng/1.6.37/lib -L/usr/local/lib -lpng16 -lz -lphysfs -lSDL2_image -lSDL2_mixer -lSDL2 -lm -framework ApplicationServices -framework Cocoa -framework OpenGL -o "d2x-rebirth/d2x-rebirth"

I've been doing some searching and I'm guessing this is related to the #undef main line in Sconstruct. I've tried tweaking a few things, but that error remains.

Hope this helps, if anyone wants to look into building with SDL2 on macOS. I'll do some more poking later, but I've never worked with SDL.

As for no sound on d1x, should I open a separate issue for that? I double-checked my data files by running Descent in SheepShaver, and there the sound plays fine.

Edit

I understand now that the d1x sound issues are game data-related. No problems anymore.

raptor commented 3 years ago

Is SDL2 or SDL1.2 the proper front-end to use? I think SDL1.2 support should probably be removed completely to reduce maintenance load if both are supported equally.

vLKp commented 3 years ago

SDL2 is the future. It is not yet default due to the sound issue reported in #474. I have not removed SDL1.2 because I am currently the only maintainer, and its presence has not been enough of a burden to me to motivate the change.

Majkitos commented 3 years ago

Anybody got this working on OS X Catalina? I cannot successfully build with scons. Getting similar/main/game.cpp:190:23: error: unused variable 'initial_small_game_screen_mode' [-Werror,-Wunused-const-variable] constexpr screen_mode initial_small_game_screen_mode{320, 200};

vLKp commented 3 years ago

That is not an OSX problem. That is a clang problem. Commit 4a8d7c7574ef0bcdfc5e478dd65b38a7abefcc56 introduced a global constexpr variable that is only used in the !OGL builds, but is defined in all builds. gcc accepts this without a warning. clang warns, and the -Werror promotes it to an error.

Commit 15bd145daf7993ed0a0c7c270501f0310cfe6a9f adds a preprocessor guard around the global so that it is only defined when it will be used.

yermak commented 3 years ago

D1X-Rebirth-MacOS.zip For those who looking for D1 build for mac I did latest build https://github.com/yermak/dxx-rebirth/releases/tag/2021-01-26

You will need to place files from original descent into Resource folder

matatata commented 3 years ago

Thank you raptor. With your instructions I was able to build D2X on a MacBookAir M1. However I built dylibbundler (step 6) and added its build directory to the PATH export PATH=$PATH:/path/to/macdylibbundler/ before building D2x (step 5). This way I think I did not need step 7.

This is my Apple Silicon built (Big Sur M1) D2X-Rebirth.app.zip. You will need to place files from original descent into Resource folder

vLKp commented 3 years ago

Support for automatically running dylibbundler was added in 14562e74b3832a90b9e60d05ae69d7b570a7eadd (May 2021) and a few subsequent commits. It was not present when raptor wrote the original instructions.

nastys commented 3 years ago

I had to make a couple of changes to the code and manually sign everything, but I was able to build both D1X and D2X for Apple Silicon.

vLKp commented 3 years ago

For the change to common/arch/cocoa/tool_bundle.py, could you explain its purpose? If env does not have that key, then accessing it will fail. Is env not an object that has the has_key method? If not, what is its type here?

For the change in similar/main/inferno.cpp, this is a clang bug, in my opinion. The variable is used: it has a non-trivial destructor with global side effects. I added a similar change to the main code, to suppress that warning without use of a dummy variable or dead assignment.

nastys commented 3 years ago
scons: done reading SConscript files.
scons: Building targets ...
scons: *** [D1X-Rebirth.app/Contents/Info.plist] AttributeError : 'SConsEnvironment' object has no attribute 'has_key'
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/scons/4.2.0/libexec/lib/python3.9/site-packages/SCons/Action.py", line 1279, in execute
    result = self.execfunction(target=target, source=rsources, env=env)
  File "/Users/nastys/test/dxx-rebirth/common/arch/cocoa/tool_bundle.py", line 47, in subst_in_file
    if not env.has_key('SUBST_DICT'):
  File "/opt/homebrew/Cellar/scons/4.2.0/libexec/lib/python3.9/site-packages/SCons/Environment.py", line 2384, in __getattr__
    attr = getattr(self.__dict__['__subject'], name)
AttributeError: 'SConsEnvironment' object has no attribute 'has_key'
scons: building terminated because of errors.

It looks like has_key is not an attribute in Python 3.9? I don't know.

Kreeblah commented 3 years ago

I think it's either an SConstruct bug or a Python bug. I just tried building the current commit on my Intel Mac, and it failed the same way. I also tried some tarballs of previous releases from the DXX Rebirth web site, and they're failing the same way, even ones that used to build just fine.

This is with SConstruct 4.2.0 and Python 3.9.6.

vLKp commented 3 years ago

I see in the release notes for SConstruct 4.2.0 ( https://scons.org/scons-420-is-available.html ):

Internal has_key methods removed from SCons' dictionary-like objects SubstitutionEnvironment and OverrideEnvironment - in other words, an env - to match Python 3 which no longer has dict.has_key.

So this works fine in SConstruct 4.1.0, but will break for anyone using SConstruct 4.2.0 and later. Since upstream made this change on purpose, I doubt it will be reverted. I see that SConstruct 4.1.0 and SConstruct 4.2.0 provide __contains__ on SubstitutionEnvironment, which should do what is needed here.

vLKp commented 3 years ago

The above commit should prevent this error in a way that retains the test, and is compatible with both old and new SCons.

Kreeblah commented 3 years ago

That did it. The tree successfully builds and runs for me now with SConstruct 4.2.0.