aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-01-05 18:11:31 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-01-05 18:11:31 -0800
commitc35586c36c8ac7aaf1c934862555976ca0f04c89 (patch)
tree4c94d73731ebf1015b6918af1989e6b722eb2863
parent6efa942efdd468c10c6377ad04c9fb9b61f34d16 (diff)
fix bug with emcc not respecting absolute paths and always placing outputs in the current directory
-rwxr-xr-xemcc4
-rw-r--r--tests/runner.py17
2 files changed, 19 insertions, 2 deletions
diff --git a/emcc b/emcc
index 6bb209a5..36c2464a 100755
--- a/emcc
+++ b/emcc
@@ -550,12 +550,12 @@ try:
if final_suffix == 'html':
if DEBUG: print >> sys.stderr, 'emcc: generating HTML'
shell = open(shared.path_from_root('src', 'shell.html')).read()
- html = open(target_basename + '.html', 'w')
+ html = open(target, 'w')
html.write(shell.replace('{{{ SCRIPT_CODE }}}', open(final).read()))
html.close()
else:
# copy final JS to output
- shutil.move(final, target_basename + '.js')
+ shutil.move(final, target)
finally:
if not TEMP_DIR:
diff --git a/tests/runner.py b/tests/runner.py
index 0433b99f..07d55650 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -5165,6 +5165,23 @@ Options that are modified or new in %s include:
assert os.path.exists('a.out.js'), '\n'.join(output)
self.assertContained('hello, world!', run_js('a.out.js'))
+ # emcc [..] -o [path] ==> should work with absolute paths
+ try:
+ os.mkdir('a_dir')
+ os.chdir('a_dir')
+ os.mkdir('b_dir')
+ for path in [os.path.abspath(os.path.join('..', 'file1.js')), os.path.join('b_dir', 'file2.js')]:
+ clear()
+ output = Popen([compiler, path_from_root('tests', 'hello_world.ll'), '-o', path], stdout=PIPE, stderr=PIPE).communicate()
+ assert os.path.exists(path), path + ' does not exist; ' + '\n'.join(output)
+ self.assertContained('hello, world!', run_js(path))
+ finally:
+ os.chdir(self.get_dir())
+ try:
+ shutil.rmtree('a_dir')
+ except:
+ pass
+
# dlmalloc. dlmalloc is special in that it is the only part of libc that is (1) hard to write well, and
# very speed-sensitive. So we do not implement it in JS in library.js, instead we compile it from source
for source, has_malloc in [('hello_world' + suffix, False), ('hello_malloc.cpp', True)]: