diff options
author | Nick Bray <ncbray@chromium.org> | 2013-08-06 14:19:31 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-08-08 16:32:32 -0700 |
commit | 0535038c6060a1cf621855607af305489a1aabcd (patch) | |
tree | 7ca9efb4045f339f90647479da694c0b38726880 | |
parent | 34229a78e51a3f59818cd1c38c01794d4afe4676 (diff) |
Improve the generation of ~/.emscripten on Windows.
-rw-r--r-- | tools/settings_template_readonly.py | 2 | ||||
-rw-r--r-- | tools/shared.py | 15 |
2 files changed, 12 insertions, 5 deletions
diff --git a/tools/settings_template_readonly.py b/tools/settings_template_readonly.py index 7ab89b48..14b45a20 100644 --- a/tools/settings_template_readonly.py +++ b/tools/settings_template_readonly.py @@ -16,7 +16,7 @@ V8_ENGINE = os.path.expanduser(os.getenv('V8') or 'd8') # executable JAVA = 'java' # executable -TEMP_DIR = '/tmp' # You will need to modify this on Windows +TEMP_DIR = '{{{ TEMP }}}' #CLOSURE_COMPILER = '..' # define this to not use the bundled version diff --git a/tools/shared.py b/tools/shared.py index 97b4afaa..b3689c88 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -200,18 +200,25 @@ if '\n' in EM_CONFIG: else: CONFIG_FILE = os.path.expanduser(EM_CONFIG) if not os.path.exists(CONFIG_FILE): + # Note: repr is used to ensure the paths are escaped correctly on Windows. + # The full string is replaced so that the template stays valid Python. config_file = open(path_from_root('tools', 'settings_template_readonly.py')).read().split('\n') config_file = config_file[1:] # remove "this file will be copied..." config_file = '\n'.join(config_file) # autodetect some default paths - config_file = config_file.replace('{{{ EMSCRIPTEN_ROOT }}}', __rootpath__) + config_file = config_file.replace('\'{{{ EMSCRIPTEN_ROOT }}}\'', repr(__rootpath__)) llvm_root = os.path.dirname(find_executable('llvm-dis') or '/usr/bin/llvm-dis') - config_file = config_file.replace('{{{ LLVM_ROOT }}}', llvm_root) + config_file = config_file.replace('\'{{{ LLVM_ROOT }}}\'', repr(llvm_root)) node = find_executable('node') or find_executable('nodejs') or 'node' - config_file = config_file.replace('{{{ NODE }}}', node) + config_file = config_file.replace('\'{{{ NODE }}}\'', repr(node)) python = find_executable('python2') or find_executable('python') or \ sys.executable or 'python' - config_file = config_file.replace('{{{ PYTHON }}}', python) + config_file = config_file.replace('\'{{{ PYTHON }}}\'', repr(python)) + if WINDOWS: + tempdir = os.environ.get('TEMP') or os.environ.get('TMP') or 'c:\\temp' + else: + tempdir = '/tmp' + config_file = config_file.replace('\'{{{ TEMP }}}\'', repr(tempdir)) # write open(CONFIG_FILE, 'w').write(config_file) |