Skip to content

Commit

Permalink
update build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jcosborn committed Apr 27, 2022
1 parent 9cc96d6 commit 931ba5f
Show file tree
Hide file tree
Showing 8 changed files with 347 additions and 169 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ It currently supports

Installation guide: [INSTALL.md](INSTALL.md)

Build guide: [BUILD.md](BUILD.md)

Further examples:
- [tests/examples](tests/examples)
19 changes: 12 additions & 7 deletions build/Makefile.in
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
# Simple Makefile for QEX builds
# Hands off build commands to the nimscript Makefile.nims
# This will then load config options from config.nims
# Extra arguments to Nim can be provided in NIMFLAGS, e.g.
# make NIMFLAGS="--rangeChecks:on --assertions:on" <myprog>
# Hands off build commands to the nimscript qex/build/Makefile.nims
# This will then load config options from qexconfig.nims
# Extra arguments to Nim can be provided in ARGS, e.g.
# make ARGS="--rangeChecks:on --assertions:on" <myprog>
# or directly on the command line
# make -- --rangeChecks:on --assertions:on <myprog>
# or
# make :--rangeChecks:on :--assertions:on <myprog>
# run `make help` for more details and options

NIM = @@NIM
#NIMFLAGS = "-d:defPrec=S"
#ARGS = "-d:defPrec=S"

runNim:
@echo "Passing build commands to Makefile.nims"
$(NIM) $(NIMFLAGS) qex/build/Makefile.nims $(MAKECMDGOALS)
@echo "Passing build commands to qex/build/Makefile.nims"
$(NIM) qex/build/Makefile.nims $(ARGS) $(MAKECMDGOALS)

%: runNim
@ # do nothing silently
Expand Down
54 changes: 20 additions & 34 deletions build/build.nims
Original file line number Diff line number Diff line change
@@ -1,56 +1,42 @@
import os, strUtils

var nim = paramStr(0)
var nimargs = newSeq[string](0)
var nimuserargs = newSeq[string](0)
var script = ""
var args = newSeq[string](0)
var qexDir = thisDir().parentDir

for i in 1..paramCount():
let p = paramStr(i)
if p[0]=='-':
nimargs.add p
nimuserargs.add p
elif p[0]==':':
let t = p[1..^1]
if t[0]=='-':
nimuserargs.add t
else:
nimuserargs.add "-d:" & t
else:
if script=="": script = p
else: args.add p

echo "Using Nim: ", nim
echo "Nim user args: ", nimargs
echo "Nim user args: ", nimuserargs
echo "Makefile script: ", script
echo "Script args: ", args
echo "QEX dir: ", qexDir

include "buildTasks.nims"

var iarg = 0
while iarg<args.len:
currentArg = args[iarg]
var found = false
for t in configTasks:
#echo t.cmd
if args[iarg].len>=t.cmd.len and args[iarg][0..(t.cmd.len-1)] == t.cmd:
echo "Processing config arg: ", currentArg
found = true
t.f()
if not found: break # assume it is a build arg
inc iarg
setUserNimFlags(nimuserargs)
let cmdargs = parseOpts(args)

if iarg == args.len:
for t in buildTasks:
if t.cmd == "help":
t.f()

while iarg<args.len:
currentArg = args[iarg]
echo "Processing build arg: ", currentArg
var found = false
for t in buildTasks:
if args[iarg].len>=t.cmd.len and args[iarg][0..(t.cmd.len-1)] == t.cmd:
found = true
t.f()
if not found: # check if source
let failed = tryBuildSource(currentArg)
if failed:
echo "Error: invalid build arg: ", currentArg
quit(1)
inc iarg
if cmdargs.len == 0:
runTask("help")
else:
var t = getTask(cmdargs[0])
if t.cmd == "":
runMake(cmdargs)
else:
let cargs = cmdargs[1..^1]
runTask(t, cargs)
Loading

0 comments on commit 931ba5f

Please sign in to comment.