From b74dd6d2a2e312473c7c7222cf62970f2ba3739d Mon Sep 17 00:00:00 2001 From: Ed Burke Date: Thu, 7 Mar 2024 11:52:46 -0500 Subject: [PATCH] skipCompile test --- src/nasher/compile.nim | 6 +++--- src/nasher/utils/shared.nim | 9 +++++++++ src/nasher/utils/target.nim | 4 +++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/nasher/compile.nim b/src/nasher/compile.nim index f3cd775..9f3ac6b 100644 --- a/src/nasher/compile.nim +++ b/src/nasher/compile.nim @@ -104,7 +104,7 @@ 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] @@ -112,7 +112,7 @@ proc getUpdated(updatedNSS: var seq[string], files: seq[string]): seq[string] = 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 @@ -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. diff --git a/src/nasher/utils/shared.nim b/src/nasher/utils/shared.nim index e07f8bc..94ac111 100644 --- a/src/nasher/utils/shared.nim +++ b/src/nasher/utils/shared.nim @@ -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 diff --git a/src/nasher/utils/target.nim b/src/nasher/utils/target.nim index 0e93944..ddc7cf7 100644 --- a/src/nasher/utils/target.nim +++ b/src/nasher/utils/target.nim @@ -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] @@ -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: @@ -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])