diff --git a/Dockerfile.cross b/Dockerfile.cross index 262ed7471..4d69b713a 100644 --- a/Dockerfile.cross +++ b/Dockerfile.cross @@ -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 @@ -43,7 +49,6 @@ RUN cargo fetch RUN chmod -R 777 /usr/local/cargo ## COPY BUILD SCRIPTS - WORKDIR /code RUN rm -rf /scratch @@ -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"] diff --git a/Makefile b/Makefile index 3a9a2c93e..b7168b704 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/build/build.sh b/build/build_cross.sh similarity index 82% rename from build/build.sh rename to build/build_cross.sh index de07b48d3..f56c4d102 100755 --- a/build/build.sh +++ b/build/build_cross.sh @@ -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" \ No newline at end of file diff --git a/build/build_windows.sh b/build/build_windows.sh new file mode 100755 index 000000000..9f5421a74 --- /dev/null +++ b/build/build_windows.sh @@ -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 diff --git a/build/cargo-config b/build/cargo-config index 4727075fd..58e431ea3 100644 --- a/build/cargo-config +++ b/build/cargo-config @@ -1,3 +1,7 @@ [target.x86_64-apple-darwin] linker = "x86_64-apple-darwin14-clang" -ar = "x86_64-apple-darwin14-ar" \ No newline at end of file +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" \ No newline at end of file