forked from starifly/NekoBoxForAndroid
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: bundle Mieru native binary (no external plugin required) #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
694d08e
feat: bundle Mieru native binary (no external plugin required)
hawkff 19abde5
chore: mark buildScript/lib/mieru.sh executable
hawkff 7f3fec1
ci: harden Mieru build wiring across all workflows
hawkff e436305
ci: use -f not -x to verify Mieru artifacts
hawkff 3a93d09
ci: validate resolved NDK toolchain dir in mieru.sh
hawkff 8153cd3
ci: re-clone Mieru source if existing checkout is unhealthy
hawkff 489f034
ci: support darwin-arm64 NDK host in mieru.sh
hawkff 8b04339
ci: address review - env_ndk.sh in cache hash, consolidate MIERU_VERS…
hawkff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| #!/bin/bash | ||
| # Build the Mieru client binary for all Android ABIs and install them as | ||
| # bundled native executables (app/executableSo/<abi>/libmieru.so). | ||
| # | ||
| # This lets NekoBox run Mieru profiles without the separate external plugin | ||
| # (moe.matsuri.exe.mieru). PluginManager.initNativeInternal resolves | ||
| # "mieru-plugin" -> libmieru.so from nativeLibraryDir. | ||
| # | ||
| # Usage: ./run lib mieru | ||
| set -e | ||
|
|
||
| source "buildScript/init/env.sh" | ||
|
|
||
| if [ -z "$ANDROID_NDK_HOME" ]; then | ||
| echo "Error: ANDROID_NDK_HOME is not set (NDK required to cross-compile Mieru)." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Mieru release tag to build from source. | ||
| MIERU_VERSION="${MIERU_VERSION:-v3.34.0}" | ||
|
|
||
| DEPS="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin" | ||
| # macOS NDK host dirs are darwin-x86_64 / darwin-arm64; fall back if linux is absent. | ||
| if [ ! -d "$DEPS" ]; then | ||
| DEPS="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin" | ||
| fi | ||
| if [ ! -d "$DEPS" ]; then | ||
| DEPS="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-arm64/bin" | ||
| fi | ||
| if [ ! -d "$DEPS" ]; then | ||
| echo "Error: NDK LLVM toolchain not found under $ANDROID_NDK_HOME (unsupported host or NDK layout)." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| WORK="$(pwd)/.mieru-build" | ||
| OUT="$(pwd)/app/executableSo" | ||
|
|
||
| # Fetch source (shallow clone at the pinned tag). Re-clone fresh if the existing | ||
| # checkout is missing or its git operations fail (e.g. corrupted by a prior build). | ||
| need_clone=1 | ||
| if [ -d "$WORK/.git" ]; then | ||
| if git -C "$WORK" fetch --depth 1 origin "refs/tags/$MIERU_VERSION" \ | ||
| && git -C "$WORK" checkout -q FETCH_HEAD; then | ||
| need_clone=0 | ||
| else | ||
| echo ">> existing $WORK is unusable; re-cloning" | ||
| fi | ||
| fi | ||
| if [ "$need_clone" -eq 1 ]; then | ||
| rm -rf "$WORK" | ||
| git clone --depth 1 --branch "$MIERU_VERSION" https://github.com/enfein/mieru.git "$WORK" | ||
| fi | ||
|
|
||
| pushd "$WORK" >/dev/null | ||
|
|
||
| build_abi() { | ||
| local abi="$1" goarch="$2" cc="$3" goarm="$4" | ||
| echo ">> building libmieru.so for $abi" | ||
| mkdir -p "$OUT/$abi" | ||
| env GOOS=android GOARCH="$goarch" ${goarm:+GOARM=$goarm} CGO_ENABLED=1 \ | ||
| CC="$DEPS/$cc" \ | ||
| go build -trimpath -ldflags='-s -w' \ | ||
| -o "$OUT/$abi/libmieru.so" ./cmd/mieru | ||
| } | ||
|
|
||
| build_abi "arm64-v8a" "arm64" "aarch64-linux-android21-clang" | ||
| build_abi "armeabi-v7a" "arm" "armv7a-linux-androideabi21-clang" "7" | ||
| build_abi "x86" "386" "i686-linux-android21-clang" | ||
| build_abi "x86_64" "amd64" "x86_64-linux-android21-clang" | ||
|
|
||
| popd >/dev/null | ||
|
|
||
| echo ">> installed Mieru binaries:" | ||
| ls -la "$OUT"/*/libmieru.so |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.