*/*: remove depfile support via patched Nim

This commit is contained in:
Anna “CyberTailor” 2023-04-25 16:02:03 +05:00
parent e5a9c7048c
commit 325bfa4fea
Signed by: CyberTaIlor
GPG Key ID: E7B76EDC50864BB1
3 changed files with 7 additions and 21 deletions

View File

@ -14,7 +14,6 @@
.Op Fl Fl nimbleDir : Ns Ar path
.Op Fl Fl nim : Ns Ar path
.Op Fl Fl url : Ns Ar url
.Op Fl Fl useDepfile
.Op nim opts...
.Ar sourceDir
.Op Ar buildDir
@ -61,10 +60,6 @@ file.
Some packages specify their dependencies using URLs and
.Nm
is unable to find them unless such metadata file exists.
.
.It Fl Fl useDepfile
Tell the Nim compiler to make a depfile.
Only available with patched Nim.
.El
.Pp
All unrecognized flags are passed to the Nim compiler.

View File

@ -10,7 +10,6 @@ type
Options* = object
showHelp*: bool
debug*: bool
useDepfile*: bool
nimbleDir*: string
binDir*: string
nim*: string # Nim compiler location
@ -23,8 +22,8 @@ type
const
help* = """
Usage: nimbus [-h] [--debug] [--useDepfile] [--nimbleDir:path] [--binDir:path]
[--nim:path] [--url:url] [nim opts...] sourceDir [buildDir]
Usage: nimbus [-h] [--debug] [--nimbleDir:path] [--binDir:path] [--nim:path]
[--url:url] [nim opts...] sourceDir [buildDir]
positional arguments:
sourceDir
@ -33,7 +32,6 @@ positional arguments:
optional arguments:
-h, --help show this help message and exit
--debug Show debugging information.
--useDepfile Tell Nim compiler to make a depfile.
--nimbleDir:path Nimble directory (default: $1).
--binDir:path Executable directory (default: $2).
--nim:path Nim compiler (default: nim).
@ -160,7 +158,7 @@ func parseFlag(flag, val: string, result: var Options, kind = cmdLongOption) =
case f
of "help", "h": result.showHelp = true
of "debug": result.debug = true
of "usedepfile": result.useDepfile = true
of "usedepfile": discard
of "nimbledir": result.nimbleDir = val
of "bindir": result.binDir = val
of "nim": result.nim = val
@ -180,7 +178,6 @@ proc parseCmdLine*(): Options =
# set default values here
result.debug = false
result.showHelp = false
result.useDepfile = false
var argc = 0
for kind, key, val in getOpt():

View File

@ -21,22 +21,17 @@ proc processDependencies(requires: seq[string], options: Options): seq[string] =
else:
result.add(dep.getPath(options).quoteShell)
proc application(ninja: File, input, output: string, paths: seq[string],
useDepfile: bool) =
proc application(ninja: File, input, output: string, paths: seq[string]) =
debug(fmt"[build.ninja] Generating target for application '{output}'")
let depfile = quoteShell(output & ".d")
var vars = newStringTable()
if paths.len != 0:
vars["paths"] = "-p:" & paths.join(" -p:")
if useDepfile:
let depfile = quoteShell(output & ".d")
vars["depfileopt"] = "--depfile:" & depfile
ninja.build([output],
rule = "nimc",
inputs = [input],
implicit = if useDepfile: newSeq[string]()
else: @["PHONY"],
variables = vars
)
@ -152,8 +147,7 @@ proc setup(options: Options) =
if pkgInfo.bin.len != 0:
debug("[build.ninja] Generating 'nimc' rule")
ninja.rule("nimc",
command = "$nim $nimflags c --nimcache:$nimcache -o:$out " &
"$depfileopt $paths $in",
command = "$nim $nimflags c --nimcache:$nimcache -o:$out $paths $in",
description = "Compiling Nim application $out",
depfile = "$out.d",
deps = "gcc",
@ -184,7 +178,7 @@ proc setup(options: Options) =
for bin in pkgInfo.bin:
let output = bin.lastPathPart.addFileExt(ExeExt)
let input = pkgInfo.getSourceDir(options) / bin.addFileExt("nim")
ninja.application(input, output, depPaths, options.useDepfile)
ninja.application(input, output, depPaths)
ninja.newline()
debug("[build.ninja] Generating 'all' target")