diff --git a/build_tools.sh b/build_tools.sh new file mode 100644 index 0000000000..4d867b0ad1 --- /dev/null +++ b/build_tools.sh @@ -0,0 +1,3 @@ +./bin/nim c --noNimblePath -p:compiler -o:./bin/nimble dist/nimble/src/nimble.nim +./bin/nim c --noNimblePath -p:compiler -o:./bin/nimsuggest dist/nimsuggest/nimsuggest.nim +./bin/nim c -o:./bin/nimgrep tools/nimgrep.nim diff --git a/compiler/installer.ini b/compiler/installer.ini index 4fc03dd1d0..c09218aa8b 100644 --- a/compiler/installer.ini +++ b/compiler/installer.ini @@ -50,6 +50,7 @@ Files: "readme.txt;install.txt;contributors.txt;copying.txt" Files: "makefile" Files: "koch.nim" Files: "install_nimble.nims" +Files: "install_tools.nims" Files: "icons/nim.ico" Files: "icons/nim.rc" @@ -77,7 +78,8 @@ Files: "lib" [Other] Files: "examples" -#Files: "dist/nimble" +Files: "dist/nimble" +Files: "dist/nimsuggest" Files: "tests" diff --git a/install_tools.nims b/install_tools.nims new file mode 100644 index 0000000000..6ecc545a5a --- /dev/null +++ b/install_tools.nims @@ -0,0 +1,15 @@ + +import ospaths + +mode = ScriptMode.Verbose + +let nimbleExe = "./bin/nimble".toExe +selfExec "c --noNimblePath -p:compiler -o:" & nimbleExe & + " dist/nimble/src/nimble.nim" + +let nimsugExe = "./bin/nimsuggest".toExe +selfExec "c --noNimblePath -p:compiler -o:" & nimsugExe & + " dist/nimsuggest/nimsuggest.nim" + +let nimgrepExe = "./bin/nimgrep".toExe +selfExec "c -o:./bin/nimgrep tools/nimgrep.nim" diff --git a/koch.nim b/koch.nim index fab0e67cb7..1e78abbca1 100644 --- a/koch.nim +++ b/koch.nim @@ -123,6 +123,8 @@ proc testUnixInstall() = execCleanPath("./koch boot -d:release", destDir / "bin") # check the docs build: execCleanPath("./koch web", destDir / "bin") + # check nimble builds: + execCleanPath("./bin/nim e install_tools.nims") # check the tests work: execCleanPath("./koch tests", destDir / "bin") else: @@ -149,7 +151,7 @@ proc csource(args: string) = exec("$4 cc $1 -r $3 --var:version=$2 --var:mingw=none csource --main:compiler/nim.nim compiler/installer.ini $1" % [args, VersionAsString, compileNimInst, findNim()]) -proc bundleNimble() = +proc bundleNimbleSrc() = if dirExists("dist/nimble/.git"): exec("git --git-dir dist/nimble/.git pull") else: @@ -157,20 +159,33 @@ proc bundleNimble() = let tags = execProcess("git --git-dir dist/nimble/.git tag -l v*").splitLines let tag = tags[^1] exec("git --git-dir dist/nimble/.git checkout " & tag) + +proc bundleNimbleExe() = + bundleNimbleSrc() # now compile Nimble and copy it to $nim/bin for the installer.ini # to pick it up: exec(findNim() & " c dist/nimble/src/nimble.nim") copyExe("dist/nimble/src/nimble".exe, "bin/nimble".exe) +proc bundleNimsuggest(buildExe: bool) = + if dirExists("dist/nimsuggest/.git"): + exec("git --git-dir dist/nimsuggest/.git pull") + else: + exec("git clone https://github.com/nim-lang/nimsuggest.git dist/nimsuggest") + if buildExe: + exec(findNim() & " c --noNimblePath -p:compiler dist/nimsuggest/nimsuggest.nim") + copyExe("dist/nimsuggest/nimsuggest".exe, "bin/nimsuggest".exe) + proc zip(args: string) = - bundleNimble() + bundleNimbleSrc() exec("$3 cc -r $2 --var:version=$1 --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" % [VersionAsString, compileNimInst, findNim()]) exec("$# --var:version=$# --var:mingw=none --main:compiler/nim.nim zip compiler/installer.ini" % ["tools/niminst/niminst".exe, VersionAsString]) proc xz(args: string) = - bundleNimble() + bundleNimbleSrc() + bundleNimsuggest(false) exec("$3 cc -r $2 --var:version=$1 --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" % [VersionAsString, compileNimInst, findNim()]) exec("$# --var:version=$# --var:mingw=none --main:compiler/nim.nim xz compiler/installer.ini" % @@ -181,7 +196,8 @@ proc buildTool(toolname, args: string) = copyFile(dest="bin"/ splitFile(toolname).name.exe, source=toolname.exe) proc nsis(args: string) = - bundleNimble() + bundleNimbleExe() + bundleNimsuggest(true) # make sure we have generated the niminst executables: buildTool("tools/niminst/niminst", args) #buildTool("tools/nimgrep", args) diff --git a/web/download.rst b/web/download.rst index 583398c204..11c130c23c 100644 --- a/web/download.rst +++ b/web/download.rst @@ -45,6 +45,7 @@ Now open a terminal and follow these instructions: ``cd ~/programs/nim``. * run ``sh build.sh``. * Add ``$your_install_dir/bin`` to your PATH. +* To build associated tools like ``nimble`` and ``nimsuggest`` run ``nim e install_tools.nims``. After restarting your terminal, you should be able to run ``nim -v`` which should show you the version of Nim you just installed.