Skip to content

Commit

Permalink
Actual v2 (the previous commit saying v2 was v1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Patitotective committed Jan 10, 2024
1 parent 0b00c02 commit 23ab073
Show file tree
Hide file tree
Showing 5 changed files with 196 additions and 263 deletions.
26 changes: 12 additions & 14 deletions ImExample.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ requires "tinydialogs >= 1.0.0"
requires "constructor >= 1.2.0"

import std/[strformat, options]
import src/types
import src/configtype

const config = initConfig()

Expand All @@ -28,13 +28,12 @@ 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} -d:configPath={configPath} {flags}"
let args = &"--app:gui --out:{outPath} --cpu:{arch} {flags}"

task buildr, "Build the application for release":
exec "nimble install -d -y"
exec &"nim c -d:release {args} main.nim"
exec &"nimble c -d:release {args} main.nim"

const desktop = """
const desktopTemplate = """
[Desktop Entry]
Name=$name
Exec=AppRun
Expand All @@ -52,14 +51,13 @@ task buildapp, "Build the AppImage":
let appimagePath = &"{config.name}-{version}-{arch}.AppImage"

# Compile applicaiton executable
if not existsDir("AppDir"): mkDir("AppDir")
exec "nimble install -d -y"
exec &"nim c -d:release -d:appimage {args} --out:AppDir/AppRun main.nim"
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",
desktop % [
desktopTemplate % [
"name", config.name,
"categories", config.categories.join(";"),
"version", config.version,
Expand All @@ -71,9 +69,9 @@ task buildapp, "Build the AppImage":
cpFile(config.iconPath, "AppDir/.DirIcon")
cpFile(config.svgIconPath, &"AppDir/{config.name}.svg")

if config.appstreamPath.isSome:
if config.appstreamPath.len > 0:
mkDir("AppDir/usr/share/metainfo")
cpFile(config.appstreamPath.get, &"AppDir/usr/share/metainfo/{config.name}.appdata.xml")
cpFile(config.appstreamPath, &"AppDir/usr/share/metainfo/{config.name}.appdata.xml")

# Get appimagetool
var appimagetoolPath = "appimagetool"
Expand All @@ -82,15 +80,15 @@ task buildapp, "Build the AppImage":
exec(&"{appimagetoolPath} --help")
except OSError:
appimagetoolPath = "./appimagetool-x86_64.AppImage"
if not existsFile(appimagetoolPath):
if not fileExists(appimagetoolPath):
echo &"Downloading {appimagetoolPath}"
exec &"wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O ", 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[0]}|{config.ghRepo.get[0]}|latest|{config.name}-*-{arch}.AppImage.zsync\" AppDir {appimagePath}"
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}"
Loading

0 comments on commit 23ab073

Please sign in to comment.