diff options
author | Fredrik Høisæther Rasch <fredrik.rasch@gmail.com> | 2017-08-06 02:18:15 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-08-06 02:18:15 +0200 |
commit | c39e2029762387d05f7b3d81490c6129703c1b60 (patch) | |
tree | 68b9b76672de12c670808f882a014f77d7c40eb9 /lib/pure | |
parent | bbeadf184e613d6ae476fe4252d60b1e3a92e7dd (diff) | |
download | Nim-c39e2029762387d05f7b3d81490c6129703c1b60.tar.gz |
Introduce first class support for Android (#5772)
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/nativesockets.nim | 2 | ||||
-rw-r--r-- | lib/pure/ospaths.nim | 19 | ||||
-rw-r--r-- | lib/pure/osproc.nim | 3 |
3 files changed, 20 insertions, 4 deletions
diff --git a/lib/pure/nativesockets.nim b/lib/pure/nativesockets.nim index 7568408a6..1a62c0bf6 100644 --- a/lib/pure/nativesockets.nim +++ b/lib/pure/nativesockets.nim @@ -233,7 +233,7 @@ proc getAddrInfo*(address: string, port: Port, domain: Domain = AF_INET, # OpenBSD doesn't support AI_V4MAPPED and doesn't define the macro AI_V4MAPPED. # FreeBSD doesn't support AI_V4MAPPED but defines the macro. # https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=198092 - when not defined(freebsd) and not defined(openbsd) and not defined(netbsd): + when not defined(freebsd) and not defined(openbsd) and not defined(netbsd) and not defined(android): if domain == AF_INET6: hints.ai_flags = AI_V4MAPPED var gaiResult = getaddrinfo(address, $port, addr(hints), result) diff --git a/lib/pure/ospaths.nim b/lib/pure/ospaths.nim index fa5342fcf..769fa9872 100644 --- a/lib/pure/ospaths.nim +++ b/lib/pure/ospaths.nim @@ -528,11 +528,26 @@ when declared(getEnv) or defined(nimscript): elif getEnv("XDG_CONFIG_DIR"): return string(getEnv("XDG_CONFIG_DIR")) & "/" else: return string(getEnv("HOME")) & "/.config/" + when defined(android): + {.pragma: getTempDirEffects, tags: [ReadEnvEffect, ReadIOEffect, WriteDirEffect].} + elif defined(windows): + {.pragma: getTempDirEffects, tags: [ReadEnvEffect, ReadIOEffect].} + else: + {.pragma: getTempDirEffects, tags: [ReadIOEffect].} + proc getTempDir*(): string {.rtl, extern: "nos$1", - tags: [ReadEnvEffect, ReadIOEffect].} = + getTempDirEffects.} = ## Returns the temporary directory of the current user for applications to ## save temporary files in. - when defined(windows): return string(getEnv("TEMP")) & "\\" + when defined(tempDir): + const tempDir {.strdefine.}: string = nil + return tempDir + elif defined(windows): return string(getEnv("TEMP")) & "\\" + elif defined(android): + let tempDir = getHomeDir() / "nimtempfs" + try: createDir(tempDir) + except OSError: discard + return tempDir else: return "/tmp/" proc expandTilde*(path: string): string {. diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim index 23c8546c4..3635aecc1 100644 --- a/lib/pure/osproc.nim +++ b/lib/pure/osproc.nim @@ -762,7 +762,8 @@ elif not defined(useNimRtl): var sysCommand: string var sysArgsRaw: seq[string] if poEvalCommand in options: - sysCommand = "/bin/sh" + const useShPath {.strdefine.} = "/bin/sh" + sysCommand = useShPath sysArgsRaw = @[sysCommand, "-c", command] assert args.len == 0, "`args` has to be empty when using poEvalCommand." else: |