Merge pull request #53 from Bloomingg/feat/add-win32-platform

feat: auto build win32 platform dll with ci
dev_1
blooming 9 months ago committed by GitHub
commit 034aa2df0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 19
      .github/workflows/auto-build-electron.yml
  2. 19
      magefile.go

@ -24,9 +24,9 @@ jobs:
- os: windows-latest - os: windows-latest
arch: amd64 arch: amd64
build: buildWindows build: buildWindows
# - os: windows-latest - os: windows-latest
# arch: 386 arch: 386
# build: buildWindows386 build: buildWindows
steps: steps:
- name: Checkout code - name: Checkout code
@ -48,10 +48,23 @@ jobs:
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CXX=aarch64-linux-gnu-g++" >> $GITHUB_ENV echo "CXX=aarch64-linux-gnu-g++" >> $GITHUB_ENV
- name: Install MinGW-w64 using Chocolatey
if: runner.os == 'Windows' && matrix.arch == '386'
run: |
curl -L -o mingw32.7z https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/8.1.0/threads-posix/dwarf/i686-8.1.0-release-posix-dwarf-rt_v6-rev0.7z/download
7z x mingw32.7z -oC:/mingw32
- name: Setup and build on Windows ${{ matrix.arch }} - name: Setup and build on Windows ${{ matrix.arch }}
if: runner.os == 'Windows' if: runner.os == 'Windows'
run: | run: |
./bootstrap_install_mage.bat ./bootstrap_install_mage.bat
$env:GOARCH="${{ matrix.arch }}"
if ($env:GOARCH -eq "386") {
$env:PATH = "C:/mingw32/bin;$env:PATH"
gcc --version
$env:CC="gcc -m32"
$env:CXX="g++ -m32"
}
mage ${{ matrix.build }} mage ${{ matrix.build }}
- name: Setup and build on ${{ matrix.os }} ${{ matrix.arch }} - name: Setup and build on ${{ matrix.os }} ${{ matrix.arch }}

@ -127,11 +127,26 @@ func BuildWindows() error {
fmt.Println("Building for Windows...") fmt.Println("Building for Windows...")
outPath += "windows" outPath += "windows"
arch := os.Getenv("GOARCH")
cc := os.Getenv("CC")
cxx := os.Getenv("CXX")
if len(arch) == 0 {
arch = runtime.GOARCH
}
if len(cc) == 0 {
cc = "gcc"
}
if len(cxx) != 0 {
os.Setenv("CXX", cxx)
}
os.Setenv("GOOS", "windows") os.Setenv("GOOS", "windows")
os.Setenv("GOARCH", "amd64") os.Setenv("GOARCH", arch)
os.Setenv("CGO_ENABLED", "1") os.Setenv("CGO_ENABLED", "1")
os.Setenv("CC", "gcc") os.Setenv("CC", cc)
cmd := exec.Command("go", "build", "-buildmode=c-shared", "-trimpath", "-ldflags=-s -w", "-o", outPath+"/"+soName+".dll", ".") cmd := exec.Command("go", "build", "-buildmode=c-shared", "-trimpath", "-ldflags=-s -w", "-o", outPath+"/"+soName+".dll", ".")
cmd.Dir = goSrc cmd.Dir = goSrc

Loading…
Cancel
Save