mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-18 21:40:32 +00:00
-d:nocaas mode for easier bootstrapping on exotic OSes (Haiku)
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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!)
|
||||
|
||||
@@ -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
|
||||
|
||||
1
koch.nim
1
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)
|
||||
|
||||
Reference in New Issue
Block a user