Skip to content

Commit

Permalink
Changed package structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
h3rald committed Oct 8, 2018
1 parent 39cd940 commit cc9b975
Show file tree
Hide file tree
Showing 16 changed files with 200 additions and 159 deletions.
88 changes: 80 additions & 8 deletions 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"]

requires "nim >= 0.19.0"

before install:
exec "nifty install"

# 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

bin = "hastyscribe"
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

[Deps]
Requires: "nim >= 0.19.0"
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!"
37 changes: 0 additions & 37 deletions lib/config.nim

This file was deleted.

34 changes: 0 additions & 34 deletions lib/consts.nim

This file was deleted.

58 changes: 0 additions & 58 deletions nakefile.nim

This file was deleted.

33 changes: 27 additions & 6 deletions hastyscribe.nim → src/hastyscribe.nim
Expand Up @@ -11,16 +11,37 @@ import
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
toc*: bool
Expand Down Expand Up @@ -469,7 +490,7 @@ proc compile*(hs: var HastyScribe, input_file: string) =
### 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
Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions 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"

34 changes: 34 additions & 0 deletions 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;
}
"""
16 changes: 0 additions & 16 deletions 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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
54 changes: 54 additions & 0 deletions 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
}
}
}

0 comments on commit cc9b975

Please sign in to comment.