ggez / good-web-game

An alternative ggez implementation on top of miniquad.
MIT License
337 stars 31 forks source link

"No such file or directory" when building for Android #66

Closed MOj0 closed 2 years ago

MOj0 commented 2 years ago

OS: Ubuntu 22.04.1 LTS

I cloned the repository and when I run the following command in the root folder: sudo docker run -e RUST_BACKTRACE='full' --rm -v $(pwd)":/root/src" -w /root/src notfl3/cargo-apk cargo quad-apk build --example meshbatch I get this output:

Updating crates.io index
 Downloading crates ...
  Downloaded dasp_frame v0.11.0
  Downloaded num-integer v0.1.45
  Downloaded num-iter v0.1.43
  Downloaded ordered-float v2.10.0
  Downloaded num_cpus v1.13.1
  Downloaded owned_ttf_parser v0.15.2
  Downloaded proc-macro2 v1.0.46
  Downloaded quote v1.0.21
  Downloaded quad-alsa-sys v0.3.2
  Downloaded ppv-lite86 v0.2.16
  Downloaded rand v0.7.3
  Downloaded rand_core v0.5.1
  Downloaded rand_core v0.4.2
  Downloaded rand_hc v0.1.0
  Downloaded rand_chacha v0.2.2
  Downloaded rand_os v0.1.3
  Downloaded rand_core v0.3.1
  Downloaded rand_pcg v0.1.2
  Downloaded rustc-hash v1.1.0
  Downloaded rayon v1.5.3
  Downloaded sapp-android v0.1.15
  Downloaded sapp-linux v0.1.13
  Downloaded scopeguard v1.1.0
  Downloaded serde v1.0.145
  Downloaded smallvec v0.6.14
  Downloaded sid v0.6.1
  Downloaded serde_derive v1.0.145
  Downloaded smart-default v0.6.0
  Downloaded syn v1.0.102
  Downloaded thiserror v1.0.37
  Downloaded twox-hash v1.5.0
  Downloaded ttf-parser v0.15.2
  Downloaded uuid v0.8.2
  Downloaded vec_map v0.8.2
  Downloaded thiserror-impl v1.0.37
  Downloaded xi-unicode v0.3.0
  Downloaded zip v0.5.13
  Downloaded approx v0.3.2
  Downloaded audir-sles v0.1.0
  Downloaded approx v0.5.1
  Downloaded adler32 v1.2.0
  Downloaded ab_glyph v0.2.17
  Downloaded autocfg v0.1.8
  Downloaded audrey v0.3.0
  Downloaded bytemuck v1.12.1
  Downloaded byteorder v1.4.3
  Downloaded bytemuck_derive v1.2.1
  Downloaded png v0.15.3
  Downloaded rand v0.6.5
  Downloaded ab_glyph_rasterizer v0.1.7
  Downloaded cgmath v0.17.0
  Downloaded crossbeam-channel v0.5.6
  Downloaded crossbeam-epoch v0.9.11
  Downloaded dasp_sample v0.11.0
  Downloaded crossbeam-utils v0.8.12
  Downloaded float_next_after v0.1.5
  Downloaded deflate v0.7.20
  Downloaded euclid v0.22.7
  Downloaded getrandom v0.1.16
  Downloaded gilrs v0.8.2
  Downloaded glyph_brush_draw_cache v0.1.5
  Downloaded image v0.22.5
  Downloaded lewton v0.9.4
  Downloaded hound v3.5.0
  Downloaded lyon_algorithms v0.17.7
  Downloaded lyon v0.17.10
  Downloaded linked-hash-map v0.5.6
  Downloaded inflate v0.4.5
  Downloaded lyon_geom v0.17.7
  Downloaded lyon_path v0.17.7
  Downloaded memoffset v0.6.5
  Downloaded lyon_tessellation v0.17.10
  Downloaded miniquad v0.3.0-alpha.38
  Downloaded mint v0.5.9
  Downloaded rand_jitter v0.1.4
  Downloaded rayon-core v1.9.3
  Downloaded rand_xorshift v0.1.1
  Downloaded unicode-ident v1.0.5
  Downloaded glyph_brush v0.7.2
  Downloaded either v1.8.0
  Downloaded crossbeam-deque v0.8.2
  Downloaded gilrs-core v0.3.2
  Downloaded libudev-sys v0.1.4
  Downloaded maybe-uninit v2.0.0
  Downloaded glyph_brush_layout v0.2.3
  Downloaded rand_chacha v0.1.1
  Downloaded ogg v0.7.1
  Downloaded rand_isaac v0.1.1
  Downloaded nix v0.23.1
  Downloaded num-traits v0.2.15
  Downloaded num-rational v0.2.4
  Downloaded ndk-sys v0.2.2
  Downloaded libm v0.2.5
  Downloaded libc v0.2.134
  Downloaded quad-snd v0.2.5
 Downloading crates ...
  Downloaded keyframe_derive v1.0.0
  Downloaded oorandom v11.1.3
  Downloaded num-derive v0.3.3
  Downloaded quad-rand v0.2.1
  Downloaded keyframe v1.1.1
  Downloaded glam v0.17.3
   Compiling lewton v0.9.4
   Compiling audrey v0.3.0
   Compiling quad-snd v0.2.5
   Compiling good-web-game v0.5.0 (/root/src)
