mirror of
https://github.com/daylinmorgan/forge.git
synced 2024-12-23 11:30:43 -06:00
Compare commits
No commits in common. "43f3d67dcb2448db226551cfb87a56442f916dd6" and "9c5c64e72843c3542f3c37d04273c58b8300a787" have entirely different histories.
43f3d67dcb
...
9c5c64e728
8 changed files with 60 additions and 85 deletions
13
.github/workflows/build.yml
vendored
13
.github/workflows/build.yml
vendored
|
@ -12,23 +12,20 @@ jobs:
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- uses: jiro4989/setup-nim-action@v2
|
- uses: jiro4989/setup-nim-action@v1
|
||||||
with:
|
with:
|
||||||
nim-version: 2.0.8
|
nim-version: 2.0.0
|
||||||
|
|
||||||
- uses: goto-bus-stop/setup-zig@v2
|
- uses: goto-bus-stop/setup-zig@v2
|
||||||
|
|
||||||
- name: Bootstrap with installed version
|
- name: Bootstrap with installed version
|
||||||
run: |
|
run: nimble install -Y
|
||||||
nimble install -Y
|
|
||||||
|
|
||||||
- name: Generate build artifacts
|
- name: Generate build artifacts
|
||||||
run:
|
run: nimble release
|
||||||
nimble setup -l
|
|
||||||
nim release
|
|
||||||
|
|
||||||
- name: Create artifact bundles
|
- name: Create artifact bundles
|
||||||
run: nim bundle
|
run: nimble bundle
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
|
|
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -1,6 +1,6 @@
|
||||||
/bin
|
/bin
|
||||||
/dist
|
/dist
|
||||||
|
|
||||||
nimbledeps
|
# atlas
|
||||||
nimble.develop
|
*.workspace
|
||||||
nimble.paths
|
src/nim.cfg
|
||||||
|
|
24
config.nims
24
config.nims
|
@ -1,24 +0,0 @@
|
||||||
import std/[strformat, strutils]
|
|
||||||
|
|
||||||
task build, "build":
|
|
||||||
exec "nim c --outdir:bin src/forge.nim"
|
|
||||||
|
|
||||||
task release, "build release assets":
|
|
||||||
version = (gorgeEx "git describe --tags --always --match 'v*'").output
|
|
||||||
exec fmt"forge release -v {version} -V"
|
|
||||||
|
|
||||||
task bundle, "package build assets":
|
|
||||||
withDir "dist":
|
|
||||||
for dir in listDirs("."):
|
|
||||||
let cmd =
|
|
||||||
if "windows" in dir: fmt"7z a {dir}.zip {dir}"
|
|
||||||
else: fmt"tar czf {dir}.tar.gz {dir}"
|
|
||||||
cpFile("../README.md", fmt"{dir}/README.md")
|
|
||||||
exec cmd
|
|
||||||
|
|
||||||
|
|
||||||
# begin Nimble config (version 2)
|
|
||||||
--noNimblePath
|
|
||||||
when withDir(thisDir(), system.fileExists("nimble.paths")):
|
|
||||||
include "nimble.paths"
|
|
||||||
# end Nimble config
|
|
24
forge.nimble
24
forge.nimble
|
@ -7,8 +7,26 @@ bin = @["forge", "forgecc"]
|
||||||
binDir = "bin"
|
binDir = "bin"
|
||||||
|
|
||||||
|
|
||||||
requires "nim >= 2.0.0"
|
requires "nim >= 2.0.0",
|
||||||
requires "cligen"
|
"cligen",
|
||||||
requires "https://github.com/daylinmorgan/hwylterm#HEAD"
|
"https://github.com/daylinmorgan/bbansi#head"
|
||||||
|
|
||||||
|
|
||||||
|
import strformat
|
||||||
|
|
||||||
|
task release, "build release assets":
|
||||||
|
version = (gorgeEx "git describe --tags --always --match 'v*'").output
|
||||||
|
exec &"forge release -v {version} -V"
|
||||||
|
|
||||||
|
task bundle, "package build assets":
|
||||||
|
withDir "dist":
|
||||||
|
for dir in listDirs("."):
|
||||||
|
let cmd = if "windows" in dir:
|
||||||
|
&"7z a {dir}.zip {dir}"
|
||||||
|
else:
|
||||||
|
&"tar czf {dir}.tar.gz {dir}"
|
||||||
|
cpFile("../README.md", &"{dir}/README.md")
|
||||||
|
exec cmd
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
26
nimble.lock
26
nimble.lock
|
@ -1,26 +0,0 @@
|
||||||
{
|
|
||||||
"version": 2,
|
|
||||||
"packages": {
|
|
||||||
"cligen": {
|
|
||||||
"version": "1.7.5",
|
|
||||||
"vcsRevision": "85daafd76b0104387f50ff3f75c829b4c2804412",
|
|
||||||
"url": "https://github.com/c-blake/cligen.git",
|
|
||||||
"downloadMethod": "git",
|
|
||||||
"dependencies": [],
|
|
||||||
"checksums": {
|
|
||||||
"sha1": "f3ffe7329c8db755677d3ca377d02ff176cec8b1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"hwylterm": {
|
|
||||||
"version": "0.1.0",
|
|
||||||
"vcsRevision": "c2bcfd1f73dda97bd3e209c89e2abfe588f0977c",
|
|
||||||
"url": "https://github.com/daylinmorgan/hwylterm",
|
|
||||||
"downloadMethod": "git",
|
|
||||||
"dependencies": [],
|
|
||||||
"checksums": {
|
|
||||||
"sha1": "1932229840c893c39acca0b50def19913678f5f0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tasks": {}
|
|
||||||
}
|
|
|
@ -1,4 +1,5 @@
|
||||||
import std/[os, osproc, sequtils, strformat, strutils, tables]
|
import std/[os, osproc, sequtils, strformat, strutils, tables]
|
||||||
|
|
||||||
import forge/[config, utils, term, zig]
|
import forge/[config, utils, term, zig]
|
||||||
|
|
||||||
proc genFlags(target: string, args: seq[string] = @[]): seq[string] =
|
proc genFlags(target: string, args: seq[string] = @[]): seq[string] =
|
||||||
|
@ -25,7 +26,6 @@ proc targets() =
|
||||||
|
|
||||||
proc cc(target: string, dryrun: bool = false, nimble: bool = false, args: seq[string]) =
|
proc cc(target: string, dryrun: bool = false, nimble: bool = false, args: seq[string]) =
|
||||||
## compile with zig cc
|
## compile with zig cc
|
||||||
zigExists()
|
|
||||||
if args.len == 0:
|
if args.len == 0:
|
||||||
termErrQuit "expected additional arguments i.e. -- -d:release src/main.nim"
|
termErrQuit "expected additional arguments i.e. -- -d:release src/main.nim"
|
||||||
|
|
||||||
|
@ -64,7 +64,6 @@ proc release(
|
||||||
## default: ${name}-v${verison}-${target}
|
## default: ${name}-v${verison}-${target}
|
||||||
##
|
##
|
||||||
## if name or version are not specified they will be inferred from the local .nimble file
|
## if name or version are not specified they will be inferred from the local .nimble file
|
||||||
zigExists()
|
|
||||||
|
|
||||||
let cfg = newConfig(
|
let cfg = newConfig(
|
||||||
target,
|
target,
|
||||||
|
@ -126,23 +125,33 @@ proc release(
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
import cligen
|
import cligen
|
||||||
import hwylterm/cli
|
zigExists()
|
||||||
hwylCli(clCfg)
|
|
||||||
|
|
||||||
let clUse* = $bb("$command $args\n${doc}[bold]Options[/]:\n$options")
|
const
|
||||||
const vsn = staticExec "git describe --tags --always HEAD"
|
customMulti = "Usage:\n $command {SUBCMD} [sub-command options & parameters]\n\nsubcommands:\n$subcmds"
|
||||||
|
vsn = staticExec "git describe --tags --always HEAD"
|
||||||
|
|
||||||
|
|
||||||
|
if clCfg.useMulti == "": clCfg.useMulti = customMulti
|
||||||
|
if clCfg.helpAttr.len == 0:
|
||||||
|
clCfg.helpAttr = {"cmd": "\e[1;36m", "clDescrip": "", "clDflVal": "\e[33m",
|
||||||
|
"clOptKeys": "\e[32m", "clValType": "\e[31m", "args": "\e[3m"}.toTable
|
||||||
|
clCfg.helpAttrOff = {"cmd": "\e[m", "clDescrip": "\e[m", "clDflVal": "\e[m",
|
||||||
|
"clOptKeys": "\e[m", "clValType": "\e[m", "args": "\e[m"}.toTable
|
||||||
|
|
||||||
var vsnCfg = clCfg
|
var vsnCfg = clCfg
|
||||||
vsnCfg.version = vsn
|
vsnCfg.version = vsn
|
||||||
|
|
||||||
|
|
||||||
dispatchMulti(
|
dispatchMulti(
|
||||||
["multi", cf = vsnCfg],
|
["multi", cf = vsnCfg],
|
||||||
[cc, usage = clUse, help = {
|
[cc, help = {
|
||||||
"dryrun": "show command instead of executing",
|
"dryrun": "show command instead of executing",
|
||||||
"nimble": "use nimble as base command for compiling"
|
"nimble": "use nimble as base command for compiling"
|
||||||
}],
|
}],
|
||||||
[targets, usage = clUse],
|
[targets],
|
||||||
[release, usage = clUse, help = {
|
[release,
|
||||||
|
help = {
|
||||||
"target": "set target, may be repeated",
|
"target": "set target, may be repeated",
|
||||||
"bin": "set bin, may be repeated",
|
"bin": "set bin, may be repeated",
|
||||||
"dryrun": "show command instead of executing",
|
"dryrun": "show command instead of executing",
|
||||||
|
@ -151,6 +160,6 @@ when isMainModule:
|
||||||
"config-file": "path to config",
|
"config-file": "path to config",
|
||||||
"no-config": "ignore config file"
|
"no-config": "ignore config file"
|
||||||
},
|
},
|
||||||
short = {"verbose": 'V'}
|
short = {"verbose": 'V'}
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
|
@ -19,19 +19,19 @@ proc showConfig*(c: ForgeConfig) =
|
||||||
if args != "":
|
if args != "":
|
||||||
result.add fmt" | " & $args.bb("faint")
|
result.add fmt" | " & $args.bb("faint")
|
||||||
|
|
||||||
addLine $bbfmt"""
|
addLine $fmt"""
|
||||||
config =
|
config =
|
||||||
| [blue]nimble[/] {c.nimble}
|
| [blue]nimble[/] {c.nimble}
|
||||||
| [blue]outdir[/] {c.outdir}
|
| [blue]outdir[/] {c.outdir}
|
||||||
| [blue]format[/] {c.format}
|
| [blue]format[/] {c.format}
|
||||||
| [blue]version[/] {c.version}"""
|
| [blue]version[/] {c.version}""".bb
|
||||||
|
|
||||||
|
|
||||||
addLine $bb"| [green]targets[/]:"
|
addLine $"| [green]targets[/]:".bb
|
||||||
for target, args in c.targets:
|
for target, args in c.targets:
|
||||||
addLine addNameArgs(target, args)
|
addLine addNameArgs(target, args)
|
||||||
|
|
||||||
addLine $bb"| [green]bins[/]:"
|
addLine $"| [green]bins[/]:".bb
|
||||||
for bin, args in c.bins:
|
for bin, args in c.bins:
|
||||||
addline addNameArgs(bin, args)
|
addline addNameArgs(bin, args)
|
||||||
|
|
||||||
|
@ -41,7 +41,8 @@ proc loadConfigFile*(
|
||||||
f: string,
|
f: string,
|
||||||
load_targets: bool,
|
load_targets: bool,
|
||||||
load_bins: bool
|
load_bins: bool
|
||||||
): ForgeConfig =
|
): ForgeConfig =
|
||||||
|
|
||||||
let dict = loadConfig(f)
|
let dict = loadConfig(f)
|
||||||
|
|
||||||
# get the top level flags
|
# get the top level flags
|
||||||
|
@ -64,7 +65,7 @@ proc loadConfigFile*(
|
||||||
proc inferName(s: string, nimbleFile: string): string =
|
proc inferName(s: string, nimbleFile: string): string =
|
||||||
if s != "":
|
if s != "":
|
||||||
return s
|
return s
|
||||||
elif nimbleFile != "":
|
elif nimbleFile != "":
|
||||||
return nimbleFile.rsplit(".", maxsplit = 1)[0]
|
return nimbleFile.rsplit(".", maxsplit = 1)[0]
|
||||||
|
|
||||||
proc findNimbleFile(): string =
|
proc findNimbleFile(): string =
|
||||||
|
@ -111,7 +112,7 @@ proc newConfig*(
|
||||||
nimble: bool,
|
nimble: bool,
|
||||||
configFile: string,
|
configFile: string,
|
||||||
noConfig: bool
|
noConfig: bool
|
||||||
): ForgeConfig =
|
): ForgeConfig =
|
||||||
|
|
||||||
let nimbleFile = findNimbleFile()
|
let nimbleFile = findNimbleFile()
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import std/strutils
|
import std/strutils
|
||||||
|
|
||||||
import hwylterm
|
import bbansi
|
||||||
|
|
||||||
let prefix = "[bold magenta]forge[/] [yellow]||[/] ".bb
|
let prefix = "[bold magenta]forge[/] [yellow]||[/] ".bb
|
||||||
|
|
||||||
|
@ -14,4 +14,4 @@ template termErrQuit*(args: varargs[string | BbString, `$`]) =
|
||||||
termErr args
|
termErr args
|
||||||
quit 1
|
quit 1
|
||||||
|
|
||||||
export hwylterm
|
export bbansi
|
||||||
|
|
Loading…
Reference in a new issue