gameflorist / dunedynasty

(Continuation of the abandoned sourceforge project.) Dune Dynasty is a remaster / enhancement of the classic real-time strategy game Dune II by Westwood Studios. It builds upon the original reverse-engineered game engine and adds many enhancements, modernizations and new features. Windows, macOS and Linux are supported.
GNU General Public License v2.0
65 stars 8 forks source link

Merging/mac arm port #6

Closed Dracks closed 10 months ago

Dracks commented 10 months ago

Hello,

I tried to pick up all the changes from @YuriyGuts from this repo: https://github.com/YuriyGuts/dunedynasty-macos on the version 1.5.7 (cherry pick and stuff), to get the differences and with hope had a new version suporting arm macs.

This is base on tag 1.5.7, I expect conflicts and this stuff, but before investing time on them, I prefered to open a draft P/R to see what happens :) (and also your opinion)

codeflorist commented 10 months ago

hey, thanks for your PR!

commits e5a4994 and 9323ab8 are purely documentation and git-related.

i already cherry-picked 9e66c78 (Add more scaling options to be playable on HiDPI (Retina) displays) for v1.6.0 and built further upon it. HiDPI should already work fine in my releases. this seems to be nothing specific for ARM.

to be honest, i don't know what that audlib MAKEFILE from a907e2d is supposed to do. AUDlib is used for supporting the Dune 2000 soundtrack - so also nothing ARM specific.

bottom line is: i don't think there is anything specifically enabling mac ARM ports in YuriyGuts' commits. i assume, that it should just work out of the box for my fork - just as it did for the intel mac version. so the question is how to actually build it. i assume, you need an actual ARM mac, which unfortunately i don't have.

if you have one, you could simply try the steps detailed here to build one from my current source state (v1.6.1). if you are successful, i'd be happy to include the port in the download-section!

Dracks commented 10 months ago

yeah, I had that feeling, when I did the cherry pick,

For another project, to build docker images in the github actions (arm linux images), I had it working, Maybe we can do something similar?

codeflorist commented 10 months ago

i was actually researching this just before. github has just recently introduced Apple silicon M1 arm runners (see here). unfortunately it's only available as a large XL runner at the moment, which means it's only available for paid plans.

maybe github will provide a free runner in the future, then i could indeed use that to build the ARM port.

Dracks commented 10 months ago

theorically, on an intel mac, you should be able to build an arm64 version, Maybe with that is enough. Maybe I can take a look, but for what I see in your workflows, they don't create the release, or upload artifacts there, right?

That's something will be nice to add. Also, will be nice to add some appImage or flathub for linux.

codeflorist commented 10 months ago

theorically, on an intel mac, you should be able to build an arm64 version, Maybe with that is enough. Maybe I can take a look, but for what I see in your workflows, they don't create the release, or upload artifacts there, right?

i think i actually got that to work.

first of all, now all build workflows generate an artifact. only the most recent runs have artifacts though - older ones are deleted to save github space.

i added additional workflows for windows x86 and macos arm64.

to build for macos arm64 on macos intel, it seems the solution was to use --bottle-tag=arm94_monterey in the brew commands for the packages and it's dependencies - also making sure they are not already preinstalled in the runner:

PACKAGES=(argtable sdl2 dumb libogg flac libpng freetype libvorbis ca-certificates openssl@3 opus opusfile physfs theora giflib jpeg-turbo xz lz4 zstd libtiff webp pcre2 gettext glib lame mpg123 libsndfile portaudio readline allegro fluid-synth mad enet)
for PACKAGE in "${PACKAGES[@]}"
do
            brew uninstall --force --ignore-dependencies $PACKAGE
            brew fetch --force --bottle-tag=arm64_monterey $PACKAGE
            brew install $(brew --cache --bottle-tag=arm64_monterey $PACKAGE)
done

for building you have to add the flag -DCMAKE_OSX_ARCHITECTURES=arm64 to the cmake call.

build for macos arm64 seems successful, but i have no way to test it. could you grab the artifact from the latest run at https://github.com/gameflorist/dunedynasty/actions/workflows/macos-arm64-build.yml and test if it works?

Also, will be nice to add some appImage or flathub for linux.

i was researching to provide a finished linux package with all libs before, but wasn't successful. could you provide a solution or PR for this?

Dracks commented 10 months ago

Waw, nice,

Let's continue the discussion of linux, in an issue, I've got a linux as personal laptop (I will confirm it when possible that the mac arm works good :) )

Dracks commented 10 months ago

Hi, I just tried to run the dunedynasti, since it's not a self-contained package, needs the dependencies, (it also happened when I tried on linux) I don't have time now, next week I will try to install deps and try it well :)

codeflorist commented 10 months ago

Hi, I just tried to run the dunedynasti, since it's not a self-contained package, needs the dependencies, (it also happened when I tried on linux) I don't have time now, next week I will try to install deps and try it well :)

Hmm, the macOS packages should actually be self-contained, since i use dylibbundler to bundle all required dylibs into the libs-subfolder and patch the executable accordingly (see this script).

At least this is working on Intel macOS.

Is there any error message regrading which library is missing?

The Linux release is different and indeed requires the dependencies to be installed, since i wasn't successful in creating a self-contained package.

Dracks commented 10 months ago

the last artifact from the mac-arm downloaded this: image

In intel mac, or linux, you should be able to download the artifact and see the contents, with a cli command file you can see the architecture of the program, theorically :)

codeflorist commented 10 months ago

the macOS X86-64 artifact works without installing any dependencies, since everything needed comes within the libs folder.

i was hoping the macOS ARM64 artifact to behave the same way. is there an error upon launching the executable? maybe something like dyld: Library not loaded....?

i verified, that the executable and the dylib-files are all ARM64 - so that is looking good.

btw: i changed the workflows to create a zip archive from the dist folder, since the artifact-zip does not retain the executable permissions. so it comes double-zipped now.

Dracks commented 10 months ago

oh, I just checked the error, sorry, the problem is that my mac is a company mac, and... this is the error:

 '/Users/singlavalls/Downloads/macos-arm64-build/libs/liballegro_acodec.5.2.8.dylib' not valid for use in process: library load disallowed by system policy)

I will try if I can disable quarentine, or this stuff

codeflorist commented 9 months ago

@Dracks hey dracks! a friend of mine could verify, that the ARM64 build is working. 👍

the only problem was, that macOS was quarantining not only the executable (due to unknown developer), but also the included dylibs. i wrote a setup script, that lifts quarantine for all files, that i will include with the future macOS releases.

i'm working on the next release now.

thanks for all your help!