-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathImExample.nimble
94 lines (77 loc) · 2.7 KB
/
ImExample.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
# Package
author = "Patitotective"
description = "A new awesome Dear ImGui application"
license = "MIT"
backend = "cpp"
# Dependencies
requires "nim >= 1.6.2"
requires "kdl >= 2.0.1"
requires "nimgl >= 1.3.2"
requires "stb_image >= 2.5"
requires "imstyle >= 3.0.0"
requires "openurl >= 2.0.4"
requires "tinydialogs >= 1.0.0"
requires "constructor >= 1.2.0"
import std/[strformat, options]
import src/configtype
const config = Config()
version = config.version
namedBin["main"] = config.name
let arch = getEnv("ARCH", "amd64")
let outPath = getEnv("OUTPATH", toExe &"{config.name}-{version}-{arch}")
let flags = getEnv("FLAGS")
let args = &"--app:gui --out:{outPath} --cpu:{arch} {flags}"
task buildr, "Build the application for release":
exec &"nimble c -d:release {args} main.nim"
const desktopTemplate = """
[Desktop Entry]
Name=$name
Exec=AppRun
Comment=$comment
Icon=$name
Type=Application
Categories=$categories
X-AppImage-Name=$name
X-AppImage-Version=$version
X-AppImage-Arch=$arch
"""
task buildapp, "Build the AppImage":
let appimagePath = &"{config.name}-{version}-{arch}.AppImage"
# Compile applicaiton executable
if not dirExists("AppDir"): mkDir("AppDir")
exec &"nimble c -d:release -d:appimage {args} --out:AppDir/AppRun main.nim"
# Make desktop file
writeFile(
&"AppDir/{config.name}.desktop",
desktopTemplate % [
"name", config.name,
"categories", config.categories.join(";"),
"version", config.version,
"comment", config.comment,
"arch", arch
]
)
# Copy icons
cpFile(config.iconPath, "AppDir/.DirIcon")
cpFile(config.svgIconPath, &"AppDir/{config.name}.svg")
if config.appstreamPath.len > 0:
mkDir("AppDir/usr/share/metainfo")
cpFile(config.appstreamPath, &"AppDir/usr/share/metainfo/{config.name}.appdata.xml")
# Get appimagetool
var appimagetoolPath = "appimagetool"
try:
echo "Checking for appimagetool..."
exec(&"{appimagetoolPath} --help")
except OSError:
appimagetoolPath = "./appimagetool-x86_64.AppImage"
if not fileExists(appimagetoolPath):
echo &"Downloading {appimagetoolPath}"
exec &"wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O {appimagetoolPath}"
exec &"chmod +x {appimagetoolPath}"
# Actually use appimagetool to build the AppImage
if config.ghRepo.isSome:
echo "Building updateable AppImage"
exec &"{appimagetoolPath} -u \"gh-releases-zsync|{config.ghRepo.get.user}|{config.ghRepo.get.repo}|latest|{config.name}-*-{arch}.AppImage.zsync\" AppDir {appimagePath}"
else:
echo &"ghRepo not defined. Skipping updateable AppImage"
exec &"{appimagetoolPath} AppDir {appimagePath}"