Skip to content

Commit 93d961a

Browse files
committed
Debian variant and osxsdk test
1 parent 57fd9fe commit 93d961a

File tree

5 files changed

+109
-15
lines changed

5 files changed

+109
-15
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
matrix:
3131
variant:
3232
- ubuntu
33+
- debian
3334
- alpine
3435
steps:
3536
-
@@ -64,8 +65,6 @@ jobs:
6465
-
6566
name: Set up Docker Buildx
6667
uses: docker/setup-buildx-action@v2
67-
with:
68-
buildkitd-flags: --debug
6968
-
7069
name: Login to DockerHub
7170
if: github.event_name != 'pull_request'

.github/workflows/test.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,15 @@ jobs:
2020
strategy:
2121
fail-fast: false
2222
matrix:
23+
type:
24+
- osxcross
2325
variant:
2426
- ubuntu
27+
- debian
2528
- alpine
29+
include:
30+
- type: osxsdk
31+
variant: alpine
2632
steps:
2733
-
2834
name: Checkout
@@ -34,7 +40,7 @@ jobs:
3440
name: Test
3541
uses: docker/bake-action@v2
3642
with:
37-
targets: test
43+
targets: test-${{ matrix.type }}
3844
set: |
3945
*.cache-from=type=gha,scope=${{ matrix.variant }}
4046
env:

Dockerfile

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
# syntax=docker/dockerfile:1-labs
1+
# syntax=docker/dockerfile:1
22

33
ARG BASE_VARIANT="ubuntu"
44
ARG UBUNTU_VERSION="18.04"
5+
ARG DEBIAN_VERSION="bullseye"
56
ARG ALPINE_VERSION="3.16"
67

78
ARG CMAKE_VERSION="3.20.1"
@@ -58,6 +59,40 @@ ARG CMAKE_VERSION
5859
RUN mkdir -p /opt/cmake && cd /opt/cmake && wget -q https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-$(uname -m).tar.gz -O - | tar xvz --strip 1
5960
ENV PATH=/opt/cmake/bin:$PATH
6061

62+
FROM debian:${DEBIAN_VERSION} AS base-debian
63+
RUN export DEBIAN_FRONTEND="noninteractive" \
64+
&& apt-get update \
65+
&& apt-get install --no-install-recommends -y \
66+
bash \
67+
binutils-multiarch-dev \
68+
build-essential \
69+
ca-certificates \
70+
clang \
71+
git \
72+
libbz2-dev \
73+
libmpc-dev \
74+
libmpfr-dev \
75+
libgmp-dev \
76+
liblzma-dev \
77+
libpsi3-dev \
78+
libssl-dev \
79+
libxml2-dev \
80+
libz-dev \
81+
lzma-dev \
82+
make \
83+
patch \
84+
python \
85+
uuid-dev \
86+
wget \
87+
xz-utils \
88+
zlib1g-dev \
89+
&& apt-get -y autoremove \
90+
&& apt-get clean \
91+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
92+
ARG CMAKE_VERSION
93+
RUN mkdir -p /opt/cmake && cd /opt/cmake && wget -q https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-$(uname -m).tar.gz -O - | tar xvz --strip 1
94+
ENV PATH=/opt/cmake/bin:$PATH
95+
6196
FROM alpine:${ALPINE_VERSION} AS base-alpine
6297
RUN apk add --update --no-cache \
6398
bash \
@@ -112,25 +147,57 @@ FROM build-dummy AS build-linux-s390x
112147
FROM build-linux-${TARGETARCH}${TARGETVARIANT} AS build-linux
113148
FROM build-${TARGETOS} AS build
114149

115-
FROM ubuntu:${UBUNTU_VERSION} AS test-ubuntu
116-
RUN apt-get update && apt-get install -y clang file lld libc6-dev
150+
FROM --platform=$BUILDPLATFORM ubuntu:${UBUNTU_VERSION} AS test-ubuntu
151+
RUN export DEBIAN_FRONTEND="noninteractive" && apt-get update && apt-get install -y clang file lld libc6-dev
117152

118-
FROM alpine:${ALPINE_VERSION} AS test-alpine
153+
FROM --platform=$BUILDPLATFORM debian:${DEBIAN_VERSION} AS test-debian
154+
RUN export DEBIAN_FRONTEND="noninteractive" && apt-get update && apt-get install -y clang file lld libc6-dev
155+
156+
FROM --platform=$BUILDPLATFORM alpine:${ALPINE_VERSION} AS test-alpine
119157
RUN apk add --no-cache clang file lld musl-dev
120158

