aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSigmund Vik <sigmund_vik@yahoo.com>2012-03-20 14:26:50 +0100
committerSigmund Vik <sigmund_vik@yahoo.com>2012-03-20 14:26:50 +0100
commitf829735cc3e20e5d2165a020e87c4128d2ed9792 (patch)
tree6a4d4589ec780ee560e4a8ab8bc8ab55318e4d34 /src
parentbe2dafadec0e5a39e3e55a3663183ca6a8dd5d8e (diff)
Misc fixes for Windows.
Most of these changes have to do with how python scripts are invoked. For Linux, 'Popen([EMCC] + args)' works because the first line in emcc is '#!/usr/bin/env python'. On Windows, the python interpreter has to be explicitly invoked, e.g. 'Popen(['python', EMCC] + args)'. Note that there is no harm in explicitly invoking the python interpreter on Linux, so this works on both platforms. For Windows, execvp() behaves differently than on Linux: http://mail.python.org/pipermail/python-list/2002-July/763863.html http://msdn.microsoft.com/en-us/library/3xw6zy53.aspx This causes many strange things to happen as the parent process terminated before its children. In this change the use of execvp() has been replaced with subprocess.call(). This change also fixes some code that assumed that the path separator always is '/', but for Windows it is '\'. And where the path module can be required, we use path.normalize() and path.resolve() to check if a filename is absolute in a platform agnostic manner.
Diffstat (limited to 'src')
-rw-r--r--src/compiler.js7
-rw-r--r--src/shell.js7
2 files changed, 10 insertions, 4 deletions
diff --git a/src/compiler.js b/src/compiler.js
index c39927e7..29ae47dd 100644
--- a/src/compiler.js
+++ b/src/compiler.js
@@ -29,11 +29,14 @@ if (ENVIRONMENT_IS_NODE) {
};
var nodeFS = require('fs');
+ var nodePath = require('path');
read = function(filename) {
+ filename = nodePath['normalize'](filename);
var ret = nodeFS['readFileSync'](filename).toString();
- if (!ret && filename[0] != '/') {
- filename = __dirname.split('/').slice(0, -1).join('/') + '/src/' + filename;
+ // The path is absolute if the normalized version is the same as the resolved.
+ if (!ret && filename != nodePath['resolve'](filename)) {
+ filename = path.join(__dirname, '..', 'src', filename);
ret = nodeFS['readFileSync'](filename).toString();
}
return ret;
diff --git a/src/shell.js b/src/shell.js
index 5b6419c0..55f96194 100644
--- a/src/shell.js
+++ b/src/shell.js
@@ -24,11 +24,14 @@ if (ENVIRONMENT_IS_NODE) {
};
var nodeFS = require('fs');
+ var nodePath = require('path');
Module['read'] = function(filename) {
+ filename = nodePath['normalize'](filename);
var ret = nodeFS['readFileSync'](filename).toString();
- if (!ret && filename[0] != '/') {
- filename = __dirname.split('/').slice(0, -1).join('/') + '/src/' + filename;
+ // The path is absolute if the normalized version is the same as the resolved.
+ if (!ret && filename != nodePath['resolve'](filename)) {
+ filename = path.join(__dirname, '..', 'src', filename);
ret = nodeFS['readFileSync'](filename).toString();
}
return ret;