From a2c5ffba0cd82b5677fa57612f7dcb7af2348f45 Mon Sep 17 00:00:00 2001 From: alaviss Date: Thu, 9 Aug 2018 15:50:36 +0700 Subject: [PATCH] Uses XDG_CACHE_HOME if available (#8585) * compiler/options: use XDG_CACHE_HOME if set * doc/nimc: update documentation --- compiler/options.nim | 2 +- doc/nimc.rst | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/options.nim b/compiler/options.nim index be9342085b..44519ea22e 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -482,7 +482,7 @@ include packagehandling proc getOsCacheDir(): string = when defined(posix): - result = getHomeDir() / ".cache" + result = string getEnv("XDG_CACHE_HOME", getHomeDir() / ".cache") else: result = getHomeDir() / genSubDir diff --git a/doc/nimc.rst b/doc/nimc.rst index 277c88ec11..fca5b273cf 100644 --- a/doc/nimc.rst +++ b/doc/nimc.rst @@ -159,7 +159,8 @@ Generated C code directory The generated files that Nim produces all go into a subdirectory called ``nimcache``. Its full path is -- ``~/.cache/$projectname(_r|_d)`` on Posix +- ``$XDG_CACHE_HOME/$projectname(_r|_d)`` or ``~/.cache/$projectname(_r|_d)`` + on Posix - ``$HOME/nimcache/$projectname(_r|_d)`` on Windows. The ``_r`` suffix is used for release builds, ``_d`` is for debug builds.