Skip to content

Commit

Permalink
add nimCompile to simplify koch; add nimfind to koch tools (#9723)
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour authored and Araq committed Nov 15, 2018
1 parent 3fe8b4f commit 2eb14bd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
37 changes: 17 additions & 20 deletions koch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions tools/kochdocs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tools/nimfind.nims
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--define:nimfind
--define:nimcore

0 comments on commit 2eb14bd

Please sign in to comment.