Skip to content

Commit 4965d45

Browse files
committed
improve docs/naming a bit
1 parent 8c4fccb commit 4965d45

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

tools/nimdigger.nim

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -87,21 +87,21 @@ type
8787
oldnew: string # eg: v0.20.0~10..v0.20.0
8888
bisectCmd: string # eg: bin/nim c --hints:off --skipparentcfg --skipusercfg $timn_D/tests/nim/all/t12329.nim 'arg1 bar' 'arg2'
8989
bisectBugfix: bool
90-
CsourcesOpt = ref object
90+
CsourcesState = ref object ## represents csources or csources_v1 repos
9191
url: string
92-
dir: string
92+
dir: string # e.g. /pathto/Nim/csources
9393
rev: string
9494
binDir: string
95-
csourcesBuildArgs: string
95+
csourcesBuildArgs: string ## extra args to build csources
9696
revs: seq[string]
9797
fetch: bool
9898
name: string
9999
nimCsourcesExe: string
100100
DiggerState = ref object ## nimdigger internal state
101-
coptv0, coptv1: CsourcesOpt
102-
binDir: string
103-
nimDir: string
104-
rev: string
101+
nimDir: string # e.g.: /pathto/Nim
102+
binDir: string # e.g.: $nimDir/bin
103+
rev: string # e.g.: hash obtained from `git rev-parse HEAD`
104+
csourceV0, csourceV1: CsourcesState
105105

106106
const
107107
csourcesRevs = "v0.9.4 v0.13.0 v0.15.2 v0.16.0 v0.17.0 v0.17.2 v0.18.0 v0.19.0 v0.20.0 64e34778fa7e114b4afc753c7845dee250584167".split
@@ -205,7 +205,7 @@ proc toNimCsourcesExe(binDir: string, name: string, rev: string): string =
205205
let rev2 = rev.replace(".", "_")
206206
result = binDir / fmt"nim_nimdigger_{name}_{rev2}{ExeExt2}"
207207

208-
proc buildCsourcesRev(copt: CsourcesOpt) =
208+
proc buildCsourcesRev(copt: CsourcesState) =
209209
# sync with `_nimBuildCsourcesIfNeeded`
210210
let csourcesExe = toNimCsourcesExe(copt.binDir, copt.name, copt.rev)
211211
if csourcesExe.fileExists:
@@ -231,7 +231,7 @@ proc buildCsourcesRev(copt: CsourcesOpt) =
231231
else:
232232
copyFile(oldNim, csourcesExe)
233233

234-
proc buildCsourcesAnyRevs(copt: CsourcesOpt) =
234+
proc buildCsourcesAnyRevs(copt: CsourcesState) =
235235
for rev in copt.revs:
236236
copt.rev = rev
237237
buildCsourcesRev(copt)
@@ -243,18 +243,18 @@ proc toCsourcesRev(rev: string): string =
243243
if ver >= a.parseNimGitTag: return a
244244
return csourcesRevs[1] # because v0.9.4 seems broken
245245

246-
proc getNimCsourcesAnyExe(state: DiggerState): CsourcesOpt =
246+
proc getCsourcesState(state: DiggerState): CsourcesState =
247247
let file = state.nimDir/"config/build_config.txt" # for newer nim versions, this file specifies correct csources_v1 to use
248248
if file.fileExists:
249249
let tab = file.readFile.parseKeyVal
250-
result = state.coptv1
250+
result = state.csourceV1
251251
result.rev = tab["nim_csourcesHash"]
252252
elif gitIsAncestorOf(state.nimDir, "a9b62de", state.rev): # commit that introduced csources_v1
253-
result = state.coptv1
253+
result = state.csourceV1
254254
result.rev = csourcesV1Revs[0]
255255
else:
256256
let tag = gitLatestTag(state.nimDir)
257-
result = state.coptv0
257+
result = state.csourceV0
258258
result.rev = tag.toCsourcesRev
259259
result.nimCsourcesExe = toNimCsourcesExe(state.binDir, result.name, result.rev)
260260

@@ -272,9 +272,9 @@ proc main2(opt: DiggerOpt) =
272272
else:
273273
createDir nimDir.parentDir
274274
gitClone("https://github.com/nim-lang/Nim", nimDir)
275-
state.coptv0 = CsourcesOpt(dir: nimDir/"csources", url: "https://github.com/nim-lang/csources.git", name: "csources", revs: csourcesRevs)
276-
state.coptv1 = CsourcesOpt(dir: nimDir/"csources_v1", url: "https://github.com/nim-lang/csources_v1.git", name: "csources_v1", revs: csourcesV1Revs)
277-
for copt in [state.coptv0, state.coptv1]:
275+
state.csourceV0 = CsourcesState(dir: nimDir/"csources", url: "https://github.com/nim-lang/csources.git", name: "csources", revs: csourcesRevs)
276+
state.csourceV1 = CsourcesState(dir: nimDir/"csources_v1", url: "https://github.com/nim-lang/csources_v1.git", name: "csources_v1", revs: csourcesV1Revs)
277+
for copt in [state.csourceV0, state.csourceV1]:
278278
copt.binDir = state.binDir
279279
copt.fetch = opt.fetch
280280
if opt.buildAllCsources:
@@ -289,7 +289,7 @@ proc main2(opt: DiggerOpt) =
289289
let isCached = nimDiggerExe.fileExists
290290
echo fmt"digger getting nim: {nimDiggerExe} cached: {isCached}"
291291
if not isCached:
292-
let copt = getNimCsourcesAnyExe(state)
292+
let copt = getCsourcesState(state)
293293
buildCsourcesRev(copt)
294294
discard runCmdOutput(fmt"{copt.nimCsourcesExe} c -o:{nimDiggerExe} -d:release --hints:off --skipUserCfg compiler/nim.nim", nimDir)
295295
copyFile(nimDiggerExe, state.binDir / "nim" & ExeExt2)

0 commit comments

Comments
 (0)