2727 os, strutils, parseopt, osproc, streams
2828
2929import tools / kochdocs
30+ import tools / deps
3031
3132const VersionAsString = system.NimVersion
3233
@@ -115,52 +116,25 @@ proc copyExe(source, dest: string) =
115116
116117const
117118 compileNimInst = " tools/niminst/niminst"
119+ distDir = " dist"
118120
119121proc csource (args: string ) =
120122 nimexec ((" cc $1 -r $3 --var:version=$2 --var:mingw=none csource " &
121123 " --main:compiler/nim.nim compiler/installer.ini $1" ) %
122124 [args, VersionAsString , compileNimInst])
123125
124126proc bundleC2nim (args: string ) =
125- if not dirExists (" dist/c2nim/.git" ):
126- exec (" git clone https://github.com/nim-lang/c2nim.git dist/c2nim" )
127+ cloneDependency (distDir, " https://github.com/nim-lang/c2nim.git" )
127128 nimCompile (" dist/c2nim/c2nim" ,
128129 options = " --noNimblePath --path:. " & args)
129130
130131proc bundleNimbleExe (latest: bool , args: string ) =
131- if not dirExists (" dist/nimble/.git" ):
132- exec (" git clone https://github.com/nim-lang/nimble.git dist/nimble" )
133- if not latest:
134- withDir (" dist/nimble" ):
135- exec (" git fetch" )
136- exec (" git checkout " & NimbleStableCommit )
132+ let commit = if latest: " HEAD" else : NimbleStableCommit
133+ cloneDependency (distDir, " https://github.com/nim-lang/nimble.git" ,
134+ commit = commit, allowBundled = true )
137135 # installer.ini expects it under $nim/bin
138136 nimCompile (" dist/nimble/src/nimble.nim" ,
139- options = " -d:release --nilseqs:on " & args)
140-
141- proc buildNimble (latest: bool , args: string ) =
142- # if koch is used for a tar.xz, build the dist/nimble we shipped
143- # with the tarball:
144- var installDir = " dist/nimble"
145- if not latest and dirExists (installDir) and not dirExists (" dist/nimble/.git" ):
146- discard " don't do the git dance"
147- else :
148- if not dirExists (" dist/nimble/.git" ):
149- if dirExists (installDir):
150- var id = 0
151- while dirExists (" dist/nimble" & $ id):
152- inc id
153- installDir = " dist/nimble" & $ id
154- exec (" git clone https://github.com/nim-lang/nimble.git " & installDir)
155- withDir (installDir):
156- if latest:
157- exec (" git checkout -f master" )
158- exec (" git pull" )
159- else :
160- exec (" git fetch" )
161- exec (" git checkout " & NimbleStableCommit )
162- nimCompile (installDir / " src/nimble.nim" ,
163- options = " --noNimblePath --nilseqs:on -d:release " & args)
137+ options = " -d:release --noNimblePath --nilseqs:on " & args)
164138
165139proc bundleNimsuggest (args: string ) =
166140 nimCompileFold (" Compile nimsuggest" , " nimsuggest/nimsuggest.nim" ,
@@ -318,10 +292,10 @@ proc boot(args: string) =
318292 # in order to use less memory, we split the build into two steps:
319293 # --compileOnly produces a $project.json file and does not run GCC/Clang.
320294 # jsonbuild then uses the $project.json file to build the Nim binary.
321- exec " $# $# $# $# --nimcache:$# --compileOnly compiler" / " nim.nim" %
322- [nimi, bootOptions, extraOption, args, smartNimcache ]
323- exec " $# jsonscript $# --nimcache:$# compiler" / " nim.nim" %
324- [nimi, args, smartNimcache ]
295+ exec " $# $# $# --nimcache:$# $# --compileOnly compiler" / " nim.nim" %
296+ [nimi, bootOptions, extraOption, smartNimcache, args ]
297+ exec " $# jsonscript --nimcache:$# $# compiler" / " nim.nim" %
298+ [nimi, smartNimcache, args ]
325299
326300 if sameFileContent (output, i.thVersion):
327301 copyExe (output, finalDest)
@@ -479,7 +453,7 @@ proc runCI(cmd: string) =
479453 when defined (posix): # appveyor (on windows) didn't run this
480454 kochExecFold (" Boot" , " boot" )
481455 # boot without -d:nimHasLibFFI to make sure this still works
482- kochExecFold (" Boot in release mode" , " boot -d:release -d:danger " )
456+ kochExecFold (" Boot in release mode" , " boot -d:release" )
483457
484458 # # build nimble early on to enable remainder to depend on it if needed
485459 kochExecFold (" Build Nimble" , " nimble" )
@@ -491,7 +465,7 @@ proc runCI(cmd: string) =
491465 if getEnv (" NIM_TEST_PACKAGES" , " false" ) == " true" :
492466 execFold (" Test selected Nimble packages" , " nim c -r testament/testament cat nimble-packages" )
493467 else :
494- buildTools () # altenatively, kochExec "tools --toolsNoNimble"
468+ buildTools ()
495469
496470 # # run tests
497471 execFold (" Test nimscript" , " nim e tests/test_nimscript.nims" )
@@ -628,13 +602,13 @@ when isMainModule:
628602 of " temp" : temp (op.cmdLineRest)
629603 of " xtemp" : xtemp (op.cmdLineRest)
630604 of " wintools" : bundleWinTools (op.cmdLineRest)
631- of " nimble" : buildNimble (latest, op.cmdLineRest)
605+ of " nimble" : bundleNimbleExe (latest, op.cmdLineRest)
632606 of " nimsuggest" : bundleNimsuggest (op.cmdLineRest)
633607 of " toolsnonimble" :
634608 buildTools (op.cmdLineRest)
635609 of " tools" :
636610 buildTools (op.cmdLineRest)
637- buildNimble (latest, op.cmdLineRest)
611+ bundleNimbleExe (latest, op.cmdLineRest)
638612 of " pushcsource" , " pushcsources" : pushCsources ()
639613 of " valgrind" : valgrind (op.cmdLineRest)
640614 of " c2nim" : bundleC2nim (op.cmdLineRest)
0 commit comments