warning: field is never read: `root`
  --> src/filesystem.rs:24:5
   |
24 |     root: Option<path::PathBuf>,
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default
note: `Filesystem` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
  --> src/filesystem.rs:22:10
   |
22 | #[derive(Debug)]
   |          ^^^^^
   = note: this warning originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: `good-web-game` (lib) generated 1 warning
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/ops/build/compile.rs:165:18
stack backtrace:
   0:     0x55a48f0e2c6d - std::backtrace_rs::backtrace::libunwind::trace::h22893a5306c091b4
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x55a48f0e2c6d - std::backtrace_rs::backtrace::trace_unsynchronized::h29c3bc6f9e91819d
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x55a48f0e2c6d - std::sys_common::backtrace::_print_fmt::he497d8a0ec903793
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x55a48f0e2c6d - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9c2a9d2774d81873
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x55a48f10aeac - core::fmt::write::hba4337c43d992f49
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/fmt/mod.rs:1194:17
   5:     0x55a48f0dda81 - std::io::Write::write_fmt::heb73de6e02cfabed
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/io/mod.rs:1655:15
   6:     0x55a48f0e5115 - std::sys_common::backtrace::_print::h63c8b24acdd8e8ce
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x55a48f0e5115 - std::sys_common::backtrace::print::h426700d6240cdcc2
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x55a48f0e5115 - std::panicking::default_hook::{{closure}}::hc9a76eed0b18f82b
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:295:22
   9:     0x55a48f0e4dc9 - std::panicking::default_hook::h2e88d02087fae196
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:314:9
  10:     0x55a48f0e5662 - std::panicking::rust_panic_with_hook::habfdcc2e90f9fd4c
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:698:17
  11:     0x55a48f0e5547 - std::panicking::begin_panic_handler::{{closure}}::he054b2a83a51d2cd
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:588:13
  12:     0x55a48f0e3124 - std::sys_common::backtrace::__rust_end_short_backtrace::ha48b94ab49b30915
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:138:18
  13:     0x55a48f0e5279 - rust_begin_unwind
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:584:5
  14:     0x55a48e97ffe3 - core::panicking::panic_fmt::h366d3a309ae17c94
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:143:14
  15:     0x55a48e9800d3 - core::result::unwrap_failed::hddd78f4658ac7d0f
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/result.rs:1785:5
  16:     0x55a48e9e8c2c - <cargo_quad_apk::ops::build::compile::SharedLibraryExecutor as cargo::core::compiler::Executor>::exec::hecd7f5a732703b11
  17:     0x55a48eafc29c - core::ops::function::FnOnce::call_once{{vtable.shim}}::h89048bd199c4c0bd
  18:     0x55a48eafafcc - core::ops::function::FnOnce::call_once{{vtable.shim}}::h53362546aa0cb559
  19:     0x55a48eafafcc - core::ops::function::FnOnce::call_once{{vtable.shim}}::h53362546aa0cb559
  20:     0x55a48ea16366 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h8587960837c1a47f
  21:     0x55a48ea7cfee - std::sys_common::backtrace::__rust_begin_short_backtrace::h18f4b9ad908d67c2
  22:     0x55a48ecd71ca - core::ops::function::FnOnce::call_once{{vtable.shim}}::haf12b2dab199031b
  23:     0x55a48f0ebeb3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha99802c2c52ada61
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/alloc/src/boxed.rs:1861:9
  24:     0x55a48f0ebeb3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha39aea1c57e28a15
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/alloc/src/boxed.rs:1861:9
  25:     0x55a48f0ebeb3 - std::sys::unix::thread::Thread::new::thread_start::h9f8e3d72b1f7662f
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys/unix/thread.rs:108:17
  26:     0x7f15c01c6ea7 - start_thread
  27:     0x7f15bffaadef - clone
  28:                0x0 - <unknown>
