Skip to content

Commit 80a7562

Browse files
committed
fix workflow1
1 parent c9415b2 commit 80a7562

File tree

2 files changed

+91
-27
lines changed

2 files changed

+91
-27
lines changed

.github/workflows/build.yml

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ jobs:
4343
matrix:
4444
job:
4545
- { name: 'hiddify-core-android', os: 'ubuntu-latest', target: 'android'}
46-
- { name: 'hiddify-core-linux-amd64', os: 'ubuntu-22.04', target: 'linux-amd64', naive: true , corenet: 'windows/amd64' }
47-
- { name: 'hiddify-core-linux-arm64', os: 'ubuntu-24.04-arm', target: 'linux-arm64', naive: true , corenet: 'linux/arm64' }
46+
- { name: 'hiddify-core-linux-amd64', os: 'ubuntu-22.04', target: 'linux-amd64', naive: true , corenet: 'linux/amd64', build_corenet: true }
47+
- { name: 'hiddify-core-linux-arm64', os: 'ubuntu-24.04-arm', target: 'linux-arm64', naive: true , corenet: 'linux/arm64', build_corenet: true }
4848
- { name: "hiddify-core-windows-amd64", os: 'ubuntu-latest', target: 'windows-amd64', aarch: 'x64', naive: true, corenet: 'windows/amd64' }
4949
# - { name: "hiddify-core-macos", os: 'macos-15', target: 'macos' }
5050
# - { name: "hiddify-core-ios", os: "macos-15", target: "ios" }
@@ -111,6 +111,46 @@ jobs:
111111
run: |
112112
brew install create-dmg tree coreutils
113113
114+
- name: Clone cronet-go
115+
if: matrix.naive && matrix.build_corenet
116+
run: |
117+
set -xeuo pipefail
118+
CRONET_GO_VERSION=$(cat .github/CRONET_GO_VERSION)
119+
git init ~/cronet-go
120+
git -C ~/cronet-go remote add origin https://github.com/sagernet/cronet-go.git
121+
git -C ~/cronet-go fetch --depth=1 origin "$CRONET_GO_VERSION"
122+
git -C ~/cronet-go checkout FETCH_HEAD
123+
git -C ~/cronet-go submodule update --init --recursive --depth=1
124+
- name: Cache Chromium toolchain
125+
if: matrix.naive && matrix.build_corenet
126+
id: cache-chromium-toolchain
127+
uses: actions/cache@v4
128+
with:
129+
path: |
130+
~/cronet-go/naiveproxy/src/third_party/llvm-build/Release+Asserts
131+
~/cronet-go/naiveproxy/src/out/sysroot-build
132+
key: chromium-toolchain-${{ matrix.arch }}-${{ matrix.variant }}-${{ hashFiles('.github/CRONET_GO_VERSION') }}
133+
- name: Download Chromium toolchain
134+
if: matrix.naive && matrix.build_corenet
135+
run: |
136+
set -xeuo pipefail
137+
cd ~/cronet-go
138+
if [[ "${{ matrix.variant }}" == "musl" ]]; then
139+
go run ./cmd/build-naive --target=linux/${{ matrix.arch }} --libc=musl download-toolchain
140+
else
141+
go run ./cmd/build-naive --target=linux/${{ matrix.arch }} download-toolchain
142+
fi
143+
- name: Set Chromium toolchain environment
144+
if: matrix.naive && matrix.build_corenet
145+
run: |
146+
set -xeuo pipefail
147+
cd ~/cronet-go
148+
if [[ "${{ matrix.variant }}" == "musl" ]]; then
149+
go run ./cmd/build-naive --target=linux/${{ matrix.arch }} --libc=musl env >> $GITHUB_ENV
150+
else
151+
go run ./cmd/build-naive --target=linux/${{ matrix.arch }} env >> $GITHUB_ENV
152+
fi
153+
114154
- name: Build
115155
run: |
116156
make -j$(($(nproc) + 1)) ${{ matrix.job.target }}

Makefile

Lines changed: 49 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ endif
1313
CRONET_GO_VERSION := $(shell cat hiddify-sing-box/.github/CRONET_GO_VERSION)
1414
TAGS=with_gvisor,with_quic,with_wireguard,with_utls,with_clash_api,with_grpc,with_awg,with_naive_outbound
1515
IOS_ADD_TAGS=with_dhcp,with_low_memory,with_conntrack
16-
GOBUILDLIB=CGO_ENABLED=1 go build -trimpath -tags $(TAGS) -ldflags="-w -s" -buildmode=c-shared
16+
GOBUILDLIB=CGO_ENABLED=1 go build -trimpath -tags $(TAGS) -ldflags="-w -s -checklinkname=0" -buildmode=c-shared
17+
GOBUILDLIBWINDOWS=CGO_ENABLED=1 go build -trimpath -tags $(TAGS),with_purego,badlinkname,tfogo_checklinkname0 -ldflags="-w -s -checklinkname=0" -buildmode=c-shared
1718
GOBUILDSRV=CGO_ENABLED=1 go build -ldflags "-s -w" -trimpath -tags $(TAGS)
1819

20+
CRONET_DIR=./cronet
1921
.PHONY: protos
2022
protos:
2123
go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@latest
@@ -64,47 +66,69 @@ webui:
6466
windows-amd64: prepare
6567
rm -rf $(BINDIR)/*
6668
go run -v "github.com/sagernet/cronet-go/cmd/build-naive@$(CRONET_GO_VERSION)" extract-lib --target windows/amd64 -o $(BINDIR)/
67-
cp $(BINDIR)/libcronet.dll ./libcronet.dll
68-
env GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CGO_LDFLAGS="libcronet.dll" $(GOBUILDLIB) -o $(BINDIR)/$(LIBNAME).dll ./platform/desktop
69+
env GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc $(GOBUILDLIBWINDOWS) -o $(BINDIR)/$(LIBNAME).dll ./platform/desktop
6970
go install -mod=readonly github.com/akavel/rsrc@latest ||echo "rsrc error in installation"
7071
go run ./cli tunnel exit
7172
cp $(BINDIR)/$(LIBNAME).dll ./$(LIBNAME).dll
7273
$$(go env GOPATH)/bin/rsrc -ico ./assets/hiddify-cli.ico -o ./cmd/bydll/cli.syso ||echo "rsrc error in syso"
73-
env GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CGO_LDFLAGS="$(LIBNAME).dll libcronet.dll" $(GOBUILDSRV) -o $(BINDIR)/$(CLINAME).exe ./cmd/bydll
74+
env GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CGO_LDFLAGS="$(LIBNAME).dll" $(GOBUILDSRV) -o $(BINDIR)/$(CLINAME).exe ./cmd/bydll
7475
rm ./*.dll
7576
make webui
7677

7778

78-
linux-amd64: prepare
79-
mkdir -p $(BINDIR)/lib
80-
rm -rf $(BINDIR)/lib/*
81-
go run -v "github.com/sagernet/cronet-go/cmd/build-naive@$(CRONET_GO_VERSION)" extract-lib --target linux/amd64 -o $(BINDIR)/lib/
82-
mkdir -p lib
83-
cp $(BINDIR)/lib/libcronet.so ./lib/libcronet.so
84-
env GOOS=linux GOARCH=amd64 CGO_LDFLAGS="./lib/libcronet.so" $(GOBUILDLIB) -o $(BINDIR)/lib/$(LIBNAME).so ./platform/desktop
85-
cp $(BINDIR)/lib/$(LIBNAME).so ./lib/$(LIBNAME).so
86-
env GOOS=linux GOARCH=amd64 CGO_LDFLAGS="./lib/$(LIBNAME).so ./lib/libcronet.so" $(GOBUILDSRV) -o $(BINDIR)/$(CLINAME) ./cmd/bydll
87-
rm -rf ./lib
88-
chmod +x $(BINDIR)/$(CLINAME)
89-
make webui
9079

91-
linux-arm64: prepare
80+
################################
81+
# Install Cronet + Generate Env
82+
################################
83+
install_cronet:
84+
# rm -rf $(CRONET_DIR)
85+
git init $(CRONET_DIR) || echo "dir exist"
86+
cd $(CRONET_DIR) && \
87+
git remote add origin https://github.com/sagernet/cronet-go.git ||echo "remote exist"; \
88+
git fetch --depth=1 origin $(CRONET_GO_VERSION) && \
89+
git checkout FETCH_HEAD && \
90+
git submodule update --init --recursive --depth=1 && \
91+
if [ "$(VARIANT)" = "musl" ]; then \
92+
go run ./cmd/build-naive --target=linux/$(ARCH) --libc=musl download-toolchain && \
93+
go run ./cmd/build-naive --target=linux/$(ARCH) --libc=musl env > cronet.env; \
94+
else \
95+
go run ./cmd/build-naive --target=linux/$(ARCH) download-toolchain && \
96+
go run ./cmd/build-naive --target=linux/$(ARCH) env > cronet.env; \
97+
fi
98+
99+
################################
100+
# Generic Linux Builder
101+
################################
102+
linux-%:
103+
$(MAKE) ARCH=$* build-linux
104+
105+
define load_cronet_env
106+
set -a; \
107+
while IFS= read -r line; do \
108+
key=$${line%%=*}; \
109+
value=$${line#*=}; \
110+
export "$$key=$$value"; \
111+
done < $(CRONET_DIR)/cronet.env; \
112+
set +a;
113+
endef
114+
build-linux: prepare install_cronet
92115
mkdir -p $(BINDIR)/lib
93-
rm -rf $(BINDIR)/lib/*
94-
go run -v "github.com/sagernet/cronet-go/cmd/build-naive@$(CRONET_GO_VERSION)" extract-lib --target linux/arm64 -o $(BINDIR)/lib/
95-
mkdir -p lib
96-
cp $(BINDIR)/lib/libcronet.so ./lib/libcronet.so
97-
env GOOS=linux GOARCH=arm64 $(GOBUILDLIB) -o $(BINDIR)/lib/$(LIBNAME).so ./platform/desktop
116+
$(load_cronet_env)
117+
GOOS=linux GOARCH=$(ARCH) CGO_ENABLED=1 $(GOBUILDLIB) -o $(BINDIR)/lib/$(LIBNAME).so ./platform/desktop
118+
98119
cp $(BINDIR)/lib/$(LIBNAME).so ./lib/$(LIBNAME).so
99-
env GOOS=linux GOARCH=arm64 CGO_LDFLAGS="./lib/$(LIBNAME).so ./lib/libcronet.so" $(GOBUILDSRV) -o $(BINDIR)/$(CLINAME) ./cmd/bydll
100-
rm -rf ./lib
120+
121+
GOOS=linux GOARCH=$(ARCH) CGO_ENABLED=1 CGO_LDFLAGS="./lib/$(LIBNAME).so -Wl,-rpath,\$$ORIGIN/lib -fuse-ld=lld" \
122+
$(GOBUILDSRV) -o $(BINDIR)/$(CLINAME) ./cmd/bydll
123+
101124
chmod +x $(BINDIR)/$(CLINAME)
102125
make webui
103126

104127

105-
linux-custom: prepare
128+
linux-custom: prepare install_cronet
106129
mkdir -p $(BINDIR)/
107130
#env GOARCH=mips $(GOBUILDSRV) -o $(BINDIR)/$(CLINAME) ./cmd/
131+
$(load_cronet_env)
108132
go build -ldflags "-s -w" -trimpath -tags $(TAGS) -o $(BINDIR)/$(CLINAME) ./cmd/main
109133
chmod +x $(BINDIR)/$(CLINAME)
110134
make webui

0 commit comments

Comments
 (0)