Skip to content

Commit

Permalink
update taskfile
Browse files Browse the repository at this point in the history
  • Loading branch information
alessio-perugini committed Dec 13, 2024
1 parent ffea896 commit 5531756
Showing 1 changed file with 123 additions and 11 deletions.
134 changes: 123 additions & 11 deletions DistTasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ version: "3"

vars:
CONTAINER: "docker.elastic.co/beats-dev/golang-crossbuild"
GO_VERSION: "1.16.4"
GO_VERSION: "1.17.8"

tasks:
Windows_32bit:
desc: Builds Windows 32 bit binaries
dir: "{{.TOOL_DIR}}/{{.DIST_DIR}}"
dir: "{{.DIST_DIR}}"
cmds:
- |
docker run -v {{ .TOOL_DIR }}:/home/build -w /home/build \
docker run -v `pwd`/..:/home/build -w /home/build \
-e CGO_ENABLED=1 \
{{.CONTAINER}}:{{.CONTAINER_TAG}} \
--build-cmd "{{.BUILD_COMMAND}}" \
Expand All @@ -45,10 +45,10 @@ tasks:

Windows_64bit:
desc: Builds Windows 64 bit binaries
dir: "{{.TOOL_DIR}}/{{.DIST_DIR}}"
dir: "{{.DIST_DIR}}"
cmds:
- |
docker run -v {{ .TOOL_DIR }}:/home/build -w /home/build \
docker run -v `pwd`/..:/home/build -w /home/build \
-e CGO_ENABLED=1 \
{{.CONTAINER}}:{{.CONTAINER_TAG}} \
--build-cmd "{{.BUILD_COMMAND}}" \
Expand All @@ -66,10 +66,10 @@ tasks:

Linux_32bit:
desc: Builds Linux 32 bit binaries
dir: "{{.TOOL_DIR}}/{{.DIST_DIR}}"
dir: "{{.DIST_DIR}}"
cmds:
- |
docker run -v {{ .TOOL_DIR }}:/home/build -w /home/build \
docker run -v `pwd`/..:/home/build -w /home/build \
-e CGO_ENABLED=1 \
{{.CONTAINER}}:{{.CONTAINER_TAG}} \
--build-cmd "{{.BUILD_COMMAND}}" \
Expand All @@ -87,10 +87,10 @@ tasks:

Linux_64bit:
desc: Builds Linux 64 bit binaries
dir: "{{.TOOL_DIR}}/{{.DIST_DIR}}"
dir: "{{.DIST_DIR}}"
cmds:
- |
docker run -v {{ .TOOL_DIR }}:/home/build -w /home/build \
docker run -v `pwd`/..:/home/build -w /home/build \
-e CGO_ENABLED=1 \
{{.CONTAINER}}:{{.CONTAINER_TAG}} \
--build-cmd "{{.BUILD_COMMAND}}" \
Expand All @@ -106,12 +106,103 @@ tasks:
PACKAGE_PLATFORM: "Linux_64bit"
PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"

Linux_ARMv7:
desc: Builds Linux ARMv7 binaries
dir: "{{.DIST_DIR}}"
cmds:
- |
docker run -v `pwd`/..:/home/build -w /home/build \
-e CGO_ENABLED=1 \
{{.CONTAINER}}:{{.CONTAINER_TAG}} \
--build-cmd "{{.BUILD_COMMAND}}" \
-p "{{.BUILD_PLATFORM}}"
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
vars:
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_7"
BUILD_COMMAND: "go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}} {{.LDFLAGS}}"
BUILD_PLATFORM: "linux/armv7"
CONTAINER_TAG: "{{.GO_VERSION}}-armhf"
PACKAGE_PLATFORM: "Linux_ARMv7"
PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"

