Added support for nimble.
h3rald h3rald@h3rald.com
Sun, 21 Oct 2018 14:56:48 +0200
12 files changed,
92 insertions(+),
61 deletions(-)
M
README.md
→
README.md
@@ -1,3 +1,5 @@
+[![Nimble](https://raw.githubusercontent.com/yglukhov/nimble-tag/master/nimble.png)](https://github.com/h3rald/nifty) + [![Release](https://img.shields.io/github/release/h3rald/nifty.svg)](https://github.com/h3rald/nifty) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/h3rald/nifty/master/LICENSE)
D
lib/config.nim
@@ -1,46 +0,0 @@
-import - os, - parsecfg, - streams, - strutils, - logging - -import - niftylogger - -const - cfgfile = "../nifty.nimble".slurp - -var - appname*: string - version*: string - appdesc*: string - f = newStringStream(cfgfile) - -if f != nil: - var p: CfgParser - open(p, f, "../nifty.nimble") - while true: - var e = next(p) - case e.kind - of cfgEof: - break - of cfgKeyValuePair: - case e.key: - of "version": - version = e.value - of "name": - appname = e.value - of "description": - appdesc = e.value - else: - discard - of cfgError: - fatal("Configuration error.") - quit(1) - else: - discard - close(p) -else: - fatal("Cannot process configuration file.") - quit(2)
M
nifty.nim
→
src/nifty.nim
@@ -8,18 +8,18 @@ strutils,
sequtils import - lib/niftylogger + niftypkg/niftylogger newNiftyLogger().addHandler() setLogFilter(lvlInfo) import - lib/config, - lib/project, - lib/messaging + niftypkg/config, + niftypkg/project, + niftypkg/messaging let usage* = """ $1 v$2 - $3 - (c) 2017-2018 Fabio Cevasco + (c) 2017-2018 $4 Usage: nifty <command> [<package>] Executes <command> (on <package>).@@ -31,7 +31,7 @@ --log, -l Specifies the log level (debug|info|notice|warn|error|fatal).
Default: info --help, -h Displays this message. --version, -h Displays the version of the application. -""" % [appname, version, appdesc] +""" % [pkgTitle, pkgVersion, pkgDescription, pkgAuthor] # Helper Methods@@ -153,7 +153,7 @@ of "help", "h":
echo usage quit(0) of "version", "v": - echo version + echo pkgVersion quit(0) else: discard
M
nifty.nimble
→
nifty.nimble
@@ -1,10 +1,80 @@
-[Package] -name = "nifty" -version = "1.0.0" -author = "Fabio Cevasco" -description = "A decentralized (pseudo) package manager and script runner." +import + ospaths + +template thisModuleFile: string = instantiationInfo(fullPaths = true).filename + +when fileExists(thisModuleFile.parentDir / "src/niftypkg/config.nim"): + # In the git repository the Nimble sources are in a ``src`` directory. + import src/niftypkg/config +else: + # When the package is installed, the ``src`` directory disappears. + import niftypkg/config + +# Package + +name = pkgTitle +version = pkgVersion +author = pkgAuthor +description = pkgDescription license = "MIT" -bin = "nifty" +bin = @["nifty"] +srcDir = "src" +installExt = @["nim"] + +# Dependencies + +requires "nim >= 0.19.0" + +const compile = "nim c -d:release" +const linux_x86 = "--cpu:i386 --os:linux -o:nifty" +const linux_x64 = "--cpu:amd64 --os:linux -o:nifty" +const linux_arm = "--cpu:arm --os:linux -o:nifty" +const windows_x64 = "--cpu:amd64 --os:windows -o:nifty.exe" +const macosx_x64 = "-o:nifty" +const program = "nifty" +const program_file = "src/nifty.nim" +const zip = "zip -X" -[Deps] -requires: "nim >= 0.18.0" +proc shell(command, args: string, dest = "") = + exec command & " " & args & " " & dest + +proc filename_for(os: string, arch: string): string = + return "nifty" & "_v" & version & "_" & os & "_" & arch & ".zip" + +task windows_x64_build, "Build nifty for Windows (x64)": + shell compile, windows_x64, program_file + +task linux_x86_build, "Build nifty for Linux (x86)": + shell compile, linux_x86, program_file + +task linux_x64_build, "Build nifty for Linux (x64)": + shell compile, linux_x64, program_file + +task linux_arm_build, "Build nifty for Linux (ARM)": + shell compile, linux_arm, program_file + +task macosx_x64_build, "Build nifty for Mac OS X (x64)": + shell compile, macosx_x64, program_file + +task release, "Release nifty": + echo "\n\n\n WINDOWS - x64:\n\n" + windows_x64_buildTask() + shell zip, filename_for("windows", "x64"), program & ".exe" + shell "rm", program & ".exe" + echo "\n\n\n LINUX - x64:\n\n" + linux_x64_buildTask() + shell zip, filename_for("linux", "x64"), program + shell "rm", program + echo "\n\n\n LINUX - x86:\n\n" + linux_x86_buildTask() + shell zip, filename_for("linux", "x86"), program + shell "rm", program + echo "\n\n\n LINUX - ARM:\n\n" + linux_arm_buildTask() + shell zip, filename_for("linux", "arm"), program + shell "rm", program + echo "\n\n\n MAC OS X - x64:\n\n" + macosx_x64_buildTask() + shell zip, filename_for("macosx", "x64"), program + shell "rm", program +echo "\n\n\n ALL DONE!"
A
src/niftypkg/config.nim
@@ -0,0 +1,5 @@
+const + pkgTitle* = "nifty" + pkgVersion* = "1.0.1" + pkgAuthor* = "Fabio Cevasco" + pkgDescription* = "A decentralized (pseudo) package manager and script runner."