katyo / oboe-rs

Rust bindings for Oboe high-performance audio IO Android library
65 stars 22 forks source link

Oboe 0.3.1 failing to compile on rust 1.52.0 nightly #25

Closed benluelo closed 3 years ago

benluelo commented 3 years ago

This is my first issue, so please let me know if you need anything else!

Expected Behaviour

Compile with no issues.

Current Behaviour

Fails to compile with this error:

error: attribute must be applied to a `static` variable
   --> /home/ben/.cargo/registry/src/github.com-1ecc6299db9ec823/oboe-0.3.1/src/audio_stream.rs:625:5
    |
625 |     #[used]
    |     ^^^^^^^

error: aborting due to previous error

error: could not compile `oboe`

Steps to Reproduce

  1. clone bevy on branch v0.4.0 https://github.com/bevyengine/bevy/tree/v0.4.0/examples/android
  2. run cargo apk run --example android

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

Failure Logs

// snip
       Fresh oboe-sys v0.3.0
       Fresh bevy_diagnostic v0.4.0 (/home/ben/codeprojects/bevy/crates/bevy_diagnostic)
       Fresh bevy_scene v0.4.0 (/home/ben/codeprojects/bevy/crates/bevy_scene)
       Fresh bevy_winit v0.4.0 (/home/ben/codeprojects/bevy/crates/bevy_winit)
       Fresh bevy_gilrs v0.4.0 (/home/ben/codeprojects/bevy/crates/bevy_gilrs)
   Compiling oboe v0.3.1
     Running `rustc --crate-name oboe --edition=2018 /home/ben/.cargo/registry/src/github.com-1ecc6299db9ec823/oboe-0.3.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="java-interface"' --cfg 'feature="jni"' --cfg 'feature="ndk"' --cfg 'feature="ndk-glue"' -C metadata=04654b9a4299ecf2 -C extra-filename=-04654b9a4299ecf2 --out-dir /home/ben/codeprojects/bevy/target/aarch64-linux-android/debug/deps --target aarch64-linux-android -C linker=/usr/lib/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android29-clang -L dependency=/home/ben/codeprojects/bevy/target/aarch64-linux-android/debug/deps -L dependency=/home/ben/codeprojects/bevy/target/debug/deps --extern jni=/home/ben/codeprojects/bevy/target/aarch64-linux-android/debug/deps/libjni-9eb37b51ac2e2edc.rmeta --extern ndk=/home/ben/codeprojects/bevy/target/aarch64-linux-android/debug/deps/libndk-91afc5cdbbbc12d9.rmeta --extern ndk_glue=/home/ben/codeprojects/bevy/target/aarch64-linux-android/debug/deps/libndk_glue-2fcd4096334b7677.rmeta --extern num_derive=/home/ben/codeprojects/bevy/target/debug/deps/libnum_derive-dfaf4941df856d3f.so --extern num_traits=/home/ben/codeprojects/bevy/target/aarch64-linux-android/debug/deps/libnum_traits-7f532ff9580dc3a4.rmeta --extern oboe_sys=/home/ben/codeprojects/bevy/target/aarch64-linux-android/debug/deps/liboboe_sys-ba461f8f7c0e2421.rmeta --cap-lints allow -L native=/home/ben/codeprojects/bevy/target/aarch64-linux-android/debug/build/oboe-sys-d900614c4d870bd7/out/library`
   Compiling minimp3 v0.5.1
     Running `rustc --crate-name minimp3 --edition=2018 /home/ben/.cargo/registry/src/github.com-1ecc6299db9ec823/minimp3-0.5.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' -C metadata=12ea4e666b1dd364 -C extra-filename=-12ea4e666b1dd364 --out-dir /home/ben/codeprojects/bevy/target/aarch64-linux-android/debug/deps --target aarch64-linux-android -C linker=/usr/lib/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android29-clang -L dependency=/home/ben/codeprojects/bevy/target/aarch64-linux-android/debug/deps -L dependency=/home/ben/codeprojects/bevy/target/debug/deps --extern minimp3_sys=/home/ben/codeprojects/bevy/target/aarch64-linux-android/debug/deps/libminimp3_sys-d0683fec26ab3590.rmeta --extern slice_deque=/home/ben/codeprojects/bevy/target/aarch64-linux-android/debug/deps/libslice_deque-c750e1093616f99b.rmeta --extern thiserror=/home/ben/codeprojects/bevy/target/aarch64-linux-android/debug/deps/libthiserror-9a1780d7923cbca9.rmeta --cap-lints allow -L native=/home/ben/codeprojects/bevy/target/aarch64-linux-android/debug/build/minimp3-sys-c290b1b7b216fbc9/out`
error: attribute must be applied to a `static` variable
   --> /home/ben/.cargo/registry/src/github.com-1ecc6299db9ec823/oboe-0.3.1/src/audio_stream.rs:625:5
    |
625 |     #[used]
    |     ^^^^^^^

error: aborting due to previous error

error: could not compile `oboe`

Caused by:
  process didn't exit successfully: `rustc --crate-name oboe --edition=2018 /home/ben/.cargo/registry/src/github.com-1ecc6299db9ec823/oboe-0.3.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="java-interface"' --cfg 'feature="jni"' --cfg 'feature="ndk"' --cfg 'feature="ndk-glue"' -C metadata=04654b9a4299ecf2 -C extra-filename=-04654b9a4299ecf2 --out-dir /home/ben/codeprojects/bevy/target/aarch64-linux-android/debug/deps --target aarch64-linux-android -C linker=/usr/lib/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android29-clang -L dependency=/home/ben/codeprojects/bevy/target/aarch64-linux-android/debug/deps -L dependency=/home/ben/codeprojects/bevy/target/debug/deps --extern jni=/home/ben/codeprojects/bevy/target/aarch64-linux-android/debug/deps/libjni-9eb37b51ac2e2edc.rmeta --extern ndk=/home/ben/codeprojects/bevy/target/aarch64-linux-android/debug/deps/libndk-91afc5cdbbbc12d9.rmeta --extern ndk_glue=/home/ben/codeprojects/bevy/target/aarch64-linux-android/debug/deps/libndk_glue-2fcd4096334b7677.rmeta --extern num_derive=/home/ben/codeprojects/bevy/target/debug/deps/libnum_derive-dfaf4941df856d3f.so --extern num_traits=/home/ben/codeprojects/bevy/target/aarch64-linux-android/debug/deps/libnum_traits-7f532ff9580dc3a4.rmeta --extern oboe_sys=/home/ben/codeprojects/bevy/target/aarch64-linux-android/debug/deps/liboboe_sys-ba461f8f7c0e2421.rmeta --cap-lints allow -L native=/home/ben/codeprojects/bevy/target/aarch64-linux-android/debug/build/oboe-sys-d900614c4d870bd7/out/library` (exit code: 1)
warning: build failed, waiting for other jobs to finish...
error: build failed
Error: Command 'cargo build --target aarch64-linux-android --example android --verbose' had a non-zero exit code.
katyo commented 3 years ago

Hmm... https://github.com/katyo/oboe-rs/blob/a98967e15c8aaa4f285839ffba454332f6d63363/oboe/src/audio_stream.rs#L622-L627

Seems it should looks like so:

pub struct AudioStreamAsync<D, F> { 
     raw: AudioStreamHandle, 

     #[allow(dead_code)] 
     callback: AudioCallbackWrapper<D, F>, 
 } 
katyo commented 3 years ago

@benluelo Can you test latest master?

benluelo commented 3 years ago

I moved the android bevy example to a new project and added the oboe at the latest master as a dependency, and oboe v0.4.0 builds fine, however oboe v0.3.1 still fails to compile. Its a dependency of cpal v0.13.1, and I'm not sure how to change that dependency.

oboe = { git = "https://github.com/katyo/oboe-rs", branch = "master" }
starccy commented 3 years ago

@benluelo My way is:

  1. Clone the cpal to local.
  2. Modify its Cargo.toml and change oboe to the git version you mentioned above.
  3. Modify my project Cargo.toml, add a [patch] field for cpal, which point to the local cpal path.
katyo commented 3 years ago

Fixed in 0.4.1