121-
FROM test-${BASE_VARIANT} AS test
159+
FROM test-${BASE_VARIANT} AS test-osxcross
122160
COPY --from=build /out/osxcross /osxcross
123161
ENV PATH="/osxcross/bin:$PATH"
124162
ENV LD_LIBRARY_PATH="/osxcross/lib:$LD_LIBRARY_PATH"
125163
WORKDIR /src
126164
RUN --mount=type=bind,source=./test <<EOT
165+
set -e
166+
127167
o64-clang -v test.c -O3 -o /tmp/test
128168
file /tmp/test
169+
129170
o64-clang++ -v test.cpp -O3 -o /tmp/testcxx
130171
file /tmp/testcxx
172+
131173
o64-clang++ -v test_libcxx.cpp -O3 -o /tmp/testlibcxx
132174
file /tmp/testlibcxx
133175
EOT
134176

177+
FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.1.2 AS xx
178+
FROM test-alpine AS test-osxsdk
179+
WORKDIR /src
180+
COPY --from=xx / /
181+
RUN apk add --no-cache clang file lld musl-dev
182+
ARG TARGETPLATFORM
183+
RUN xx-apk add gcc g++ musl-dev
184+
RUN --mount=type=bind,source=./test \
185+
--mount=from=sdk,src=/osxsdk,target=/xx-sdk <<EOT
186+
set -e
187+
echo "sysroot: $(xx-info sysroot)"
188+
189+
xx-clang -v test.c -O3 -o /tmp/test
190+
xx-verify /tmp/test
191+
file /tmp/test
192+
193+
xx-clang++ -v test.cpp -O3 -o /tmp/testcxx
194+
xx-verify /tmp/testcxx
195+
file /tmp/testcxx
196+
197+
xx-clang++ -v test_libcxx.cpp -O3 -o /tmp/testlibcxx
198+
xx-verify /tmp/testlibcxx
199+
file /tmp/testlibcxx
200+
EOT
201+
135202
FROM scratch
136203
COPY --from=build /out /

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,20 @@ Image: crazymax/osxcross:latest
7070

7171
### Supported tags
7272

73-
`alpine` and `ubuntu` variants are available for this image with `ubuntu` the
74-
default one.
73+
`alpine`, `debian` and `ubuntu` variants are available for this image with
74+
`ubuntu` being the default one.
7575

7676
* `edge`, `edge-ubuntu`
77+
* `edge-debian`
7778
* `edge-alpine`
78-
* `latest`, `latest-ubuntu`, `xx.x`, `xx.x-ubuntu`
79-
* `latest-alpine`, `xx.x-alpine`
79+
* `latest`, `latest-ubuntu`, `xx.x`, `xx.x-rx`, `xx.x-ubuntu`, `xx.x-rx-ubuntu`
80+
* `latest-debian`, `xx.x-debian`, `xx.x-rx-debian`
81+
* `latest-alpine`, `xx.x-alpine`, `xx.x-rx-alpine`
8082

83+
> **Note:**
84+
>
8185
> `xx.x` has to be replaced with one of the MaxOSX releases available (e.g. `11.3`).
86+
> `rx` has to be replaced with a release number (e.g. `r6`).
8287
8388
## Usage
8489

@@ -121,11 +126,13 @@ like [`tonistiigi/xx`](https://github.com/tonistiigi/xx):
121126

122127
ARG OSXCROSS_VERSION=latest
123128
FROM crazymax/osxcross:${OSXCROSS_VERSION}-alpine AS osxcross
129+
FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.1.2 AS xx
124130

125131
FROM --platform=$BUILDPLATFORM alpine
126-
COPY --from=tonistiigi/xx / /
132+
COPY --from=xx / /
127133
RUN apk add --no-cache clang lld musl-dev
128134
ARG TARGETPLATFORM
135+
RUN xx-apk add gcc g++ musl-dev
129136
RUN --mount=type=bind,target=. \
130137
--mount=from=osxcross,src=/osxsdk,target=/xx-sdk \
131138
xx-clang ...

docker-bake.hcl

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,25 @@ target "image-all" {
5353
]
5454
}
5555

56-
target "test" {
57-
target = "test"
56+
group "test" {
57+
targets = ["test-osxcross", "test-osxsdk"]
58+
}
59+
60+
target "test-osxcross" {
61+
target = "test-osxcross"
5862
args = {
5963
BASE_VARIANT = BASE_VARIANT
6064
}
6165
output = ["type=cacheonly"]
6266
}
67+
68+
target "test-osxsdk" {
69+
target = "test-osxsdk"
70+
output = ["type=cacheonly"]
71+
platforms = [
72+
"darwin/amd64",
73+
"darwin/arm64",
74+
"linux/amd64",
75+
"linux/arm64",
76+
]
77+
}

0 commit comments

Comments
 (0)