fix: build with target arch
This commit is contained in:
parent
0050e20fba
commit
893a2c616b
20
.github/workflows/auto-build-electron.yml
vendored
20
.github/workflows/auto-build-electron.yml
vendored
@ -24,9 +24,9 @@ jobs:
|
||||
- os: windows-latest
|
||||
arch: amd64
|
||||
build: buildWindows
|
||||
- os: windows-latest
|
||||
arch: 386
|
||||
build: buildWindows
|
||||
# - os: windows-latest
|
||||
# arch: 386
|
||||
# build: buildWindows386
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@ -39,11 +39,18 @@ jobs:
|
||||
|
||||
- name: Check Go version
|
||||
run: go version
|
||||
|
||||
|
||||
- name: Install ARM64 cross-compilation toolchain
|
||||
if: matrix.arch == 'arm64' && matrix.os == 'ubuntu-latest'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
|
||||
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
|
||||
echo "CXX=aarch64-linux-gnu-g++" >> $GITHUB_ENV
|
||||
|
||||
- name: Setup and build on Windows ${{ matrix.arch }}
|
||||
if: runner.os == 'Windows'
|
||||
run: |
|
||||
echo "GOARCH=${{ matrix.arch }}" >> $GITHUB_ENV
|
||||
./bootstrap_install_mage.bat
|
||||
mage ${{ matrix.build }}
|
||||
|
||||
@ -51,7 +58,8 @@ jobs:
|
||||
if: runner.os != 'Windows'
|
||||
run: |
|
||||
sudo bash ./bootstrap_install_mage.sh
|
||||
sudo mage ${{ matrix.build }}
|
||||
export GOARCH=${{ matrix.arch }}
|
||||
sudo -E mage ${{ matrix.build }}
|
||||
|
||||
- name: Upload Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
|
27
magefile.go
27
magefile.go
@ -57,8 +57,14 @@ func BuildAndroid() error {
|
||||
func BuildIOS() error {
|
||||
fmt.Println("Building for iOS...")
|
||||
outPath += "ios"
|
||||
arch := os.Getenv("GOARCH")
|
||||
|
||||
if len(arch) == 0 {
|
||||
arch = runtime.GOARCH
|
||||
}
|
||||
|
||||
os.Setenv("GOOS", "darwin")
|
||||
os.Setenv("GOARCH", "arm64")
|
||||
os.Setenv("GOARCH", arch)
|
||||
os.Setenv("CGO_ENABLED", "1")
|
||||
os.Setenv("CC", "clang")
|
||||
|
||||
@ -81,11 +87,26 @@ func BuildLinux() error {
|
||||
fmt.Println("Building for Linux...")
|
||||
|
||||
outPath += "linux"
|
||||
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", "linux")
|
||||
os.Setenv("GOARCH", "amd64")
|
||||
os.Setenv("GOARCH", arch)
|
||||
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+".so", ".")
|
||||
cmd.Dir = goSrc
|
||||
|
Loading…
x
Reference in New Issue
Block a user