Skip to content

Commit

Permalink
skipCompile test
Browse files Browse the repository at this point in the history
  • Loading branch information
tinygiant98 committed Mar 7, 2024
1 parent 3a39237 commit b74dd6d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/nasher/compile.nim
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ proc getIncludesUpdated(file: string,
updated[file] = true
return true

proc getUpdated(updatedNSS: var seq[string], files: seq[string]): seq[string] =
proc getUpdated(updatedNSS: var seq[string], files, skips: seq[string]): seq[string] =
let included = files.getIncludes
var updated: Table[string, bool]

for file in updatedNss:
updated[file] = true

for file in files:
if file.getIncludesUpdated(included, updated):
if file.getIncludesUpdated(included, updated) and file notin skips:
result.add(file)

updatedNss = result
Expand Down Expand Up @@ -171,7 +171,7 @@ proc compile*(opts: Options, target: Target, updatedNss: var seq[string], exitCo
debug("Recompiling", "executable script " & file)
updatedNss.add(file)

scripts = getUpdated(updatedNss, files)
scripts = getUpdated(updatedNss, files, target.skips)
for script in scripts:
## Ensure any updated scripts have their compiled version deleted so
## they will be re-compiled if compilation fails for some reason.
Expand Down
9 changes: 9 additions & 0 deletions src/nasher/utils/shared.nim
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,20 @@ iterator walkSourceFiles*(target: Target): string =
if file notin excluded:
yield file

iterator walkSkippedFiles*(target: Target): string =
const globOpts = defaultGlobOptions - {GlobOption.DirLinks} + {GlobOption.Absolute}
for pattern in target.skips:
for file in walkGlob(pattern, options = globOpts):
yield file

proc getSourceFiles*(target: Target): seq[string] =
## Returns all files in the source tree matching include patterns while not
## matching exclude patterns.
toSeq(target.walkSourceFiles).deduplicate

proc getSkippedFiles*(target: Target): seq[string] =
toSeq(target.walkSkippedFiles).deduplicate

proc getTimeDiff*(a, b: Time): int =
## Compares two times and returns the difference in seconds. If 0, the files
## are the same age. If positive, a is newer than b. If negative, b is newer
Expand Down
4 changes: 3 additions & 1 deletion src/nasher/utils/target.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type
Target* = ref object
name*, description*, file*, branch*, parent*: string
modName*, modMinGameVersion*, modDescription*: string
includes*, excludes*, filters*, flags*, groups*: seq[string]
includes*, excludes*, filters*, flags*, groups*, skips*: seq[string]
variables*: seq[KeyValuePair]
rules*: seq[Rule]

Expand Down Expand Up @@ -212,6 +212,7 @@ proc parseCfgPackage(s: Stream, filename = "nasher.cfg"): seq[Target] =
of "source", "include": target.includes.add(e.value)
of "exclude": target.excludes.add(e.value)
of "filter": target.filters.add(e.value)
of "skipCompile": target.skips.add(e.value)
# Unused, but kept for backwards compatibility
of "version", "url", "author": discard
else:
Expand All @@ -225,6 +226,7 @@ proc parseCfgPackage(s: Stream, filename = "nasher.cfg"): seq[Target] =
of "include": target.includes.add(e.value)
of "exclude": target.excludes.add(e.value)
of "filter": target.filters.add(e.value)
of "skipCompile": target.skips.add(e.value)
else:
p.raisePackageError("invalid key $1 for section [$2$3]" %
[e.key.escape, if context.len > 0: context & "." else: "", section])
Expand Down

0 comments on commit b74dd6d

Please sign in to comment.