feat: cross-compile for android (! for termux users) (#264)
* feat: cross-compile for android (! for termux users) * chore: Update docs for - feat: cross-compile for android (! for termux users)
This commit is contained in:
committed by
GitHub
parent
a411100fa4
commit
d2e3993398
+3
-8
@@ -10,12 +10,7 @@ rustflags = ["-C", "target-feature=-crt-static"]
|
|||||||
[target.aarch64-unknown-linux-musl]
|
[target.aarch64-unknown-linux-musl]
|
||||||
rustflags = ["-C", "target-feature=-crt-static"]
|
rustflags = ["-C", "target-feature=-crt-static"]
|
||||||
|
|
||||||
|
# Android/Termux: no hardcoded linker so native Termux builds use the system cc.
|
||||||
|
# For CI cross-compilation the linker is set via CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER env var.
|
||||||
[target.aarch64-linux-android]
|
[target.aarch64-linux-android]
|
||||||
rustflags = [
|
rustflags = ["-C", "link-args=-rdynamic"]
|
||||||
"-C",
|
|
||||||
"linker=aarch64-linux-android-clang",
|
|
||||||
"-C",
|
|
||||||
"link-args=-rdynamic",
|
|
||||||
"-C",
|
|
||||||
"default-linker-libraries",
|
|
||||||
]
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ name: Prebuild
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main, feat/interchangable-ffi]
|
branches: [main, feat/interchangable-ffi, feat/termux]
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -36,6 +36,12 @@ jobs:
|
|||||||
artifact_name: target/aarch64-unknown-linux-musl/release/libfff_nvim.so
|
artifact_name: target/aarch64-unknown-linux-musl/release/libfff_nvim.so
|
||||||
ext: so
|
ext: so
|
||||||
|
|
||||||
|
## Android (Termux)
|
||||||
|
- os: ubuntu-latest
|
||||||
|
target: aarch64-linux-android
|
||||||
|
artifact_name: target/aarch64-linux-android/release/libfff_nvim.so
|
||||||
|
ext: so
|
||||||
|
|
||||||
## macOS builds
|
## macOS builds
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
target: x86_64-apple-darwin
|
target: x86_64-apple-darwin
|
||||||
@@ -73,11 +79,25 @@ jobs:
|
|||||||
run: cargo install cargo-zigbuild
|
run: cargo install cargo-zigbuild
|
||||||
|
|
||||||
- name: Build for Linux
|
- name: Build for Linux
|
||||||
if: contains(matrix.os, 'ubuntu')
|
if: contains(matrix.os, 'ubuntu') && !contains(matrix.target, 'android')
|
||||||
run: |
|
run: |
|
||||||
cargo zigbuild --release --target ${{ matrix.zigbuild_target || matrix.target }} -p fff-nvim
|
cargo zigbuild --release --target ${{ matrix.zigbuild_target || matrix.target }} -p fff-nvim
|
||||||
mv "${{ matrix.artifact_name }}" "${{ matrix.target }}.${{ matrix.ext }}"
|
mv "${{ matrix.artifact_name }}" "${{ matrix.target }}.${{ matrix.ext }}"
|
||||||
|
|
||||||
|
- name: Build for Android (Termux)
|
||||||
|
if: contains(matrix.target, 'android')
|
||||||
|
run: |
|
||||||
|
NDK_BIN="$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin"
|
||||||
|
|
||||||
|
# NDK clang for C deps (libgit2, lmdb, blake3) that need Bionic sysroot headers
|
||||||
|
export CC_aarch64_linux_android="$NDK_BIN/aarch64-linux-android24-clang"
|
||||||
|
export CXX_aarch64_linux_android="$NDK_BIN/aarch64-linux-android24-clang++"
|
||||||
|
export AR_aarch64_linux_android="$NDK_BIN/llvm-ar"
|
||||||
|
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="$NDK_BIN/aarch64-linux-android24-clang"
|
||||||
|
|
||||||
|
cargo build --release --target ${{ matrix.target }} -p fff-nvim
|
||||||
|
mv "${{ matrix.artifact_name }}" "${{ matrix.target }}.${{ matrix.ext }}"
|
||||||
|
|
||||||
- name: Build for macOS
|
- name: Build for macOS
|
||||||
if: contains(matrix.os, 'macos')
|
if: contains(matrix.os, 'macos')
|
||||||
run: |
|
run: |
|
||||||
@@ -137,6 +157,13 @@ jobs:
|
|||||||
lib_filename: libfff_c.so
|
lib_filename: libfff_c.so
|
||||||
ext: so
|
ext: so
|
||||||
|
|
||||||
|
## Android (Termux)
|
||||||
|
- os: ubuntu-latest
|
||||||
|
target: aarch64-linux-android
|
||||||
|
artifact_name: target/aarch64-linux-android/release/libfff_c.so
|
||||||
|
lib_filename: libfff_c.so
|
||||||
|
ext: so
|
||||||
|
|
||||||
## macOS builds
|
## macOS builds
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
target: x86_64-apple-darwin
|
target: x86_64-apple-darwin
|
||||||
@@ -183,11 +210,24 @@ jobs:
|
|||||||
run: cargo install cargo-zigbuild
|
run: cargo install cargo-zigbuild
|
||||||
|
|
||||||
- name: Build for Linux
|
- name: Build for Linux
|
||||||
if: contains(matrix.os, 'ubuntu')
|
if: contains(matrix.os, 'ubuntu') && !contains(matrix.target, 'android')
|
||||||
run: |
|
run: |
|
||||||
cargo zigbuild --release --target ${{ matrix.zigbuild_target || matrix.target }} -p fff-c
|
cargo zigbuild --release --target ${{ matrix.zigbuild_target || matrix.target }} -p fff-c
|
||||||
mv "${{ matrix.artifact_name }}" "c-lib-${{ matrix.target }}.${{ matrix.ext }}"
|
mv "${{ matrix.artifact_name }}" "c-lib-${{ matrix.target }}.${{ matrix.ext }}"
|
||||||
|
|
||||||
|
- name: Build for Android (Termux)
|
||||||
|
if: contains(matrix.target, 'android')
|
||||||
|
run: |
|
||||||
|
NDK_BIN="$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin"
|
||||||
|
|
||||||
|
export CC_aarch64_linux_android="$NDK_BIN/aarch64-linux-android24-clang"
|
||||||
|
export CXX_aarch64_linux_android="$NDK_BIN/aarch64-linux-android24-clang++"
|
||||||
|
export AR_aarch64_linux_android="$NDK_BIN/llvm-ar"
|
||||||
|
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="$NDK_BIN/aarch64-linux-android24-clang"
|
||||||
|
|
||||||
|
cargo build --release --target ${{ matrix.target }} -p fff-c
|
||||||
|
mv "${{ matrix.artifact_name }}" "c-lib-${{ matrix.target }}.${{ matrix.ext }}"
|
||||||
|
|
||||||
- name: Build for macOS
|
- name: Build for macOS
|
||||||
if: contains(matrix.os, 'macos')
|
if: contains(matrix.os, 'macos')
|
||||||
run: |
|
run: |
|
||||||
@@ -206,6 +246,7 @@ jobs:
|
|||||||
mv "${{ matrix.artifact_name }}" "c-lib-${{ matrix.target }}.${{ matrix.ext }}"
|
mv "${{ matrix.artifact_name }}" "c-lib-${{ matrix.target }}.${{ matrix.ext }}"
|
||||||
|
|
||||||
- name: Prepare npm package
|
- name: Prepare npm package
|
||||||
|
if: "!contains(matrix.target, 'android')"
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
# Copy the built binary into the platform npm package directory
|
# Copy the built binary into the platform npm package directory
|
||||||
@@ -218,6 +259,7 @@ jobs:
|
|||||||
path: c-lib-${{ matrix.target }}.*
|
path: c-lib-${{ matrix.target }}.*
|
||||||
|
|
||||||
- name: Upload npm package artifact
|
- name: Upload npm package artifact
|
||||||
|
if: "!contains(matrix.target, 'android')"
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: npm-${{ matrix.npm_package }}
|
name: npm-${{ matrix.npm_package }}
|
||||||
|
|||||||
Generated
+2
-2
@@ -2509,9 +2509,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zlob"
|
name = "zlob"
|
||||||
version = "1.2.9"
|
version = "1.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "674f4e74544c0a00887c0dff7862fe13742de8c5dbcf6db9eac0643362554d44"
|
checksum = "07934fb13f0f4e14281bab6b0e984cfc03891d2cf5b0a8bd0ab14fd240e21106"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bindgen",
|
"bindgen",
|
||||||
"bitflags 2.9.1",
|
"bitflags 2.9.1",
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ heed = "0.22.0"
|
|||||||
ignore = "0.4.22"
|
ignore = "0.4.22"
|
||||||
memmap2 = "0.9"
|
memmap2 = "0.9"
|
||||||
mimalloc = "0.1.47"
|
mimalloc = "0.1.47"
|
||||||
zlob = "1.2.9"
|
zlob = "1.3.0"
|
||||||
|
|
||||||
mlua = { version = "0.11.1", features = ["module", "luajit"] }
|
mlua = { version = "0.11.1", features = ["module", "luajit"] }
|
||||||
neo_frizbee = "0.8.1"
|
neo_frizbee = "0.8.1"
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
*fff.nvim.txt* For Neovim >= 0.10.0 Last change: 2026 February 26
|
*fff.nvim.txt* For Neovim >= 0.10.0 Last change: 2026 February 28
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
Table of Contents *fff.nvim-table-of-contents*
|
Table of Contents *fff.nvim-table-of-contents*
|
||||||
|
|||||||
@@ -11,18 +11,24 @@ function M.get_triple()
|
|||||||
if os_name == 'darwin' then
|
if os_name == 'darwin' then
|
||||||
os_name = 'apple-darwin'
|
os_name = 'apple-darwin'
|
||||||
elseif os_name == 'linux' then
|
elseif os_name == 'linux' then
|
||||||
-- Detect if we're on musl or glibc
|
-- Detect Android/Termux before checking musl/glibc.
|
||||||
local handle = io.popen('ldd --version 2>&1')
|
-- Termux uses Bionic libc (not glibc or musl) and has no ldd.
|
||||||
if handle then
|
if os.getenv('TERMUX_VERSION') or os.getenv('ANDROID_ROOT') then
|
||||||
local output = handle:read('*a')
|
os_name = 'linux-android'
|
||||||
handle:close()
|
else
|
||||||
if output and output:match('musl') then
|
-- Detect if we're on musl or glibc
|
||||||
os_name = 'unknown-linux-musl'
|
local handle = io.popen('ldd --version 2>&1')
|
||||||
|
if handle then
|
||||||
|
local output = handle:read('*a')
|
||||||
|
handle:close()
|
||||||
|
if output and output:match('musl') then
|
||||||
|
os_name = 'unknown-linux-musl'
|
||||||
|
else
|
||||||
|
os_name = 'unknown-linux-gnu'
|
||||||
|
end
|
||||||
else
|
else
|
||||||
os_name = 'unknown-linux-gnu'
|
os_name = 'unknown-linux-gnu'
|
||||||
end
|
end
|
||||||
else
|
|
||||||
os_name = 'unknown-linux-gnu'
|
|
||||||
end
|
end
|
||||||
elseif os_name:match('windows') or os_name:match('mingw') or os_name:match('msys') then
|
elseif os_name:match('windows') or os_name:match('mingw') or os_name:match('msys') then
|
||||||
os_name = 'pc-windows-msvc'
|
os_name = 'pc-windows-msvc'
|
||||||
|
|||||||
Reference in New Issue
Block a user