Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions embuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ def main():
# Check sanity so that if settings file has changed, the cache is cleared here.
# Otherwise, the cache will clear in an emcc process, which is invoked while building
# a system library into the cache, causing trouble.
cache.setup()
shared.check_sanity()

if args.lto:
Expand Down
2 changes: 1 addition & 1 deletion emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3513,7 +3513,7 @@ def consume_arg_file():
logger.error('jcache is no longer supported')
elif check_arg('--cache'):
config.CACHE = os.path.normpath(consume_arg())
cache.setup(config.CACHE)
cache.setup()
# Ensure child processes share the same cache (e.g. when using emcc to compiler system
# libraries)
os.environ['EM_CACHE'] = config.CACHE
Expand Down
1 change: 1 addition & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,7 @@ def verify_includes(stderr):
end = stderr.index('End of search list.')
includes = stderr[start:end]
includes = [i.strip() for i in includes.splitlines()[1:]]
cache.ensure_setup()
cachedir = os.path.normpath(cache.cachedir)
llvmroot = os.path.normpath(os.path.dirname(config.LLVM_ROOT))
for i in includes:
Expand Down
1 change: 1 addition & 0 deletions tools/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def remove_quotes(arg):


def get_building_env():
cache.ensure()
env = os.environ.copy()
# point CC etc. to the em* tools.
env['CC'] = EMCC
Expand Down
15 changes: 13 additions & 2 deletions tools/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,24 @@ def lock(reason):


def ensure():
ensure_setup()
utils.safe_ensure_dirs(cachedir)


def erase():
ensure_setup()
with lock('erase'):
# Delete everything except the lockfile itself
utils.delete_contents(cachedir, exclude=[os.path.basename(cachelock_name)])


def get_path(name):
ensure_setup()
return Path(cachedir, name)


def get_sysroot(absolute):
ensure_setup()
if absolute:
return os.path.join(cachedir, 'sysroot')
return 'sysroot'
Expand All @@ -94,6 +98,7 @@ def get_sysroot_dir(*parts):


def get_lib_dir(absolute):
ensure_setup()
path = Path(get_sysroot(absolute=absolute), 'lib')
if settings.MEMORY64:
path = Path(path, 'wasm64-emscripten')
Expand Down Expand Up @@ -137,6 +142,7 @@ def get_lib(libname, *args, **kwargs):
# Request a cached file. If it isn't in the cache, it will be created with
# the given creator function
def get(shortname, creator, what=None, force=False, quiet=False, deferred=False):
ensure_setup()
cachename = Path(cachedir, shortname)
# Check for existence before taking the lock in case we can avoid the
# lock completely.
Expand Down Expand Up @@ -168,13 +174,18 @@ def get(shortname, creator, what=None, force=False, quiet=False, deferred=False)
return str(cachename)


def setup(dirname):
def setup():
global cachedir, cachelock, cachelock_name
# figure out the root directory for all caching
cachedir = Path(dirname).resolve()
cachedir = Path(config.CACHE).resolve()

# since the lock itself lives inside the cache directory we need to ensure it
# exists.
ensure()
cachelock_name = Path(cachedir, 'cache.lock')
cachelock = filelock.FileLock(cachelock_name)


def ensure_setup():
if not cachedir:
setup()
1 change: 0 additions & 1 deletion tools/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,6 @@ def get_llvm_target():
def init():
set_version_globals()
setup_temp_dirs()
cache.setup(config.CACHE)


# ============================================================================
Expand Down