-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathDockerfile.cross
54 lines (42 loc) · 1.91 KB
/
Dockerfile.cross
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
FROM --platform=linux/amd64 rust:1.82.0-bookworm
# Install build dependencies
RUN apt-get update \
&& apt install -y clang gcc g++ zlib1g-dev libmpc-dev libmpfr-dev libgmp-dev build-essential cmake \
# Support for Windows cross-compile
mingw-w64
## ADD MACOS SUPPORT
WORKDIR /opt
# Add macOS and Windows Rust targets
RUN rustup target add x86_64-apple-darwin aarch64-apple-darwin x86_64-pc-windows-gnu
# Build osxcross
# See https://github.com/tpoechtrager/osxcross/blob/master/build.sh#L31-L49 for SDK overview.
#
# SDK availability is tricky. There is 10.10 and 10.11. at
# - https://s3.dockerproject.org/darwin/v2/MacOSX10.10.sdk.tar.xz
# - https://s3.dockerproject.org/darwin/v2/MacOSX10.11.sdk.tar.xz
# and we have https://github.com/phracker/MacOSX-SDKs/releases.
# At some point we might want to use our own package.
RUN git clone https://github.com/tpoechtrager/osxcross \
&& cd osxcross \
# Don't change file name when downloading because osxcross auto-detects the version from the name
&& wget -nc https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz \
&& mv MacOSX11.3.sdk.tar.xz tarballs/ \
&& UNATTENDED=yes OSX_VERSION_MIN=10.15 ./build.sh \
# Cleanups before Docker layer is finalized
&& rm -r tarballs/
RUN chmod +rx /opt/osxcross
RUN chmod +rx /opt/osxcross/target
RUN chmod -R +rx /opt/osxcross/target/bin
# RUN ls -l /opt/osxcross/target/bin
RUN /opt/osxcross/target/bin/x86_64-apple-darwin20.4-clang --version
RUN /opt/osxcross/target/bin/aarch64-apple-darwin20.4-clang --version
# allow non-root user to download more deps later
RUN chmod -R 777 /usr/local/cargo
## COPY BUILD SCRIPTS
WORKDIR /code
COPY guest/*.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/*.sh
RUN mkdir /.cargo
RUN chmod +rx /.cargo
COPY guest/cargo-config.toml /.cargo/config.toml
CMD ["bash", "-c", "echo 'Argument missing. Pass one build script (e.g. build_macos.sh) to docker run' && exit 1"]