-
Notifications
You must be signed in to change notification settings - Fork 1
/
caprese.nimble
119 lines (103 loc) · 3.35 KB
/
caprese.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Package
version = "0.1.0"
author = "zenywallet"
description = "A front-end web server specialized for real-time message exchange"
license = "MIT"
srcDir = "src"
installExt = @["nim", "a", "jar"]
installDirs = @["bin", "brotli", "zopfli"]
bin = @["caprese"]
# Dependencies
requires "nim >= 1.6.4"
when NimMajor >= 2:
requires "checksums"
requires "nimcrypto"
requires "karax >= 1.2.3"
task bearssl, "Build BearSSL":
withDir "deps/bearssl":
exec "make -j$(nproc)"
exec "mkdir -p ../../src/lib/bearssl"
exec "cp build/libbearssl.a ../../src/lib/bearssl/"
task openssl, "Build OpenSSL":
withDir "deps/openssl":
if fileExists("libssl.so"):
exec "make clean"
exec "./Configure no-shared"
exec "make -j$(nproc)"
exec "mkdir -p ../../src/lib/openssl"
exec "cp libssl.a ../../src/lib/openssl/"
exec "cp libcrypto.a ../../src/lib/openssl/"
exec "cp apps/openssl ../../src/lib/openssl/"
task libressl, "Build LibreSSL":
withDir "deps/libressl":
if dirExists("openbsd"):
exec "rm -rf openbsd"
exec "git checkout master"
exec "git reset --hard"
exec "git pull"
exec "./autogen.sh"
exec "./configure"
exec "make -j$(nproc)"
exec "mkdir -p ../../src/lib/libressl"
exec "cp ssl/.libs/libssl.a ../../src/lib/libressl/"
exec "cp crypto/.libs/libcrypto.a ../../src/lib/libressl/"
task boringssl, "Build BoringSSL":
withDir "deps/boringssl":
mkDir "build"
cd "build"
exec "cmake .."
exec "make -j$(nproc)"
cd ".."
exec "mkdir -p ../../src/lib/boringssl"
exec "cp build/ssl/libssl.a ../../src/lib/boringssl/"
exec "cp build/crypto/libcrypto.a ../../src/lib/boringssl/"
task selfcert, "Generate Self-Signed Certificate":
exec "nim c -r src/caprese/self_cert.nim"
task zopfli, "Copy zopfli":
withDir "deps/zopfli":
exec "mkdir -p ../../src/zopfli"
exec "cp src/zopfli/* ../../src/zopfli/"
task brotli, "Copy brotli":
withDir "deps/brotli":
exec "mkdir -p ../../src/brotli"
exec "cp -r c ../../src/brotli/"
task depsAll, "Build deps":
exec "git submodule update --init"
bearsslTask()
opensslTask()
libresslTask()
boringsslTask()
selfcertTask()
zopfliTask()
brotliTask()
task missingFileWorkaround, "Missing File Workaround":
withDir "src":
exec "mkdir -p src/bin"
exec "mkdir -p src/brotli"
exec "mkdir -p src/zopfli"
exec "touch src/bin/empty.a"
exec "touch src/brotli/empty.a"
exec "touch src/zopfli/empty.a"
exec "touch src/THIS_FOLDER_FOR_MISSING_FILE_WORKAROUND.a"
before install:
missingFileWorkaroundTask()
before build:
if getEnv("NOSSL") == "1":
exec "git submodule update --init deps/zopfli"
exec "git submodule update --init deps/brotli"
exec "mkdir -p src/lib"
exec "touch src/lib/NOSSL.a"
else:
exec "git submodule update --init"
if not fileExists("src/lib/bearssl/libbearssl.a"):
bearsslTask()
if not fileExists("src/lib/openssl/libssl.a") or not fileExists("src/lib/openssl/libcrypto.a"):
opensslTask()
if not fileExists("src/lib/libressl/libssl.a") or not fileExists("src/lib/libressl/libcrypto.a"):
libresslTask()
if not fileExists("src/lib/boringssl/libssl.a") or not fileExists("src/lib/boringssl/libcrypto.a"):
boringsslTask()
selfcertTask()
exec "rm -f src/lib/NOSSL.a"
zopfliTask()
brotliTask()