Vendor things

This commit is contained in:
John Doty 2024-03-08 11:03:01 -08:00
parent 5deceec006
commit 977e3c17e5
19434 changed files with 10682014 additions and 0 deletions

View file

@ -0,0 +1 @@
{"files":{"CHANGELOG.md":"0d9f3fc98ce629209a33f51ef5440811d42da28c0b1864df7dba7d1a068b2324","Cargo.toml":"0a84f592b67413e85fd952da7c99e550e1c112658e123f9dd11ab8804a363173","README.md":"9adf2ca8412635302cbfa7d9a55537e92b3c1e3e3e2b963f4ecc478d774b4c96","generate_bindings.sh":"ded996afaf14cec05178c7e38d69beb345cea65ceb401a60398e073123fac99f","src/ffi_aarch64.rs":"79bd83b35c68ae98c0489fdad75148d95c63406d3fca2e177ec227f9f55a1ca6","src/ffi_arm.rs":"bebf892fa936e63b9ca0486bfe9aabc05b0ce15adea54fe68e3029fbf8f7a63d","src/ffi_i686.rs":"6ff9753712f7ab74989739bbf66b2b0fa4dd60a5c2e3ad6b85ab787c0aa4a32c","src/ffi_x86_64.rs":"c0d4a97d1db210a22f24eece710c8dee86d52324223284eacce65ff0aa10af9d","src/lib.rs":"a6c91f43cadf0feed28403ffc3885158f399e6aaae055f1fae7e9bc7a8742c95","wrapper.h":"e2737078fc0a188ef1b95088337ffbdafbf5a84101fe72b5e6b9918a0d891214"},"package":"3cf2aae958bd232cac5069850591667ad422d263686d75b52a065f9badeee5a3"}

34
third-party/vendor/ndk-sys/CHANGELOG.md vendored Normal file
View file

