Skip to content
Closed
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
27 changes: 17 additions & 10 deletions Dockerfile.cross
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,37 @@ RUN apt-get update
RUN apt install -y clang gcc g++ zlib1g-dev libmpc-dev libmpfr-dev libgmp-dev
RUN apt install -y build-essential cmake

## add support for windows cross-compile
RUN apt install -y mingw-w64

# add some llvm configs for later - how to cross-compile this in wasmer-llvm-backend???
RUN echo deb http://deb.debian.org/debian buster-backports main >> /etc/apt/sources.list
RUN apt-get update
RUN apt install -y libllvm8 llvm-8 llvm-8-dev llvm-8-runtime
ENV LLVM_SYS_80_PREFIX=/usr/lib/llvm-8

## ADD MACOS SUPPORT

WORKDIR /opt

# Pin to proper nightly and add macOS Rust target
RUN rustup default nightly-2020-06-08

# Add macOS and Windows Rust target
RUN rustup target add x86_64-apple-darwin
RUN rustup target add x86_64-pc-windows-msvc
RUN rustup target add x86_64-pc-windows-gnu

# Build osxcross
RUN git clone https://github.com/tpoechtrager/osxcross
RUN cd osxcross && \
wget -nc https://s3.dockerproject.org/darwin/v2/MacOSX10.10.sdk.tar.xz && \
mv MacOSX10.10.sdk.tar.xz tarballs/ && \
UNATTENDED=yes OSX_VERSION_MIN=10.7 ./build.sh
RUN chmod +rx /opt/osxcross
RUN chmod +rx /opt/osxcross/target
RUN chmod -R +rx /opt/osxcross/target/bin
mv MacOSX10.10.sdk.tar.xz tarballs/

## TODO: add support for windows cross-compile
# TODO: enable when github is not so flaky
# RUN cd osxcross && UNATTENDED=yes OSX_VERSION_MIN=10.7 ./build.sh

# RUN chmod +rx /opt/osxcross
# RUN chmod +rx /opt/osxcross/target
# RUN chmod -R +rx /opt/osxcross/target/bin

# PRE-FETCH MANY DEPS
WORKDIR /scratch
Expand All @@ -43,7 +49,6 @@ RUN cargo fetch
RUN chmod -R 777 /usr/local/cargo

## COPY BUILD SCRIPTS

WORKDIR /code
RUN rm -rf /scratch

Expand All @@ -54,4 +59,6 @@ RUN mkdir /.cargo
RUN chmod +rx /.cargo
COPY build/cargo-config /.cargo/config

CMD ["/opt/build_osx.sh"]
# TODO: re-enable when github is not so flaky
# CMD ["/opt/build_cross.sh"]
CMD ["/opt/build_windows.sh"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: all build build-rust build-go test docker-image docker-image-centos7 docker-image-cross

DOCKER_TAG := 0.8.2
DOCKER_TAG := 0.9.0-dev
USER_ID := $(shell id -u)
USER_GROUP = $(shell id -g)

Expand Down
2 changes: 1 addition & 1 deletion build/build.sh → build/build_cross.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

"$DIR/build_linux.sh"
"$DIR/build_windows.sh"
"$DIR/build_osx.sh"
6 changes: 6 additions & 0 deletions build/build_windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

# ref: https://www.reddit.com/r/rust/comments/5k8uab/crosscompiling_from_ubuntu_to_windows_with_rustup/

cargo build --release --target=x86_64-pc-windows-gnu --verbose
cp target/x86_64-pc-windows-gnu/release/deps/libgo_cosmwasm.dll api
6 changes: 5 additions & 1 deletion build/cargo-config
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[target.x86_64-apple-darwin]
linker = "x86_64-apple-darwin14-clang"
ar = "x86_64-apple-darwin14-ar"
ar = "x86_64-apple-darwin14-ar"

[target.x86_64-pc-windows-gnu]
linker = "x86_64-w64-mingw32-gcc"
ar = "x86_64-w64-mingw32-gcc-ar"