error: worker panicked
thread 'main' panicked at 'child threads shouldn't panic: Any { .. }', /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/cargo-0.62.0/src/cargo/core/compiler/job_queue.rs:565:10
stack backtrace:
   0:     0x55a48f0e2c6d - std::backtrace_rs::backtrace::libunwind::trace::h22893a5306c091b4
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x55a48f0e2c6d - std::backtrace_rs::backtrace::trace_unsynchronized::h29c3bc6f9e91819d
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x55a48f0e2c6d - std::sys_common::backtrace::_print_fmt::he497d8a0ec903793
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x55a48f0e2c6d - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9c2a9d2774d81873
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x55a48f10aeac - core::fmt::write::hba4337c43d992f49
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/fmt/mod.rs:1194:17
   5:     0x55a48f0dda81 - std::io::Write::write_fmt::heb73de6e02cfabed
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/io/mod.rs:1655:15
   6:     0x55a48f0e5115 - std::sys_common::backtrace::_print::h63c8b24acdd8e8ce
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x55a48f0e5115 - std::sys_common::backtrace::print::h426700d6240cdcc2
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x55a48f0e5115 - std::panicking::default_hook::{{closure}}::hc9a76eed0b18f82b
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:295:22
   9:     0x55a48f0e4dc9 - std::panicking::default_hook::h2e88d02087fae196
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:314:9
  10:     0x55a48f0e5662 - std::panicking::rust_panic_with_hook::habfdcc2e90f9fd4c
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:698:17
  11:     0x55a48f0e5547 - std::panicking::begin_panic_handler::{{closure}}::he054b2a83a51d2cd
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:588:13
  12:     0x55a48f0e3124 - std::sys_common::backtrace::__rust_end_short_backtrace::ha48b94ab49b30915
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:138:18
  13:     0x55a48f0e5279 - rust_begin_unwind
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:584:5
  14:     0x55a48e97ffe3 - core::panicking::panic_fmt::h366d3a309ae17c94
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:143:14
  15:     0x55a48e9800d3 - core::result::unwrap_failed::hddd78f4658ac7d0f
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/result.rs:1785:5
  16:     0x55a48eb468c9 - cargo::core::compiler::job_queue::JobQueue::execute::hba7ec7a43962ba31
  17:     0x55a48eacf87c - cargo::core::compiler::context::Context::compile::h12a1634d09886c54
  18:     0x55a48ec97aab - cargo::ops::cargo_compile::compile_ws::hc7ed5025c3dd63b8
  19:     0x55a48ec978b1 - cargo::ops::cargo_compile::compile_with_exec::hdd1df846945e4d8f
  20:     0x55a48e9e5212 - cargo_quad_apk::ops::build::compile::build_shared_libraries::h2e67de507c24ff76
  21:     0x55a48e9b7945 - cargo_quad_apk::ops::build::build::h1b15337b0f0cb992
  22:     0x55a48e9c8aca - cargo_quad_apk::main::he8379582492ed856
  23:     0x55a48e9cbe53 - std::sys_common::backtrace::__rust_begin_short_backtrace::h70860d16cf446d25
  24:     0x55a48e9f8599 - std::rt::lang_start::{{closure}}::he9d9d9652557586f
  25:     0x55a48f0d665e - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::had4f69b3aefb47a8
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/ops/function.rs:259:13
  26:     0x55a48f0d665e - std::panicking::try::do_call::hf2ad5355fcafe775
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:492:40
  27:     0x55a48f0d665e - std::panicking::try::h0a63ac363423e61e
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:456:19
  28:     0x55a48f0d665e - std::panic::catch_unwind::h18088edcecb8693a
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panic.rs:137:14
  29:     0x55a48f0d665e - std::rt::lang_start_internal::{{closure}}::ha7dad166dc711761
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/rt.rs:128:48
  30:     0x55a48f0d665e - std::panicking::try::do_call::hda0c61bf3a57d6e6
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:492:40
  31:     0x55a48f0d665e - std::panicking::try::hbc940e68560040a9
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:456:19
  32:     0x55a48f0d665e - std::panic::catch_unwind::haed0df2aeb3fa368
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panic.rs:137:14
  33:     0x55a48f0d665e - std::rt::lang_start_internal::h9c06694362b5b80c
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/rt.rs:128:20
  34:     0x55a48e9cbce2 - main
  35:     0x7f15bfed3d0a - __libc_start_main
  36:     0x55a48e9802da - _start
  37:                0x0 - <unknown>

