removed a bit of cruft from koch

This commit is contained in:
Araq
2015-04-22 20:42:36 +02:00
parent 8dadeebd08
commit 3b00d9cc7a
2 changed files with 21 additions and 29 deletions

View File

@@ -81,7 +81,7 @@ proc exec(cmd: string, errorcode: int = QuitFailure) =
echo(cmd)
if execShellCmd(cmd) != 0: quit("FAILURE", errorcode)
proc tryExec(cmd: string): bool =
proc tryExec(cmd: string): bool =
echo(cmd)
result = execShellCmd(cmd) == 0
@@ -96,7 +96,7 @@ proc copyExe(source, dest: string) =
const
compileNimInst = "-d:useLibzipSrc tools/niminst/niminst"
proc csource(args: string) =
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()])
@@ -114,13 +114,13 @@ proc nsis(args: string) =
# make sure we have generated the niminst executables:
buildTool("tools/niminst/niminst", args)
buildTool("tools/nimgrep", args)
# produce 'nimrod_debug.exe':
# produce 'nim_debug.exe':
exec "nim c compiler" / "nim.nim"
copyExe("compiler/nim".exe, "bin/nim_debug".exe)
exec(("tools" / "niminst" / "niminst --var:version=$# --var:mingw=mingw$#" &
" nsis compiler/nim") % [VersionAsString, $(sizeof(pointer)*8)])
proc install(args: string) =
proc install(args: string) =
exec("$# cc -r $# --var:version=$# --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" %
[findNim(), compileNimInst, VersionAsString])
exec("sh ./install.sh $#" % args)
@@ -139,12 +139,10 @@ proc pdf(args="") =
# -------------- boot ---------------------------------------------------------
proc findStartNim: string =
proc findStartNim: string =
# we try several things before giving up:
# * bin/nim
# * $PATH/nim
# * bin/nimrod
# * $PATH/nimrod
# If these fail, we try to build nim with the "build.(sh|bat)" script.
var nim = "nim".exe
result = "bin" / nim
@@ -152,34 +150,27 @@ proc findStartNim: string =
for dir in split(getEnv("PATH"), PathSep):
if existsFile(dir / nim): return dir / nim
# try the old "nimrod.exe":
var nimrod = "nimrod".exe
result = "bin" / nimrod
if existsFile(result): return
for dir in split(getEnv("PATH"), PathSep):
if existsFile(dir / nim): return dir / nimrod
when defined(Posix):
const buildScript = "build.sh"
if existsFile(buildScript):
if existsFile(buildScript):
if tryExec("./" & buildScript): return "bin" / nim
else:
const buildScript = "build.bat"
if existsFile(buildScript):
if existsFile(buildScript):
if tryExec(buildScript): return "bin" / nim
echo("Found no nim compiler and every attempt to build one failed!")
quit("FAILURE")
proc thVersion(i: int): string =
proc thVersion(i: int): string =
result = ("compiler" / "nim" & $i).exe
proc boot(args: string) =
var output = "compiler" / "nim".exe
var finalDest = "bin" / "nim".exe
# default to use the 'c' command:
let bootOptions = if args.len == 0 or args.startsWith("-"): "c" else: ""
copyExe(findStartNim(), 0.thVersion)
for i in 0..2:
echo "iteration: ", i+1
@@ -204,7 +195,7 @@ const
".bzrignore", "nim", "nim.exe", "koch", "koch.exe", ".gitignore"
]
proc cleanAux(dir: string) =
proc cleanAux(dir: string) =
for kind, path in walkDir(dir):
case kind
of pcFile:
@@ -215,25 +206,25 @@ proc cleanAux(dir: string) =
removeFile(path)
of pcDir:
case splitPath(path).tail
of "nimcache":
of "nimcache":
echo "removing dir: ", path
removeDir(path)
of "dist", ".git", "icons": discard
else: cleanAux(path)
else: discard
proc removePattern(pattern: string) =
for f in walkFiles(pattern):
proc removePattern(pattern: string) =
for f in walkFiles(pattern):
echo "removing: ", f
removeFile(f)
proc clean(args: string) =
proc clean(args: string) =
if existsFile("koch.dat"): removeFile("koch.dat")
removePattern("web/*.html")
removePattern("doc/*.html")
cleanAux(getCurrentDir())
for kind, path in walkDir(getCurrentDir() / "build"):
if kind == pcDir:
if kind == pcDir:
echo "removing dir: ", path
removeDir(path)
@@ -276,7 +267,7 @@ when defined(withUpdate):
"Local branch must be ahead of it. Exiting...")
else:
quit("An error has occurred.")
else:
echo("No repo or executable found!")
when defined(haveZipLib):
@@ -293,7 +284,7 @@ when defined(withUpdate):
quit("Error reading archive.")
else:
quit("No failback available. Exiting...")
echo("Starting update...")
boot(args)
echo("Update complete!")
@@ -346,8 +337,8 @@ proc temp(args: string) =
copyExe(output, finalDest)
if args.len > 0: exec(finalDest & " " & args)
proc showHelp() =
quit(HelpText % [VersionAsString & spaces(44-len(VersionAsString)),
proc showHelp() =
quit(HelpText % [VersionAsString & spaces(44-len(VersionAsString)),
CompileDate, CompileTime], QuitSuccess)
var op = initOptParser()

View File

@@ -62,6 +62,7 @@ Bugs
- scopes are still broken for generic instantiation!
- blocks can "export" an identifier but the CCG generates {} for them ...
- ConcreteTypes in a 'case' means we don't check for duplicated case branches
- typedesc matches a generic type T!
version 0.9.x