add nimCompile to simplify koch; add nimfind to koch tools (#9723)

This commit is contained in:
Timothee Cour
2018-11-15 11:32:31 -08:00
committed by Andreas Rumpf
parent 3fe8b4f69d
commit 2eb14bdd41
3 changed files with 29 additions and 20 deletions

View File

@@ -117,10 +117,11 @@ proc bundleNimbleSrc(latest: bool) =
proc bundleNimbleExe(latest: bool) =
bundleNimbleSrc(latest)
# now compile Nimble and copy it to $nim/bin for the installer.ini
# to pick it up:
nimexec("c -d:release --nilseqs:on dist/nimble/src/nimble.nim")
copyExe("dist/nimble/src/nimble".exe, "bin/nimble".exe)
# installer.ini expects it under $nim/bin
nimCompile("dist/nimble/src/nimble.nim", options = "-d:release --nilseqs:on")
proc buildNimfind() =
nimCompile("tools/nimfind.nim", options = "-d:release")
proc buildNimble(latest: bool) =
# old installations created nim/nimblepkg/*.nim files. We remove these
@@ -146,27 +147,24 @@ proc buildNimble(latest: bool) =
else:
exec("git checkout -f stable")
exec("git pull")
nimexec("c --noNimblePath --nilseqs:on -d:release " & installDir / "src/nimble.nim")
copyExe(installDir / "src/nimble".exe, "bin/nimble".exe)
nimCompile(installDir / "src/nimble.nim", options = "--noNimblePath --nilseqs:on -d:release")
proc bundleNimsuggest() =
nimexec "c -d:release -o:" & ("bin/nimsuggest".exe) &
" nimsuggest/nimsuggest.nim"
nimCompile("nimsuggest/nimsuggest.nim", options = "-d:release")
proc buildVccTool() =
nimexec("c -o:bin/vccexe.exe tools/vccenv/vccexe")
nimCompile("tools/vccenv/vccexe.nim")
proc bundleWinTools() =
nimexec("c tools/finish.nim")
copyExe("tools/finish".exe, "finish".exe)
removeFile("tools/finish".exe)
# TODO: consider building under `bin` instead of `.`
nimCompile("tools/finish.nim", outputDir = "")
buildVccTool()
nimexec("c -o:bin/nimgrab.exe -d:ssl tools/nimgrab.nim")
nimexec("c -o:bin/nimgrep.exe tools/nimgrep.nim")
nimCompile("tools/nimgrab.nim", options = "-d:ssl")
nimCompile("tools/nimgrep.nim")
when false:
# not yet a tool worth including
nimexec(r"c --cc:vcc --app:gui -o:bin\downloader.exe -d:ssl --noNimblePath " &
r"--path:..\ui tools\downloader.nim")
nimCompile(r"tools\downloader.nim", options = r"--cc:vcc --app:gui -d:ssl --noNimblePath --path:..\ui")
proc zip(latest: bool; args: string) =
bundleNimbleExe(latest)
@@ -200,12 +198,11 @@ proc buildTool(toolname, args: string) =
proc buildTools(latest: bool) =
bundleNimsuggest()
nimexec "c -d:release -o:" & ("bin/nimgrep".exe) & " tools/nimgrep.nim"
nimCompile("tools/nimgrep.nim", options = "-d:release")
when defined(windows): buildVccTool()
nimexec "c -o:" & ("bin/nimpretty".exe) & " nimpretty/nimpretty.nim"
nimCompile("nimpretty/nimpretty.nim", options = "-d:release")
buildNimble(latest)
buildNimfind()
proc nsis(latest: bool; args: string) =
bundleNimbleExe(latest)

View File

@@ -52,8 +52,18 @@ proc execCleanPath*(cmd: string,
putEnv("PATH", prevPath)
proc nimexec*(cmd: string) =
# Consider using `nimCompile` instead
exec findNim() & " " & cmd
proc nimCompile*(input: string, outputDir = "bin", mode = "c", options = "") =
# TODO: simplify pending https://github.com/nim-lang/Nim/issues/9513
var cmd = findNim() & " " & mode
let output = outputDir / input.splitFile.name.exe
cmd.add " -o:" & output
cmd.add " " & options
cmd.add " " & input
exec cmd
const
pdf = """
doc/manual.rst

2
tools/nimfind.nims Normal file
View File

@@ -0,0 +1,2 @@
--define:nimfind
--define:nimcore