Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Adding support for android (and others architectures) #92

Open
lattice0 opened this issue Sep 27, 2020 · 3 comments
Open

Adding support for android (and others architectures) #92

lattice0 opened this issue Sep 27, 2020 · 3 comments

Comments

@lattice0
Copy link

Hi, I'll add support for other architectures. Take a look at the structure of the prebuilt binaries I have:

|-- android
|   |-- arm64-v8a
|   |   |-- include
|   |   |-- lib
|   |   `-- share
|   |-- armeabi-v7a
|   |   |-- include
|   |   |-- lib
|   |   `-- share
|   |-- x86
|   |   |-- include
|   |   |-- lib
|   |   `-- share
|   `-- x86_64
|       |-- include
|       |-- lib
|       `-- share
`-- desktop
    |-- aarch64
    |   |-- include
    |   |-- lib
    |   `-- share
    |-- x86_64
    |   |-- bin
    |   |-- include
    |   |-- lib
    |   `-- share
    `-- x86_64_generic
        |-- bin
        |-- include
        |-- lib
        `-- share

they're respecting android's jniLibs search model (even though we won't use it in this project). I have a docker container that builds then in this structure. For desktop this container builds with some hardware decoding support which is nice, I may link it here in the future, gotta clean it.

Anyways, looks like for now, rust-ffmpeg-sys supports specifying a folder that contains lib, bin, include. I'm planning to add an environment variable called MULTI_ARCHITECTURE_PREBUILT which would point to the root of my tree I just pasted here. Then if it's android it goes into android + right arch. I think I might change desktop/{x86_64,aarch64,x86_64_generic} to desktop/{linux/macos/windows}/{x86_64,aarch64,x86_64_generic}. Also there should be an iOS folder. What you think?

I'll have to delay iOS, Windows and macOS support because I dont have them now to build, but I plan to support them.

I also didn't look at how to use cargo to cross compile (for android for now) using build.rs. Gonna look on that. If somebody have a tip I appreciate. I want to build for android on linux, and for linux on linux (which already works)

@lattice0
Copy link
Author

Here's a draft:

master...lucaszanella:master

It's working when build to linux on linux. When building to android on linux using https://mozilla.github.io/firefox-browser-architecture/experiments/2017-09-21-rust-on-android.html (make standalone toolchain script), it starts selecting the dependencies and include paths correctly but it currently fails with this:

/usr/include/x86_64-linux-gnu/gnu/stubs.h:7:11: fatal error: 'gnu/stubs-32.h' file not found
 /usr/include/x86_64-linux-gnu/gnu/stubs.h:7:11: fatal error: 'gnu/stubs-32.h' file not found, err: true
 thread 'main' panicked at 'Unable to generate bindings: ()', build.rs:1249:6

probably something related with bindings library, gonna investigate.

@lattice0
Copy link
Author

Installing libc6-dev-i386 fixed the last error.

I removed avdevice since I dont have this lib for android. Using:

cargo build --verbose -vv --target aarch64-linux-android --release --no-default-features --features "avcodec avfilter avformat swresample swscale"

made the building work!

Gonna take a while to test on Android with real video data but it seems everything is ok 👍

I think I'm gonna wait a little to send a PR though? Don't know, gonna test more. I plan to add support for raspberry pi and nvidia jetson nano because I'm gonna use them in my project in the future, but cross compiling for them is kinda hard I guess.

@kornelski
Copy link
Collaborator

Thanks for this work. It's fine if you send a PR early. Others can help testing too.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants