Skip to content

ykasidit/android_ndk_c_rust_go_builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Android NDK C/C++, Rust and Golang binary builder docker image

Use this image to quickly build Rust, Go or C/C++ executables, shared/static libs for Android.

Full credit to the respective authors.

Dockerhub page: https://hub.docker.com/r/ykasidit/android_ndk_c_rust_go_builder

Below are some docker run example usage/commands. (For faster builds that keeps a cache of dependencies, you can use docker create with a loop wait cmd like bash -c "while true; do sleep 1; done" then docker start your image as a running container then docker exec into that container to build into an existing container instead.)

Rust: build executable or shared/static lib for Android

(Run in an existing Rust cargo created project folder)

docker run --rm -v $(pwd):/build ykasidit/android_ndk_c_rust_go_builder_ext:latest bash -c "cd /build && cargo ndk build"

Rust: build executable or shared/static lib for GNU/Linux (Ubuntu 20.04)

(Run in an existing Rust cargo created project folder)

docker run --rm -v $(pwd):/build ykasidit/android_ndk_c_rust_go_builder_ext:latest bash -c "cd /build && cargo build"

Rust: clean the project ('target' folder)

(Run in an existing Rust cargo created project folder)

docker run --rm -v $(pwd):/build ykasidit/android_ndk_c_rust_go_builder_ext:latest bash -c "cd /build && cargo clean"

Rust: Generate headers for calling from C code

  • First create a file named cbindgen.toml containing the text: language = "C"
  • Then run command: (Run in an existing Rust cargo created project folder)

docker run --rm -v $(pwd):/build ykasidit/android_ndk_c_rust_go_builder_ext:latest bash -c "cd /build && cbindgen . -o yourlib.h"

C/C++: build Android.mk for Android

(Run in the 'jni' folder - that contains the Android.mk file - inside the desired NDK C/C++ project folder)

docker run --rm -v $(pwd):/build ykasidit/android_ndk_c_rust_go_builder_ext:latest bash -c "cd /build/qcdm_filter/android_exec_5/jni && ndk-build -j$(nproc)"

C/C++: build GNU/Linux Makefile (to build C/C++ code, etc)

(Run in the folder that has your Makefile)

docker run --rm -v $(pwd):/build ykasidit/android_ndk_c_rust_go_builder_ext:latest bash -c "cd /build/qcdm_filter && make -j$(nproc)"

Golang: Build for Android

(Run in the folder of the go.mod or upper then cd into them if have other folder dependencies)

docker run --rm -v $(pwd):/build ykasidit/android_ndk_c_rust_go_builder_ext:latest bash -c 'cd /build && CC=$ANDROID_TOOLCHAIN CXX=$ANDROID_TOOLCHAIN CGO_ENABLED=1 CGO_CFLAGS=-fcommon GOOS=android GOARCH=arm64 go build -ldflags="-s -w"'

Golang: Build for GNU/Linux

(Run in the folder of the go.mod or upper then cd into them if have other folder dependencies)

docker run --rm -v $(pwd):/build ykasidit/android_ndk_c_rust_go_builder_ext:latest bash -c 'cd /build && go build'

Releases

No releases published

Packages

No packages published