I'm not sure what could be the problem, however when I ran the same command in the miniquad repo the build completed and it worked successfully on my Android device.

PSteinhaus commented 2 years ago

sigh, that should be fixed asap indeed. Thanks for sharing.

I don't know what the problem is either, but I assume miniquad now being at 0.3.13 while I still use an old alpha might likely be the culprit. High time to update that.

PSteinhaus commented 2 years ago

Ok, I looked into it, but I fear I don't see an elegant solution to this. With EventHandlerFree disappearing I think I'd have to restructure everything to no longer store the miniquad context (because we can't), but to instead hand it through, coming from update and draw, everywhere where it was used before.

This makes everything a bit more clunky, but it's not the end of the world.

I'm pretty optimistic that this would fix the problem, as miniquad would be in sync again, but to be honest I'm not sure if I'll get up the motivation to do this soon, with ggez aiming for its own Android support somewhere in the not-too-soon future.

But I guess I'll try. It's not that much work.

EDIT: Another approach would be to write an instruction on how to get older version of cargo-quad-apk running yourself, without depending on the latest docker image. This would have the benefit of enabling people to keep on building for Android even with older versions of gwg. And it would also be most correct in terms of this being a recurring problem otherwise...

But in the end it would probably be best to do both, meh... I don't think I'll write the latter thing though, as I just have to little experience with Docker to give any reliable advice on this.

PSteinhaus commented 2 years ago

OK. I just released 0.6.0 . In it I changed everything to respect the loss of EventHandlerFree, making us hand around quad_ctx a lot. I checked everything except the Android build. If your project is simple enough to adapt to the new changes I'd be very thankful if you could perhaps try it again with these changes. Or perhaps it's way simpler to just try one of the examples, but I'm just done for today (and busy tomorrow).

So... now that I did all this I wondered: "Well, this is annoying. How does macroquad solve this?" And what do you know, they just solve it by storing the miniquad context inside of a big juicy unsafe static variable: ^^

static mut CONTEXT: Option<Context> = None;

...

miniquad::start(
    conf::Conf {
        sample_count: 4,
        ..config
    },
    |ctx| {
        unsafe {
            MAIN_FUTURE = Some(Box::pin(future));
        }
        unsafe { CONTEXT = Some(Context::new(ctx)) };
        Box::new(Stage {})
    },
);

To be honest I feel a bit stupid now. Maybe that would have been the way to go and I'll do so in the next version as well...

MOj0 commented 2 years ago

Great! It works now :). And I see that putting that quad_ctx in an unsafe static variable would be easier, but there is also this comment where that variable is set, so ¯_(ツ)_/¯ . Anyways, I'm closing this since it is working.