Introduce first class support for Android (#5772)

This commit is contained in:
Fredrik Høisæther Rasch 2017-08-06 02:18:15 +02:00 • committed by Andreas Rumpf
commit c39e202976
15 changed files with 109 additions and 14 deletions

View file

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

View file

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

View file

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