-d:nocaas mode for easier bootstrapping on exotic OSes (Haiku)

This commit is contained in:
Araq 2013-09-01 15:54:32 +02:00
commit 6825a69a70
4 changed files with 37 additions and 22 deletions

View file

@ -8,7 +8,10 @@
# #
import import
options, strutils, os, tables, sockets, ropes, platform options, strutils, os, tables, ropes, platform
when useCaas:
import sockets
type type
TMsgKind* = enum TMsgKind* = enum
@ -529,14 +532,19 @@ var
gWarnCounter*: int = 0 gWarnCounter*: int = 0
gErrorMax*: int = 1 # stop after gErrorMax errors gErrorMax*: int = 1 # stop after gErrorMax errors
gSilence*: int # == 0 if we produce any output at all gSilence*: int # == 0 if we produce any output at all
stdoutSocket*: TSocket
proc SuggestWriteln*(s: string) = when useCaas:
if gSilence == 0: var stdoutSocket*: TSocket
if isNil(stdoutSocket): Writeln(stdout, s)
else: 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) Writeln(stdout, s)
stdoutSocket.send(s & "\c\L")
proc SuggestQuit*() = proc SuggestQuit*() =
if not isServing: if not isServing:

View file

@ -15,6 +15,7 @@ const
useEffectSystem* = true useEffectSystem* = true
hasFFI* = defined(useFFI) hasFFI* = defined(useFFI)
newScopeForIf* = true newScopeForIf* = true
useCaas* = not defined(noCaas)
type # please make sure we have under 32 options type # please make sure we have under 32 options
# (improves code efficiency a lot!) # (improves code efficiency a lot!)

View file

@ -9,11 +9,13 @@
## Implements the "compiler as a service" feature. ## Implements the "compiler as a service" feature.
import import
sockets,
times, commands, options, msgs, nimconf, times, commands, options, msgs, nimconf,
extccomp, strutils, os, platform, parseopt extccomp, strutils, os, platform, parseopt
when useCaas:
import sockets
# We cache modules and the dependency graph. However, we don't check for # 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 # file changes but expect the client to tell us about them, otherwise the
# repeated CRC calculations may turn out to be too slow. # repeated CRC calculations may turn out to be too slow.
@ -80,19 +82,22 @@ proc serve*(action: proc (){.nimcall.}) =
FlushFile(stdout) FlushFile(stdout)
of "tcp", "": of "tcp", "":
var server = Socket() when useCaas:
let p = getConfigVar("server.port") var server = Socket()
let port = if p.len > 0: parseInt(p).TPort else: 6000.TPort let p = getConfigVar("server.port")
server.bindAddr(port, getConfigVar("server.address")) let port = if p.len > 0: parseInt(p).TPort else: 6000.TPort
var inp = "".TaintedString server.bindAddr(port, getConfigVar("server.address"))
server.listen() var inp = "".TaintedString
new(stdoutSocket) server.listen()
while true: new(stdoutSocket)
accept(server, stdoutSocket) while true:
stdoutSocket.readLine(inp) accept(server, stdoutSocket)
execute inp.string stdoutSocket.readLine(inp)
stdoutSocket.send("\c\L") execute inp.string
stdoutSocket.close() stdoutSocket.send("\c\L")
stdoutSocket.close()
else:
quit "server.type not supported; compiler built without caas support"
else: else:
echo "Invalid server.type:", typ echo "Invalid server.type:", typ
quit 1 quit 1

View file

@ -52,6 +52,7 @@ Boot options:
(not needed on Windows) (not needed on Windows)
-d:useFFI build Nimrod with FFI support at compile time -d:useFFI build Nimrod with FFI support at compile time
-d:nativeStacktrace use native stack traces (only for Mac OS X or Linux) -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) proc exe(f: string): string = return addFileExt(f, ExeExt)