attempt to re-enable trimcc tool

This commit is contained in:
Araq 2017-01-06 10:58:42 +01:00
commit d54539a648

View file

@ -1,6 +1,6 @@
# Trim C compiler installation to a minimum # Trim C compiler installation to a minimum
import strutils, os, pegs, strtabs, math, threadpool, times import strutils, os, pegs, strtabs, math, times
const const
Essential = """gcc.exe g++.exe gdb.exe ld.exe as.exe c++.exe cpp.exe cc1.exe Essential = """gcc.exe g++.exe gdb.exe ld.exe as.exe c++.exe cpp.exe cc1.exe
@ -10,7 +10,7 @@ fenv.h fmtmsg.h fnmatch.h ftw.h errno.h glob.h gtmath.h if.h in.h ipc.h
langinfo.h locale.h math.h mman.h netdb.h nl_types.h poll.h pthread.h pwd.h langinfo.h locale.h math.h mman.h netdb.h nl_types.h poll.h pthread.h pwd.h
sched.h select.h semaphore.h signal.h socket.h spawn.h stat.h statvfs.h stdio.h sched.h select.h semaphore.h signal.h socket.h spawn.h stat.h statvfs.h stdio.h
stdlib.h string.h strings.h tcp.h time.h types.h ucontext.h uio.h utsname.h stdlib.h string.h strings.h tcp.h time.h types.h ucontext.h uio.h utsname.h
unistd.h wait.h varargs.h windows.h zlib.h libgdi32.a libcomdlg32.a unistd.h wait.h varargs.h windows.h zlib.h
""".split """.split
proc includes(headerpath, headerfile: string, whitelist: StringTableRef) = proc includes(headerpath, headerfile: string, whitelist: StringTableRef) =
@ -20,7 +20,7 @@ proc includes(headerpath, headerfile: string, whitelist: StringTableRef) =
comment <- '/*' @ '*/' / '//' .* comment <- '/*' @ '*/' / '//' .*
ws <- (comment / \s+)* """: ws <- (comment / \s+)* """:
let m = matches[0].extractFilename let m = matches[0].extractFilename
if whitelist[m] != "processed": if whitelist.getOrDefault(m) != "processed":
whitelist[m] = "found" whitelist[m] = "found"
proc processIncludes(dir: string, whitelist: StringTableRef) = proc processIncludes(dir: string, whitelist: StringTableRef) =
@ -29,10 +29,10 @@ proc processIncludes(dir: string, whitelist: StringTableRef) =
of pcFile: of pcFile:
let name = extractFilename(path) let name = extractFilename(path)
if ('.' notin name and "include" in path) or ("c++" in path): if ('.' notin name and "include" in path) or ("c++" in path):
let n = whitelist[name] let n = whitelist.getOrDefault(name)
if n != "processed": whitelist[name] = "found" if n != "processed": whitelist[name] = "found"
if name.endswith(".h"): if name.endswith(".h"):
let n = whitelist[name] let n = whitelist.getOrDefault(name)
if n == "found": includes(path, name, whitelist) if n == "found": includes(path, name, whitelist)
of pcDir: processIncludes(path, whitelist) of pcDir: processIncludes(path, whitelist)
else: discard else: discard
@ -72,8 +72,8 @@ proc newName(f: string): string =
proc ccStillWorks(): bool = proc ccStillWorks(): bool =
const const
c1 = r"nim c --verbosity:0 --force_build koch" c1 = r"nim c --verbosity:0 --force_build koch"
c2 = r"nim c --verbosity:0 --force_build --threads:on --out:tempOne.exe trimcc" c2 = r"nim c --verbosity:0 --force_build --threads:on --out:tempOne.exe tools/trimcc"
c3 = r"nim c --verbosity:0 --force_build --threads:on --out:tempTwo.exe fakeDeps" c3 = r"nim c --verbosity:0 --force_build --threads:on --out:tempTwo.exe tools/fakeDeps"
c4 = r".\koch.exe" c4 = r".\koch.exe"
c5 = r".\tempOne.exe" c5 = r".\tempOne.exe"
c6 = r".\tempTwo.exe" c6 = r".\tempTwo.exe"