mirror of
https://github.com/daylinmorgan/forge.git
synced 2024-11-13 20:47:53 -06:00
Compare commits
7 commits
19919e1dd9
...
9840e6ea04
Author | SHA1 | Date | |
---|---|---|---|
9840e6ea04 | |||
096443f5ea | |||
09a9265343 | |||
2118c5d05c | |||
212076b6d2 | |||
f3ac3d7722 | |||
c71d50dc9b |
10 changed files with 69 additions and 66 deletions
|
@ -1,5 +1,3 @@
|
||||||
nimble
|
|
||||||
|
|
||||||
[target]
|
[target]
|
||||||
x86_64-linux-gnu
|
x86_64-linux-gnu
|
||||||
aarch64-linux-gnu
|
aarch64-linux-gnu
|
||||||
|
|
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
|
@ -14,7 +14,7 @@ jobs:
|
||||||
|
|
||||||
- uses: jiro4989/setup-nim-action@v1
|
- uses: jiro4989/setup-nim-action@v1
|
||||||
with:
|
with:
|
||||||
nim-version: ${{ env.NIM_VERSION }}
|
nim-version: 2.0.0
|
||||||
|
|
||||||
- uses: goto-bus-stop/setup-zig@v2
|
- uses: goto-bus-stop/setup-zig@v2
|
||||||
|
|
||||||
|
|
2
.github/workflows/nightly.yml
vendored
2
.github/workflows/nightly.yml
vendored
|
@ -17,7 +17,7 @@ jobs:
|
||||||
build-artifacts:
|
build-artifacts:
|
||||||
needs: check-commits
|
needs: check-commits
|
||||||
if: ${{ needs.check-commits.outputs.quit != 'true' }}
|
if: ${{ needs.check-commits.outputs.quit != 'true' }}
|
||||||
uses: daylinmorgan/actions/.github/workflows/build-nim-forge.yml@main
|
uses: ./.github/workflows/build.yml
|
||||||
|
|
||||||
generate-release:
|
generate-release:
|
||||||
needs: build-artifacts
|
needs: build-artifacts
|
||||||
|
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,2 +1,6 @@
|
||||||
/bin
|
/bin
|
||||||
/dist
|
/dist
|
||||||
|
|
||||||
|
# atlas
|
||||||
|
*.workspace
|
||||||
|
src/nim.cfg
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
version = "2023.1001"
|
version = "2023.1002"
|
||||||
author = "Daylin Morgan"
|
author = "Daylin Morgan"
|
||||||
description = "build nim binaries for all the platforms"
|
description = "build nim binaries for all the platforms"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
@ -8,7 +8,9 @@ binDir = "bin"
|
||||||
|
|
||||||
|
|
||||||
requires "nim >= 2.0.0",
|
requires "nim >= 2.0.0",
|
||||||
"cligen"
|
"cligen",
|
||||||
|
"https://github.com/daylinmorgan/bbansi#head"
|
||||||
|
|
||||||
|
|
||||||
import strformat
|
import strformat
|
||||||
|
|
||||||
|
|
16
nimble.lock
16
nimble.lock
|
@ -1,16 +0,0 @@
|
||||||
{
|
|
||||||
"version": 2,
|
|
||||||
"packages": {
|
|
||||||
"cligen": {
|
|
||||||
"version": "1.6.14",
|
|
||||||
"vcsRevision": "bee21f2d0878d4eba4631fd8b67370e4778424de",
|
|
||||||
"url": "https://github.com/c-blake/cligen.git",
|
|
||||||
"downloadMethod": "git",
|
|
||||||
"dependencies": [],
|
|
||||||
"checksums": {
|
|
||||||
"sha1": "195164d6a417c5393ee8aac1d1c2dfb0d45574b1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tasks": {}
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
import std/[os, osproc, sequtils, strformat, strutils, tables, terminal]
|
import std/[os, osproc, sequtils, strformat, strutils, tables]
|
||||||
|
|
||||||
import forge/[config, utils, term, zig]
|
import forge/[config, utils, term, zig]
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ proc genFlags(target: string, args: seq[string] = @[]): seq[string] =
|
||||||
proc targets() =
|
proc targets() =
|
||||||
## show available targets
|
## show available targets
|
||||||
let targetList = zigTargets()
|
let targetList = zigTargets()
|
||||||
termEcho styleBright, fgGreen, "available targets:"
|
termEcho "[bold green]available targets:".bb
|
||||||
stderr.writeLine targetList.columns
|
stderr.writeLine targetList.columns
|
||||||
|
|
||||||
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]) =
|
||||||
|
@ -85,17 +85,16 @@ proc release(
|
||||||
checkTargets(cfg.targets.keys.toSeq())
|
checkTargets(cfg.targets.keys.toSeq())
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
termEcho $cfg
|
cfg.showConfig
|
||||||
|
|
||||||
if dryrun:
|
if dryrun:
|
||||||
termEcho styleBright, fgBlue, "dry run...see below for commands"
|
termEcho "[bold blue]dry run...see below for commands".bb
|
||||||
|
|
||||||
let
|
let
|
||||||
baseCmd = if nimble or cfg.nimble: "nimble" else: "nim"
|
baseCmd = if nimble or cfg.nimble: "nimble" else: "nim"
|
||||||
rest = parseArgs(args)
|
rest = parseArgs(args)
|
||||||
|
|
||||||
termEcho styleBright, fgYellow,
|
termEcho fmt"[bold yellow]compiling {cfg.bins.len} binaries for {cfg.targets.len} targets".bb
|
||||||
&"compiling {cfg.bins.len} binaries for {cfg.targets.len} targets"
|
|
||||||
|
|
||||||
for t, tArgs in cfg.targets:
|
for t, tArgs in cfg.targets:
|
||||||
for b, bArgs in cfg.bins:
|
for b, bArgs in cfg.bins:
|
||||||
|
@ -118,7 +117,7 @@ proc release(
|
||||||
stderr.writeLine cmd
|
stderr.writeLine cmd
|
||||||
else:
|
else:
|
||||||
if verbose:
|
if verbose:
|
||||||
termEcho styleBright, "cmd: ", ansiResetCode, cmd
|
termEcho fmt"[bold]cmd[/]: {cmd}".bb
|
||||||
let errCode = execCmd cmd
|
let errCode = execCmd cmd
|
||||||
if errCode != 0:
|
if errCode != 0:
|
||||||
termErr "cmd: ", cmd
|
termErr "cmd: ", cmd
|
||||||
|
@ -129,7 +128,7 @@ when isMainModule:
|
||||||
zigExists()
|
zigExists()
|
||||||
|
|
||||||
const
|
const
|
||||||
customMulti = "${doc}Usage:\n $command {SUBCMD} [sub-command options & parameters]\n\nsubcommands:\n$subcmds"
|
customMulti = "Usage:\n $command {SUBCMD} [sub-command options & parameters]\n\nsubcommands:\n$subcmds"
|
||||||
vsn = staticExec "git describe --tags --always HEAD"
|
vsn = staticExec "git describe --tags --always HEAD"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import std/[parsecfg, tables, os, strutils, strformat]
|
import std/[parsecfg, tables, os, strutils, strformat]
|
||||||
|
import term
|
||||||
|
|
||||||
type
|
type
|
||||||
ForgeConfig* = object
|
ForgeConfig* = object
|
||||||
|
@ -10,36 +11,52 @@ type
|
||||||
version*: string
|
version*: string
|
||||||
nimble*: bool
|
nimble*: bool
|
||||||
|
|
||||||
proc `$`*(c: ForgeConfig): string =
|
proc showConfig*(c: ForgeConfig) =
|
||||||
var lines: seq[string] = @[]
|
var lines: string = ""
|
||||||
lines.add "config ="
|
template addLine(l: string) = lines.add(l & "\n")
|
||||||
lines.add "| nimble " & $c.nimble
|
proc addNameArgs(name, args: string): string =
|
||||||
lines.add "| outdir " & c.outdir
|
result.add fmt"| {name}"
|
||||||
lines.add "| format " & c.format
|
if args != "":
|
||||||
lines.add "| version " & c.version
|
result.add fmt" | " & $args.bb("faint")
|
||||||
lines.add "| targets:"
|
|
||||||
|
addLine $fmt"""
|
||||||
|
config =
|
||||||
|
| [blue]nimble[/] {c.nimble}
|
||||||
|
| [blue]outdir[/] {c.outdir}
|
||||||
|
| [blue]format[/] {c.format}
|
||||||
|
| [blue]version[/] {c.version}""".bb
|
||||||
|
|
||||||
|
|
||||||
|
addLine $"| [green]targets[/]:".bb
|
||||||
for target, args in c.targets:
|
for target, args in c.targets:
|
||||||
lines.add "| " & target & (if args != "": "|" & args else: "")
|
addLine addNameArgs(target, args)
|
||||||
lines.add "| bins:"
|
|
||||||
|
addLine $"| [green]bins[/]:".bb
|
||||||
for bin, args in c.bins:
|
for bin, args in c.bins:
|
||||||
lines.add "| " & bin & (if args != "": "|" & args else: "")
|
addline addNameArgs(bin, args)
|
||||||
|
|
||||||
lines.join("\n")
|
termEcho lines
|
||||||
|
|
||||||
proc loadConfigFile*(f: string, load_targets: bool,
|
proc loadConfigFile*(
|
||||||
load_bins: bool): ForgeConfig =
|
f: string,
|
||||||
let
|
load_targets: bool,
|
||||||
dict = loadConfig(f)
|
load_bins: bool
|
||||||
base = dict.getOrDefault("")
|
): ForgeConfig =
|
||||||
|
|
||||||
|
let dict = loadConfig(f)
|
||||||
|
|
||||||
|
# get the top level flags
|
||||||
|
if dict.hasKey(""):
|
||||||
|
let base = dict[""]
|
||||||
|
result.nimble = base.hasKey("nimble")
|
||||||
|
result.outdir = base.getOrDefault("outdir")
|
||||||
|
result.name = base.getOrDefault("name")
|
||||||
|
result.version = base.getOrDefault("version")
|
||||||
|
result.format = base.getOrDefault("format")
|
||||||
|
|
||||||
result.targets = newOrderedTable[string, string]()
|
result.targets = newOrderedTable[string, string]()
|
||||||
result.bins = newOrderedTable[string, string]()
|
result.bins = newOrderedTable[string, string]()
|
||||||
|
|
||||||
result.nimble = base.hasKey("nimble")
|
|
||||||
result.outdir = base.getOrDefault("outdir")
|
|
||||||
result.name = base.getOrDefault("name")
|
|
||||||
result.version = base.getOrDefault("version")
|
|
||||||
result.format = base.getOrDefault("format")
|
|
||||||
if dict.hasKey("target") and load_targets:
|
if dict.hasKey("target") and load_targets:
|
||||||
result.targets = dict.getOrDefault("target")
|
result.targets = dict.getOrDefault("target")
|
||||||
if dict.hasKey("bin") and load_bins:
|
if dict.hasKey("bin") and load_bins:
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
import std/terminal
|
import std/strutils
|
||||||
|
|
||||||
# TODO support NO_COLOR for these
|
import bbansi
|
||||||
let prefix = ansiForegroundColorCode(fgMagenta, bright = true) & "forge" &
|
|
||||||
ansiResetCode & ansiForegroundColorCode(fgYellow) & " || " & ansiResetCode
|
|
||||||
|
|
||||||
template termEcho*(args: varargs[untyped]) =
|
let prefix = "[bold magenta]forge[/] [yellow]||[/] ".bb
|
||||||
stderr.styledWriteLine(prefix, args)
|
|
||||||
|
|
||||||
template termErr*(args: varargs[untyped]) =
|
template termEcho*(args: varargs[string | BbString, `$`]) =
|
||||||
stderr.styledWriteLine(prefix, fgRed, "error ", fgDefault, args)
|
stderr.writeLine $prefix, args.join(" ")
|
||||||
|
|
||||||
template termErrQuit*(args: varargs[untyped]) =
|
template termErr*(args: varargs[string | BbString, `$`]) =
|
||||||
termErr(args)
|
stderr.writeLine $prefix, $"[red]error ||[/] ".bb, args.join(" ")
|
||||||
|
|
||||||
|
template termErrQuit*(args: varargs[string | BbString, `$`]) =
|
||||||
|
termErr args
|
||||||
quit 1
|
quit 1
|
||||||
|
|
||||||
|
export bbansi
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import std/[json, os, osproc, terminal]
|
import std/[json, os, osproc]
|
||||||
|
|
||||||
import term
|
import term
|
||||||
|
|
||||||
proc zigTargets*(): seq[string] =
|
proc zigTargets*(): seq[string] =
|
||||||
|
@ -26,7 +25,7 @@ template callZig*(zigCmd: string) =
|
||||||
|
|
||||||
proc zigExists*() =
|
proc zigExists*() =
|
||||||
if (findExe "zig") == "":
|
if (findExe "zig") == "":
|
||||||
termErr "zig not found"
|
termErr "[red]zig not found".bb
|
||||||
termErr " forge requires a working installation of zig"
|
termErr " forge requires a working installation of zig"
|
||||||
termErr " see: https://ziglang.org/download/"
|
termErr " see: https://ziglang.org/download/"
|
||||||
quit 1
|
quit 1
|
||||||
|
|
Loading…
Reference in a new issue