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
|
version = "0.7.0"
author = "nandi"
description = "libcosmic behind a C ABI, driven from Nim"
license = "MIT"
srcDir = "nim"
installExt = @["nim", "so"] # the module, plus the cdylib beside it
requires "nim >= 2.0.0"
# The package version and the cdylib's ABI are the same thing: cosmicnim
# 0.2.0 speaks to the v0.2.0 release and no other. Resolving the tag from
# `version` is what keeps a stale library from loading against new bindings.
const
BaseUrl = "https://rickub.com/nandi/cosmicnim"
Target = "x86_64-unknown-linux-gnu"
LibName = "libcosmic_ffi.so"
proc fetchLibInto(dir: string) =
# NimScript has no `/` path operator, hence the plain concatenation.
let
tag = getEnv("COSMICNIM_TAG", "v" & version)
url = BaseUrl & "/releases/download/" & tag &
"/cosmic_ffi-" & tag & "-" & Target & ".tar.gz"
tmp = dir & "/.cosmicnim-fetch"
echo "fetching ", tag, " from ", BaseUrl
rmDir tmp
mkDir tmp
exec "curl -fsSL -o '" & tmp & "/asset.tar.gz' '" & url & "'"
# The workflow publishes a checksum beside every tarball.
if gorgeEx("curl -fsSL -o '" & tmp & "/asset.sha256' '" &
url & ".sha256'").exitCode == 0:
exec "cd '" & tmp & "' && sed 's| .*| asset.tar.gz|' asset.sha256 | sha256sum -c -"
else:
echo "no .sha256 published alongside the asset; skipping checksum"
exec "tar xzf '" & tmp & "/asset.tar.gz' -C '" & tmp & "'"
exec "cp '" & tmp & "'/cosmic_ffi-*/" & LibName & " '" & dir & "/" & LibName & "'"
rmDir tmp
echo "installed ", dir & "/" & LibName
task fetchLib, "Download the prebuilt cdylib matching this package version":
fetchLibInto(srcDir)
before install:
# Ship the cdylib with the package, fetching it if it is not here yet.
if not fileExists(srcDir & "/" & LibName):
fetchLibInto(srcDir)
|