Skip to content

Commit

Permalink
Working version for i686
Browse files Browse the repository at this point in the history
Unfortunately this triggers rust-lang/rust#12859
  • Loading branch information
zzeroo committed May 12, 2020
1 parent 10e5aee commit 3b0041e
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 5 deletions.
65 changes: 61 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM fedora:latest AS builder
FROM fedora:latest
WORKDIR /app
# https://github.com/gsauthof/pe-util
RUN dnf install -y \
Expand All @@ -7,8 +7,8 @@ RUN dnf install -y \
gcc \
make \
cmake \
gcc-c++ boost-devel \
&& yum clean all
gcc-c++ \
boost-devel

RUN git clone https://github.com/gsauthof/pe-util.git \
&& cd pe-util \
Expand All @@ -18,4 +18,61 @@ RUN git clone https://github.com/gsauthof/pe-util.git \
&& cmake .. -DCMAKE_BUILD_TYPE=Release \
&& make VERBOSE=1

CMD ["ls", "-al"]
RUN cp /app/pe-util/build/peldd /usr/bin/

ADD package.sh /usr/bin/package.sh
RUN chmod 755 /usr/bin/package.sh


RUN dnf install -y \
mingw32-gcc \
mingw32-freetype \
mingw32-cairo \
mingw32-harfbuzz \
mingw32-pango \
mingw32-poppler \
mingw32-gtk3 \
mingw32-winpthreads-static \
mingw32-glib2-static \
gcc \
zip \
&& dnf clean all -y

RUN useradd -ms /bin/bash rust

# User tasks
USER rust

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=stable --profile=minimal

RUN . ~/.cargo/env && \
rustup target add i686-pc-windows-gnu && \
rustup target add x86_64-pc-windows-gnu

ADD cargo.config /home/rust/.cargo/config

ENV PKG_CONFIG_ALLOW_CROSS=1
ENV PKG_CONFIG_PATH=/usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig/
ENV GTK_INSTALL_PATH=/usr/i686-w64-mingw32/sys-root/mingw/
VOLUME /home/rust/src
WORKDIR /home/rust/src

# This calls the final job
## Create a package.sh in your project folder overrides the one in /usr/bin/ (don't forget `chmod +x packages.sh`)
CMD ["package.sh"]

# Usage:
## Build the container
# ```
## docker build . -t rust-crosspile
# ```

## Now build a image **in your source directory!**. Your sources are mounted as a docker VOLUME
# ```
## docker create -v `pwd`:/home/rust/src --name PROJECT-build rust-crosspile:latest
# ```

# From now on everytime you want conpile and pack the latest version call `docker start`
## docker start -ai PROJECT-build

## docker rm PROJECT-build
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Docker Container to cross compile rust binaries for Windows
## Usage
First build the Image, from within this project directory.
```bash
:wqdocker build . -t PROJECTNAME-build-image
docker build . -t PROJECTNAME-build-image
# eg: docker build . -t rust-crosspile
```


Expand Down
3 changes: 3 additions & 0 deletions cargo.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[target.i686-pc-windows-gnu]
linker = "i686-w64-mingw32-gcc"
ar = "i686-w64-mingw32-gcc-ar"
2 changes: 2 additions & 0 deletions package.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash
set -e

#statements
source ~/.cargo/env
cargo build --target=i686-pc-windows-gnu --release

Expand Down

0 comments on commit 3b0041e

Please sign in to comment.