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

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

View File

@@ -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:

View File

@@ -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!)

View File

@@ -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

View File

@@ -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)