summary refs log tree commit diff stats
path: root/compiler/service.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/service.nim')
-rw-r--r--compiler/service.nim35
1 files changed, 20 insertions, 15 deletions
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