Fix cross platform build

This commit is contained in:
Joey Yakimowich-Payne 2018-08-08 15:05:36 +09:00
commit a9d5d174cf
3 changed files with 20 additions and 21 deletions

View file

@ -1,21 +1,14 @@
FROM debian FROM debian
ENV PATH=$PATH:/opt/Nim/bin:/root/.nimble/bin ENV PATH=$PATH:/root/.nimble/bin
RUN apt update && \ RUN apt update && \
apt -y install libc-dev gcc curl git perl mingw-w64 libzip-dev \ apt -y install libc-dev gcc curl git perl mingw-w64 libzip-dev wget \
&& \ && \
rm -rf /var/cache/apt/; rm -rf /var/cache/apt/;
RUN mkdir -p /opt && cd /opt && \ RUN apt -y install xz-utils make
curl -LO https://github.com/nim-lang/Nim/archive/v0.18.0.tar.gz && \ RUN CHOOSENIM_CHOOSE_VERSION="0.18.0" curl https://nim-lang.org/choosenim/init.sh -sSf | bash -s -- "-y"
tar zxf v0.18.0.tar.gz && rm -f v0.18.0.tar.gz && \
mv Nim-0.18.0 Nim && cd Nim && \
git clone --depth 1 git://github.com/nim-lang/csources && \
cd csources && sh build.sh && \
cd .. && ./bin/nim c koch && ./koch boot -d:release && \
nim e install_nimble.nims && \
rm -rf /opt/Nim/tests;
ADD scripts /scripts ADD scripts /scripts
ADD project /src ADD project /src

View file

@ -7,11 +7,8 @@ cp -Rp * /workdir/linux/
rm -rf /workdir/linux/src/nimcache rm -rf /workdir/linux/src/nimcache
cd /workdir/linux cd /workdir/linux
nimble c --cpu:amd64 --os:linux --opt:speed --embedsrc --threads:on --checks:on -c -d:release src/*.nim nim c --cpu:amd64 --os:linux --opt:speed --embedsrc --threads:on --checks:on -d:release src/*.nim
cd src cp src/docker_nim_dev_example $my_pwd/dist/linux.exe
cp /opt/Nim/lib/nimbase.h nimcache
gcc -o linux.exe nimcache/*.c
cp linux.exe $my_pwd/dist/
echo "Copied linux.exe to $my_pwd/dist" echo "Copied linux.exe to $my_pwd/dist"
cd $my_pwd cd $my_pwd

View file

@ -7,12 +7,21 @@ cp -Rp * /workdir/windows/
rm -rf /workdir/windows/src/nimcache rm -rf /workdir/windows/src/nimcache
cd /workdir/windows cd /workdir/windows
nimble c --cpu:amd64 --os:windows --opt:speed --embedsrc --threads:on --checks:on -c -d:release src/*.nim wget https://zlib.net/zlib-1.2.11.tar.gz
cd src tar -xf zlib-1.2.11.tar.gz
cp /opt/Nim/lib/nimbase.h nimcache/
x86_64-w64-mingw32-gcc --save-temps nimcache/*.c -o windows.exe cd zlib-1.2.11/
# Replace the prefix with our custom one
sed -i.bak "s/PREFIX =/PREFIX = x86_64-w64-mingw32-/g" win32/Makefile.gcc
PREFIXDIR=/usr/x86_64-w64-mingw32 BINARY_PATH=$PREFIXDIR/bin INCLUDE_PATH=$PREFIXDIR/include LIBRARY_PATH=$PREFIXDIR/lib SHARED_MODE=1 make -f win32/Makefile.gcc
cd /workdir/windows
nim c --cpu:amd64 --os:windows --opt:speed --embedsrc --threads:on --checks:on --gcc.exe:x86_64-w64-mingw32-gcc --gcc.linkerexe:x86_64-w64-mingw32-gcc -d:release --passL:"-L/workdir/windows/zlib-1.2.11/ -lzlib1" --passC:"-I/workdir/windows/zlib-1.2.11/" src/*.nim
cp src/docker_nim_dev_example.exe $my_pwd/dist/windows.exe
cp windows.exe $my_pwd/dist/
echo "Copied windows.exe to $my_pwd/dist" echo "Copied windows.exe to $my_pwd/dist"
cd $my_pwd cd $my_pwd