diff options
author | Araq <rumpf_a@web.de> | 2013-09-01 15:54:32 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2013-09-01 15:54:32 +0200 |
commit | 6825a69a70f177d7997f3e673b24c6c6c2d7449b (patch) | |
tree | 0a09571c3e9707478a7e21d0fe352abd0da97e0d | |
parent | 8087f51d145c553c6bbca3987015ed5f87d0d654 (diff) | |
download | Nim-6825a69a70f177d7997f3e673b24c6c6c2d7449b.tar.gz |
-d:nocaas mode for easier bootstrapping on exotic OSes (Haiku)
-rw-r--r-- | compiler/msgs.nim | 22 | ||||
-rw-r--r-- | compiler/options.nim | 1 | ||||
-rw-r--r-- | compiler/service.nim | 35 | ||||
-rw-r--r-- | koch.nim | 1 |
4 files changed, 37 insertions, 22 deletions
diff --git a/compiler/msgs.nim b/compiler/msgs.nim index 3e5304358..dd7bad943 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -8,7 +8,10 @@ # import - options, strutils, os, tables, sockets, ropes, platform + options, strutils, os, tables, ropes, platform + +when useCaas: + import sockets type TMsgKind* = enum @@ -529,14 +532,19 @@ var gWarnCounter*: int = 0 gErrorMax*: int = 1 # stop after gErrorMax errors gSilence*: int # == 0 if we produce any output at all - stdoutSocket*: TSocket -proc SuggestWriteln*(s: string) = - if gSilence == 0: - if isNil(stdoutSocket): Writeln(stdout, s) - else: +when useCaas: + var stdoutSocket*: TSocket + +proc SuggestWriteln*(s: string) = + if gSilence == 0: + when useCaas: + if isNil(stdoutSocket): Writeln(stdout, s) + else: + Writeln(stdout, s) + stdoutSocket.send(s & "\c\L") + else: Writeln(stdout, s) - stdoutSocket.send(s & "\c\L") proc SuggestQuit*() = if not isServing: diff --git a/compiler/options.nim b/compiler/options.nim index 2b25b2650..3c91d4439 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -15,6 +15,7 @@ const useEffectSystem* = true hasFFI* = defined(useFFI) newScopeForIf* = true + useCaas* = not defined(noCaas) type # please make sure we have under 32 options # (improves code efficiency a lot!) diff --git a/compiler/service.nim b/compiler/service.nim index 8e8fe20bf..1de83af7c 100644 --- a/compiler/service.nim +++ b/compiler/service.nim @@ -9,11 +9,13 @@ ## Implements the "compiler as a service" feature. -import - sockets, +import times, commands, options, msgs, nimconf, extccomp, strutils, os, platform, parseopt +when useCaas: + import sockets + # We cache modules and the dependency graph. However, we don't check for # file changes but expect the client to tell us about them, otherwise the # repeated CRC calculations may turn out to be too slow. @@ -80,19 +82,22 @@ proc serve*(action: proc (){.nimcall.}) = FlushFile(stdout) of "tcp", "": - var server = Socket() - let p = getConfigVar("server.port") - let port = if p.len > 0: parseInt(p).TPort else: 6000.TPort - server.bindAddr(port, getConfigVar("server.address")) - var inp = "".TaintedString - server.listen() - new(stdoutSocket) - while true: - accept(server, stdoutSocket) - stdoutSocket.readLine(inp) - execute inp.string - stdoutSocket.send("\c\L") - stdoutSocket.close() + when useCaas: + var server = Socket() + let p = getConfigVar("server.port") + let port = if p.len > 0: parseInt(p).TPort else: 6000.TPort + server.bindAddr(port, getConfigVar("server.address")) + var inp = "".TaintedString + server.listen() + new(stdoutSocket) + while true: + accept(server, stdoutSocket) + stdoutSocket.readLine(inp) + execute inp.string + stdoutSocket.send("\c\L") + stdoutSocket.close() + else: + quit "server.type not supported; compiler built without caas support" else: echo "Invalid server.type:", typ quit 1 diff --git a/koch.nim b/koch.nim index 30ad8c597..97fcf5b2c 100644 --- a/koch.nim +++ b/koch.nim @@ -52,6 +52,7 @@ Boot options: (not needed on Windows) -d:useFFI build Nimrod with FFI support at compile time -d:nativeStacktrace use native stack traces (only for Mac OS X or Linux) + -d:noCaas build Nimrod without CAAS support """ proc exe(f: string): string = return addFileExt(f, ExeExt) |