[Feature] flake.nix/dockerfile for simple cross compilation
I want to be able to enter an environment and be able to build for all targets with no extra setup.
Currently cross compiling isn't smooth, and setting up an environment with the correct development dependencies is not always straight forward.
Nix Flakes are great for this, but a Dockerfile (where I have started) works too, albeit not as nice to work with as Flakes.
It's taken me a few days to figure out the linux/linux and linux/windows build environments. Not sure how far I'll get with osx pipeline.
I also want to thank you so much for putting all this together. I've been dreaming of making a VST for about 10 years and now I feel I'm able to. Besides setting up the environment, you've made it a straight forward process <3.
# Can build linux and windows, gain_gui_iced
FROM rust
RUN apt-get update \
&& \
apt-get install -y \
libasound2-dev \
libgl-dev \
libjack-dev \
libxcb1-dev \
libxcb-icccm4-dev \
libxcursor-dev \
libxkbcommon-dev \
libxcb-shape0-dev \
libxcb-xfixes0-dev \
libx11-xcb-dev \
libxcb-dri2-0-dev \
curl \
python3 \
cmake \
clang \
gcc \
g++ \
zlib1g-dev \
libmpc-dev \
libmpfr-dev \
libgmp-dev \
gcc-mingw-w64 \
&& \
rustup target add \
x86_64-pc-windows-gnu \
x86_64-apple-darwin \
&& \
cargo install cross
RUN git clone https://github.com/tpoechtrager/osxcross /usr/local/osxcross &&\
cd /usr/local/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
ENV PATH "$(pwd)/osxcross/target/bin:$PATH"
WORKDIR /home/local/project
ENTRYPOINT ["/bin/bash"]
For Windows cross compilation on Linux you don't really need anything special. Compiling with --target x86_64-pc-windows-gnu works great as long as you don't enable the assert_process_allocs feature as for whatever reason the assert-no-alloc custom allocator seems to hang indefinitely on that (cross compiled) target.
With macOS it's a more complicated because you need to macOS frameworks. And while things like osxcross exist, I'm pretty sure it's against Apple's EULA to extract and use the frameworks that way.
I guess setting up the correct environment applies to all environments, not just for cross compilation. Would you be open to this idea?
I couldn't compile anything with an editor because of missing libs on my system, which having an environment like docker was a lifesaver. A preset file would help beginners like myself set things up without hassle.
God to know about the EULA, what a shame.
FWIW, I have a shell.nix: https://github.com/magnetophon/voice_master/blob/master/shell.nix