Skip to content

Commit

Permalink
ndk-sys: Generate against latest upstream NDK (11769913) (#471)
Browse files Browse the repository at this point in the history
We're seeing with the R26 NDK release, which was published only half a
month before the Android 14 (U, API level 34) release, that a lot of new
APIs are still missing.  This is not something we can deal with for very
long in the NDK Rust crate, as we'd like to try out and use the latest
functions at some point.  These are not showing up in the followup r26b
and r26c releases, nor does the r27 release seem close.

Fortunately live NDK builds of the `aosp-main` branch were pointed
out which seem to include mostly if not exclusively stable changes to
NDK (related) headers.  As we're generally analyzing the changes and
propagating them to the NDK wrappers (mostly additions, because API
breaks are disallowed) we'd quickly catch a faulty push.

For now the only break is in a previously-faulty enum-constant name
in `ADataSpace`.

Furthermore the upstream NDK finally contains some fixes that have
been submitted to C++-like headers to make them once again C-compatible,
and will allow us to start submitting bindings for:

- `ASurfaceControl`
- `ASurfaceTexture`
- `Parcel`
- `AIBinder`
- And more.

New functions and enum variants enabled by this `ndk-sys` upgrade will
be submitted in separate PRs too.
  • Loading branch information
MarijnS95 committed Apr 26, 2024
1 parent 6893a70 commit ce07460
Show file tree
Hide file tree
Showing 9 changed files with 26,719 additions and 19,573 deletions.
1 change: 1 addition & 0 deletions ndk-sys/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Unreleased

- Generate against upstream NDK build `11769913`. (#471)
- Add `nativewindow` feature to link against `libnativewindow`. (#465)

# 0.5.0 (2023-10-15)
Expand Down
2 changes: 1 addition & 1 deletion ndk-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ndk-sys"
version = "0.5.0+25.2.9519653"
version = "0.5.0+11769913"
authors = ["The Rust Windowing contributors"]
edition = "2021"
description = "FFI bindings for the Android NDK"
Expand Down
13 changes: 12 additions & 1 deletion ndk-sys/generate_bindings.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

set -ex

os=$(uname -s)

if [[ "$os" == "Darwin" ]]; then
Expand All @@ -10,7 +12,16 @@ else
host_tag="linux-x86_64"
fi

sysroot="${ANDROID_NDK_ROOT}"/toolchains/llvm/prebuilt/${host_tag}/sysroot/
# Builds can be found at https://ci.android.com for the `ndk` component
build_id=$(grep -oP 'version = "\d\.\d.\d\+\K\d+' ./Cargo.toml)
# From https://cs.android.com/android/platform/superproject/main/+/main:development/python-packages/fetchartifact/fetchartifact/__init__.py
target="ndk"
artifact_name="ndk_platform.tar.bz2"
url="https://androidbuildinternal.googleapis.com/android/internal/build/v3/builds/$build_id/$target/attempts/latest/artifacts/$artifact_name/url"
echo "Downloading sysroot $build_id from $url"
curl -L $url -o "$artifact_name"
tar xvf "$artifact_name" "ndk/sysroot/usr/include"
sysroot="$PWD/ndk/sysroot/"
[ ! -d "$sysroot" ] && echo "Android sysroot $sysroot does not exist!" && exit 1

while read ARCH && read TARGET ; do
Expand Down
Loading

0 comments on commit ce07460

Please sign in to comment.