Try to create SPP cache dir and use fallback if it fails.
This commit is contained in:
parent
b8ae0df0ae
commit
2aa80afc51
12
SConscript
12
SConscript
@ -66,6 +66,9 @@ def _wrap_default(default):
|
|||||||
default(arg)
|
default(arg)
|
||||||
return _wrapped
|
return _wrapped
|
||||||
|
|
||||||
|
def _get_fallback_cache_dir() -> str:
|
||||||
|
return Dir('#cache').abspath
|
||||||
|
|
||||||
def _find_system_cache_dir() -> str:
|
def _find_system_cache_dir() -> str:
|
||||||
if os.name == 'posix':
|
if os.name == 'posix':
|
||||||
if os.environ.get('XDG_CACHE_HOME'):
|
if os.environ.get('XDG_CACHE_HOME'):
|
||||||
@ -76,7 +79,7 @@ def _find_system_cache_dir() -> str:
|
|||||||
# TODO: just guessing
|
# TODO: just guessing
|
||||||
return os.environ['LocalAppData']
|
return os.environ['LocalAppData']
|
||||||
# fallback
|
# fallback
|
||||||
return Dir('#cache').abspath
|
return _get_fallback_cache_dir()
|
||||||
|
|
||||||
Import('config')
|
Import('config')
|
||||||
|
|
||||||
@ -169,6 +172,13 @@ env['SYSTEM_CACHE_DIR'] = os.path.join(_find_system_cache_dir(), 'spp_cache')
|
|||||||
env['CLONE_DIR'] = os.path.join(env['SYSTEM_CACHE_DIR'], 'cloned')
|
env['CLONE_DIR'] = os.path.join(env['SYSTEM_CACHE_DIR'], 'cloned')
|
||||||
|
|
||||||
print(f'Detected system cache directory: {env["SYSTEM_CACHE_DIR"]}')
|
print(f'Detected system cache directory: {env["SYSTEM_CACHE_DIR"]}')
|
||||||
|
try:
|
||||||
|
os.makedirs(env['SYSTEM_CACHE_DIR'], exist_ok=True)
|
||||||
|
except:
|
||||||
|
env['SYSTEM_CACHE_DIR'] = os.path.join(_get_fallback_cache_dir(), 'spp_cache')
|
||||||
|
env['CLONE_DIR'] = os.path.join(env['SYSTEM_CACHE_DIR'], 'cloned')
|
||||||
|
print(f'Creating spp cache dir failed, using fallback: {env["SYSTEM_CACHE_DIR"]}.')
|
||||||
|
os.makedirs(env['SYSTEM_CACHE_DIR'], exist_ok=True) # no more safeguards!
|
||||||
|
|
||||||
# allow compiling to variant directories (each gets their own bin/lib/cache dirs)
|
# allow compiling to variant directories (each gets their own bin/lib/cache dirs)
|
||||||
if variant:
|
if variant:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user