Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ jobs:
go-version: ${{ env.GO_VERSION }}

- name: Build
working-directory: scripts
run: bash -x ./build.sh
run: bash -x ./scripts/build.sh

- name: Calculate MD5 checksum
run: echo "MD5=$(md5sum libcore.aar | cut -d ' ' -f 1)" >> $GITHUB_ENV
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ binary*.go
.vscode
/debug.go
.build
libneko
sing-box
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
## Build

```
cd ./scripts/ && bash -x ./build.sh
bash -x ./scripts/build.sh
```
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,5 @@ require (
lukechampine.com/blake3 v1.3.0 // indirect
)

replace github.com/matsuridayo/libneko => ../libneko

replace github.com/sagernet/sing-box => ../sing-box
replace github.com/matsuridayo/libneko => ./libneko
replace github.com/sagernet/sing-box => ./sing-box
14 changes: 8 additions & 6 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
#!/usr/bin/env bash

SCRIPT_DIR="$(dirname $(readlink -f $0))"

set -e

source ./env.sh
source $SCRIPT_DIR/env.sh

bash ./sources.sh
bash $SCRIPT_DIR/sources.sh

if [ -z "$GOPATH" ]; then
GOPATH=$(go env GOPATH)
fi

PATH="$PATH:$GOPATH/bin"
GOMOBILE_VERSION="v0.0.0-20231127183840-76ac6878050a"

cd "$SCRIPT_DIR/../"

# Install gomobile
if [ ! -f "$GOPATH/bin/gomobile" ]; then
go get -v "golang.org/x/mobile@$GOMOBILE_VERSION"
go install -v "$GOPATH/pkg/mod/golang.org/x/mobile@$GOMOBILE_VERSION/cmd/gomobile"
fi

gomobile init

cd ..

gomobile bind -v \
-androidapi 21 \
-trimpath \
-ldflags='-s -w' \
-tags='with_conntrack,with_gvisor,with_quic,with_wireguard,with_utls,with_clash_api,with_ech' .

rm -v "$GOPATH/bin/gomobile" "$GOPATH/bin/gobind" libcore-sources.jar
rm -v "$GOPATH/bin/gomobile" "$GOPATH/bin/gobind" "$SCRIPT_DIR/../libcore-sources.jar"
21 changes: 9 additions & 12 deletions scripts/sources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,22 @@ set -e

COMMIT_SING_BOX="01b72e129794acae89e1c7929d0ba5a63b0e67f8"
COMMIT_LIBNEKO="1c47a3af71990a7b2192e03292b4d246c308ef0b"
SCRIPT_DIR="$(dirname $(readlink -f $0))"

if [[ -d ../../sing-box ]]; then
if [[ "$(git -C ../../sing-box rev-parse HEAD)" != "$COMMIT_SING_BOX" ]]; then
if [[ -d "$SCRIPT_DIR/../sing-box" ]]; then
if [[ "$(git -C "$SCRIPT_DIR/../sing-box" rev-parse HEAD)" != "$COMMIT_SING_BOX" ]]; then
echo "ERROR: Wrong 'sing-box' commit hash!"
fi
else
mkdir -v ../../sing-box && cd ../../sing-box
git clone --no-checkout https://github.com/MatsuriDayo/sing-box "$(pwd)"
git -c advice.detachedHead=false checkout "$COMMIT_SING_BOX"
cd - &>/dev/null
git clone --no-checkout https://github.com/MatsuriDayo/sing-box "$SCRIPT_DIR/../sing-box"
git --git-dir="$SCRIPT_DIR/../sing-box/.git" -C "$SCRIPT_DIR/../sing-box" -c advice.detachedHead=false checkout "$COMMIT_SING_BOX"
fi

if [[ -d ../../libneko ]]; then
if [[ "$(git -C ../../libneko rev-parse HEAD)" != "$COMMIT_LIBNEKO" ]]; then
if [[ -d "$SCRIPT_DIR/../libneko" ]]; then
if [[ "$(git -C "$SCRIPT_DIR/../libneko" rev-parse HEAD)" != "$COMMIT_LIBNEKO" ]]; then
echo "ERROR: Wrong 'libneko' commit hash!"
fi
else
mkdir -v ../../libneko && cd ../../libneko
git clone --no-checkout https://github.com/MatsuriDayo/libneko "$(pwd)"
git -c advice.detachedHead=false checkout "$COMMIT_LIBNEKO"
cd - &>/dev/null
git clone --no-checkout https://github.com/MatsuriDayo/libneko "$SCRIPT_DIR/../libneko"
git --git-dir="$SCRIPT_DIR/../libneko/.git" -C "$SCRIPT_DIR/../libneko" -c advice.detachedHead=false checkout "$COMMIT_LIBNEKO"
fi