aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/js-optimizer.js39
-rw-r--r--tools/shared.py15
2 files changed, 34 insertions, 20 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index e1cfbe65..5dac36f0 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -26,15 +26,30 @@ 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();
- // 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();
+ if (!nodeFS.existsSync) {
+ nodeFS.existsSync = function(path) {
+ try {
+ return !!nodeFS.readFileSync(path);
+ } catch(e) {
+ return false;
+ }
+ }
+ }
+
+ function find(filename) {
+ var prefixes = [nodePath.join(__dirname, '..', 'src'), process.cwd()];
+ for (var i = 0; i < prefixes.length; ++i) {
+ var combined = nodePath.join(prefixes[i], filename);
+ if (nodeFS.existsSync(combined)) {
+ return combined;
+ }
}
- return ret;
+ return filename;
+ }
+
+ read = function(filename) {
+ var absolute = find(filename);
+ return nodeFS['readFileSync'](absolute).toString();
};
load = function(f) {
@@ -98,14 +113,6 @@ if (typeof print === 'undefined') {
}
// *** Environment setup code ***
-// Fix read for our location
-read = function(filename) {
- // The path is absolute if the normalized version is the same as the resolved.
- filename = path.normalize(filename);
- if (filename != path.resolve(filename)) filename = path.join(__dirname, '..', 'src', filename);
- return fs.readFileSync(filename).toString();
-}
-
var uglify = require('../tools/eliminator/node_modules/uglify-js');
var fs = require('fs');
var path = require('path');
diff --git a/tools/shared.py b/tools/shared.py
index 700849e8..2fc894d0 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -47,12 +47,19 @@ except Exception, e:
EXPECTED_LLVM_VERSION = (3,1)
+def check_clang_version():
+ expected = 'clang version ' + '.'.join(map(str, EXPECTED_LLVM_VERSION))
+ actual = Popen([CLANG, '-v'], stderr=PIPE).communicate()[1].split('\n')[0]
+ if expected in actual:
+ return True
+
+ print >> sys.stderr, 'warning: LLVM version appears incorrect (seeing "%s", expected "%s")' % (actual, expected)
+ return False
+
+
def check_llvm_version():
try:
- expected = 'clang version ' + '.'.join(map(str, EXPECTED_LLVM_VERSION))
- actual = Popen([CLANG, '-v'], stderr=PIPE).communicate()[1].split('\n')[0][0:len(expected)]
- if expected != actual:
- print >> sys.stderr, 'warning: LLVM version appears incorrect (seeing "%s", expected "%s")' % (actual, expected)
+ check_clang_version();
except Exception, e:
print >> sys.stderr, 'warning: Could not verify LLVM version: %s' % str(e)