Moved build tasks to nimble file.
h3rald h3rald@h3rald.com
Sat, 24 Nov 2018 13:09:34 +0100
4 files changed,
71 insertions(+),
101 deletions(-)
M
config.nim
→
config.nim
@@ -1,37 +1,5 @@
-import - os, - parsecfg, - streams, - strutils - const - cfgfile = "hastysite.nimble".slurp - -var - appname* = "HastySite" - version*: string - f = newStringStream(cfgfile) - -if f != nil: - var p: CfgParser - open(p, f, "hastysite.nimble") - while true: - var e = next(p) - case e.kind - of cfgEof: - break - of cfgKeyValuePair: - case e.key: - of "version": - version = e.value - else: - discard - of cfgError: - stderr.writeLine("Configuration error.") - quit(1) - else: - discard - close(p) -else: - stderr.writeLine("Cannot process configuration file.") - quit(2) + pkgName* = "HastySite" + pkgVersion* = "1.2.2" + pkgDescription* = "A small but powerful static site generator" + pkgAuthor* = "Fabio Cevasco"
M
hastysite.nim
→
hastysite.nim
@@ -427,7 +427,7 @@ hastysite command
Commands: init - Initializes a new site in the current directory. -""" % [appname, version] +""" % [pkgName, pkgVersion] if scripts: for key, value in hs.scripts.pairs: text &= " " & key & " - " & value.getStr & "\n"@@ -470,7 +470,7 @@ of "help", "h":
echo usage(scripts, hs) quit(0) of "version", "v": - echo version + echo pkgVersion quit(0) else: discard
M
hastysite.nimble
→
hastysite.nimble
@@ -1,10 +1,68 @@
-[Package] -name = "hastysite" -version = "1.2.2" -author = "Fabio Cevasco" -description = "A small but powerful static site generator" +import config + +# Package +version = pkgVersion +author = pkgAuthor +description = pkgDescription license = "MIT" -bin = "hastysite" +bin = @["hastysite"] -[Deps] +# Deps requires: "nim >= 0.19.0" + +# Tasks +const + compile = "nim c -d:release" + linux_x86 = "--cpu:i386 --os:linux" + linux_x64 = "--cpu:amd64 --os:linux" + linux_arm = "--cpu:arm --os:linux" + windows_x64 = "--cpu:amd64 --os:windows" + macosx_x64 = "" + #parallel = "--parallelBuild:1 --verbosity:3" + hs = "hastysite" + hs_file = "hastysite.nim" + zip = "zip -X" + +proc shell(command, args: string, dest = "") = + exec command & " " & args & " " & dest + +proc filename_for(os: string, arch: string): string = + return "hastysite" & "_v" & version & "_" & os & "_" & arch & ".zip" + +task windows_x64_build, "Build hastysite for Windows (x64)": + shell compile, windows_x64, hs_file + +task linux_x86_build, "Build hastysite for Linux (x86)": + shell compile, linux_x86, hs_file + +task linux_x64_build, "Build hastysite for Linux (x64)": + shell compile, linux_x64, hs_file + +task linux_arm_build, "Build hastysite for Linux (ARM)": + shell compile, linux_arm, hs_file + +task macosx_x64_build, "Build hastysite for Mac OS X (x64)": + shell compile, macosx_x64, hs_file + +task release, "Release hastysite": + echo "\n\n\n WINDOWS - x64:\n\n" + windows_x64_buildTask() + shell zip, filename_for("windows", "x64"), hs & ".exe" + shell "rm", hs & ".exe" + echo "\n\n\n LINUX - x64:\n\n" + linux_x64_buildTask() + shell zip, filename_for("linux", "x64"), hs + shell "rm", hs + echo "\n\n\n LINUX - x86:\n\n" + linux_x86_buildTask() + shell zip, filename_for("linux", "x86"), hs + shell "rm", hs + echo "\n\n\n LINUX - ARM:\n\n" + linux_arm_buildTask() + shell zip, filename_for("linux", "arm"), hs + shell "rm", hs + echo "\n\n\n MAC OS X - x64:\n\n" + macosx_x64_buildTask() + shell zip, filename_for("macosx", "x64"), hs + shell "rm", hs + echo "\n\n\n ALL DONE!"
D
nakefile.nim
@@ -1,56 +0,0 @@
-import - nake, - config - -const - compile = "nim c -d:release" - linux_x86 = "--cpu:i386 --os:linux" - linux_x64 = "--cpu:amd64 --os:linux" - linux_arm = "--cpu:arm --os:linux" - windows_x64 = "--cpu:amd64 --os:windows" - macosx_x64 = "" - #parallel = "--parallelBuild:1 --verbosity:3" - hs = "hastysite" - hs_file = "hastysite.nim" - zip = "zip -X" - -proc filename_for(os: string, arch: string): string = - return "hastysite" & "_v" & version & "_" & os & "_" & arch & ".zip" - -task "windows-x64-build", "Build hastysite for Windows (x64)": - direshell compile, windows_x64, hs_file - -task "linux-x86-build", "Build hastysite for Linux (x86)": - direshell compile, linux_x86, hs_file - -task "linux-x64-build", "Build hastysite for Linux (x64)": - direshell compile, linux_x64, hs_file - -task "linux-arm-build", "Build hastysite for Linux (ARM)": - direshell compile, linux_arm, hs_file - -task "macosx-x64-build", "Build hastysite for Mac OS X (x64)": - direshell compile, macosx_x64, hs_file - -task "release", "Release hastysite": - echo "\n\n\n WINDOWS - x64:\n\n" - runTask "windows-x64-build" - direshell zip, filename_for("windows", "x64"), hs & ".exe" - direshell "rm", hs & ".exe" - echo "\n\n\n LINUX - x64:\n\n" - runTask "linux-x64-build" - direshell zip, filename_for("linux", "x64"), hs - direshell "rm", hs - echo "\n\n\n LINUX - x86:\n\n" - runTask "linux-x86-build" - direshell zip, filename_for("linux", "x86"), hs - direshell "rm", hs - echo "\n\n\n LINUX - ARM:\n\n" - runTask "linux-arm-build" - direshell zip, filename_for("linux", "arm"), hs - direshell "rm", hs - echo "\n\n\n MAC OS X - x64:\n\n" - runTask "macosx-x64-build" - direshell zip, filename_for("macosx", "x64"), hs - direshell "rm", hs - echo "\n\n\n ALL DONE!"