Skip to content

Commit

Permalink
Rename as 'cargo-ndk' and polish
Browse files Browse the repository at this point in the history
  • Loading branch information
tyranron committed Apr 6, 2021
1 parent a2aea59 commit ad15b8c
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 86 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ on:
pull_request:
push:
schedule:
- cron: '0 12 * * 3'
- cron: '45 11 * * 3'

env:
PUBLISH: ${{ github.event_name == 'push'
&& (startsWith(github.ref, 'refs/tags/0')
|| startsWith(github.ref, 'refs/tags/1')
&& (startsWith(github.ref, 'refs/tags/1')
|| startsWith(github.ref, 'refs/tags/2')
|| startsWith(github.ref, 'refs/tags/3')
|| startsWith(github.ref, 'refs/tags/4')
Expand Down Expand Up @@ -71,7 +70,7 @@ jobs:
DOCKER_APIKEY: ${{ secrets.QUAYIO_API_TOKEN }}
with:
provider: quay
destination_container_repo: quay.io/instrumentisto/rust-ndk-builder
destination_container_repo: quay.io/instrumentisto/cargo-ndk
readme_file: README.md
if: ${{ env.PUBLISH == 'true' }}
- name: Update README on Docker Hub
Expand All @@ -81,7 +80,7 @@ jobs:
DOCKER_PASS: ${{ secrets.DOCKERHUB_BOT_PASS }}
with:
provider: dockerhub
destination_container_repo: instrumentisto/rust-ndk-builder
destination_container_repo: instrumentisto/cargo-ndk
readme_file: README.md
if: ${{ env.PUBLISH == 'true' }}

Expand Down
27 changes: 16 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
rust-ndk-builder image changelog
===========================
cagon-ndk image changelog
=========================

All user visible changes to this project will be documented in this file. This project uses [Semantic Versioning 2.0.0].




## [r21e-r0] · 2021-??-??
[r21e-r0]: /../../tree/r21e-r0
## [2.2.0-ndkr21e-rust1.51-r0] · 2021-04-06
[2.2.0-ndkr21e-rust1.51-r0]: /../../tree/2.2.0-ndkr21e-rust1.51-r0

### Added

- Android NDK r21e
- cargo-ndk crate
- Rust targets:
- aarch64-linux-android
- armv7-linux-androideabi
- x86_64-linux-android
- i686-linux-android
- [Android NDK] r21e: <https://github.com/android/ndk/wiki/Changelog-r21#r21e>
- [cargo-ndk] 2.2.0: <https://github.com/bbqsrc/cargo-ndk/releases/tag/v2.2.0>
- [Rust] 1.51: <https://blog.rust-lang.org/2021/03/25/Rust-1.51.0.html>
- [Rust] targets:
- `aarch64-linux-android`
- `armv7-linux-androideabi`
- `x86_64-linux-android`
- `i686-linux-android`





[Android NDK]: https://developer.android.com/ndk
[cargo-ndk]: https://crates.io/crates/cargo-ndk
[Rust]: https://www.rust-lang.org
[Semantic Versioning 2.0.0]: https://semver.org
52 changes: 33 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
# https://hub.docker.com/_/rust
ARG rust_ver=1.51
FROM ghcr.io/instrumentisto/rust:${rust_ver}-slim-buster
FROM rust:${rust_ver}-slim-buster

ARG android_ndk_ver=r21e
ARG cargo_ndk_ver=2.2.0
ARG build_rev=0

LABEL org.opencontainers.image.source="\
https://github.com/instrumentisto/rust-ndk-builder-docker-image"
https://github.com/instrumentisto/cargo-ndk-docker-image"


# Install Rust targets for Android platforms
RUN rustup target add aarch64-linux-android \
armv7-linux-androideabi \
i686-linux-android \
x86_64-linux-android


# Install Android NDK
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends --no-install-suggests \
ca-certificates \
&& update-ca-certificates \
\
# Install tools needed for Android NDK installation
&& toolDeps="apt-transport-https wget unzip gnupg" \
# Install installation tools
&& toolDeps="curl unzip" \
&& apt-get install -y --no-install-recommends --no-install-suggests \
$toolDeps \
\
# Install Android NDK
&& wget https://dl.google.com/android/repository/android-ndk-${android_ndk_ver}-linux-x86_64.zip \
&& unzip android-ndk-${android_ndk_ver}-linux-x86_64.zip \
\
# Install Rust targets for Android platform
&& rustup target add aarch64-linux-android \
armv7-linux-androideabi \
x86_64-linux-android \
i686-linux-android \
\
# Install cargo-ndk crate
&& cargo install cargo-ndk \
# Install NDK itself
&& curl -fL -o /tmp/android-ndk.zip \
https://dl.google.com/android/repository/android-ndk-${android_ndk_ver}-linux-x86_64.zip \
&& unzip /tmp/android-ndk.zip -d /usr/local/ \
\
# Cleanup unnecessary stuff
&& apt-get purge -y --auto-remove \
Expand All @@ -35,7 +41,15 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/* \
/tmp/*

# Path to the Android NDK for cargo-ndk crate.
ENV NDK_HOME=/android-ndk-${android_ndk_ver}
# Path to the Android NDK for cargo-ndk Cargo plugin
ENV ANDROID_NDK_HOME=/usr/local/android-ndk-${android_ndk_ver} \
NDK_HOME=/usr/local/android-ndk-${android_ndk_ver}

WORKDIR "/app"


# Install cargo-ndk Cargo plugin
RUN cargo install --version=${cargo_ndk_ver} cargo-ndk \
\
# Cleanup unnecessary stuff
&& rm -rf /usr/local/cargo/registry/ \
/tmp/*
28 changes: 19 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,25 @@ eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\

ANDROID_NDK_VER ?= $(strip \
$(shell grep 'ARG android_ndk_ver=' Dockerfile | cut -d '=' -f2))
CARGO_NDK_VER ?= $(strip \
$(shell grep 'ARG cargo_ndk_ver=' Dockerfile | cut -d '=' -f2))
RUST_VER ?= $(strip \
$(shell grep 'ARG rust_ver=' Dockerfile | cut -d '=' -f2))
BUILD_REV ?= $(strip \
$(shell grep 'ARG build_rev=' Dockerfile | cut -d '=' -f2))

NAMESPACES := instrumentisto \
ghcr.io/instrumentisto \
quay.io/instrumentisto
NAME := rust-ndk-builder
TAGS ?= $(ANDROID_NDK_VER)-r$(BUILD_REV) \
$(ANDROID_NDK_VER)-r$(BUILD_REV)-debian-slim-buster \
$(ANDROID_NDK_VER)-r$(BUILD_REV)-debian \
$(ANDROID_NDK_VER) \
$(ANDROID_NDK_VER)-debian-slim-buster \
$(ANDROID_NDK_VER)-debian \
debian-slim-buster \
debian \
NAME := cargo-ndk
TAGS ?= $(CARGO_NDK_VER)-ndk$(ANDROID_NDK_VER)-rust$(RUST_VER)-r$(BUILD_REV) \
$(CARGO_NDK_VER)-ndk$(ANDROID_NDK_VER)-rust$(RUST_VER) \
$(CARGO_NDK_VER)-ndk$(ANDROID_NDK_VER) \
$(strip $(shell echo $(CARGO_NDK_VER) | cut -d '.' -f1,2))-ndk$(ANDROID_NDK_VER) \
$(strip $(shell echo $(CARGO_NDK_VER) | cut -d '.' -f1))-ndk$(ANDROID_NDK_VER) \
$(CARGO_NDK_VER) \
$(strip $(shell echo $(CARGO_NDK_VER) | cut -d '.' -f1,2)) \
$(strip $(shell echo $(CARGO_NDK_VER) | cut -d '.' -f1)) \
latest
VERSION ?= $(word 1,$(subst $(comma), ,$(TAGS)))

Expand Down Expand Up @@ -68,12 +74,16 @@ docker-tags = $(strip $(if $(call eq,$(tags),),\
# Usage:
# make docker.image [tag=($(VERSION)|<docker-tag>)]] [no-cache=(no|yes)]
# [ANDROID_NDK_VER=<android-ndk-version>]
# [CARGO_NDK_VER=<cargo-ndk-version>]
# [RUST_VER=<rust-version>]
# [BUILD_REV=<build-revision>]

docker.image:
docker build --network=host --force-rm \
$(if $(call eq,$(no-cache),yes),--no-cache --pull,) \
--build-arg android_ndk_ver=$(ANDROID_NDK_VER) \
--build-arg cargo_ndk_ver=$(CARGO_NDK_VER) \
--build-arg rust_ver=$(RUST_VER) \
--build-arg build_rev=$(BUILD_REV) \
-t instrumentisto/$(NAME):$(if $(call eq,$(tag),),$(VERSION),$(tag)) ./

Expand Down
110 changes: 79 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,68 +1,109 @@
rust-ndk-builder Docker image
========================
cargo-ndk Docker image
======================

[![Release](https://img.shields.io/github/v/release/instrumentisto/rust-ndk-builder-docker-image "Release")](https://github.com/instrumentisto/rust-ndk-builder-docker-image/releases)
[![CI](https://github.com/instrumentisto/rust-ndk-builder-docker-image/workflows/CI/badge.svg?branch=master "CI")](https://github.com/instrumentisto/rust-ndk-builder-docker-image/actions?query=workflow%3ACI+branch%3Amaster)
[![Docker Hub](https://img.shields.io/docker/pulls/instrumentisto/rust-ndk-builder?label=Docker%20Hub%20pulls "Docker Hub pulls")](https://hub.docker.com/r/instrumentisto/rust-ndk-builder)
[![Release](https://img.shields.io/github/v/release/instrumentisto/cargo-ndk-docker-image "Release")](https://github.com/instrumentisto/cargo-ndk-docker-image/releases)
[![CI](https://github.com/instrumentisto/cargo-ndk-docker-image/workflows/CI/badge.svg?branch=master "CI")](https://github.com/instrumentisto/cargo-ndk-docker-image/actions?query=workflow%3ACI+branch%3Amaster)
[![Docker Hub](https://img.shields.io/docker/pulls/instrumentisto/cargo-ndk?label=Docker%20Hub%20pulls "Docker Hub pulls")](https://hub.docker.com/r/instrumentisto/cargo-ndk)

[Docker Hub](https://hub.docker.com/r/instrumentisto/rust-ndk-builder)
| [GitHub Container Registry](https://github.com/orgs/instrumentisto/packages/container/package/rust-ndk-builder)
| [Quay.io](https://quay.io/repository/instrumentisto/rust-ndk-builder)
[Docker Hub](https://hub.docker.com/r/instrumentisto/cargo-ndk)
| [GitHub Container Registry](https://github.com/orgs/instrumentisto/packages/container/package/cargo-ndk)
| [Quay.io](https://quay.io/repository/instrumentisto/cargo-ndk)

[Changelog](https://github.com/instrumentisto/rust-ndk-builder-docker-image/blob/master/CHANGELOG.md)
[Changelog](https://github.com/instrumentisto/cargo-ndk-docker-image/blob/master/CHANGELOG.md)




## Supported tags and respective `Dockerfile` links

- [`r21e-r0`, `r21e-r0-debian-slim-buster`, `r21e-r0-debian` `r21e`, `r21e-debian-slim-buster`, `r21e-debian`, `debian-slim-buster`, `debian`, `lastest`][101]
- [`2.2.0-ndkr21e-rust1.51-r0`, `2.2.0-ndkr21e-rust1.51`, `2.2.0-ndkr21e`, `2.2-ndkr21e`, `2-ndkr21e`, `2.2.0`, `2.2`, `2`, `latest`][101]




## What this Docker image for?
## Supported targets

- `aarch64-linux-android`
- `armv7-linux-androideabi`
- `x86_64-linux-android`
- `i686-linux-android`


Docker image with [cargo-ndk], [Android NDK] and Rust targets for building Rust code for Android.

[cargo-ndk]: https://crates.io/crates/cargo-ndk
[Android NDK]: https://developer.android.com/ndk

## What is cargo-ndk?

This [Cargo] extension handles all the environment configuration needed for successfully building libraries for Android from a [Rust] codebase, with support for generating the correct `jniLibs/` directory structure.

This image also contains [Android NDK] and [Rust] targets for building source code for [Android].

## What targets are supported by this Docker image?
> https://crates.io/crates/cargo-ndk
- aarch64-linux-android
- armv7-linux-androideabi
- x86_64-linux-android
- i686-linux-android
> https://developer.android.com/ndk



## How to use this Docker image

Mount your project directory and run the `cargo ndk` command:
```bash
docker run --rm -v '/some/rust/project:/app' instrumentisto/rust-ndk-builder cargo ndk -o /app/jniLibs build
docker run --rm -v /my/rust/project:/app -w /app instrumentisto/cargo-ndk \
cargo ndk -o ./jniLibs build
```

After that you will see `jniLibs` folder with libraries for all supported by Android targets.
After doing that you will see `jniLibs/` folder with libraries for all the supported [Android] targets.




## License
## Image versions


### `X`

Latest tag of `X` [cargo-ndk]'s major version.


### `X.Y`

Latest tag of `X.Y` [cargo-ndk]'s minor version.


### `X.Y.Z`

Latest tag of a concrete `X.Y` version of [cargo-ndk].


[cargo ndk] is licensed under [Apache-2.0]/[MIT] license
### `ndkrA`

View [license information][4] for the Android NDK contained in this image.
Latest tag containing a pinned concrete `rA` version of [Android NDK].


### `rustM.N`

Latest tag containing a pinned `M.N` minor version of [Rust].


### `X.Y.Z-ndkrA-rustM.N-rN`

Concrete `N` image revision tag of a [cargo-ndk]'s concrete `X.Y.Z` version with pinned `rA` version of [Android NDK] and pinned `M.N` version of [Rust].

Once build, it's never updated.




## License

[cargo-ndk] is licensed under [Apache-2.0][5]/[MIT][6] licenses.
[Android NDK] is licensed under [its own license][4].

As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).

As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.

The [sources][3] for producing `instrumentisto/rust-ndk-builder` Docker image are licensed under [Blue Oak Model License 1.0.0][2].
The [sources][3] for producing `instrumentisto/cargo-ndk` Docker image are licensed under [Blue Oak Model License 1.0.0][2].



Expand All @@ -77,13 +118,20 @@ If you have any problems with or questions about this image, please contact us t



[Android]: https://www.android.com
[Android NDK]: https://developer.android.com/ndk
[Apache-2.0]: https://choosealicense.com/licenses/apache-2.0
[Cargo]: https://doc.rust-lang.org/cargo
[cargo-ndk]: https://crates.io/crates/cargo-ndk
[DockerHub]: https://hub.docker.com
[Apache-2.0]: https://choosealicense.com/licenses/apache-2.0/
[MIT]: https://choosealicense.com/licenses/mit/
[MIT]: https://choosealicense.com/licenses/mit
[Rust]: https://www.rust-lang.org

[1]: https://github.com/instrumentisto/rust-ndk-builder-docker-image/issues
[2]: https://github.com/instrumentisto/rust-ndk-builder-docker-image/blob/master/LICENSE.md
[3]: https://github.com/instrumentisto/rust-ndk-builder-docker-image
[1]: https://github.com/instrumentisto/cargo-ndk-docker-image/issues
[2]: https://github.com/instrumentisto/cargo-ndk-docker-image/blob/master/LICENSE.md
[3]: https://github.com/instrumentisto/cargo-ndk-docker-image
[4]: https://developer.android.com/studio/terms
[5]: https://github.com/bbqsrc/cargo-ndk/blob/main/LICENSE-APACHE
[6]: https://github.com/bbqsrc/cargo-ndk/blob/main/LICENSE-MIT

[101]: https://github.com/instrumentisto/rust-ndk-builder-docker-image/blob/master/Dockerfile
[101]: https://github.com/instrumentisto/cargo-ndk-docker-image/blob/master/Dockerfile
Loading

0 comments on commit ad15b8c

Please sign in to comment.