@ -0,0 +1,34 @@
# Unreleased
# 0.4.1 (2022-11-23)
- Re-release of `0.4.0` to combat a faulty `0.4.0+25.0.8775105` publish. Now also includes `+23.1.7779620` version metadata.
# 0.4.0 (2022-07-24)
- **Breaking:** Turn `enum` type aliases into newtype wrappers. (#245, #315)
# 0.3.0 (2022-01-05)
- **Breaking:** Use `jni-sys` for low-level JNI types instead of those autogenerated by `bindgen` based on the header.
These JNI types are _not_ publicly (re)exported anymore. (#209)
- Regenerate against NDK 23.1.7779620, now including all Android-related headers. (#201)
# 0.2.2 (2021-11-22)
- Regenerate against NDK 23.0.7599858. (#178)
# 0.2.1 (2020-10-15)
- Fix documentation build on docs.rs
# 0.2.0 (2020-09-15)
- **Breaking:** `onSaveInstanceState` signature corrected to take `outSize` as a `*mut size_t` instead of `*mut usize`.
- Add `media` bindings
- Add `bitmap` and `hardware_buffer` bindings
- Add `aaudio` bindings
# 0.1.0 (2020-04-22)
- Initial release! 🎉

47
third-party/vendor/ndk-sys/Cargo.toml vendored Normal file
View file

@ -0,0 +1,47 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2018"
name = "ndk-sys"
version = "0.4.1+23.1.7779620"
authors = ["The Rust Windowing contributors"]
description = "FFI bindings for the Android NDK"
homepage = "https://github.com/rust-windowing/android-ndk-rs"
documentation = "https://docs.rs/android-ndk-sys"
readme = "README.md"
keywords = [
"android",
"ndk",
]
license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-windowing/android-ndk-rs"
[package.metadata.docs.rs]
rustdoc-args = [
"--cfg",
"docsrs",
]
targets = [
"aarch64-linux-android",
"armv7-linux-androideabi",
"i686-linux-android",
"x86_64-linux-android",
]
[dependencies.jni-sys]
version = "0.3.0"
[features]
audio = []
bitmap = []
media = []
test = []

175
third-party/vendor/ndk-sys/README.md vendored Normal file
View file

@ -0,0 +1,175 @@
# Rust on Android
[![Rust](https://github.com/rust-windowing/android-ndk-rs/workflows/Rust/badge.svg)](https://github.com/rust-windowing/android-ndk-rs/actions) ![MIT license](https://img.shields.io/badge/License-MIT-green.svg) ![APACHE2 license](https://img.shields.io/badge/License-APACHE2-green.svg)
Libraries and tools for Rust programming on Android targets:
Name | Description | Badges
--- | --- | ---
[`ndk-sys`](./ndk-sys) | Raw FFI bindings to the NDK | [![crates.io](https://img.shields.io/crates/v/ndk-sys.svg)](https://crates.io/crates/ndk-sys) [![crates.io](https://docs.rs/ndk-sys/badge.svg)](https://docs.rs/ndk-sys)
[`ndk`](./ndk) | Safe abstraction of the bindings | [![crates.io](https://img.shields.io/crates/v/ndk.svg)](https://crates.io/crates/ndk) [![crates.io](https://docs.rs/ndk/badge.svg)](https://docs.rs/ndk)
[`ndk-context`](./ndk-context) | Android handles | [![crates.io](https://img.shields.io/crates/v/ndk-context.svg)](https://crates.io/crates/ndk-context)
[`ndk-glue`](./ndk-glue) | Startup code | [![crates.io](https://img.shields.io/crates/v/ndk-glue.svg)](https://crates.io/crates/ndk-glue) [![crates.io](https://docs.rs/ndk-glue/badge.svg)](https://docs.rs/ndk-glue)
[`ndk-build`](./ndk-build) | Everything for building apk's | [![crates.io](https://img.shields.io/crates/v/ndk-build.svg)](https://crates.io/crates/ndk-build) [![crates.io](https://docs.rs/ndk-build/badge.svg)](https://docs.rs/ndk-build)
[`cargo-apk`](./cargo-apk) | Build tool | [![crates.io](https://img.shields.io/crates/v/cargo-apk.svg)](https://crates.io/crates/cargo-apk) [![crates.io](https://docs.rs/cargo-apk/badge.svg)](https://docs.rs/cargo-apk)
See [`ndk-examples`](./ndk-examples) for examples using the NDK and the README files of the crates for more details.
## Supported NDK versions
`android-ndk-rs` aims to support at least the `LTS` and `Rolling Release` branches of the NDK, as described on [their wiki](https://github.com/android/ndk/wiki#supported-downloads). Additionally the `Beta Release` might be supported to prepare for an upcoming release.
As of writing (2021-07-24) the following NDKs are tested:
Branch | Version | Status | Working
-|-|:-:|:-:
r18 | 18.1.5063045 | _Deprecated_ | :x:
r19 | 19.2.5345600 | _Deprecated_ | :heavy_check_mark:
r20 | 20.1.5948944 | _Deprecated_ | :heavy_check_mark:
r21 | 21.4.7075529 | _Deprecated_ | :heavy_check_mark:
r22 | 22.1.7171670 | _Deprecated_ | :heavy_check_mark:
r23 | beta 1/2 | _Deprecated_ | :heavy_check_mark:
r23 | 23.0.7272597-beta3 | _Deprecated_ | :heavy_check_mark: Workaround in [#189](https://github.com/rust-windowing/android-ndk-rs/pull/189)
r23 | 23.1.7779620 | LTS | :heavy_check_mark: Workaround in [#189](https://github.com/rust-windowing/android-ndk-rs/pull/189)
r24 | 24.0.7856742-beta1 | Rolling Release | :heavy_check_mark: Workaround in [#189](https://github.com/rust-windowing/android-ndk-rs/pull/189)
## Quick start: `Hello World` crate on Android
Quick start setting up a new project with support for Android, using the `ndk-glue` layer for communicating with the Android framework through [`NativeActivity`](https://developer.android.com/reference/android/app/NativeActivity) and `cargo-apk` for packaging a crate in an Android `.apk` file.
This short guide can also be used as a reference for converting existing crates to be runnable on Android.
### 1. Install the Android NDK and SDK
Make sure the Android NDK is installed, together with a target platform (`30` by default), `build-tools` and `platform-tools`, using either the [`sdkmanager`](https://developer.android.com/studio/command-line/sdkmanager) or [Android Studio](https://developer.android.com/studio/projects/install-ndk).
### 2. Create a new library crate
```console
$ cargo new hello_world_android --lib
```
Never name your project `android` as this results in a target binary named `libandroid.so` which is also the name of Android's framework library: this will fail to link.
### 3. Configure crate for use on Android
Add the `ndk-glue` dependency to your crate.
`Cargo.toml`
```toml
# This dependency will only be included when targeting Android
[target.'cfg(target_os = "android")'.dependencies]
ndk-glue = "xxx" # Substitute this with the latest ndk-glue version you wish to use
```
Then configure the library target to be compiled to a Rust `lib` (for use in an executable on desktop) and a `cdylib` to create a native binary that can be bundled in the final `.apk` and loaded by Android.
`Cargo.toml`
```toml
[lib]
crate-type = ["lib", "cdylib"]
```
### 4. Wrap entry point with `ndk-glue`
Create a `main` function holding your code in the library portion of the crate, and wrap it in the `ndk_glue::main` attribute macro when targeting Android.
`src/lib.rs`
```rust
#[cfg_attr(target_os = "android", ndk_glue::main(backtrace = "on"))]
pub fn main() {
println!("Hello World");
}
```
See the [`ndk-macro` documentation](./ndk-macro/README.md) for more options.
Additionally, to make this crate runnable outside of Android, create a binary that calls the main function in the library.
`src/main.rs`
```rust
fn main() {
hello_world_android::main()
}
```
As a sanity check, run this binary to make sure everything is set up correctly:
```console
$ cargo run
```
### 5. Run the crate on your Android device
Install `cargo apk` for building, running and debugging your application:
```console
$ cargo install cargo-apk
```
We can now directly execute our `Hello World` application on a real connected device or an emulator:
```console
$ cargo apk run
```
If the crate includes a runnable binary as suggested above, you will likely be greeted by the following error:
```console
$ cargo apk run
error: extra arguments to `rustc` can only be passed to one target, consider filtering
the package by passing, e.g., `--lib` or `--bin NAME` to specify a single target
Error: Command `cargo rustc --target aarch64-linux-android -- -L hello_world_android/target/cargo-apk-temp-extra-link-libraries` had a non-zero exit code.
```
To solve this, add `--lib` to the run invocation, like so:
```console
$ cargo apk run --lib
```
### 6. Inspect the output
`ndk-glue` redirects stdout and stderr to Android `logcat`, including the `println!("Hello World")` by the example above. See [Logging and stdout](##Logging-and-stdout) below how to access it.
## Rendering to the window
Android native apps have no easy access to [Android's User Interface](https://developer.android.com/guide/topics/ui) functionality (bar [JNI](##jni) interop). Applications can instead draw pixels directly to the window using [`ANativeWindow_lock`](https://developer.android.com/ndk/reference/group/a-native-window#group___a_native_window_1ga0b0e3b7d442dee83e1a1b42e5b0caee6), or use a graphics API like OpenGL or Vulkan for high performance rendering.
## Logging and stdout
Stdout is redirected to the android log api when using `ndk-glue`. Any logger that logs to
stdout, like `println!`, should therefore work.
To filter on this output in `logcat`:
```console
$ adb logcat RustStdoutStderr:D *:S
```
### Android logger
Enable the `"logger"` feature on the `ndk-glue` macro and configure its log tag and debug level through the attribute macro:
`src/lib.rs`
```rust
#[cfg_attr(target_os = "android", ndk_glue::main(logger(level = "debug", tag = "my-tag")))]
pub fn main() {
log!("hello world");
}
```
## App/APK configuration
Android APKs contain a file called `AndroidManifest.xml`, which has things like permission requests and feature declarations, plus configuration of activities, intents, resource folders and more. This file is autogenerated by `cargo-apk`. To control what goes in it through Cargo.toml, refer to [`cargo-apk`'s README](./cargo-apk/README.md).
## Overriding crate paths
The macro `ndk_glue::main` tries to determine crate names from current _Cargo.toml_.
You can override this names with specific paths like so:
```rust
#[ndk_glue::main(
ndk_glue = "path::to::ndk_glue",
)]
fn main() {}
```
## JNI
Java Native Interface (JNI) allows executing Java code in a VM from native applications. To access
the JNI use the `AndroidContext` from the `ndk-context` crate. `ndk-examples` contains a `jni_audio`
example which will print out all output audio devices in the log.
- [`jni`](https://crates.io/crates/jni), JNI bindings for Rust

View file

@ -0,0 +1,59 @@
#!/bin/sh
while read ARCH && read TARGET ; do
bindgen wrapper.h -o src/ffi_$ARCH.rs \
--blocklist-item 'JNI\w+' \
--blocklist-item 'C?_?JNIEnv' \
--blocklist-item '_?JavaVM' \
--blocklist-item '_?j\w+' \
--newtype-enum '\w+_(result|status)_t' \
--newtype-enum 'ACameraDevice_request_template' \
--newtype-enum 'ADataSpace' \
--newtype-enum 'AHardwareBuffer_Format' \
--newtype-enum 'AHardwareBuffer_UsageFlags' \
--newtype-enum 'AHdrMetadataType' \
--newtype-enum 'AIMAGE_FORMATS' \
--newtype-enum 'AMediaDrmEventType' \
--newtype-enum 'AMediaDrmKeyType' \
--newtype-enum 'AMediaKeyStatusType' \
--newtype-enum 'ANativeWindowTransform' \
--newtype-enum 'ANativeWindow_ChangeFrameRateStrategy' \
--newtype-enum 'ANativeWindow_FrameRateCompatibility' \
--newtype-enum 'ANativeWindow_LegacyFormat' \
--newtype-enum 'AndroidBitmapCompressFormat' \
--newtype-enum 'AndroidBitmapFormat' \
--newtype-enum 'AppendMode' \
--newtype-enum 'DeviceTypeCode' \
--newtype-enum 'DurationCode' \
--newtype-enum 'FeatureLevelCode' \
--newtype-enum 'FuseCode' \
--newtype-enum 'HeapTaggingLevel' \
--newtype-enum 'OperandCode' \
--newtype-enum 'OperationCode' \
--newtype-enum 'OutputFormat' \
--newtype-enum 'PaddingCode' \
--newtype-enum 'PreferenceCode' \
--newtype-enum 'PriorityCode' \
--newtype-enum 'ResNsendFlags' \
--newtype-enum 'ResultCode' \
--newtype-enum 'SeekMode' \
--newtype-enum 'acamera_\w+' \
--newtype-enum 'android_LogPriority' \
--newtype-enum 'android_fdsan_error_level' \
--newtype-enum 'android_fdsan_owner_type' \
--newtype-enum 'cryptoinfo_mode_t' \
--newtype-enum 'log_id' \
-- \
--sysroot="${ANDROID_NDK_ROOT}"/toolchains/llvm/prebuilt/linux-x86_64/sysroot/ --target=$TARGET
# --newtype-enum '_bindgen_ty_63' \
done << EOF
arm
arm-linux-androideabi
aarch64
aarch64-linux-android
i686
i686-linux-android
x86_64
x86_64-linux-android
EOF

File diff suppressed because it is too large Load diff

21624
third-party/vendor/ndk-sys/src/ffi_arm.rs vendored Normal file

File diff suppressed because it is too large Load diff

23375
third-party/vendor/ndk-sys/src/ffi_i686.rs vendored Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

53
third-party/vendor/ndk-sys/src/lib.rs vendored Normal file
View file

@ -0,0 +1,53 @@
//! Raw FFI bindings to the Android NDK.
//!
//! The bindings are pre-generated and the right one for the platform is selected at compile time.
// Bindgen lints
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(improper_ctypes)]
#![allow(clippy::all)]
// Temporarily allow UB nullptr dereference in bindgen layout tests until fixed upstream:
// https://github.com/rust-lang/rust-bindgen/pull/2055
// https://github.com/rust-lang/rust-bindgen/pull/2064
#![allow(deref_nullptr)]
// Test setup lints
#![cfg_attr(test, allow(dead_code))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
use jni_sys::*;
#[cfg(not(any(target_os = "android", feature = "test")))]
compile_error!("android-ndk-sys only supports compiling for Android");
#[cfg(all(
any(target_os = "android", feature = "test"),
any(target_arch = "arm", target_arch = "armv7")
))]
include!("ffi_arm.rs");
#[cfg(all(any(target_os = "android", feature = "test"), target_arch = "aarch64"))]
include!("ffi_aarch64.rs");
#[cfg(all(any(target_os = "android", feature = "test"), target_arch = "x86"))]
include!("ffi_i686.rs");
#[cfg(all(any(target_os = "android", feature = "test"), target_arch = "x86_64"))]
include!("ffi_x86_64.rs");
#[cfg(target_os = "android")]
#[link(name = "android")]
extern "C" {}
#[cfg(all(feature = "media", target_os = "android"))]
#[link(name = "mediandk")]
extern "C" {}
#[cfg(all(feature = "bitmap", target_os = "android"))]
#[link(name = "jnigraphics")]
extern "C" {}
#[cfg(all(feature = "audio", target_os = "android"))]
#[link(name = "aaudio")]
extern "C" {}

80
third-party/vendor/ndk-sys/wrapper.h vendored Normal file
View file

@ -0,0 +1,80 @@
#include <android/api-level.h>
#include <android/asset_manager.h>
#include <android/asset_manager_jni.h>
// #include <android/binder_auto_utils.h>
// #include <android/binder_enums.h>
// #include <android/binder_ibinder.h>
// #include <android/binder_ibinder_jni.h>
// #include <android/binder_interface_utils.h>
// #include <android/binder_internal_logging.h>
// #include <android/binder_parcelable_utils.h>
// #include <android/binder_parcel.h>
// #include <android/binder_parcel_jni.h>
// #include <android/binder_parcel_utils.h>
// #include <android/binder_status.h>
// #include <android/binder_to_string.h>
#include <android/bitmap.h>
#include <android/choreographer.h>
#include <android/configuration.h>
#include <android/data_space.h>
#include <android/dlext.h>
#include <android/fdsan.h>
#include <android/file_descriptor_jni.h>
// #include <android/font.h>
// #include <android/font_matcher.h>
#include <android/hardware_buffer.h>
#include <android/hardware_buffer_jni.h>
#include <android/hdr_metadata.h>
#include <android/imagedecoder.h>
#include <android/input.h>
#include <android/keycodes.h>
#include <android/log.h>
#include <android/looper.h>
#include <android/multinetwork.h>
#include <android/native_activity.h>
#include <android/native_window.h>
#include <android/native_window_jni.h>
#include <android/ndk-version.h>
#include <android/NeuralNetworks.h>
#include <android/NeuralNetworksTypes.h>
#include <android/obb.h>
#include <android/permission_manager.h>
#include <android/rect.h>
#include <android/sensor.h>
#include <android/set_abort_message.h>
#include <android/sharedmem.h>
#include <android/sharedmem_jni.h>
#include <android/storage_manager.h>
// #include <android/surface_control.h>
#include <android/surface_texture.h>
#include <android/surface_texture_jni.h>
#include <android/sync.h>
// #include <android/system_fonts.h>
// #include <android/thermal.h>
#include <android/trace.h>
#include <android/versioning.h>
#include <android/window.h>
#include <aaudio/AAudio.h>
#include <amidi/AMidi.h>
#include <camera/NdkCameraCaptureSession.h>
#include <camera/NdkCameraDevice.h>
#include <camera/NdkCameraError.h>
#include <camera/NdkCameraManager.h>
#include <camera/NdkCameraMetadata.h>
#include <camera/NdkCameraMetadataTags.h>
#include <camera/NdkCameraWindowType.h>
#include <camera/NdkCaptureRequest.h>
#include <media/NdkImage.h>
#include <media/NdkImageReader.h>
#include <media/NdkMediaCodec.h>
#include <media/NdkMediaCrypto.h>
#include <media/NdkMediaDataSource.h>
#include <media/NdkMediaDrm.h>
#include <media/NdkMediaError.h>
#include <media/NdkMediaExtractor.h>
#include <media/NdkMediaFormat.h>
#include <media/NdkMediaMuxer.h>