Changed package structure.
h3rald h3rald@h3rald.com
Mon, 08 Oct 2018 18:12:58 +0200
16 files changed,
200 insertions(+),
159 deletions(-)
jump to
M
hastyscribe.nim
→
src/hastyscribe.nim
@@ -11,15 +11,36 @@ httpclient,
logging import - packages/niftylogger, - lib/markdown, - lib/config, - lib/consts, - lib/utils + ../packages/niftylogger, + hastyscribepkg/markdown, + hastyscribepkg/config, + hastyscribepkg/consts, + hastyscribepkg/utils export consts + +when defined(discount): + {.passL: "-L../packages/discount".} + {.passL: "-lmarkdown".} +else: + import os + when dirExists("src/hastyscribepkg/vendor"): + {.passL: "-Lsrc/hastyscribepkg/vendor".} + else: + {.passL: "-Lhastyscribepkg/vendor".} + when defined(macosx): + {.passL: "-lmarkdown_macosx_x64".} + when defined(windows): + {.passL: "-lmarkdown_windows_x64".} + when defined(linux): + when defined(arm): + {.passL: "-lmarkdown_linux_arm".} + when defined(i386): + {.passL: "-lmarkdown_linux_x86".} + when defined(amd64): + {.passL: "-lmarkdown_linux_x64".} type HastyOptions* = object@@ -469,7 +490,7 @@
### MAIN when isMainModule: - let usage = " HastyScribe v" & version & " - Self-contained Markdown Compiler" & """ + let usage = " HastyScribe v" & pkgVersion & " - Self-contained Markdown Compiler" & """ (c) 2013-2018 Fabio Cevasco
M
hastyscribe.nimble
→
hastyscribe.nimble
@@ -1,11 +1,83 @@
-[Package] -name = "hastyscribe" -version = "1.11.0" -author = "Fabio Cevasco" -description = "Self-contained markdown compiler generating self-contained HTML documents" +import + ospaths + +template thisModuleFile: string = instantiationInfo(fullPaths = true).filename + +when fileExists(thisModuleFile.parentDir / "src/hastyscribepkg/config.nim"): + # In the git repository the Nimble sources are in a ``src`` directory. + import src/hastyscribepkg/config +else: + # When the package is installed, the ``src`` directory disappears. + import hastyscribepkg/config + +# Package + +version = pkgVersion +author = pkgAuthor +description = pkgDescription license = "MIT" +bin = @["hastyscribe"] +srcDir = "src" +installFiles = @["nifty.json"] -bin = "hastyscribe" +requires "nim >= 0.19.0" + +before install: + exec "nifty install" -[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 = "" + hs = "src/hastyscribe" + hs_file = "src/hastyscribe.nim" + zip = "zip -X" + +proc shell(command, args: string, dest = "") = + exec command & " " & args & " " & dest + +proc filename_for(os: string, arch: string): string = + return "hastyscribe" & "_v" & version & "_" & os & "_" & arch & ".zip" + +task windows_x64_build, "Build HastyScribe for Windows (x64)": + shell compile, windows_x64, hs_file + +task linux_x86_build, "Build HastyScribe for Linux (x86)": + shell compile, linux_x86, hs_file + +task linux_x64_build, "Build HastyScribe for Linux (x64)": + shell compile, linux_x64, hs_file + +task linux_arm_build, "Build HastyScribe for Linux (ARM)": + shell compile, linux_arm, hs_file + +task macosx_x64_build, "Build HastyScribe for Mac OS X (x64)": + shell compile, macosx_x64, hs_file + +task release, "Release HastyScribe": + 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
lib/config.nim
@@ -1,37 +0,0 @@
-import - parsecfg, - streams, - strutils - -const - cfgfile = "../hastyscribe.nimble".slurp - -var - version*: string - f = newStringStream(cfgfile) - -if f != nil: - var p: CfgParser - open(p, f, "hastyscribe.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) - -
D
lib/consts.nim
@@ -1,34 +0,0 @@
- -const - stylesheet* = "../packages/hastystyles/styles/hastyscribe.css".slurp - hastyscribe_font* = "../packages/hastystyles/fonts/hastyscribe.woff".slurp - fa_solid_font* = "../packages/hastystyles/fonts/fa-solid-900.woff".slurp - fa_brands_font* = "../packages/hastystyles/fonts/fa-brands-400.woff".slurp - sourcecodepro_font* = "../packages/hastystyles/fonts/SourceCodePro-Regular.woff".slurp - sourcecodepro_it_font* = "../packages/hastystyles/fonts/SourceCodePro-It.woff".slurp - sourcecodepro_bold_font* = "../packages/hastystyles/fonts/SourceCodePro-Bold.woff".slurp - sourcecodepro_boldit_font* = "../packages/hastystyles/fonts/SourceCodePro-BoldIt.woff".slurp - sourcesanspro_font* = "../packages/hastystyles/fonts/SourceSansPro-Light.woff".slurp - sourcesanspro_bold_font* = "../packages/hastystyles/fonts/SourceSansPro-Semibold.woff".slurp - sourcesanspro_it_font* = "../packages/hastystyles/fonts/SourceSansPro-LightIt.woff".slurp - sourcesanspro_boldit_font* = "../packages/hastystyles/fonts/SourceSansPro-SemiboldIt.woff".slurp - watermark_style* = """ -#container { - position: relative; - z-index: 0; -} -#container:after { - content: ""; - opacity: 0.1; - z-index: -1; - position: absolute; - top: 0; - left: 0; - bottom: 0; - right: 0; - background-image: url($1); - background-repeat: no-repeat; - background-position: center 70px; - background-attachment: fixed; -} -"""
M
lib/markdown.nim
→
src/hastyscribepkg/markdown.nim
@@ -1,19 +1,3 @@
-when defined(discount): - {.passL: "-Lpackages/discount".} - {.passL: "-lmarkdown".} -else: - {.passL: "-Lvendor".} - when defined(macosx): - {.passL: "-lmarkdown_macosx_x64".} - when defined(windows): - {.passL: "-lmarkdown_windows_x64".} - when defined(linux): - when defined(arm): - {.passL: "-lmarkdown_linux_arm".} - when defined(i386): - {.passL: "-lmarkdown_linux_x86".} - when defined(amd64): - {.passL: "-lmarkdown_linux_x64".} const MKDIO_D* = true type
D
nakefile.nim
@@ -1,58 +0,0 @@
-import - nake - -import - lib/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 = "hastyscribe" - hs_file = "hastyscribe.nim" - zip = "zip -X" - -proc filename_for(os: string, arch: string): string = - return "hastyscribe" & "_v" & version & "_" & os & "_" & arch & ".zip" - -task "windows-x64-build", "Build HastyScribe for Windows (x64)": - direshell compile, windows_x64, hs_file - -task "linux-x86-build", "Build HastyScribe for Linux (x86)": - direshell compile, linux_x86, hs_file - -task "linux-x64-build", "Build HastyScribe for Linux (x64)": - direshell compile, linux_x64, hs_file - -task "linux-arm-build", "Build HastyScribe for Linux (ARM)": - direshell compile, linux_arm, hs_file - -task "macosx-x64-build", "Build HastyScribe for Mac OS X (x64)": - direshell compile, macosx_x64, hs_file - -task "release", "Release HastyScribe": - 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!"
A
src/hastyscribepkg/config.nim
@@ -0,0 +1,5 @@
+const + pkgVersion* = "1.11.0" + pkgAuthor* = "Fabio Cevasco" + pkgDescription* = "Self-contained markdown compiler generating self-contained HTML documents" +
A
src/hastyscribepkg/consts.nim
@@ -0,0 +1,34 @@
+ +const + stylesheet* = "../../packages/hastystyles/styles/hastyscribe.css".slurp + hastyscribe_font* = "../../packages/hastystyles/fonts/hastyscribe.woff".slurp + fa_solid_font* = "../../packages/hastystyles/fonts/fa-solid-900.woff".slurp + fa_brands_font* = "../../packages/hastystyles/fonts/fa-brands-400.woff".slurp + sourcecodepro_font* = "../../packages/hastystyles/fonts/SourceCodePro-Regular.woff".slurp + sourcecodepro_it_font* = "../../packages/hastystyles/fonts/SourceCodePro-It.woff".slurp + sourcecodepro_bold_font* = "../../packages/hastystyles/fonts/SourceCodePro-Bold.woff".slurp + sourcecodepro_boldit_font* = "../../packages/hastystyles/fonts/SourceCodePro-BoldIt.woff".slurp + sourcesanspro_font* = "../../packages/hastystyles/fonts/SourceSansPro-Light.woff".slurp + sourcesanspro_bold_font* = "../../packages/hastystyles/fonts/SourceSansPro-Semibold.woff".slurp + sourcesanspro_it_font* = "../../packages/hastystyles/fonts/SourceSansPro-LightIt.woff".slurp + sourcesanspro_boldit_font* = "../../packages/hastystyles/fonts/SourceSansPro-SemiboldIt.woff".slurp + watermark_style* = """ +#container { + position: relative; + z-index: 0; +} +#container:after { + content: ""; + opacity: 0.1; + z-index: -1; + position: absolute; + top: 0; + left: 0; + bottom: 0; + right: 0; + background-image: url($1); + background-repeat: no-repeat; + background-position: center 70px; + background-attachment: fixed; +} +"""
A
src/nifty.json
@@ -0,0 +1,54 @@
+{ + "storage": "packages", + "commands": { + "build": { + "name+configure.sh": { + "pwd": "{{name}}", + "cmd": "./configure.sh && make" + } + }, + "install": { + "git+src": { + "cmd": "git clone {{src}} --depth 1" + }, + "git+src+tag": { + "cmd": "git clone --branch {{tag}} {{src}} --depth 1" + }, + "curl+src+name": { + "cmd": "curl {{src}} -o {{name}}" + }, + "_syntax": "install [<package>]", + "_description": "Installs the specified package (or all mapped packages) to the storage directory." + }, + "upgrade": { + "_syntax": "upgrade [<package>]", + "_description": "Upgrades the specified previously-installed package (or all packages).", + "git+name": { + "cmd": "git pull", + "pwd": "{{name}}" + }, + "curl+src+name": { + "cmd": "curl {{src}} -o {{name}}" + } + } + }, + "packages": { + "hastystyles": { + "name": "hastystyles", + "src": "https://github.com/h3rald/hastystyles.git", + "git": true + }, + "discount": { + "configure.sh": true, + "name": "discount", + "src": "https://github.com/Orc/discount.git", + "tag": "v2.2.2", + "git": true + }, + "niftylogger.nim": { + "name": "niftylogger.nim", + "src": "https://raw.githubusercontent.com/h3rald/nifty/master/lib/niftylogger.nim", + "curl": true + } + } +}