Skip to content

Commit b119476

Browse files
committed
[DRAFT] build: use absolute path
1 parent 4179790 commit b119476

4 files changed

Lines changed: 19 additions & 19 deletions

File tree

.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

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: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
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)
@@ -20,12 +22,12 @@ fi
2022

2123
gomobile init
2224

23-
cd ..
25+
cd $SCRIPT_DIR/../
2426

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)