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
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ See docs/process.md for how version tagging works.

Current Trunk
-------------
- Honor `CACHE` setting in config file as an alternative to `EM_CACHE`
environment variable or `--cache` commandline flag.

1.39.15: 05/06/2020
-------------------
Expand Down
2 changes: 1 addition & 1 deletion emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2959,7 +2959,7 @@ def consume_arg():
logger.error('jcache is no longer supported')
newargs[i] = ''
elif check_arg('--cache'):
os.environ['EM_CACHE'] = os.path.normpath(consume_arg())
shared.CACHE = os.path.normpath(consume_arg())
shared.reconfigure_cache()
elif newargs[i] == '--clear-cache':
logger.info('clearing cache as requested by --clear-cache')
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ def test_emconfig(self):
temp_dir = tempfile.mkdtemp(prefix='emscripten_temp_')

with chdir(temp_dir):
self.do([PYTHON, EMCC, '--em-config', custom_config_filename] + MINIMAL_HELLO_WORLD + ['-O2'])
run_process([PYTHON, EMCC, '--em-config', custom_config_filename] + MINIMAL_HELLO_WORLD + ['-O2'])
result = run_js('a.out.js')

self.assertContained('hello, world!', result)
Expand Down
8 changes: 2 additions & 6 deletions tools/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,9 @@ class Cache(object):
# acquired.
EM_EXCLUSIVE_CACHE_ACCESS = int(os.environ.get('EM_EXCLUSIVE_CACHE_ACCESS', '0'))

def __init__(self, use_subdir=True):
def __init__(self, dirname, use_subdir=True):
# figure out the root directory for all caching
dirname = os.environ.get('EM_CACHE')
if dirname:
dirname = os.path.normpath(dirname)
if not dirname:
dirname = os.path.expanduser(os.path.join('~', '.emscripten_cache'))
dirname = os.path.normpath(dirname)
self.root_dirname = dirname

def try_remove_ending(thestring, ending):
Expand Down
10 changes: 7 additions & 3 deletions tools/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ def parse_config_file():
'WASMTIME',
'WASM_ENGINES',
'FROZEN_CACHE',
'CACHE',
)

# Only propagate certain settings from the config file.
Expand Down Expand Up @@ -641,7 +642,7 @@ def check_vanilla():
# if we are using vanilla LLVM, i.e. we don't have our asm.js backend, then we
# must use wasm (or at least try to). to know that, we have to run llc to
# see which backends it has. we cache this result.
temp_cache = cache.Cache(use_subdir=False)
temp_cache = cache.Cache(CACHE, use_subdir=False)

def has_vanilla_targets():
logger.debug('testing for asm.js target, because if not present (i.e. this is plain vanilla llvm, not emscripten fastcomp), we will use the wasm target instead (set EMCC_WASM_BACKEND to skip this check)')
Expand Down Expand Up @@ -2791,7 +2792,7 @@ def save_intermediate(src, dst):

def reconfigure_cache():
global Cache
Cache = cache.Cache()
Cache = cache.Cache(CACHE)


# Placeholder strings used for SINGLE_FILE
Expand Down Expand Up @@ -3385,6 +3386,7 @@ def make_fetch_worker(source_file, output_file):
WASMER = None
WASMTIME = None
WASM_ENGINES = []
CACHE = None
FROZEN_CACHE = False

# Emscripten compiler spawns other processes, which can reimport shared.py, so
Expand All @@ -3408,6 +3410,8 @@ def make_fetch_worker(source_file, output_file):
V8_ENGINE = fix_js_engine(V8_ENGINE, listify(V8_ENGINE))
JS_ENGINES = [listify(engine) for engine in JS_ENGINES]
WASM_ENGINES = [listify(engine) for engine in WASM_ENGINES]
if not CACHE:
CACHE = os.path.expanduser(os.path.join('~', '.emscripten_cache'))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we put a default value in tools/settings_template.py?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No.. we don't normal users to be setting this. Its mostly for the benefit of emsdk. See emscripten-core/emsdk#495.

Right now emsdk has to use the environment variable which I'd like to change.


# Install our replacement Popen handler if we are running on Windows to avoid
# python spawn process function.
Expand Down Expand Up @@ -3503,5 +3507,5 @@ def make_fetch_worker(source_file, output_file):
PRINT_STAGES = int(os.getenv('EMCC_VERBOSE', '0'))

# compatibility with existing emcc, etc. scripts
Cache = cache.Cache()
Cache = cache.Cache(CACHE)
chunkify = cache.chunkify