diff options
author | Andreas Rumpf <andreas@andreas-desktop> | 2010-08-08 23:50:06 +0200 |
---|---|---|
committer | Andreas Rumpf <andreas@andreas-desktop> | 2010-08-08 23:50:06 +0200 |
commit | 040c57f0a566b257ab7fcca4c6557be4b3c76f24 (patch) | |
tree | a5fa842ab305997a8a00b74b17c894c47efe6081 /rod | |
parent | 25ff3913ec98af6aa920e94e15df88eb4021e224 (diff) | |
download | Nim-040c57f0a566b257ab7fcca4c6557be4b3c76f24.tar.gz |
added missing files
Diffstat (limited to 'rod')
-rwxr-xr-x | rod/noprefix2.nim | 15 | ||||
-rwxr-xr-x | rod/tccgen.nim | 73 |
2 files changed, 88 insertions, 0 deletions
diff --git a/rod/noprefix2.nim b/rod/noprefix2.nim new file mode 100755 index 000000000..6fbdaaddc --- /dev/null +++ b/rod/noprefix2.nim @@ -0,0 +1,15 @@ +# strip those silly GTK/ATK prefixes... + +import + expandimportc, os + +const + filelist = [ + ("gtk/pango", "pango"), + ("gtk/pangoutils", "pango") + ] + +for filename, prefix in items(filelist): + var f = addFileExt(filename, "nim") + main("lib/newwrap" / f, "lib/newwrap" / filename & ".new.nim", prefix) + diff --git a/rod/tccgen.nim b/rod/tccgen.nim new file mode 100755 index 000000000..3e3c311a4 --- /dev/null +++ b/rod/tccgen.nim @@ -0,0 +1,73 @@ +# +# +# The Nimrod Compiler +# (c) Copyright 2010 Andreas Rumpf +# +# See the file "copying.txt", included in this +# distribution, for details about the copyright. +# + +import + os, strutils, options, msgs, tinyc + +{.compile: "../tinyc/libtcc.c".} + +proc tinyCErrorHandler(closure: pointer, msg: cstring) {.cdecl.} = + rawMessage(errGenerated, $msg) + +proc initTinyCState: PccState = + result = openCCState() + setErrorFunc(result, nil, tinyCErrorHandler) + +var + gTinyC = initTinyCState() + libIncluded = false + +proc addFile(filename: string) = + if addFile(gTinyC, filename) != 0'i32: + rawMessage(errCannotOpenFile, filename) + +proc setupEnvironment = + #defineSymbol(gTinyC, "__x86_64__", nil) + #defineSymbol(gTinyC, "__linux__", nil) + #defineSymbol(gTinyC, "__linux", nil) + var nimrodDir = getPrefixDir() + + addIncludePath(gTinyC, libpath) + when defined(windows): + addSysincludePath(gTinyC, nimrodDir / "tinyc/win32/include") + addSysincludePath(gTinyC, nimrodDir / "tinyc/include") + when defined(windows): + defineSymbol(gTinyC, "__i386__", nil) + defineSymbol(gTinyC, "_WIN32", nil) + # we need Mingw's headers too: + var gccbin = getConfigVar("gcc.path") % ["nimrod", nimrodDir] + addSysincludePath(gTinyC, gccbin /../ "include") + #addFile(nimrodDir / r"tinyc\win32\wincrt1.o") + addFile(nimrodDir / r"tinyc\win32\alloca86.o") + addFile(nimrodDir / r"tinyc\win32\chkstk.o") + #addFile(nimrodDir / r"tinyc\win32\crt1.o") + + #addFile(nimrodDir / r"tinyc\win32\dllcrt1.o") + #addFile(nimrodDir / r"tinyc\win32\dllmain.o") + addFile(nimrodDir / r"tinyc\win32\libtcc1.o") + + #addFile(nimrodDir / r"tinyc\win32\lib\crt1.c") + #addFile(nimrodDir / r"tinyc\lib\libtcc1.c") + else: + addSysincludePath(gTinyC, "/usr/include") + +proc compileCCode*(ccode: string) = + if not libIncluded: + libIncluded = true + setupEnvironment() + discard compileString(gTinyC, ccode) + +proc run*() = + var a: array[0..1, cstring] + a[0] = "" + a[1] = "" + var err = tinyc.run(gTinyC, 0'i32, addr(a)) != 0'i32 + closeCCState(gTinyC) + if err: rawMessage(errExecutionOfProgramFailed, "") + |