dtaralla / rrise

A Rust binding for Wwise
Other
13 stars 4 forks source link

Adding Support for MacOS #1

Open superkittens opened 2 years ago

superkittens commented 2 years ago

Are there any plans to add support development with rrise on MacOS? I see there is a MacOS build script with a todo!() macro.

dtaralla commented 2 years ago

I'd really like to, but I have no way to test on Mac and never used Wwise for deployment on MacOS either :/ it's a bit too "shot in the dark" for me!

superkittens commented 2 years ago

So I'm working on getting this to build on mac. It's not too bad so far but I'm running into a bindgen error "failed to add native library libAKSoundEngine.a: file too small to be an archive" Have you run into this before on the Windows/Linux end?

dtaralla commented 2 years ago

Hmmm I've never seen this error before; maybe try reinstalling the MacOS stack from Wwise launcher and try again? Maybe your version of the library is truncated or didn't copy properly? What is the size of this file compared to other platforms like Linux? It should be pretty big AFAIK. Also just to make sure: are you on 2021.1.7?

superkittens commented 2 years ago

I'm on 21.1.9 but I'm not sure if that would affect the build process (I was able to build another C++ project using this version). Quick check, the command to build rrise is RUSTFLAGS="cfg=wwrelease" cargo build --release right?

dtaralla commented 2 years ago

In my case on Windows, this is how I build: $env:RUSTFLAGS="--cfg wwrelease"; cargo build --release, I'm not sure about your RUSTFLAGS. Also, do you have this linking error when building without --release and wwrelease?

dtaralla commented 2 years ago

I can try cross-compiling to MacOS from WSL2 maybe. Could you push on your fork a branch with your experimental MacOS support for rrise so that I can dig deeper?

superkittens commented 2 years ago

Yeah even without --release and wwrelease, I get the linker errors. I pushed my changes which you can find here

dtaralla commented 2 years ago

Unfortunately I couldn't get it to cross-compile, sorry. I couldn't find a way to get the standard library for MacOS, only its SDK v.v Let me know if/when you find anything, I'll be happy to merge.

superkittens commented 2 years ago

Hey thanks for trying. I'll keep plugging away at this and see if I can make any progress

Maufeat commented 1 year ago

Hey, is there any progress? I just stumbled across this crate

dtaralla commented 1 year ago

Couldn't do anything from my side as I don't have any macs...

Maufeat commented 1 year ago

Mh, I tried to run it but I get 5 errors. No linker errors though.

/Applications/Audiokinetic/Wwise 2021.1.7.7796/SDK/samples/SoundEngine/POSIX/../Common/AkFileHelpersBase.h:90:28: error: expected expression

/Applications/Audiokinetic/Wwise 2021.1.7.7796/SDK/include/AK/SoundEngine/Common/IAkPlugin.h:1729:23: error: expected '(' Applications/Audiokinetic/Wwise 2021.1.7.7796/SDK/include/AK/SoundEngine/Common/IAkPlugin.h:1718:6: error: member initializer 'pNext' does not name a non-static data member or base class /Applications/Audiokinetic/Wwise 2021.1.7.7796/SDK/include/AK/SoundEngine/Common/IAkPlugin.h:1729:59: error: expected ';' after expression

Maufeat commented 1 year ago

Now I get no error, but instead just get a libclang error: (printing flags at second line of snippet)

  cargo:rustc-link-lib=c++
  idx: 0x135f06a50, fname: 0x135f04790, c_args: ["-I/Applications/Audiokinetic/Wwise 2021.1.11.7933/SDK/include", "-x", "c++", "-std", "c++11", "-isysroot", "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk", "-include", "c/ak.h", "c/utilities/default_streaming_mgr.h"], c_args.len(): 10, c_unsaved: 0x8, c_unsaved.len(): 0, opts: 1

  --- stderr
  thread 'main' panicked at 'libclang error; possible causes include:
  - Invalid flag syntax
  - Unrecognized flags
  - Invalid flag arguments
  - File I/O errors
  - Host vs. target architecture mismatch
  If you encounter an error missing from this list, please file an issue or a PR!', /Users/s.habermann/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.63.0/ir/context.rs:530:15
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/270c94e484e19764a2832ef918c95224eb3f17c7/library/std/src/panicking.rs:575:5
     1: core::panicking::panic_fmt
               at /rustc/270c94e484e19764a2832ef918c95224eb3f17c7/library/core/src/panicking.rs:64:14
     2: core::panicking::panic_display
               at /rustc/270c94e484e19764a2832ef918c95224eb3f17c7/library/core/src/panicking.rs:136:5
     3: core::panicking::panic_str
               at /rustc/270c94e484e19764a2832ef918c95224eb3f17c7/library/core/src/panicking.rs:120:5
     4: core::option::expect_failed
               at /rustc/270c94e484e19764a2832ef918c95224eb3f17c7/library/core/src/option.rs:1923:5
     5: core::option::Option<T>::expect
     6: bindgen::ir::context::BindgenContext::new
     7: bindgen::Bindings::generate
     8: bindgen::Builder::generate
     9: build_script_build::main
    10: core::ops::function::FnOnce::call_once
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
dtaralla commented 1 year ago

I'd check the various causes given on stderr. Maybe one of the flags needs to be adapted from MSVC for clang. Did you try compiling with the code from this repository? Superkittens did some mods to the buildscript to support mac, but I don't know which issue they encountered.

Maufeat commented 1 year ago

Already looked into it, yeah. Didn't helped :/ I will read more into it.

Maufeat commented 1 year ago

Got it to compile. See #4

Maufeat commented 1 year ago

My first attempt at integrating it to bevy looked good, not working since I have a few plugin/dynamic libs that are not linked but apparently it works.

Bildschirmfoto 2023-01-04 um 03 23 53

dtaralla commented 1 year ago

Very good work! It's already promising. Could you try running the supplied examples instead, to make sure I can assist you in your further questions? This way we're sure we'll be talking about the same things. You can also use the crate's tests to check if Rrise can build in common scenarios.

About the plugin errors, I think I see what's going on here. You are using dynamic loading for plugins like AkRoomVerb, and those are not installed in your toolchain. More info in the Wwise docs.

To circumvent this issue, you could try static-linking those plugins using Rrise's crate features. Just enable the corresponding features, and those warnings should go away (as well as the AK Error prints). If static-linking is not desirable, especially during development to benefit from shorter link times, you need to tell Wwise where to look for the dynamic libraries.

In a real application, you'd publish the libAkRoomVerb.bundle etc alongside your executable, so these errors wouldn't happen as the dynamic library could be found at runtime. But while developing, because you don't actually deploy the application, you need to add the %WWISE_SDK%/Mac/{profile}/lib/ path to your dynamic library locations at runtime. Look how I do it for linux and windows in my examples (like looping_event.rs).