Initial commit
This commit is contained in:
parent
9ed3717a7f
commit
17ba52126a
7 changed files with 172 additions and 0 deletions
79
Dockerfile
Normal file
79
Dockerfile
Normal file
|
@ -0,0 +1,79 @@
|
|||
FROM debian:buster-slim
|
||||
|
||||
ARG RUST_VER=1.35.0
|
||||
|
||||
RUN apt update \
|
||||
&& apt install -y -q \
|
||||
autoconf \
|
||||
automake \
|
||||
gcc \
|
||||
make \
|
||||
autotools-dev \
|
||||
curl \
|
||||
mingw-w64 \
|
||||
mingw-w64-tools \
|
||||
gcc-mingw-w64 \
|
||||
binutils-mingw-w64 \
|
||||
clang \
|
||||
llvm \
|
||||
git
|
||||
|
||||
#Build arguments
|
||||
ARG osxcross_repo="tpoechtrager/osxcross"
|
||||
ARG osxcross_revision="a845375e028d29b447439b0c65dea4a9b4d2b2f6"
|
||||
ARG darwin_sdk_version="10.11"
|
||||
ARG darwin_osx_version_min="10.7"
|
||||
ARG darwin_version="15"
|
||||
ARG darwin_sdk_url="https://github.com/phracker/MacOSX-SDKs/releases/download/10.13/MacOSX10.11.sdk.tar.xz"
|
||||
|
||||
# ENV available in docker image
|
||||
ENV OSXCROSS_REPO="${osxcross_repo}" \
|
||||
OSXCROSS_REVISION="${osxcross_revision}" \
|
||||
DARWIN_SDK_VERSION="${darwin_sdk_version}" \
|
||||
DARWIN_VERSION="${darwin_version}" \
|
||||
DARWIN_OSX_VERSION_MIN="${darwin_osx_version_min}" \
|
||||
DARWIN_SDK_URL="${darwin_sdk_url}"
|
||||
|
||||
RUN mkdir -p "/tmp/osxcross" \
|
||||
&& cd "/tmp/osxcross" \
|
||||
&& curl -sLo osxcross.tar.gz "https://codeload.github.com/${OSXCROSS_REPO}/tar.gz/${OSXCROSS_REVISION}" \
|
||||
&& tar --strip=1 -xzf osxcross.tar.gz \
|
||||
&& rm -f osxcross.tar.gz \
|
||||
&& curl -sLo tarballs/MacOSX${DARWIN_SDK_VERSION}.sdk.tar.xz \
|
||||
"${DARWIN_SDK_URL}" \
|
||||
&& yes "" | SDK_VERSION="${DARWIN_SDK_VERSION}" OSX_VERSION_MIN="${DARWIN_OSX_VERSION_MIN}" ./build.sh \
|
||||
&& mv target /usr/osxcross \
|
||||
&& mv tools /usr/osxcross/ \
|
||||
&& ln -sf ../tools/osxcross-macports /usr/osxcross/bin/omp \
|
||||
&& ln -sf ../tools/osxcross-macports /usr/osxcross/bin/osxcross-macports \
|
||||
&& ln -sf ../tools/osxcross-macports /usr/osxcross/bin/osxcross-mp \
|
||||
&& rm -rf /tmp/osxcross \
|
||||
&& rm -rf "/usr/osxcross/SDK/MacOSX${DARWIN_SDK_VERSION}.sdk/usr/share/man"
|
||||
|
||||
RUN useradd -ms /bin/bash rust
|
||||
|
||||
USER rust
|
||||
WORKDIR /home/rust
|
||||
|
||||
RUN curl https://sh.rustup.rs -sSf -o rustup.sh && \
|
||||
sh ./rustup.sh -y && \
|
||||
$HOME/.cargo/bin/rustup default $RUST_VER && \
|
||||
$HOME/.cargo/bin/rustup target add x86_64-pc-windows-gnu && \
|
||||
$HOME/.cargo/bin/rustup target add x86_64-apple-darwin && \
|
||||
rm rustup.sh
|
||||
|
||||
ENV PATH $PATH:/home/rust/.cargo/bin:/usr/osxcross/bin
|
||||
|
||||
RUN cp /usr/x86_64-w64-mingw32/lib/*crt2.o \
|
||||
/home/rust/.rustup/toolchains/1.35.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/
|
||||
|
||||
ADD lin-cargo /usr/local/bin/
|
||||
ADD mac-cargo /usr/local/bin/
|
||||
ADD mac-c++ /usr/local/bin/
|
||||
ADD mac-cc /usr/local/bin/
|
||||
ADD win-cargo /usr/local/bin/
|
||||
ADD win-cc /usr/local/bin
|
||||
|
||||
WORKDIR /workdir
|
||||
|
||||
CMD ["lin-cargo", "build", "--release"]
|
14
lin-cargo
Executable file
14
lin-cargo
Executable file
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash
|
||||
|
||||
# based on https://gist.github.com/luser/a33e5070d1c55a7d2c46fe763a9d1543
|
||||
|
||||
set -e
|
||||
|
||||
export OPENSSL_DIR=/usr/local
|
||||
export OPENSSL_STATIC="1"
|
||||
|
||||
export PATH="/root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
|
||||
cargo "$@"
|
||||
|
||||
unset OPENSSL_STATIC
|
2
mac-c++
Executable file
2
mac-c++
Executable file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
exec /usr/osxcross/bin/o64-clang++ -mmacosx-version-min=10.11 -target x86_64-apple-darwin15 -mlinker-version=242 -B /usr/x86_64-apple-darwin15/bin -isysroot /usr/osxcross/SDK/MacOSX10.11.sdk $*
|
43
mac-cargo
Executable file
43
mac-cargo
Executable file
|
@ -0,0 +1,43 @@
|
|||
#!/bin/bash
|
||||
|
||||
# based on https://gist.github.com/luser/a33e5070d1c55a7d2c46fe763a9d1543
|
||||
|
||||
set -e
|
||||
|
||||
# ensures that the host and target compilers are explicitly set, including using
|
||||
# wrappers for clang for the target to pass parameters to clang that help a lot
|
||||
# of native code more reliably compile
|
||||
export HOST_CC="gcc"
|
||||
export HOST_CXX="g++"
|
||||
export CC="mac-cc"
|
||||
export CXX="mac-c++"
|
||||
export CPP="mac-cc -E"
|
||||
# these, along with the .cargo/config in mac-cargo, help resolve issues that can
|
||||
# arise with assembly and linking
|
||||
export AR="/usr/osxcross/bin/x86_64-apple-darwin15-ar"
|
||||
export RANLIB="/usr/osxcross/bin/x86_64-apple-darwin15-ranlib"
|
||||
export TOOLCHAIN_PREFIX="/usr/osxcross/bin/x86_64-apple-darwin15-"
|
||||
|
||||
mkdir -p .cargo
|
||||
if [ -f .cargo/config ]
|
||||
then
|
||||
mv .cargo/config .cargo/config.bak
|
||||
fi
|
||||
# Point cargo at the cross-toolchain.
|
||||
cat > .cargo/config <<EOF
|
||||
[target.x86_64-apple-darwin]
|
||||
linker = "/usr/local/bin/mac-cc"
|
||||
ar = "/usr/osxcross/bin/x86_64-apple-darwin15-ar"
|
||||
EOF
|
||||
|
||||
# Build it.
|
||||
cmd="${1}"
|
||||
shift 1
|
||||
cargo "${cmd}" --target=x86_64-apple-darwin "$@"
|
||||
if [ -f .cargo/config.bak ]
|
||||
then
|
||||
mv .cargo/config.bak .cargo/config
|
||||
else
|
||||
rm .cargo/config
|
||||
fi
|
||||
unset HOST_CC HOST_CXX CC CXX CPP AR RANLIB TOOLCHAIN_PREFIX
|
2
mac-cc
Executable file
2
mac-cc
Executable file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
exec /usr/osxcross/bin/o64-clang -mmacosx-version-min=10.11 -target x86_64-apple-darwin15 -mlinker-version=242 -B /usr/x86_64-apple-darwin15/bin -isysroot /usr/osxcross/SDK/MacOSX10.11.sdk $*
|
31
win-cargo
Executable file
31
win-cargo
Executable file
|
@ -0,0 +1,31 @@
|
|||
#!/bin/bash
|
||||
|
||||
# based on https://gist.github.com/luser/a33e5070d1c55a7d2c46fe763a9d1543
|
||||
|
||||
set -e
|
||||
|
||||
# activate cross compilation
|
||||
export PKG_CONFIG_ALLOW_CROSS="1"
|
||||
|
||||
mkdir -p .cargo
|
||||
if [ -f .cargo/config ]
|
||||
then
|
||||
mv .cargo/config .cargo/config.bak
|
||||
fi
|
||||
# Point cargo at the cross-toolchain.
|
||||
cat > .cargo/config <<EOF
|
||||
[target.x86_64-pc-windows-gnu]
|
||||
linker = "win-cc"
|
||||
ar = "x86_64-w64-mingw32-ar"
|
||||
EOF
|
||||
|
||||
# Build it.
|
||||
cmd="${1}"
|
||||
shift 1
|
||||
cargo "${cmd}" --target=x86_64-pc-windows-gnu "$@"
|
||||
if [ -f .cargo/config.bak ]
|
||||
then
|
||||
mv .cargo/config.bak .cargo/config
|
||||
else
|
||||
rm .cargo/config
|
||||
fi
|
1
win-cc
Executable file
1
win-cc
Executable file
|
@ -0,0 +1 @@
|
|||
exec /usr/bin/x86_64-w64-mingw32-gcc -static $*
|
Loading…
Reference in a new issue