RiiStudio icon indicating copy to clipboard operation
RiiStudio copied to clipboard

Mac Build In Releases Section

Open ThomasAlban opened this issue 2 years ago • 47 comments

Any chance of adding a Mac Intel and M1 Build to the releases section?

ThomasAlban avatar Mar 11 '23 22:03 ThomasAlban

Possibly. I'm unfamiliar with the signing process and unsure if the brew libraries we link against require the system to have certain packages installed. If we can figure that out and add it to CI, I see no reason why not to.

snailspeed3 avatar Mar 11 '23 22:03 snailspeed3

That sounds great. I just tried to follow the steps to build Riistudio for M1 Mac (I have an M1 Pro Macbook Pro), but when I ran this command: cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=/opt/homebrew/bin/clang++ I got this error:

CMake Error at CMakeLists.txt:3 (project):
  The CMAKE_CXX_COMPILER:

    /opt/homebrew/bin/clang++

  is not a full path to an existing compiler tool.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.

Not sure what to do to fix this, as I'm not very knowledgable about CMake and C++! I'd really love to be able to use Riistudio natively on my Mac without having to use a Windows VM.

ThomasAlban avatar Mar 12 '23 15:03 ThomasAlban

I think it's not seeing clang++ from brew? Were you able to install the llvm package?

snailspeed3 avatar Mar 12 '23 16:03 snailspeed3

yeah, when I run brew install llvm it gives me a message saying it is already installed and up-to-date. I checked the /opt/homebrew/bin folder and there is no file called 'clang++'. I ran the command which installed all the brew packages and everything seemed to install fine.

ThomasAlban avatar Mar 12 '23 16:03 ThomasAlban

Perhaps it's being installed to a different directory? E.g. llvm's own bin subdirectory?

snailspeed3 avatar Mar 12 '23 16:03 snailspeed3

Yes this was the problem, I found the clang++ file in the llvm bin directory and changed the file pathway to this.

If it helps anyone, on Apple Silicon, the pathway is: /opt/homebrew/Cellar/llvm/18.1.8/bin/clang++ (or replace 18.1.8 with whichever version number it is)

I ran the rest of the commands, and they all seemed to work. Having run all the commands where is the final build located? I can't seem to find it to run Riistudio and see if everything worked.

ThomasAlban avatar Mar 12 '23 17:03 ThomasAlban

It should be in the frontend subdirectory in your build folder! Also keep in mind the latest Assimp version has some regressions, so the Windows build stays at a known good version. Otherwise the MacOS build should be basically feature-complete. :)

snailspeed3 avatar Mar 12 '23 17:03 snailspeed3

image Here's what I have in my build folder, there is no `frontend` subdirectory so something must have gone wrong. This might be the problem:

/Users/thomasalban/Downloads/RiiStudio/source/librii/objflow/ObjFlow.cpp:100:40: error: no member named 'split' in namespace 'ranges::views'
  for (auto word : std::ranges::views::split(param.AssetsListing, ";")) {
                   ~~~~~~~~~~~~~~~~~~~~^
1 error generated.
make[2]: *** [source/librii/CMakeFiles/librii.dir/objflow/ObjFlow.cpp.o] Error 1
make[1]: *** [source/librii/CMakeFiles/librii.dir/all] Error 2
make: *** [all] Error 2

ThomasAlban avatar Mar 12 '23 17:03 ThomasAlban

I just worked around that; pulling from upstream should do the trick.

snailspeed3 avatar Mar 12 '23 17:03 snailspeed3

Just ran git pull and ran the cmake commands again, now there is this error:

[ 85%] Linking CXX executable rszst
clang-15: error: no such file or directory: '/opt/homebrew/Cellar/freetype/2.13.0/lib/libfreetype.dylib'
make[2]: *** [source/cli/rszst] Error 1
make[1]: *** [source/cli/CMakeFiles/cli.dir/all] Error 2
make: *** [all] Error 2

ThomasAlban avatar Mar 12 '23 17:03 ThomasAlban

Try pulling again--should be fixed. I bumped the project's freetype version to match latest on brew.

snailspeed3 avatar Mar 12 '23 17:03 snailspeed3

Unfortunately I'm still getting the same error, the only difference is the version number of freetype :

[ 85%] Linking CXX executable rszst
clang-15: error: no such file or directory: '/opt/homebrew/Cellar/freetype/2.13.0_1/lib/libfreetype.dylib'
make[2]: *** [source/cli/rszst] Error 1
make[1]: *** [source/cli/CMakeFiles/cli.dir/all] Error 2
make: *** [all] Error 2

ThomasAlban avatar Mar 12 '23 18:03 ThomasAlban

Just tried running brew install freetype and I get this message but the version number is different, is this the issue?

Warning: freetype 2.12.1 is already installed and up-to-date.
To reinstall 2.12.1, run:
  brew reinstall freetype

ThomasAlban avatar Mar 12 '23 18:03 ThomasAlban

brew update I believe. It seems your package definitions are out of date?

snailspeed3 avatar Mar 12 '23 18:03 snailspeed3

Turns out I had some weird issue with brew update where it would just hang, but after some googling running brew update-reset fixed it for me. After doing that it was a success and I got it working!! Thank you for this wonderful piece of software :) is there a way to get it to run without the terminal opening up? And can I install it as though it were any other piece of software in the 'Applications' folder of my Mac?

ThomasAlban avatar Mar 12 '23 20:03 ThomasAlban

Thanks! To be honest, I'm not sure. I've never really touched Mac packaging, and I don't know how that would interact with the current GitHub auto-updater. I'll leave this as an open issue to track that.

snailspeed3 avatar Mar 12 '23 20:03 snailspeed3

Hi! I just wanted to ask how do i launch riistudio on mac?, i've installed it following the instructions, i had a few issues but i was able to complete the installation without errors, still i dont know how to launch it 🙈

angel8a131 avatar Mar 21 '23 20:03 angel8a131

Hi, you would open the executable in build/source/frontend/RiiStudio. Let me know if that works for you!

snailspeed3 avatar Mar 21 '23 20:03 snailspeed3

Hey, are you still planning on doing this? Unfortunately I know little about CMake, but I have built MacOS apps with Rust before so I do have some info that might be helpful that I'll just dump here:

A MacOS .app file is just a directory, this stack overflow post was really helpful for understanding its structure. So you should be able to automate the creation of that once you have an executable. I used this really helpful tool called cargo-bundle to do this for me.

In terms of the signing process, it seems like you need an Apple developer account to sign the app costing $100 a year (which is ridiculous ofc). Apple will add a quarantine flag to any app intalled which isn't signed meaning the app can't be opened, but the user can get around this by running xattr -d com.apple.quarantine path/to/binary.

ThomasAlban avatar May 17 '23 10:05 ThomasAlban

I added a very hacky Rust wrapper for the RiiStudio app, which if adapted for MacOS should allow deployment with cargo-bundle itself. I'll look into this a bit more later--though I am not enthused about the $100/yr developer subscription.

snailspeed3 avatar May 17 '23 20:05 snailspeed3

Oh cool. About the $100 a year thing, you could just not sign the apps then ask users to run the xattr command when they download it, which isn't ideal but would be better than nothing. I'm happy to help test anything!

ThomasAlban avatar May 18 '23 06:05 ThomasAlban

I've been trying to build Riistudio again, but am running into more issues (probably me not understanding how to do this properly!). I pulled the latest changes and ran brew upgrade and everything, before running: cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=/opt/homebrew/Cellar/llvm/16.0.6/bin/clang++ (changing the path to clang++ as before so that it works), this first command seems to work fine. However running cmake --build . --config Release --parallel produces a huge amount of errors, the end of which being:

/Applications/RiiStudio/source/oishii/../core/common.h:73:11: error: redefinition of 'views' as different kind of symbol
namespace views {
          ^
/opt/homebrew/Cellar/llvm/16.0.6/bin/../include/c++/v1/__ranges/views.h:29:11: note: previous definition is here
namespace views = ranges::views;
          ^
1 error generated.
gmake[2]: *** [source/LibBadUIFramework/CMakeFiles/LibBadUIFramework.dir/build.make:146: source/LibBadUIFramework/CMakeFiles/LibBadUIFramework.dir/RichNameManager.cpp.o] Error 1
1 error generated.
1 error generated.
gmake[2]: *** [source/LibBadUIFramework/CMakeFiles/LibBadUIFramework.dir/build.make:104: source/LibBadUIFramework/CMakeFiles/LibBadUIFramework.dir/Plugins.cpp.o] Error 1
gmake[2]: *** [source/oishii/CMakeFiles/oishii.dir/build.make:118: source/oishii/CMakeFiles/oishii.dir/util/util.cxx.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
1 error generated.
gmake[2]: *** [source/oishii/CMakeFiles/oishii.dir/build.make:160: source/oishii/CMakeFiles/oishii.dir/writer/node.cxx.o] Error 1
1 error generated.
gmake[2]: *** [source/LibBadUIFramework/CMakeFiles/LibBadUIFramework.dir/build.make:76: source/LibBadUIFramework/CMakeFiles/LibBadUIFramework.dir/ActionMenu.cpp.o] Error 1
1 error generated.
1 error generated.
gmake[2]: *** [source/LibBadUIFramework/CMakeFiles/LibBadUIFramework.dir/build.make:118: source/LibBadUIFramework/CMakeFiles/LibBadUIFramework.dir/PropertyView.cpp.o] Error 1
gmake[2]: *** [source/oishii/CMakeFiles/oishii.dir/build.make:132: source/oishii/CMakeFiles/oishii.dir/writer/binary_writer.cxx.o] Error 1
1 error generated.
gmake[2]: *** [source/LibBadUIFramework/CMakeFiles/LibBadUIFramework.dir/build.make:132: source/LibBadUIFramework/CMakeFiles/LibBadUIFramework.dir/Reflection.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:1710: source/LibBadUIFramework/CMakeFiles/LibBadUIFramework.dir/all] Error 2
1 error generated.
gmake[2]: *** [source/oishii/CMakeFiles/oishii.dir/build.make:146: source/oishii/CMakeFiles/oishii.dir/writer/linker.cxx.o] Error 1
1 error generated.
gmake[2]: *** [source/oishii/CMakeFiles/oishii.dir/build.make:104: source/oishii/CMakeFiles/oishii.dir/reader/binary_reader.cxx.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:1618: source/oishii/CMakeFiles/oishii.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2

I'd really appreciate some help on fixing this, thanks!

ThomasAlban avatar Jul 04 '23 21:07 ThomasAlban

Is this on a Sonoma preview build?

snailspeed3 avatar Jul 04 '23 21:07 snailspeed3

No I'm on the latest version of Ventura still

ThomasAlban avatar Jul 04 '23 21:07 ThomasAlban

Thanks for spotting that. I've fixed the build on clang-15 on Ventura, though have not validated clang-16 yet.

snailspeed3 avatar Jul 04 '23 23:07 snailspeed3

unfortunately I'm still getting errors:

[ 98%] Linking CXX executable tests
default.blight: Success
Warning: Material data is compressed. (in MAT3)
ReverseGravity2DLiftPlanet.bdl: Success
posteffect.blmap: Success
default.blmap: Success
Error: ai_json.dae: Rebuild does not match!
--> Expected: a76072344956a6036e78757def00a998
--> Actual:   2917d80cefb7c992817eaf245e4e297e
Error: Failed to read MDL0 course:  (in BRRES)
Error: old_town_ds.brres: Rebuild does not match!
--> Expected: 5908868b3d9c0f083ad3c23a1396d4ed
--> Actual:   ef3b76c1c9534de7c9eb52ad1150b8ae
ReverseGravity2DRoofActionPlanet.bdl: Success
rszst(25165,0x16e347000) malloc: *** error for object 0x45e87540c58a62ad: pointer being freed was not allocated
rszst(25165,0x16e347000) malloc: *** set a breakpoint in malloc_error_break to debug
b'RiiStudio CLI Alpha 5.10.8 (Hotfix 1) (Built Jul  4 2023 at 22:16:20, Homebrew Clang 16.0.6)\nProcessing...                   [>                                                                     ] 0 %\rExcluding tangents/bitangents\nExcluding boneweights\nExcluding animations\nExcluding lights\nExcluding cameras\nOptimizing meshes 0/0           [>                                                                     ] 0 %\rOptimizing meshes (0 / 22)      [>                                                                     ] 0 %\r' None -6
Error: course.dae failed to rebuild
/Applications/RiiStudio/build/source/cli/rszst import-command /Applications/RiiStudio/source/tests/../../tests/samples/course.dae /Applications/RiiStudio/source/tests/../../tests/out/course.dae
Error: tests.py encountered a critical error
Traceback (most recent call last):
  File "/Applications/RiiStudio/source/tests/../../tests/tests.py", line 189, in <module>
    run_tests(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
  File "/Applications/RiiStudio/source/tests/../../tests/tests.py", line 180, in run_tests
    run_test(test_exec, rszst, in_file, out_file)
  File "/Applications/RiiStudio/source/tests/../../tests/tests.py", line 146, in run_test
    rebuild(test_exec, rszst, path, rebuild_path, md5 == expected, bps)
  File "/Applications/RiiStudio/source/tests/../../tests/tests.py", line 131, in rebuild
    raise RuntimeError(err)
RuntimeError: None
gmake[2]: *** [source/tests/CMakeFiles/tests.dir/build.make:138: source/tests/tests] Error 1
gmake[2]: *** Deleting file 'source/tests/tests'
gmake[1]: *** [CMakeFiles/Makefile2:1843: source/tests/CMakeFiles/tests.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2

ThomasAlban avatar Jul 05 '23 10:07 ThomasAlban

There seems to be an issue with the Apple std::expected in this configuration. I'm falling back to tl::expected to fix that until the feature stabilizes more. Master should build now, although still with some tests diverging (for instance, the MacOS build is on a much newer version of Assimp than Windows for now (affecting the .dae output)).

snailspeed3 avatar Jul 05 '23 19:07 snailspeed3

thanks it worked! looks like a few of the tests failed though as you said

ThomasAlban avatar Jul 05 '23 21:07 ThomasAlban

I've added a MacOS build to the latest release (Apple Silicon). Note that it's neither signed nor compatible with the auto-updater.

I'll see about integrating trust at some point to automatically publish MacOS builds when new git tags are created.

snailspeed3 avatar Aug 13 '23 20:08 snailspeed3

I just downloaded the build, unzipped, right clicked and opened it, but got this error: image Looking into the log, this is the reason:

Termination Reason:    Namespace DYLD, Code 1 Library missing
Library not loaded: /Users/*/Documents/*/libgctex.dylib
Referenced from: <A6D96C6C-7FF9-3AF6-8BC5-D57B77D37F2E> /Applications/RiiStudio.app/Contents/MacOS/rust_bundle
Reason: tried: '/Users/*/Documents/*/libgctex.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/*/Documents/*/libgctex.dylib' (no such file), '/Users/*/Documents/*/libgctex.dylib' (no such file), '/usr/local/lib/libgctex.dylib' (no such file), '/usr/lib/libgctex.dylib' (no such file, not in dyld cache)
(terminated at launch; ignore backtrace)

ThomasAlban avatar Aug 13 '23 22:08 ThomasAlban