diff --git a/SConscript b/SConscript index ebb60b3..3054a82 100644 --- a/SConscript +++ b/SConscript @@ -66,6 +66,9 @@ def _wrap_default(default): default(arg) return _wrapped +def _get_fallback_cache_dir() -> str: + return Dir('#cache').abspath + def _find_system_cache_dir() -> str: if os.name == 'posix': if os.environ.get('XDG_CACHE_HOME'): @@ -76,7 +79,7 @@ def _find_system_cache_dir() -> str: # TODO: just guessing return os.environ['LocalAppData'] # fallback - return Dir('#cache').abspath + return _get_fallback_cache_dir() 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') 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) if variant: