removed a bit of cruft from koch
This commit is contained in:
parent
8dadeebd08
commit
3b00d9cc7a
2 changed files with 21 additions and 29 deletions
49
koch.nim
49
koch.nim
|
|
@ -81,7 +81,7 @@ proc exec(cmd: string, errorcode: int = QuitFailure) =
|
||||||
echo(cmd)
|
echo(cmd)
|
||||||
if execShellCmd(cmd) != 0: quit("FAILURE", errorcode)
|
if execShellCmd(cmd) != 0: quit("FAILURE", errorcode)
|
||||||
|
|
||||||
proc tryExec(cmd: string): bool =
|
proc tryExec(cmd: string): bool =
|
||||||
echo(cmd)
|
echo(cmd)
|
||||||
result = execShellCmd(cmd) == 0
|
result = execShellCmd(cmd) == 0
|
||||||
|
|
||||||
|
|
@ -96,7 +96,7 @@ proc copyExe(source, dest: string) =
|
||||||
const
|
const
|
||||||
compileNimInst = "-d:useLibzipSrc tools/niminst/niminst"
|
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" %
|
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()])
|
[args, VersionAsString, compileNimInst, findNim()])
|
||||||
|
|
||||||
|
|
@ -114,13 +114,13 @@ proc nsis(args: string) =
|
||||||
# make sure we have generated the niminst executables:
|
# make sure we have generated the niminst executables:
|
||||||
buildTool("tools/niminst/niminst", args)
|
buildTool("tools/niminst/niminst", args)
|
||||||
buildTool("tools/nimgrep", args)
|
buildTool("tools/nimgrep", args)
|
||||||
# produce 'nimrod_debug.exe':
|
# produce 'nim_debug.exe':
|
||||||
exec "nim c compiler" / "nim.nim"
|
exec "nim c compiler" / "nim.nim"
|
||||||
copyExe("compiler/nim".exe, "bin/nim_debug".exe)
|
copyExe("compiler/nim".exe, "bin/nim_debug".exe)
|
||||||
exec(("tools" / "niminst" / "niminst --var:version=$# --var:mingw=mingw$#" &
|
exec(("tools" / "niminst" / "niminst --var:version=$# --var:mingw=mingw$#" &
|
||||||
" nsis compiler/nim") % [VersionAsString, $(sizeof(pointer)*8)])
|
" 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" %
|
exec("$# cc -r $# --var:version=$# --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" %
|
||||||
[findNim(), compileNimInst, VersionAsString])
|
[findNim(), compileNimInst, VersionAsString])
|
||||||
exec("sh ./install.sh $#" % args)
|
exec("sh ./install.sh $#" % args)
|
||||||
|
|
@ -139,12 +139,10 @@ proc pdf(args="") =
|
||||||
|
|
||||||
# -------------- boot ---------------------------------------------------------
|
# -------------- boot ---------------------------------------------------------
|
||||||
|
|
||||||
proc findStartNim: string =
|
proc findStartNim: string =
|
||||||
# we try several things before giving up:
|
# we try several things before giving up:
|
||||||
# * bin/nim
|
# * bin/nim
|
||||||
# * $PATH/nim
|
# * $PATH/nim
|
||||||
# * bin/nimrod
|
|
||||||
# * $PATH/nimrod
|
|
||||||
# If these fail, we try to build nim with the "build.(sh|bat)" script.
|
# If these fail, we try to build nim with the "build.(sh|bat)" script.
|
||||||
var nim = "nim".exe
|
var nim = "nim".exe
|
||||||
result = "bin" / nim
|
result = "bin" / nim
|
||||||
|
|
@ -152,34 +150,27 @@ proc findStartNim: string =
|
||||||
for dir in split(getEnv("PATH"), PathSep):
|
for dir in split(getEnv("PATH"), PathSep):
|
||||||
if existsFile(dir / nim): return dir / nim
|
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):
|
when defined(Posix):
|
||||||
const buildScript = "build.sh"
|
const buildScript = "build.sh"
|
||||||
if existsFile(buildScript):
|
if existsFile(buildScript):
|
||||||
if tryExec("./" & buildScript): return "bin" / nim
|
if tryExec("./" & buildScript): return "bin" / nim
|
||||||
else:
|
else:
|
||||||
const buildScript = "build.bat"
|
const buildScript = "build.bat"
|
||||||
if existsFile(buildScript):
|
if existsFile(buildScript):
|
||||||
if tryExec(buildScript): return "bin" / nim
|
if tryExec(buildScript): return "bin" / nim
|
||||||
|
|
||||||
echo("Found no nim compiler and every attempt to build one failed!")
|
echo("Found no nim compiler and every attempt to build one failed!")
|
||||||
quit("FAILURE")
|
quit("FAILURE")
|
||||||
|
|
||||||
proc thVersion(i: int): string =
|
proc thVersion(i: int): string =
|
||||||
result = ("compiler" / "nim" & $i).exe
|
result = ("compiler" / "nim" & $i).exe
|
||||||
|
|
||||||
proc boot(args: string) =
|
proc boot(args: string) =
|
||||||
var output = "compiler" / "nim".exe
|
var output = "compiler" / "nim".exe
|
||||||
var finalDest = "bin" / "nim".exe
|
var finalDest = "bin" / "nim".exe
|
||||||
# default to use the 'c' command:
|
# default to use the 'c' command:
|
||||||
let bootOptions = if args.len == 0 or args.startsWith("-"): "c" else: ""
|
let bootOptions = if args.len == 0 or args.startsWith("-"): "c" else: ""
|
||||||
|
|
||||||
copyExe(findStartNim(), 0.thVersion)
|
copyExe(findStartNim(), 0.thVersion)
|
||||||
for i in 0..2:
|
for i in 0..2:
|
||||||
echo "iteration: ", i+1
|
echo "iteration: ", i+1
|
||||||
|
|
@ -204,7 +195,7 @@ const
|
||||||
".bzrignore", "nim", "nim.exe", "koch", "koch.exe", ".gitignore"
|
".bzrignore", "nim", "nim.exe", "koch", "koch.exe", ".gitignore"
|
||||||
]
|
]
|
||||||
|
|
||||||
proc cleanAux(dir: string) =
|
proc cleanAux(dir: string) =
|
||||||
for kind, path in walkDir(dir):
|
for kind, path in walkDir(dir):
|
||||||
case kind
|
case kind
|
||||||
of pcFile:
|
of pcFile:
|
||||||
|
|
@ -215,25 +206,25 @@ proc cleanAux(dir: string) =
|
||||||
removeFile(path)
|
removeFile(path)
|
||||||
of pcDir:
|
of pcDir:
|
||||||
case splitPath(path).tail
|
case splitPath(path).tail
|
||||||
of "nimcache":
|
of "nimcache":
|
||||||
echo "removing dir: ", path
|
echo "removing dir: ", path
|
||||||
removeDir(path)
|
removeDir(path)
|
||||||
of "dist", ".git", "icons": discard
|
of "dist", ".git", "icons": discard
|
||||||
else: cleanAux(path)
|
else: cleanAux(path)
|
||||||
else: discard
|
else: discard
|
||||||
|
|
||||||
proc removePattern(pattern: string) =
|
proc removePattern(pattern: string) =
|
||||||
for f in walkFiles(pattern):
|
for f in walkFiles(pattern):
|
||||||
echo "removing: ", f
|
echo "removing: ", f
|
||||||
removeFile(f)
|
removeFile(f)
|
||||||
|
|
||||||
proc clean(args: string) =
|
proc clean(args: string) =
|
||||||
if existsFile("koch.dat"): removeFile("koch.dat")
|
if existsFile("koch.dat"): removeFile("koch.dat")
|
||||||
removePattern("web/*.html")
|
removePattern("web/*.html")
|
||||||
removePattern("doc/*.html")
|
removePattern("doc/*.html")
|
||||||
cleanAux(getCurrentDir())
|
cleanAux(getCurrentDir())
|
||||||
for kind, path in walkDir(getCurrentDir() / "build"):
|
for kind, path in walkDir(getCurrentDir() / "build"):
|
||||||
if kind == pcDir:
|
if kind == pcDir:
|
||||||
echo "removing dir: ", path
|
echo "removing dir: ", path
|
||||||
removeDir(path)
|
removeDir(path)
|
||||||
|
|
||||||
|
|
@ -276,7 +267,7 @@ when defined(withUpdate):
|
||||||
"Local branch must be ahead of it. Exiting...")
|
"Local branch must be ahead of it. Exiting...")
|
||||||
else:
|
else:
|
||||||
quit("An error has occurred.")
|
quit("An error has occurred.")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
echo("No repo or executable found!")
|
echo("No repo or executable found!")
|
||||||
when defined(haveZipLib):
|
when defined(haveZipLib):
|
||||||
|
|
@ -293,7 +284,7 @@ when defined(withUpdate):
|
||||||
quit("Error reading archive.")
|
quit("Error reading archive.")
|
||||||
else:
|
else:
|
||||||
quit("No failback available. Exiting...")
|
quit("No failback available. Exiting...")
|
||||||
|
|
||||||
echo("Starting update...")
|
echo("Starting update...")
|
||||||
boot(args)
|
boot(args)
|
||||||
echo("Update complete!")
|
echo("Update complete!")
|
||||||
|
|
@ -346,8 +337,8 @@ proc temp(args: string) =
|
||||||
copyExe(output, finalDest)
|
copyExe(output, finalDest)
|
||||||
if args.len > 0: exec(finalDest & " " & args)
|
if args.len > 0: exec(finalDest & " " & args)
|
||||||
|
|
||||||
proc showHelp() =
|
proc showHelp() =
|
||||||
quit(HelpText % [VersionAsString & spaces(44-len(VersionAsString)),
|
quit(HelpText % [VersionAsString & spaces(44-len(VersionAsString)),
|
||||||
CompileDate, CompileTime], QuitSuccess)
|
CompileDate, CompileTime], QuitSuccess)
|
||||||
|
|
||||||
var op = initOptParser()
|
var op = initOptParser()
|
||||||
|
|
|
||||||
1
todo.txt
1
todo.txt
|
|
@ -62,6 +62,7 @@ Bugs
|
||||||
- scopes are still broken for generic instantiation!
|
- scopes are still broken for generic instantiation!
|
||||||
- blocks can "export" an identifier but the CCG generates {} for them ...
|
- blocks can "export" an identifier but the CCG generates {} for them ...
|
||||||
- ConcreteTypes in a 'case' means we don't check for duplicated case branches
|
- ConcreteTypes in a 'case' means we don't check for duplicated case branches
|
||||||
|
- typedesc matches a generic type T!
|
||||||
|
|
||||||
|
|
||||||
version 0.9.x
|
version 0.9.x
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue