-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnimlike.nimble
84 lines (66 loc) · 2.34 KB
/
nimlike.nimble
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Package
version = "1.0.0"
author = "Eugene Medvedev"
description = "A cgi-bin comments and likes system for Gemini"
license = "MIT"
srcDir = "src"
bin = @["nimlike"]
binDir = "build"
# Dependencies
requires "nim >= 1.6.4"
requires "jstin >= 0.1.0"
requires "elvis >= 0.5.0"
requires "regex >= 0.19.0"
# Tasks
# We're already requiring nim >= 1.4.8, so we can assume that 'distros' is available.
import os
import distros
from macros import error
# It's silly, but I have to reconstruct the compiler command line
# that nimble does in the build stage here to do multiple release builds.
# See https://github.com/nim-lang/nimble/issues/764
#
# This is kinda brittle.
#
task clean, "Clean the build directory.":
rmDir(binDir)
task release, "Produce a static release build for supported platforms.":
# External dependencies for Ubuntu required
# to cross-compile release builds.
if detectOs(Ubuntu):
# ARM compiler
foreignDep "gcc-arm-linux-gnueabihf"
else:
echo("Warning: Dependencies might be missing, you're on your own. ",
"Check nimlike.nimble for details.")
# I don't know the right invocations for foreignDep for anything
# except Ubuntu, but at least I can tell if the executables
# are there.
for requiredExe in [
"arm-linux-gnueabihf-gcc",
]:
if findExe(requiredExe) == "":
error(requiredExe & " binary was not found in PATH.")
let
compile = join(["c",
"-d:release",
"-d:strip",
"--opt:size",
"--passL:-static",
"-d:NimblePkgVersion=" & version]," ")
linux_x64_exe = projectName() & "_amd64"
linux_x64 = join(["--cpu:amd64",
"--os:linux",
"--out:build/" & linux_x64_exe]," ")
raspberry_x32_exe = projectName() & "_armhf"
raspberry_x32 = join(["--cpu:arm",
"--os:linux",
"--out:build/" & raspberry_x32_exe]," ")
rootFile = os.joinpath(srcDir, projectName() & ".nim")
cleanTask()
echo "=== Building Linux amd64..."
selfExec join([compile, linux_x64, rootFile], " ")
echo "=== Building Raspberry x32..."
echo join([compile, raspberry_x32, rootFile], " ")
selfExec join([compile, raspberry_x32, rootFile], " ")
echo "Done."