Skip to content

Commit

Permalink
koch, ci: integrate language definition building
Browse files Browse the repository at this point in the history
  • Loading branch information
zerbina committed Jan 22, 2025
1 parent ce19d32 commit 0ed40f1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ jobs:
- name: Build koch
run: nim c -d:nimStrictMode --outdir:bin koch.nim

- name: Build language definitions
run: bin/koch build-defs

- name: Build passtool
run: bin/koch single passtool -d:nimStrictMode -d:release

Expand Down
25 changes: 25 additions & 0 deletions koch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Commands:
all [args] builds all programs
single <name> [args] builds the single program with the given name
generate [dir] generates the various language-related modules
build-defs verifies the language definitions and generates
the textual representation for them
"""
Programs: seq[(string, string, bool, bool)] = @[
("tester", "tools/tester.nim", true, true),
Expand Down Expand Up @@ -56,6 +58,13 @@ proc compile(file: sink string, name: string, extra: varargs[string]): bool =
args.add file
result = run(nimExe, args)

proc check(file: sink string, extra: varargs[string]): bool =
## Runs the ``check`` command on the given NimSkull `file`.
var args = @["check"]
args.add extra
args.add file
result = run(nimExe, args)

proc saneSplit(s: string): seq[string] =
## Compared to the normal split, returns an empty sequence for an empty
## string.
Expand Down Expand Up @@ -155,6 +164,20 @@ proc generate(args: string): bool =

result = true

proc buildDefs(args: string): bool =
## Handles verifying the language definitions and producing the artifacts
## based on them.
if args.len > 0:
return false

# there's nothing to do with the compiled language definition, making sure
# the macro succeeds is enough
if not check(getCurrentDir() / "languages" / "source.nim"):
echo "Failure"
quit(1)

result = true

proc showHelp(): bool =
## Shows the help text.
echo HelpText
Expand Down Expand Up @@ -184,6 +207,8 @@ while true:
buildSingle(opts.cmdLineRest)
of "generate":
generate(opts.cmdLineRest)
of "build-defs":
buildDefs(opts.cmdLineRest)
of "help":
showHelp()
else:
Expand Down

0 comments on commit 0ed40f1

Please sign in to comment.