Skip to content

Commit

Permalink
Fixed cross-compile bug for linux/arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
Karmenzind committed Dec 20, 2023
1 parent a3e481a commit 9d62425
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
# cache-dependency-path: go.sum

- name: Install system dependencies
run: sudo apt-get install -y gcc-mingw-w64-x86-64
run: sudo apt-get install -y gcc-mingw-w64-x86-64 gcc-aarch64-linux-gnu

- name: Install dependencies
run: go mod tidy
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@

<!-- vim-markdown-toc -->

<!-- > 理论上可兼容[所有平台/架构](https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63),但我只有Linux/Win可测试,欢迎使用其他平台的朋友试用反馈 -->

## 特性

- 单文件运行,多平台兼容,无需安装任何依赖。Windows运行截图:

![](https://raw.githubusercontent.com/Karmenzind/i/master/kd/win_terminal.png)

> 理论上可兼容[所有平台/架构](https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63),但我只有Linux/Win可测试,欢迎使用其他平台的朋友试用反馈
- 支持查单词、词组( :eyes: 长句翻译功能也快写好了)
- 极速响应,超低延迟
- 本地词库(10W热词),可离线使用
Expand Down
27 changes: 20 additions & 7 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,29 @@ do_build() {
local arch=$2
local targetfile=$3

local cgo=0 cc=
local cgo=1 cc=

if [[ $os == "windows" ]]; then
local cgo=1 cc=x86_64-w64-mingw32-gcc
# cc=i686-w64-mingw32-gcc
# local buildopts=-buildmode=c-shared
fi
case $os in
windows )
local cc=x86_64-w64-mingw32-gcc
local buildopts=-buildmode=c-shared
;;
linux )
if [[ $arch == "arm64" ]]; then
local cc=aarch64-linux-gnu-gcc
fi
;;
darwin)
# TODO (k): <2023-12-21>
;;
esac

GOOS=$os GOARCH=$arch CGO_ENABLED=$cgo CC=$cc go build ${buildopts} -o ${targetfile} -ldflags="-s -w" -tags urfave_cli_no_docs cmd/kd.go
echo " Finished -> ${targetfile}"
if (($?==0)); then
echo " Finished -> ${targetfile}"
else
echo " Failed to build for $os $arch"
fi
}

if [[ $1 == "-a" ]]; then
Expand Down

0 comments on commit 9d62425

Please sign in to comment.