Skip to content

Commit

Permalink
Merge pull request #13 from whiler/7-kmactor-arm64
Browse files Browse the repository at this point in the history
7 kmactor arm64
  • Loading branch information
whiler authored Mar 10, 2023
2 parents 1c506f7 + eb4c927 commit 235ad91
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 26 deletions.
38 changes: 21 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,32 @@ jobs:
- name: Set up requirements for Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
sudo apt update -y
sudo apt install gcc libc6-dev -y
sudo apt install libx11-dev xorg-dev libxtst-dev -y
sudo cp /etc/apt/sources.list /etc/apt/sources.list.d/ports.list
sudo sed -i -e 's/^deb /deb [arch=arm64] /' -e 's/\/ubuntu/\/ubuntu-ports/' -e 's/archive/ports/' /etc/apt/sources.list.d/ports.list
sudo apt update -qq -y
sudo dpkg --add-architecture arm64
sudo apt install -qq -y gcc gcc-aarch64-linux-gnu xorg-dev
sudo apt install -qq -y libc6-dev libx11-dev libxtst-dev
sudo apt install -qq -y libc6-dev:arm64 libx11-dev:arm64 libxtst-dev:arm64
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Build
run: make release
- name: Rename for Windows
- name: Build for Windows
if: ${{ matrix.os == 'windows-latest' }}
run: mv bin/kmactor bin/kmactor-windows-latest.exe
- name: Rename for macOS
if: ${{ matrix.os == 'macos-latest' }}
run: mv bin/kmactor bin/kmactor-macos-latest
- name: Rename for Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
run: mv bin/kmactor bin/kmactor-linux-latest
run: |
Invoke-WebRequest -Uri https://github.com/mstorsjo/llvm-mingw/releases/download/20220906/llvm-mingw-20220906-msvcrt-x86_64.zip -OutFile llvm-mingw-20220906-msvcrt-x86_64.zip
unzip llvm-mingw-20220906-msvcrt-x86_64.zip
$curdir = Get-Location
$env:PATH="$curdir\llvm-mingw-20220906-msvcrt-x86_64\bin;"+"$env:PATH"
make tidy
make all
- name: Build
if: ${{ matrix.os != 'windows-latest' }}
run: |
make tidy
make all
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
Expand All @@ -50,7 +57,4 @@ jobs:
uses: softprops/action-gh-release@v1
with:
draft: true
files: |
kmactor-windows-latest.exe
kmactor-macos-latest
kmactor-linux-latest
files: kmactor-*
34 changes: 25 additions & 9 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,44 @@
DT := $(shell date +%Y%U)
REV := $(shell git rev-parse --short HEAD)
APP := $(shell basename $(CURDIR))
ARTIFACT := bin/$(APP)$(EXT)
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
EXT :=
ifeq ($(GOOS),windows)
EXT := .exe
endif
ARTIFACT := bin/$(APP)-$(GOOS)-$(GOARCH)$(EXT)
AMD64CC :=
ARM64CC :=

TAGS ?= dev
GOFLAGS ?= -race -v
GOLDFLAGS ?= -X main.buildRevision=$(DT).$(REV)

.PHONY: all amd64 arm64 build linux release tidy updep
ifeq ($(shell go env GOHOSTOS), windows)
AMD64CC = x86_64-w64-mingw32-gcc
ARM64CC = aarch64-w64-mingw32-gcc
else ifeq ($(shell go env GOHOSTOS), linux)
ifeq ($(shell go env GOHOSTARCH), amd64)
ARM64CC = aarch64-linux-gnu-gcc
else
AMD64CC = x86_64-linux-gnu-gcc
endif
endif

build: tidy
go build $(GOFLAGS) -ldflags "$(GOLDFLAGS)" -tags="$(TAGS)" -o $(ARTIFACT) cmd/main.go
.PHONY: all amd64 arm64 build release tidy updep

build:
CGO_ENABLED=1 go build $(GOFLAGS) -ldflags "$(GOLDFLAGS)" -tags="$(TAGS)" -o $(ARTIFACT) cmd/main.go

release:
GOFLAGS="-trimpath" GOLDFLAGS="$(GOLDFLAGS) -s -w" TAGS="release" $(MAKE) build

linux:
GOOS=linux $(MAKE) release

amd64:
EXT=.x86-64 GOARCH=amd64 $(MAKE) linux
GOARCH=amd64 CC=$(AMD64CC) $(MAKE) release

arm64:
EXT=.aarch64 GOARCH=arm64 $(MAKE) linux
GOARCH=arm64 CC=$(ARM64CC) $(MAKE) release

tidy: go.mod
go mod tidy
Expand Down

0 comments on commit 235ad91

Please sign in to comment.