Introduce first class support for Android (#5772)
This commit is contained in:
parent
bbeadf184e
commit
c39e202976
15 changed files with 109 additions and 14 deletions
|
|
@ -92,7 +92,7 @@ else:
|
|||
# There used to be this name in posix.nim a long time ago, not sure why!
|
||||
{.deprecated: [cSIG_HOLD: SIG_HOLD].}
|
||||
|
||||
when not defined(macosx):
|
||||
when not defined(macosx) and not defined(android):
|
||||
proc st_atime*(s: Stat): Time {.inline.} =
|
||||
## Second-granularity time of last access
|
||||
result = s.st_atim.tv_sec
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ type
|
|||
## For a typed memory object, the length in bytes.
|
||||
## For other file types, the use of this field is
|
||||
## unspecified.
|
||||
when defined(macosx):
|
||||
when defined(macosx) or defined(android):
|
||||
st_atime*: Time ## Time of last access.
|
||||
st_mtime*: Time ## Time of last data modification.
|
||||
st_ctime*: Time ## Time of last status change.
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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 {.
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ type
|
|||
OsPlatform* {.pure.} = enum ## the OS this program will run on.
|
||||
none, dos, windows, os2, linux, morphos, skyos, solaris,
|
||||
irix, netbsd, freebsd, openbsd, aix, palmos, qnx, amiga,
|
||||
atari, netware, macos, macosx, haiku, js, nimVM, standalone
|
||||
atari, netware, macos, macosx, haiku, android, js, nimVM,
|
||||
standalone
|
||||
|
||||
const
|
||||
targetOS* = when defined(windows): OsPlatform.windows
|
||||
|
|
@ -58,6 +59,7 @@ const
|
|||
elif defined(macosx): OsPlatform.macosx
|
||||
elif defined(macos): OsPlatform.macos
|
||||
elif defined(haiku): OsPlatform.haiku
|
||||
elif defined(android): OsPlatform.android
|
||||
elif defined(js): OsPlatform.js
|
||||
elif defined(nimrodVM): OsPlatform.nimVM
|
||||
elif defined(standalone): OsPlatform.standalone
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue