Skip to content

Commit 987abeb

Browse files
authored
Update build-go-win7-dll.yml
1 parent 64261b3 commit 987abeb

1 file changed

Lines changed: 53 additions & 18 deletions

File tree

Lines changed: 53 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build Go Windows DLL
1+
name: Build Go Windows DLL (Win7 / Go1.20)
22

33
permissions:
44
contents: write
@@ -7,40 +7,75 @@ on:
77
workflow_dispatch:
88
inputs:
99
branch:
10-
description: "Branch to build from"
10+
description: "要构建的代码分支(例如:unity)"
1111
required: true
1212
default: "main"
13+
dll_name:
14+
required: true
15+
default: "openimsdk"
16+
package_path:
17+
required: true
18+
default: "./"
1319

1420
jobs:
15-
build-windows-dll:
21+
build:
1622
runs-on: ubuntu-latest
23+
24+
strategy:
25+
matrix:
26+
include:
27+
- arch: amd64
28+
cc: x86_64-w64-mingw32-gcc
29+
cxx: x86_64-w64-mingw32-g++
30+
suffix: amd64
31+
- arch: "386"
32+
cc: i686-w64-mingw32-gcc
33+
cxx: i686-w64-mingw32-g++
34+
suffix: 386
35+
1736
steps:
18-
- name: Checkout repository
37+
- name: Checkout
1938
uses: actions/checkout@v4
2039
with:
21-
ref: ${{ github.event.inputs.branch }}
40+
41+
ref: ${{ inputs.branch }}
2242

23-
- name: Set up Go 1.20
43+
- name: Setup Go 1.20
2444
uses: actions/setup-go@v5
2545
with:
2646
go-version: "1.20"
2747

28-
- name: Build DLLs for Windows (32-bit and 64-bit)
48+
- name: Install mingw-w64 for CGO cross-compile
49+
run: |
50+
sudo apt-get update
51+
sudo apt-get install -y --no-install-recommends mingw-w64
52+
53+
- name: Build Windows DLL (${{ matrix.arch }})
54+
env:
55+
GOOS: windows
56+
GOARCH: ${{ matrix.arch }}
57+
CGO_ENABLED: "1"
58+
CC: ${{ matrix.cc }}
59+
CXX: ${{ matrix.cxx }}
60+
61+
CGO_CFLAGS: "-D_WIN32_WINNT=0x0601 -DWINVER=0x0601"
2962
run: |
3063
mkdir -p windows
64+
3165
32-
echo "Building 64-bit DLL..."
33-
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 \
34-
go build -buildmode=c-shared -trimpath -ldflags="-s -w" \
35-
-o ./windows/openimsdk_amd64.dll ./
66+
OUT="windows/${{ inputs.dll_name }}_${{ matrix.suffix }}.dll"
67+
68+
echo "Building ${OUT} ..."
69+
go build -buildmode=c-shared -trimpath -ldflags="-s -w" \
70+
-o "${OUT}" \
71+
"${{ inputs.package_path }}"
3672
37-
echo "Building 32-bit DLL..."
38-
GOOS=windows GOARCH=386 CGO_ENABLED=1 \
39-
go build -buildmode=c-shared -trimpath -ldflags="-s -w" \
40-
-o ./windows/openimsdk_386.dll ./
73+
ls -l windows
4174
42-
- name: Upload DLLs as Artifacts
75+
- name: Upload Artifacts
4376
uses: actions/upload-artifact@v4
4477
with:
45-
name: windows-dlls
46-
path: ./windows/*.dll
78+
name: ${{ inputs.dll_name }}-win-dlls
79+
path: |
80+
windows/${{ inputs.dll_name }}_*.dll
81+
windows/${{ inputs.dll_name }}_*.h

0 commit comments

Comments
 (0)