From 17ba52126a806daebd77eba6c10fbe1dd9c2deef Mon Sep 17 00:00:00 2001 From: Thomas Gideon Date: Tue, 11 Jun 2019 08:39:20 -0400 Subject: [PATCH] Initial commit --- Dockerfile | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ lin-cargo | 14 ++++++++++ mac-c++ | 2 ++ mac-cargo | 43 +++++++++++++++++++++++++++++ mac-cc | 2 ++ win-cargo | 31 +++++++++++++++++++++ win-cc | 1 + 7 files changed, 172 insertions(+) create mode 100644 Dockerfile create mode 100755 lin-cargo create mode 100755 mac-c++ create mode 100755 mac-cargo create mode 100755 mac-cc create mode 100755 win-cargo create mode 100755 win-cc diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d5f92f4 --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/lin-cargo b/lin-cargo new file mode 100755 index 0000000..300adee --- /dev/null +++ b/lin-cargo @@ -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 diff --git a/mac-c++ b/mac-c++ new file mode 100755 index 0000000..0d3817d --- /dev/null +++ b/mac-c++ @@ -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 $* diff --git a/mac-cargo b/mac-cargo new file mode 100755 index 0000000..faf5ea3 --- /dev/null +++ b/mac-cargo @@ -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 < .cargo/config <