Skip to content

Commit d27168e

Browse files
committed
Fix cronet library extraction
CI took the library from the head of refs/heads/go. The packages carried a library that differs from the bindings in the binary. CI reads the library file from the commit in CRONET_GO_VERSION, and the update script points that pin at the generated branch.
1 parent fe8bb7a commit d27168e

5 files changed

Lines changed: 28 additions & 21 deletions

File tree

.github/CRONET_GO_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e1d173257b86d732479dda28cc0746ba33030afe
1+
2890ac0cdcf5c5d87d26ba329148f1152406ccf2

.github/update_cronet_dev.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ git -C $PROJECTS/cronet-go fetch origin go_dev
1010
go get -x github.com/sagernet/cronet-go/all@$(git -C $PROJECTS/cronet-go rev-parse origin/go_dev)
1111
go get -x github.com/sagernet/cronet-go@$(git -C $PROJECTS/cronet-go rev-parse origin/go_dev)
1212
go mod tidy
13-
git -C $PROJECTS/cronet-go rev-parse origin/dev > "$SCRIPT_DIR/CRONET_GO_VERSION"
13+
git -C $PROJECTS/cronet-go rev-parse origin/go_dev > "$SCRIPT_DIR/CRONET_GO_VERSION"

.github/workflows/build.yml

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -178,24 +178,25 @@ jobs:
178178
with:
179179
ndk-version: r28
180180
- name: Clone cronet-go
181-
if: matrix.naive
181+
if: matrix.naive && matrix.variant != 'purego'
182182
run: |
183183
set -xeuo pipefail
184184
CRONET_GO_VERSION=$(cat .github/CRONET_GO_VERSION)
185185
git init ~/cronet-go
186186
git -C ~/cronet-go remote add origin https://github.com/sagernet/cronet-go.git
187-
git -C ~/cronet-go fetch --depth=1 origin "$CRONET_GO_VERSION"
187+
git -C ~/cronet-go sparse-checkout set --no-cone '/*' '!/lib'
188+
git -C ~/cronet-go fetch --depth=1 --filter=blob:none origin "$CRONET_GO_VERSION"
188189
git -C ~/cronet-go checkout FETCH_HEAD
189190
git -C ~/cronet-go submodule update --init --recursive --depth=1
190191
- name: Regenerate Debian keyring
191-
if: matrix.naive
192+
if: matrix.naive && matrix.variant != 'purego'
192193
run: |
193194
set -xeuo pipefail
194195
rm -f ~/cronet-go/naiveproxy/src/build/linux/sysroot_scripts/keyring.gpg
195196
cd ~/cronet-go
196197
GPG_TTY=/dev/null ./naiveproxy/src/build/linux/sysroot_scripts/generate_keyring.sh
197198
- name: Download Chromium toolchain
198-
if: matrix.naive
199+
if: matrix.naive && matrix.variant != 'purego'
199200
run: |
200201
set -xeuo pipefail
201202
cd ~/cronet-go
@@ -205,7 +206,7 @@ jobs:
205206
go run ./cmd/build-naive --target=linux/${{ matrix.arch }} download-toolchain
206207
fi
207208
- name: Set Chromium toolchain environment
208-
if: matrix.naive
209+
if: matrix.naive && matrix.variant != 'purego'
209210
run: |
210211
set -xeuo pipefail
211212
cd ~/cronet-go
@@ -255,9 +256,15 @@ jobs:
255256
- name: Extract libcronet.so
256257
if: matrix.variant == 'purego' && matrix.naive
257258
run: |
258-
cd ~/cronet-go
259-
CGO_ENABLED=0 go build -v -o "$RUNNER_TEMP/build-naive" ./cmd/build-naive
260-
GOPROXY=direct GOSUMDB=off "$RUNNER_TEMP/build-naive" extract-lib --target ${{ matrix.os }}/${{ matrix.arch }} -o $GITHUB_WORKSPACE/dist
259+
set -xeuo pipefail
260+
CRONET_GO_VERSION=$(cat .github/CRONET_GO_VERSION)
261+
LIBRARY_PATH="lib/${{ matrix.os }}_${{ matrix.arch }}/libcronet.so"
262+
git init "$RUNNER_TEMP/cronet-go-lib"
263+
git -C "$RUNNER_TEMP/cronet-go-lib" remote add origin https://github.com/sagernet/cronet-go.git
264+
git -C "$RUNNER_TEMP/cronet-go-lib" sparse-checkout set --no-cone "/$LIBRARY_PATH"
265+
git -C "$RUNNER_TEMP/cronet-go-lib" fetch --depth=1 --filter=blob:none origin "$CRONET_GO_VERSION"
266+
git -C "$RUNNER_TEMP/cronet-go-lib" checkout FETCH_HEAD
267+
cp "$RUNNER_TEMP/cronet-go-lib/$LIBRARY_PATH" dist/
261268
- name: Build (glibc)
262269
if: matrix.variant == 'glibc'
263270
run: |
@@ -624,15 +631,13 @@ jobs:
624631
if: matrix.naive
625632
run: |
626633
$CRONET_GO_VERSION = Get-Content .github/CRONET_GO_VERSION
627-
git init "$env:RUNNER_TEMP/cronet-go"
628-
git -C "$env:RUNNER_TEMP/cronet-go" remote add origin https://github.com/sagernet/cronet-go.git
629-
git -C "$env:RUNNER_TEMP/cronet-go" fetch --depth=1 origin "$CRONET_GO_VERSION"
630-
git -C "$env:RUNNER_TEMP/cronet-go" checkout FETCH_HEAD
631-
$env:CGO_ENABLED = "0"
632-
go -C "$env:RUNNER_TEMP/cronet-go" build -v -o "$env:RUNNER_TEMP/build-naive.exe" ./cmd/build-naive
633-
$env:GOPROXY = "direct"
634-
$env:GOSUMDB = "off"
635-
& "$env:RUNNER_TEMP/build-naive.exe" extract-lib --target windows/${{ matrix.arch }} -o dist
634+
$LIBRARY_PATH = "lib/windows_${{ matrix.arch }}/libcronet.dll"
635+
git init "$env:RUNNER_TEMP/cronet-go-lib"
636+
git -C "$env:RUNNER_TEMP/cronet-go-lib" remote add origin https://github.com/sagernet/cronet-go.git
637+
git -C "$env:RUNNER_TEMP/cronet-go-lib" sparse-checkout set --no-cone "/$LIBRARY_PATH"
638+
git -C "$env:RUNNER_TEMP/cronet-go-lib" fetch --depth=1 --filter=blob:none origin "$CRONET_GO_VERSION"
639+
git -C "$env:RUNNER_TEMP/cronet-go-lib" checkout FETCH_HEAD
640+
Copy-Item "$env:RUNNER_TEMP/cronet-go-lib/$LIBRARY_PATH" dist
636641
- name: Archive
637642
if: matrix.naive
638643
run: |

.github/workflows/docker.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ jobs:
6363
CRONET_GO_VERSION=$(cat .github/CRONET_GO_VERSION)
6464
git init ~/cronet-go
6565
git -C ~/cronet-go remote add origin https://github.com/sagernet/cronet-go.git
66-
git -C ~/cronet-go fetch --depth=1 origin "$CRONET_GO_VERSION"
66+
git -C ~/cronet-go sparse-checkout set --no-cone '/*' '!/lib'
67+
git -C ~/cronet-go fetch --depth=1 --filter=blob:none origin "$CRONET_GO_VERSION"
6768
git -C ~/cronet-go checkout FETCH_HEAD
6869
git -C ~/cronet-go submodule update --init --recursive --depth=1
6970
- name: Regenerate Debian keyring

.github/workflows/linux.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ jobs:
8080
CRONET_GO_VERSION=$(cat .github/CRONET_GO_VERSION)
8181
git init ~/cronet-go
8282
git -C ~/cronet-go remote add origin https://github.com/sagernet/cronet-go.git
83-
git -C ~/cronet-go fetch --depth=1 origin "$CRONET_GO_VERSION"
83+
git -C ~/cronet-go sparse-checkout set --no-cone '/*' '!/lib'
84+
git -C ~/cronet-go fetch --depth=1 --filter=blob:none origin "$CRONET_GO_VERSION"
8485
git -C ~/cronet-go checkout FETCH_HEAD
8586
git -C ~/cronet-go submodule update --init --recursive --depth=1
8687
- name: Regenerate Debian keyring

0 commit comments

Comments
 (0)