Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add suport for darwin/arm64 #100

Merged
merged 7 commits into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,6 @@ pipeline {
}
}
excludes {
exclude {
axis {
name 'PLATFORM'
values 'arm'
}
axis {
name 'GO_FOLDER'
values 'go1.14'
}
}
exclude {
axis {
name 'PLATFORM'
Expand Down Expand Up @@ -153,7 +143,10 @@ def buildImages(){
withGoEnv(){
dir("${env.BASE_DIR}"){
def platform = (PLATFORM?.trim().equals('arm')) ? '-arm' : ''
sh "make -C ${GO_FOLDER} -f ${MAKEFILE} build${platform}"
retryWithSleep(retries: 3, seconds: 15, backoff: true) {
sh "make -C ${GO_FOLDER} -f ${MAKEFILE} build${platform}"
}
sh(label: 'list Docker images', script: 'docker images --format "table {{.Repository}}:{{.Tag}}\t{{.Size}}" --filter=reference="docker.elastic.co/beats-dev/golang-crossbuild"')
}
}
}
Expand All @@ -163,6 +156,8 @@ def publishImages(){
dockerLogin(secret: "${env.DOCKER_REGISTRY_SECRET}", registry: "${env.REGISTRY}")
dir("${env.BASE_DIR}"){
def platform = (PLATFORM?.trim().equals('arm')) ? '-arm' : ''
sh(label: "push docker image to ${env.REPOSITORY}", script: "make -C ${GO_FOLDER} -f ${MAKEFILE} push${platform}")
retryWithSleep(retries: 3, seconds: 15, backoff: true) {
sh(label: "push docker image to ${env.REPOSITORY}", script: "make -C ${GO_FOLDER} -f ${MAKEFILE} push${platform}")
}
}
}
8 changes: 0 additions & 8 deletions go1.15/main/rootfs/compilers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ windows:
CC: x86_64-w64-mingw32-gcc
CXX: x86_64-w64-mingw32-g++

darwin:
386:
CC: o32-clang
CXX: o32-clang++
amd64:
CC: o64-clang
CXX: o64-clang++

linux:
386:
CC: gcc
Expand Down
2 changes: 1 addition & 1 deletion go1.16/Makefile.debian10
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
IMAGES := base arm armhf armel mips mips32 ppc s390x darwin main
IMAGES := base main darwin arm armhf armel mips mips32 ppc s390x darwin-arm64
DEBIAN_VERSION := 10
TAG_EXTENSION := -debian10

Expand Down
66 changes: 66 additions & 0 deletions go1.16/darwin-arm64/Dockerfile.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
ARG REPOSITORY
ARG VERSION
ARG TAG_EXTENSION=''
FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION}

RUN \
apt-get -o Acquire::Check-Valid-Until=false update \
&& apt-get install -qq -y --no-install-recommends --allow-unauthenticated \
cmake \
patch \
libssl-dev \
libxml2-dev \
lzma-dev \
uuid-dev \
&& rm -rf /var/lib/apt/lists/*

{{if eq .DEBIAN_VERSION "10"}}
ARG OSXCROSS_SDK_URL=https://storage.googleapis.com/obs-ci-cache/beats/MacOSX11.3.sdk.tar.xz
ARG OSXCROSS_PATH=/usr/osxcross
ARG OSXCROSS_REV=035cc170338b7b252e3f13b0e3ccbf4411bffc41
ARG SDK_VERSION=11.3
ARG DARWIN_VERSION=20
ARG OSX_VERSION_MIN=11.3
{{ else }}
RUN echo "This Docker image will work only with Debian 10" && exit 1
{{ end }}

RUN \
mkdir -p /tmp/osxcross && cd /tmp/osxcross \
&& curl -sSL "https://codeload.github.com/tpoechtrager/osxcross/tar.gz/${OSXCROSS_REV}" \
| tar -C /tmp/osxcross --strip=1 -xzf - \
&& curl -sSLo "tarballs/MacOSX${SDK_VERSION}.sdk.tar.xz" "${OSXCROSS_SDK_URL}" \
&& UNATTENDED=yes ENABLE_CLANG_INSTALL=yes ./build_clang.sh >/dev/null \
&& UNATTENDED=yes ./build.sh >/dev/null \
&& mv target "${OSXCROSS_PATH}" \
&& rm -rf /tmp/osxcross "/usr/osxcross/SDK/MacOSX${SDK_VERSION}.sdk/usr/share/man"

ENV PATH $OSXCROSS_PATH/bin:$PATH
# Add osxcross libraries to the library PATH
ENV LD_LIBRARY_PATH /usr/osxcross/lib:$LD_LIBRARY_PATH

COPY rootfs /

# Basic test
RUN cd / \
&& o64-clang helloWorld.c -o helloWorld \
&& file helloWorld \
&& file helloWorld | grep -c 'Mach-O 64-bit x86_64'

RUN cd / \
&& oa64-clang helloWorld.c -o helloWorld \
&& file helloWorld \
&& file helloWorld | grep -c 'Mach-O 64-bit arm64' \
&& rm helloWorld helloWorld.c


# Build-time metadata as defined at http://label-schema.org.
ARG BUILD_DATE
ARG IMAGE
ARG VCS_REF
ARG VCS_URL
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name=$IMAGE \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url=$VCS_URL \
org.label-schema.schema-version="1.0"
1 change: 1 addition & 0 deletions go1.16/darwin-arm64/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../Makefile.common
9 changes: 9 additions & 0 deletions go1.16/darwin-arm64/rootfs/compilers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---

darwin:
amd64:
CC: o64-clang
CXX: o64-clang++
arm64:
CC: oa64-clang
CXX: oa64-clang++
5 changes: 5 additions & 0 deletions go1.16/darwin-arm64/rootfs/helloWorld.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
4 changes: 3 additions & 1 deletion go1.16/darwin/Dockerfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ RUN \
llvm \
cmake \
patch \
{{if ne .DEBIAN_VERSION "10"}}
python \
{{ end }}
libssl-dev \
libxml2-dev \
lzma-dev \
Expand All @@ -24,7 +26,7 @@ ARG OSXCROSS_PATH=/usr/osxcross
ARG OSXCROSS_REV=8a716a43a72dab1db9630d7824ee0af3730cb8f9
ARG SDK_VERSION=10.14
ARG DARWIN_VERSION=17
ARG OSX_VERSION_MIN=10.14
ARG OSX_VERSION_MIN=10.10
{{ else }}
ARG OSXCROSS_SDK_URL=https://storage.googleapis.com/obs-ci-cache/beats/MacOSX10.11.sdk.tar.xz
ARG OSXCROSS_PATH=/usr/osxcross
Expand Down