Linux_ARMv6:
desc: Builds Linux ARMv6 binaries
dir: "{{.DIST_DIR}}"
cmds:
- |
docker run -v `pwd`/..:/home/build -w /home/build \
-e CGO_ENABLED=1 \
{{.CONTAINER}}:{{.CONTAINER_TAG}} \
--build-cmd "{{.BUILD_COMMAND}}" \
-p "{{.BUILD_PLATFORM}}"
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
vars:
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_6"
BUILD_COMMAND: "go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}} {{.LDFLAGS}}"
BUILD_PLATFORM: "linux/armv6"
# We are experiencing the following error with ARMv6 build:
#
# # github.com/arduino/arduino-cli
# net(.text): unexpected relocation type 296 (R_ARM_V4BX)
# panic: runtime error: invalid memory address or nil pointer dereference
# [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x51ae53]
#
# goroutine 1 [running]:
# cmd/link/internal/loader.(*Loader).SymName(0xc000095c00, 0x0, 0xc0000958d8, 0x5a0ac)
# /usr/local/go/src/cmd/link/internal/loader/loader.go:684 +0x53
# cmd/link/internal/ld.dynrelocsym2(0xc000095880, 0x5a0ac)
# /usr/local/go/src/cmd/link/internal/ld/data.go:777 +0x295
# cmd/link/internal/ld.(*dodataState).dynreloc2(0xc007df9800, 0xc000095880)
# /usr/local/go/src/cmd/link/internal/ld/data.go:794 +0x89
# cmd/link/internal/ld.(*Link).dodata2(0xc000095880, 0xc007d00000, 0x60518, 0x60518)
# /usr/local/go/src/cmd/link/internal/ld/data.go:1434 +0x4d4
# cmd/link/internal/ld.Main(0x8729a0, 0x4, 0x8, 0x1, 0xd, 0xe, 0x0, 0x0, 0x6d7737, 0x12, ...)
# /usr/local/go/src/cmd/link/internal/ld/main.go:302 +0x123a
# main.main()
# /usr/local/go/src/cmd/link/main.go:68 +0x1dc
# Error: failed building for linux/armv6: exit status 2
#
# This seems to be a problem in the go builder 1.16.x that removed support for the R_ARM_V4BX instruction:
# https://github.com/golang/go/pull/44998
# https://groups.google.com/g/golang-codereviews/c/yzN80xxwu2E
#
# Until there is a fix released we must use a recent gcc for Linux_ARMv6 build, so for this
# build we select the debian10 based container.
CONTAINER_TAG: "{{.GO_VERSION}}-armel-debian10"
PACKAGE_PLATFORM: "Linux_ARMv6"
PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"

Linux_ARM64:
desc: Builds Linux ARM64 binaries
dir: "{{.DIST_DIR}}"
cmds:
- |
docker run -v `pwd`/..:/home/build -w /home/build \
-e CGO_ENABLED=1 \
{{.CONTAINER}}:{{.CONTAINER_TAG}} \
--build-cmd "{{.BUILD_COMMAND}}" \
-p "{{.BUILD_PLATFORM}}"
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
vars:
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_64"
BUILD_COMMAND: "go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}} {{.LDFLAGS}}"
BUILD_PLATFORM: "linux/arm64"
CONTAINER_TAG: "{{.GO_VERSION}}-arm"
PACKAGE_PLATFORM: "Linux_ARM64"
PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"

macOS_64bit:
desc: Builds Mac OS X 64 bit binaries
dir: "{{.TOOL_DIR}}/{{.DIST_DIR}}"
dir: "{{.DIST_DIR}}"
cmds:
- |
docker run -v {{ .TOOL_DIR }}:/home/build -w /home/build \
docker run -v `pwd`/..:/home/build -w /home/build \
-e CGO_ENABLED=1 \
{{.CONTAINER}}:{{.CONTAINER_TAG}} \
--build-cmd "{{.BUILD_COMMAND}}" \
Expand Down Expand Up @@ -139,3 +230,24 @@ tasks:
CONTAINER_TAG: "{{.GO_VERSION}}-darwin-debian10"
PACKAGE_PLATFORM: "macOS_64bit"
PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"

macOS_ARM64:
desc: Builds Mac OS X ARM64 binaries
dir: "{{.DIST_DIR}}"
cmds:
- |
docker run -v `pwd`/..:/home/build -w /home/build \
-e CGO_ENABLED=1 \
{{.CONTAINER}}:{{.CONTAINER_TAG}} \
--build-cmd "{{.BUILD_COMMAND}}" \
-p "{{.BUILD_PLATFORM}}"
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
vars:
PLATFORM_DIR: "{{.PROJECT_NAME}}_osx_darwin_arm64"
BUILD_COMMAND: "go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}} {{.LDFLAGS}}"
BUILD_PLATFORM: "darwin/arm64"
CONTAINER_TAG: "{{.GO_VERSION}}-darwin-arm64-debian10"
PACKAGE_PLATFORM: "macOS_ARM64"
PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"

0 comments on commit 5531756

Please sign in to comment.