Skip to content

Commit 3b0041e

Browse files
committed
Working version for i686
Unfortunately this triggers rust-lang/rust#12859
1 parent 10e5aee commit 3b0041e

File tree

4 files changed

+68
-5
lines changed

4 files changed

+68
-5
lines changed

Dockerfile

+61-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM fedora:latest AS builder
1+
FROM fedora:latest
22
WORKDIR /app
33
# https://github.com/gsauthof/pe-util
44
RUN dnf install -y \
@@ -7,8 +7,8 @@ RUN dnf install -y \
77
gcc \
88
make \
99
cmake \
10-
gcc-c++ boost-devel \
11-
&& yum clean all
10+
gcc-c++ \
11+
boost-devel
1212

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

21-
CMD ["ls", "-al"]
21+
RUN cp /app/pe-util/build/peldd /usr/bin/
22+
23+
ADD package.sh /usr/bin/package.sh
24+
RUN chmod 755 /usr/bin/package.sh
25+
26+
27+
RUN dnf install -y \
28+
mingw32-gcc \
29+
mingw32-freetype \
30+
mingw32-cairo \
31+
mingw32-harfbuzz \
32+
mingw32-pango \
33+
mingw32-poppler \
34+
mingw32-gtk3 \
35+
mingw32-winpthreads-static \
36+
mingw32-glib2-static \
37+
gcc \
38+
zip \
39+
&& dnf clean all -y
40+
41+
RUN useradd -ms /bin/bash rust
42+
43+
# User tasks
44+
USER rust
45+
46+
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=stable --profile=minimal
47+
48+
RUN . ~/.cargo/env && \
49+
rustup target add i686-pc-windows-gnu && \
50+
rustup target add x86_64-pc-windows-gnu
51+
52+
ADD cargo.config /home/rust/.cargo/config
53+
54+
ENV PKG_CONFIG_ALLOW_CROSS=1
55+
ENV PKG_CONFIG_PATH=/usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig/
56+
ENV GTK_INSTALL_PATH=/usr/i686-w64-mingw32/sys-root/mingw/
57+
VOLUME /home/rust/src
58+
WORKDIR /home/rust/src
59+
60+
# This calls the final job
61+
## Create a package.sh in your project folder overrides the one in /usr/bin/ (don't forget `chmod +x packages.sh`)
62+
CMD ["package.sh"]
63+
64+
# Usage:
65+
## Build the container
66+
# ```
67+
## docker build . -t rust-crosspile
68+
# ```
69+
70+
## Now build a image **in your source directory!**. Your sources are mounted as a docker VOLUME
71+
# ```
72+
## docker create -v `pwd`:/home/rust/src --name PROJECT-build rust-crosspile:latest
73+
# ```
74+
75+
# From now on everytime you want conpile and pack the latest version call `docker start`
76+
## docker start -ai PROJECT-build
77+
78+
## docker rm PROJECT-build

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ Docker Container to cross compile rust binaries for Windows
55
## Usage
66
First build the Image, from within this project directory.
77
```bash
8-
:wqdocker build . -t PROJECTNAME-build-image
8+
docker build . -t PROJECTNAME-build-image
9+
# eg: docker build . -t rust-crosspile
910
```
1011

1112

cargo.config

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[target.i686-pc-windows-gnu]
2+
linker = "i686-w64-mingw32-gcc"
3+
ar = "i686-w64-mingw32-gcc-ar"

package.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
2+
set -e
23

4+
#statements
35
source ~/.cargo/env
46
cargo build --target=i686-pc-windows-gnu --release
57

0 commit comments

Comments
 (0)