Skip to content

Commit d6de0c9

Browse files
committed
build: use absolute path
1 parent 4179790 commit d6de0c9

6 files changed

Lines changed: 23 additions & 24 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ jobs:
3333
go-version: ${{ env.GO_VERSION }}
3434

3535
- name: Build
36-
working-directory: scripts
37-
run: bash -x ./build.sh
36+
run: bash -x ./scripts/build.sh
3837

3938
- name: Calculate MD5 checksum
4039
run: echo "MD5=$(md5sum libcore.aar | cut -d ' ' -f 1)" >> $GITHUB_ENV

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ binary*.go
44
.vscode
55
/debug.go
66
.build
7+
libneko
8+
sing-box

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
## Build
44

55
```
6-
cd ./scripts/ && bash -x ./build.sh
6+
bash -x ./scripts/build.sh
77
```

go.mod

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,5 @@ require (
8888
lukechampine.com/blake3 v1.3.0 // indirect
8989
)
9090

91-
replace github.com/matsuridayo/libneko => ../libneko
92-
93-
replace github.com/sagernet/sing-box => ../sing-box
91+
replace github.com/matsuridayo/libneko => ./libneko
92+
replace github.com/sagernet/sing-box => ./sing-box

scripts/build.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
11
#!/usr/bin/env bash
22

3+
SCRIPT_DIR="$(dirname $(readlink -f $0))"
4+
35
set -e
46

5-
source ./env.sh
7+
source $SCRIPT_DIR/env.sh
68

7-
bash ./sources.sh
9+
bash $SCRIPT_DIR/sources.sh
810

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

1315
PATH="$PATH:$GOPATH/bin"
1416
GOMOBILE_VERSION="v0.0.0-20231127183840-76ac6878050a"
17+
18+
cd "$SCRIPT_DIR/../"
19+
1520
# Install gomobile
1621
if [ ! -f "$GOPATH/bin/gomobile" ]; then
1722
go get -v "golang.org/x/mobile@$GOMOBILE_VERSION"
1823
go install -v "$GOPATH/pkg/mod/golang.org/x/mobile@$GOMOBILE_VERSION/cmd/gomobile"
1924
fi
2025

2126
gomobile init
22-
23-
cd ..
24-
2527
gomobile bind -v \
2628
-androidapi 21 \
2729
-trimpath \
2830
-ldflags='-s -w' \
2931
-tags='with_conntrack,with_gvisor,with_quic,with_wireguard,with_utls,with_clash_api,with_ech' .
3032

31-
rm -v "$GOPATH/bin/gomobile" "$GOPATH/bin/gobind" libcore-sources.jar
33+
rm -v "$GOPATH/bin/gomobile" "$GOPATH/bin/gobind" "$SCRIPT_DIR/../libcore-sources.jar"

scripts/sources.sh

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,22 @@ set -e
44

55
COMMIT_SING_BOX="01b72e129794acae89e1c7929d0ba5a63b0e67f8"
66
COMMIT_LIBNEKO="1c47a3af71990a7b2192e03292b4d246c308ef0b"
7+
SCRIPT_DIR="$(dirname $(readlink -f $0))"
78

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

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

0 commit comments

Comments
 (0)