-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
91dcef4
commit f4cf6c2
Showing
35 changed files
with
379 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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,113 @@ | ||
name: Mieru Plugin Build | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
description: "Release Tag" | ||
required: true | ||
publish: | ||
description: "Publish: If want ignore" | ||
required: false | ||
jobs: | ||
native: | ||
name: Native Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
- name: Fetch Status | ||
run: git submodule status 'plugin/mieru/*' > mieru_status | ||
- name: Mieru Cache | ||
id: cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
plugin/mieru/src/main/jniLibs | ||
key: ${{ hashFiles('.github/workflows/*', 'bin/lib/mieru/*', 'mieru_status') }} | ||
- name: Gradle cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.gradle | ||
key: gradle-${{ hashFiles('**/*.gradle.kts') }} | ||
- name: Golang Version | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
id: version | ||
run: | | ||
source buildScript/init/version.sh | ||
echo go_version=$GO_VERSION >> $GITHUB_OUTPUT | ||
- name: Install Golang | ||
uses: actions/setup-go@v5 | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
with: | ||
go-version: ${{ steps.version.outputs.go_version }} | ||
- name: Native Build | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: ./run plugin mieru | ||
build: | ||
name: Gradle Build | ||
runs-on: ubuntu-latest | ||
needs: | ||
- native | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
- name: Fetch Status | ||
run: git submodule status 'plugin/mieru/*' > mieru_status | ||
- name: Mieru Cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
plugin/mieru/src/main/jniLibs | ||
key: ${{ hashFiles('.github/workflows/*', 'bin/lib/mieru/*', 'mieru_status') }} | ||
- name: Gradle cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.gradle | ||
key: gradle-${{ hashFiles('**/*.gradle.kts') }} | ||
- uses: actions/setup-java@v4 | ||
with: | ||
java-version: "17" | ||
distribution: "temurin" | ||
- name: Release Build | ||
env: | ||
SKIP_BUILD: on | ||
BUILD_PLUGIN: mieru | ||
run: | | ||
echo "sdk.dir=${ANDROID_HOME}" > local.properties | ||
# export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" | ||
KEYSTORE_PASS="${{ secrets.KEYSTORE_PASS }}" ALIAS_NAME="${{ secrets.ALIAS_NAME }}" ALIAS_PASS="${{ secrets.ALIAS_PASS}}" ./gradlew :plugin:mieru:assembleFossRelease | ||
APK=$(find plugin/mieru/build/outputs/apk -name '*arm64-v8a*.apk') | ||
APK=$(dirname "$APK") | ||
echo "APK=$APK" >> $GITHUB_ENV | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: APKs | ||
path: ${{ env.APK }} | ||
publish: | ||
name: Publish Release | ||
if: github.event.inputs.publish != 'y' | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
- name: Donwload Artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: APKs | ||
path: artifacts | ||
- name: Release | ||
run: | | ||
wget -O ghr.tar.gz https://github.com/tcnksm/ghr/releases/download/v0.16.2/ghr_v0.16.2_linux_amd64.tar.gz | ||
tar -xvf ghr.tar.gz | ||
mv ghr*linux_amd64/ghr . | ||
mkdir apks | ||
find artifacts -name "*.apk" -exec cp {} apks \; | ||
find artifacts -name "*.sha256sum.txt" -exec cp {} apks \; | ||
./ghr -delete -prerelease -t "${{ github.token }}" -n "${{ github.event.inputs.tag }}" "${{ github.event.inputs.tag }}" apks |
This file contains 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 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 |
---|---|---|
|
@@ -92,6 +92,7 @@ Plugin name list: | |
* `hysteria2` | ||
* `juicity` | ||
* `naive` | ||
* `mieru` | ||
|
||
## ☠️ End users | ||
|
||
|
This file contains 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,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
buildScript/plugin/mieru/init.sh && set -x && | ||
buildScript/plugin/mieru/armeabi-v7a.sh && | ||
buildScript/plugin/mieru/arm64-v8a.sh && | ||
buildScript/plugin/mieru/x86.sh && | ||
buildScript/plugin/mieru/x86_64.sh |
This file contains 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,8 @@ | ||
#!/bin/bash | ||
|
||
source "buildScript/init/env.sh" | ||
source "buildScript/plugin/mieru/build.sh" | ||
|
||
DIR="$ROOT/arm64-v8a" | ||
mkdir -p $DIR | ||
env CC="$ANDROID_ARM64_CC" GOARCH="arm64" go build -v -o $DIR/$LIB_OUTPUT -buildvcs=false -trimpath -ldflags "-s -w -buildid=" ./cmd/mieru |
This file contains 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,10 @@ | ||
#!/bin/bash | ||
|
||
# set -x | ||
|
||
source "buildScript/init/env.sh" | ||
source "buildScript/plugin/mieru/build.sh" | ||
|
||
DIR="$ROOT/armeabi-v7a" | ||
mkdir -p $DIR | ||
env CC="$ANDROID_ARM_CC" GOARCH=arm GOARM=7 go build -v -o $DIR/$LIB_OUTPUT -buildvcs=false -trimpath -ldflags "-s -w -buildid=" ./cmd/mieru |
This file contains 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,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
#set -x | ||
|
||
source "buildScript/init/env.sh" | ||
|
||
export CGO_ENABLED=1 | ||
export GOOS=android | ||
|
||
CURR="plugin/mieru" | ||
CURR_PATH="$SRC_ROOT/$CURR" | ||
|
||
ROOT="$CURR_PATH/src/main/jniLibs" | ||
OUTPUT="mieru" | ||
LIB_OUTPUT="lib$OUTPUT.so" | ||
|
||
cd $CURR_PATH/src/main/go/mieru |
This file contains 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,13 @@ | ||
#!/usr/bin/env bash | ||
|
||
source "buildScript/init/env.sh" | ||
|
||
export CGO_ENABLED=1 | ||
export GOOS=android | ||
|
||
CURR="plugin/mieru" | ||
CURR_PATH="$SRC_ROOT/$CURR" | ||
|
||
#git submodule update --init "$CURR/*" | ||
cd $CURR_PATH/src/main/go/mieru | ||
go mod download -x |
This file contains 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,8 @@ | ||
#!/bin/bash | ||
|
||
source "buildScript/init/env.sh" | ||
source "buildScript/plugin/mieru/build.sh" | ||
|
||
DIR="$ROOT/x86" | ||
mkdir -p $DIR | ||
env CC="$ANDROID_X86_CC" GOARCH=386 go build -v -o $DIR/$LIB_OUTPUT -buildvcs=false -trimpath -ldflags "-s -w -buildid=" ./cmd/mieru |
This file contains 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,8 @@ | ||
#!/bin/bash | ||
|
||
source "buildScript/init/env.sh" | ||
source "buildScript/plugin/mieru/build.sh" | ||
|
||
DIR="$ROOT/x86_64" | ||
mkdir -p $DIR | ||
env CC="$ANDROID_X86_64_CC" GOARCH=amd64 go build -v -o $DIR/$LIB_OUTPUT -buildvcs=false -trimpath -ldflags "-s -w -buildid=" ./cmd/mieru |
This file contains 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 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,12 @@ | ||
plugins { | ||
id("com.android.application") | ||
} | ||
|
||
android { | ||
defaultConfig { | ||
applicationId = "fr.husi.plugin.mieru" | ||
} | ||
namespace = "fr.husi.plugin.mieru" | ||
} | ||
|
||
setupPlugin("mieru") |
This file contains 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,45 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:installLocation="internalOnly" | ||
tools:ignore="MissingLeanbackLauncher"> | ||
|
||
<uses-feature | ||
android:name="android.software.leanback" | ||
android:required="false"/> | ||
<uses-feature | ||
android:name="android.hardware.touchscreen" | ||
android:required="false"/> | ||
|
||
<application | ||
android:allowBackup="false" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="Mieru Plugin" | ||
android:roundIcon="@mipmap/ic_launcher_round"> | ||
<provider | ||
android:name="fr.husi.plugin.mieru.BinaryProvider" | ||
android:authorities="fr.husi.plugin.mieru.BinaryProvider" | ||
android:directBootAware="true" | ||
android:exported="true" | ||
tools:ignore="ExportedContentProvider"> | ||
<intent-filter> | ||
<action android:name="io.nekohasekai.sagernet.plugin.ACTION_NATIVE_PLUGIN"/> | ||
</intent-filter> | ||
<intent-filter> | ||
<action android:name="io.nekohasekai.sagernet.plugin.ACTION_NATIVE_PLUGIN"/> | ||
<data | ||
android:host="fr.husi" | ||
android:path="/mieru-plugin" | ||
android:scheme="plugin"/> | ||
</intent-filter> | ||
|
||
<meta-data | ||
android:name="io.nekohasekai.sagernet.plugin.id" | ||
android:value="mieru-plugin"/> | ||
<meta-data | ||
android:name="io.nekohasekai.sagernet.plugin.executable_path" | ||
android:value="libmieru.so"/> | ||
</provider> | ||
</application> | ||
|
||
</manifest> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions
43
plugin/mieru/src/main/java/fr/husi/plugin/mieru/BinaryProvider.kt
This file contains 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,43 @@ | ||
/****************************************************************************** | ||
* * | ||
* Copyright (C) 2021 by nekohasekai <contact-sagernet@sekai.icu> * | ||
* * | ||
* This program is free software: you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation, either version 3 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
* This program is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
* GNU General Public License for more details. * | ||
* * | ||
* You should have received a copy of the GNU General Public License * | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. * | ||
* * | ||
******************************************************************************/ | ||
|
||
package fr.husi.plugin.mieru | ||
|
||
import android.net.Uri | ||
import android.os.ParcelFileDescriptor | ||
import io.nekohasekai.sagernet.plugin.NativePluginProvider | ||
import io.nekohasekai.sagernet.plugin.PathProvider | ||
import java.io.File | ||
import java.io.FileNotFoundException | ||
|
||
class BinaryProvider : NativePluginProvider() { | ||
override fun populateFiles(provider: PathProvider) { | ||
provider.addPath("mieru-plugin", 0b111101101) | ||
} | ||
|
||
override fun getExecutable() = context!!.applicationInfo.nativeLibraryDir + "/libmieru.so" | ||
override fun openFile(uri: Uri): ParcelFileDescriptor = when (uri.path) { | ||
"/mieru-plugin" -> ParcelFileDescriptor.open( | ||
File(getExecutable()), | ||
ParcelFileDescriptor.MODE_READ_ONLY | ||
) | ||
|
||
else -> throw FileNotFoundException() | ||
} | ||
} |
Oops, something went wrong.