@@ -66,20 +66,24 @@ def lock(reason):
6666
6767
6868def ensure ():
69+ ensure_setup ()
6970 utils .safe_ensure_dirs (cachedir )
7071
7172
7273def erase ():
74+ ensure_setup ()
7375 with lock ('erase' ):
7476 # Delete everything except the lockfile itself
7577 utils .delete_contents (cachedir , exclude = [os .path .basename (cachelock_name )])
7678
7779
7880def get_path (name ):
81+ ensure_setup ()
7982 return Path (cachedir , name )
8083
8184
8285def get_sysroot (absolute ):
86+ ensure_setup ()
8387 if absolute :
8488 return os .path .join (cachedir , 'sysroot' )
8589 return 'sysroot'
@@ -94,6 +98,7 @@ def get_sysroot_dir(*parts):
9498
9599
96100def get_lib_dir (absolute ):
101+ ensure_setup ()
97102 path = Path (get_sysroot (absolute = absolute ), 'lib' )
98103 if settings .MEMORY64 :
99104 path = Path (path , 'wasm64-emscripten' )
@@ -137,6 +142,7 @@ def get_lib(libname, *args, **kwargs):
137142# Request a cached file. If it isn't in the cache, it will be created with
138143# the given creator function
139144def get (shortname , creator , what = None , force = False , quiet = False , deferred = False ):
145+ ensure_setup ()
140146 cachename = Path (cachedir , shortname )
141147 # Check for existence before taking the lock in case we can avoid the
142148 # lock completely.
@@ -168,13 +174,18 @@ def get(shortname, creator, what=None, force=False, quiet=False, deferred=False)
168174 return str (cachename )
169175
170176
171- def setup (dirname ):
177+ def setup ():
172178 global cachedir , cachelock , cachelock_name
173179 # figure out the root directory for all caching
174- cachedir = Path (dirname ).resolve ()
180+ cachedir = Path (config . CACHE ).resolve ()
175181
176182 # since the lock itself lives inside the cache directory we need to ensure it
177183 # exists.
178184 ensure ()
179185 cachelock_name = Path (cachedir , 'cache.lock' )
180186 cachelock = filelock .FileLock (cachelock_name )
187+
188+
189+ def ensure_setup ():
190+ if not cachedir :
191+ setup ()
0 commit comments