initial commit

This commit is contained in:
Colin Yates 2018-08-06 17:40:06 +01:00
commit 616d834838
10 changed files with 99 additions and 0 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
nimcache/
nimcache

25
Dockerfile Normal file
View file

@ -0,0 +1,25 @@
FROM debian
ENV PATH=$PATH:/opt/Nim/bin:/root/.nimble/bin
RUN apt update && \
apt -y install libc-dev gcc curl git perl mingw-w64 \
&& \
rm -rf /var/cache/apt/;
RUN mkdir -p /opt && cd /opt && \
curl -LO https://github.com/nim-lang/Nim/archive/v0.18.0.tar.gz && \
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 project /src
WORKDIR /src
CMD /scripts/build.sh

View file

@ -0,0 +1,13 @@
# Package
version = "0.1.0"
author = "Colin Yates"
description = "A new awesome nimble package"
license = "MIT"
srcDir = "src"
bin = @["docker_nim_dev_example"]
# Dependencies
requires "nim >= 0.18.0"
requires "zip"

View file

@ -0,0 +1,14 @@
import os, zip/zipfiles
# Hello Nim!
echo "Hello, World!"
proc createZip(rootDir: string) =
let filename = rootDir / "out.gz"
var z: ZipArchive
discard open(z, filename, fmWrite)
for x in walkDirRec(rootDir):
addFile(z, x, x)
close z
createZip("../")

1
project/tests/test1.nim Normal file
View file

@ -0,0 +1 @@
doAssert(1 + 1 == 2)

1
project/tests/test1.nims Normal file
View file

@ -0,0 +1 @@
switch("path", "$projectDir/../src")

17
scripts/build-linux.sh Executable file
View file

@ -0,0 +1,17 @@
#!/bin/bash
my_pwd=`pwd`
echo "Currently in $my_pwd"
mkdir -p /workdir/linux
cp -Rp * /workdir/linux/
rm -rf /workdir/linux/src/nimcache
cd /workdir/linux
nimble c --cpu:amd64 --os:linux --opt:speed --embedsrc --threads:on --checks:on -c -d:release src/*.nim
cd src
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"
cd $my_pwd

18
scripts/build-windows.sh Executable file
View file

@ -0,0 +1,18 @@
#!/bin/bash
my_pwd=`pwd`
echo "Currently in $my_pwd"
mkdir -p /workdir/windows
cp -Rp * /workdir/windows/
rm -rf /workdir/windows/src/nimcache
cd /workdir/windows
nimble c --cpu:amd64 --os:windows --opt:speed --embedsrc --threads:on --checks:on -c -d:release src/*.nim
cd src
cp /opt/Nim/lib/nimbase.h nimcache/
x86_64-w64-mingw32-gcc --save-temps nimcache/*.c -o windows.exe
cp windows.exe $my_pwd/dist/
echo "Copied windows.exe to $my_pwd/dist"
cd $my_pwd

9
scripts/build.sh Executable file
View file

@ -0,0 +1,9 @@
#!/bin/bash
mkdir /workdir
mkdir -p dist
# download the various caches and dependencies
nimble install -d -y
/scripts/build-linux.sh
/scripts/build-windows.sh