I thought this might interest you Rust folk. This is kinda like an LLVM bitcode to JVM bytecode translator. So run rustc with --emit=llvm-ir (I think that’s the flag) and then pass the bitcode image to this program, then get JVM bytecode which you can make a JVM bytecode archive (JAR) from it. Could be an interesting? The author says it can JVM code from Clang output, so why not Rustc?

Keep in mind that these are two different beasts, JVM is designed for a safe virtual machine and LLVM is chiefly used to be translated into machine code. However, stupider and more wonderful things have been done with LLVM and JVM, for example, there’s an LLVM to 6502 translator, so you could be making NES games with Rust.

I will test this in a few days, busy implementing my own JVM (hope I can do it) and I don’t have the Rust toolchain installed on my system. But hey maybe someone can make a Cargo plugin from it (is it possible?)

Thanks, later.

  • AVincentInSpace@pawb.social
    link
    fedilink
    English
    arrow-up
    3
    ·
    6 months ago

    I dunno. I just kinda aimlessly Googled terms related to Android and Rust until I found that link.

    The GitHub link in my previous comment shows a basic example of using the egui GUI framework on Android via wgpu. I haven’t found an excuse to play around with it yet, plus getting the Android NDK cross compiler working with Cargo (for crates that compile C code) is a bit of a pain, but I’d assume it works how it says on the tin.

    Tell you what, gimme a minute to screw around with this and I’ll report back

    • XTL@sopuli.xyz
      link
      fedilink
      arrow-up
      1
      ·
      6 months ago

      This is a thing I look for now and then, but it always seems to fall back to “install android studio” and I nope at that point. Maybe one of these days. Having the ability to make some simple app would be interesting.

      • AVincentInSpace@pawb.social
        link
        fedilink
        English
        arrow-up
        3
        ·
        edit-2
        6 months ago

        @[email protected] @[email protected] Alright, I’m back. Survey says: we are, indeed, Android yet!

        I found this example repo in my travels: https://github.com/inferrna/hello_world_android_egui

        It shows the same demo setup that can be experienced through a Web browser at http://egui.rs, only now as a native-code Android application. To compile it I had to:

        • install lld (it uses that linker I think exclusively and will complain if you don’t have it)
        • rustup target add aarch64-linux-android
        • ignore the build instructions in the repo since the tool they recommend (cargo apk) has been deprecated and no longer works (either that or i couldn’t get it working – xbuild is easier anyway)
        • cargo install xbuild
        • cargo update the repo since the version of android-activity it ships with is out of date and will crash since my version of Android passed it a null pointer it wasn’t expecting
        • connect phone to PC via adb
        • invoke xbuild to compile and deploy the app: x run --device adb:ADB_ID_GOES_HERE

        I did NOT have to:

        • download Android Studio, even as the command line tools (xbuild took care of downloading the SDK and NDK for me)

        (I did download them separately as part of a different troubleshooting step, but I deleted them and it continued working. Not sure what to make of this. Not about to reinstall my OS to make sure these steps are reproducible. Please let me know if they are or not!)

        UPDATE: It seems egui is not able to accept text input at all – it does not know how to bring up the virtual keyboard when you click a textbox, nor does it accept keyboard input when the virtual keyboard is forced open through third party app nor through a physical USB keyboard. Still more work to be done, but I’m shocked at how much is already possible!

        • XTL@sopuli.xyz
          link
          fedilink
          arrow-up
          1
          ·
          6 months ago

          Very interesting, thank you. I should give this a try when I get back to a dev machine. Sounds like it still downloads and uses the SDK which might be significant for licensing or other reasons, but I’m probably fine with that for personal use.