diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-03-20 16:03:39 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-03-20 16:03:39 -0700 |
commit | cdc82664d8dfcc4cb8b9df86c24611b723073236 (patch) | |
tree | f76ea279d1f2b3299d96430ba4d22dfa8f366449 /tools | |
parent | ed9b24c6844c70cee2540a4f1ce60795a7d64f03 (diff) | |
parent | cba66bcb2ae87140d43b85c64a5a8f14fb9fab8a (diff) |
Merge pull request #312 from SiggyBar/incoming
Misc fixes for Windows.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/eliminator/eliminator.coffee | 5 | ||||
-rw-r--r-- | tools/eliminator/node_modules/coffee-script/lib/command.js | 2 | ||||
-rwxr-xr-x | tools/emmaken.py | 4 | ||||
-rwxr-xr-x | tools/emmakenxx.py | 4 | ||||
-rw-r--r-- | tools/js-optimizer.js | 12 | ||||
-rw-r--r-- | tools/make_minigzip.py | 2 | ||||
-rw-r--r-- | tools/shared.py | 30 |
7 files changed, 34 insertions, 25 deletions
diff --git a/tools/eliminator/eliminator.coffee b/tools/eliminator/eliminator.coffee index ba91aa89..0af57111 100644 --- a/tools/eliminator/eliminator.coffee +++ b/tools/eliminator/eliminator.coffee @@ -369,7 +369,10 @@ class ExpressionOptimizer # function, then writes the optimized result to stdout. main = -> # Get the parse tree. - src = fs.readFileSync('/dev/stdin').toString() + src = '' + size = fs.fstatSync(process.stdin.fd).size + if size > 0 + src = fs.readSync(process.stdin.fd, size)[0] throw 'Cannot identify generated functions' if GENERATED_FUNCTIONS_MARKER in src generatedFunctionsLine = src.split('\n').filter (line) -> diff --git a/tools/eliminator/node_modules/coffee-script/lib/command.js b/tools/eliminator/node_modules/coffee-script/lib/command.js index ca255020..39813201 100644 --- a/tools/eliminator/node_modules/coffee-script/lib/command.js +++ b/tools/eliminator/node_modules/coffee-script/lib/command.js @@ -12,7 +12,7 @@ return process.stdout.write(line + '\n'); }; printWarn = function(line) { - return process.binding('stdio').writeError(line + '\n'); + return process.stderr.write(line + '\n'); }; BANNER = 'Usage: coffee [options] path/to/script.coffee'; SWITCHES = [['-c', '--compile', 'compile to JavaScript and save as .js files'], ['-i', '--interactive', 'run an interactive CoffeeScript REPL'], ['-o', '--output [DIR]', 'set the directory for compiled JavaScript'], ['-j', '--join [FILE]', 'concatenate the scripts before compiling'], ['-w', '--watch', 'watch scripts for changes, and recompile'], ['-p', '--print', 'print the compiled JavaScript to stdout'], ['-l', '--lint', 'pipe the compiled JavaScript through JavaScript Lint'], ['-s', '--stdio', 'listen for and compile scripts over stdio'], ['-e', '--eval', 'compile a string from the command line'], ['-r', '--require [FILE*]', 'require a library before executing your script'], ['-b', '--bare', 'compile without the top-level function wrapper'], ['-t', '--tokens', 'print the tokens that the lexer produces'], ['-n', '--nodes', 'print the parse tree that Jison produces'], ['--nodejs [ARGS]', 'pass options through to the "node" binary'], ['-v', '--version', 'display CoffeeScript version'], ['-h', '--help', 'display this help message']]; diff --git a/tools/emmaken.py b/tools/emmaken.py index 8e1bfdc8..ae4794f0 100755 --- a/tools/emmaken.py +++ b/tools/emmaken.py @@ -113,7 +113,7 @@ if CONFIGURE_CONFIG or CMAKE_CONFIG: compiler = 'g++' if 'CXXCompiler' in ' '.join(sys.argv) or os.environ.get('EMMAKEN_CXX') else 'gcc' cmd = [compiler] + EMSDK_OPTS + sys.argv[1:] print >> sys.stderr, 'emmaken.py, just configuring: ', cmd - exit(os.execvp(compiler, cmd)) + exit(subprocess.call(cmd)) try: #f=open('/dev/shm/tmp/waka.txt', 'a') @@ -223,7 +223,7 @@ try: print >> sys.stderr, "Running:", call, ' '.join(newargs) - os.execvp(call, [call] + newargs) + subprocess.call([call] + newargs) except Exception, e: print 'Error in emmaken.py. (Is the config file %s set up properly?) Error:' % EM_CONFIG, e raise diff --git a/tools/emmakenxx.py b/tools/emmakenxx.py index c9ab4ef4..1c31f3c2 100755 --- a/tools/emmakenxx.py +++ b/tools/emmakenxx.py @@ -4,7 +4,7 @@ see emmaken.py ''' -import os, sys +import os, subprocess, sys __rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) def path_from_root(*pathelems): @@ -14,5 +14,5 @@ from tools.shared import * emmaken = path_from_root('tools', 'emmaken.py') os.environ['EMMAKEN_CXX'] = '1' -exit(os.execvp('python', ['python', emmaken] + sys.argv[1:])) +exit(subprocess.call(['python', emmaken] + sys.argv[1:])) diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 7094cdfc..79599528 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -24,11 +24,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; @@ -97,12 +100,15 @@ if (typeof print === 'undefined') { // Fix read for our location read = function(filename) { - if (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. + 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'); // Load some modules diff --git a/tools/make_minigzip.py b/tools/make_minigzip.py index cdd9c2ab..60177318 100644 --- a/tools/make_minigzip.py +++ b/tools/make_minigzip.py @@ -9,5 +9,5 @@ zlib = shared.Building.build_library('zlib', shared.EMSCRIPTEN_TEMP_DIR, shared. print 'Building minigzip' -Popen([shared.EMCC, '-O2', shared.path_from_root('tests', 'zlib', 'minigzip.c'), zlib, '-o', shared.path_from_root('tools', 'minigzip.js')]).communicate() +Popen(['python', shared.EMCC, '-O2', shared.path_from_root('tests', 'zlib', 'minigzip.c'), zlib, '-o', shared.path_from_root('tools', 'minigzip.js')]).communicate() diff --git a/tools/shared.py b/tools/shared.py index 6a63d4ec..87d6904a 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -357,11 +357,11 @@ class Building: @staticmethod def get_building_env(): env = os.environ.copy() - env['CC'] = EMCC - env['CXX'] = EMXX - env['AR'] = EMAR - env['RANLIB'] = EMRANLIB - env['LIBTOOL'] = EMLIBTOOL + env['CC'] = 'python %r' % EMCC + env['CXX'] = 'python %r' % EMXX + env['AR'] = 'python %r' % EMAR + env['RANLIB'] = 'python %r' % EMRANLIB + env['LIBTOOL'] = 'python %r' % EMLIBTOOL env['EMMAKEN_COMPILER'] = Building.COMPILER env['EMSCRIPTEN_TOOLS'] = path_from_root('tools') env['CFLAGS'] = env['EMMAKEN_CFLAGS'] = ' '.join(Building.COMPILER_TEST_OPTS) @@ -377,10 +377,10 @@ class Building: SET(CMAKE_SYSTEM_NAME Linux) # which C and C++ compiler to use -SET(CMAKE_C_COMPILER $EMSCRIPTEN_ROOT/emcc) -SET(CMAKE_CXX_COMPILER $EMSCRIPTEN_ROOT/em++) -SET(CMAKE_AR $EMSCRIPTEN_ROOT/emar) -SET(CMAKE_RANLIB $EMSCRIPTEN_ROOT/emranlib) +SET(CMAKE_C_COMPILER python $EMSCRIPTEN_ROOT/emcc) +SET(CMAKE_CXX_COMPILER python $EMSCRIPTEN_ROOT/em++) +SET(CMAKE_AR python $EMSCRIPTEN_ROOT/emar) +SET(CMAKE_RANLIB python $EMSCRIPTEN_ROOT/emranlib) SET(CMAKE_C_FLAGS $CFLAGS) SET(CMAKE_CXX_FLAGS $CXXFLAGS) @@ -394,7 +394,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' \ - .replace('$EMSCRIPTEN_ROOT', path_from_root('')) \ + .replace('$EMSCRIPTEN_ROOT', path_from_root('').replace('\\', '/')) \ .replace('$CFLAGS', env['CFLAGS']) \ .replace('$CXXFLAGS', env['CFLAGS']) toolchainFile = mkstemp(suffix='.txt')[1] @@ -409,17 +409,17 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' \ env['EMMAKEN_JUST_CONFIGURE'] = '1' if 'cmake' in args[0]: args = Building.handle_CMake_toolchain(args, env) - Popen(args, stdout=stdout, stderr=stderr, env=env).communicate()[0] + Popen(args, stdout=stdout, stderr=stderr, env=env).communicate() del env['EMMAKEN_JUST_CONFIGURE'] @staticmethod def make(args, stdout=None, stderr=None, env=None): if env is None: env = Building.get_building_env() - Popen(args, stdout=stdout, stderr=stderr, env=env).communicate()[0] + Popen(args, stdout=stdout, stderr=stderr, env=env).communicate() @staticmethod - def build_library(name, build_dir, output_dir, generated_libs, configure=['./configure'], configure_args=[], make=['make'], make_args=['-j', '2'], cache=None, cache_name=None, copy_project=False, env_init={}, source_dir=None): + def build_library(name, build_dir, output_dir, generated_libs, configure=['sh', './configure'], configure_args=[], make=['make'], make_args=['-j', '2'], cache=None, cache_name=None, copy_project=False, env_init={}, source_dir=None): ''' Build a library into a .bc file. We build the .bc file once and cache it for all our tests. (We cache in memory since the test directory is destroyed and recreated for each test. Note that we cache separately for different compilers). @@ -555,13 +555,13 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' \ if output_filename is None: output_filename = filename + '.o' try_delete(output_filename) - Popen([EMCC, filename] + args + ['-o', output_filename], stdout=stdout, stderr=stderr, env=env).communicate() + Popen(['python', EMCC, filename] + args + ['-o', output_filename], stdout=stdout, stderr=stderr, env=env).communicate() assert os.path.exists(output_filename), 'emcc could not create output file' @staticmethod def emar(action, output_filename, filenames, stdout=None, stderr=None, env=None): try_delete(output_filename) - Popen([EMAR, action, output_filename] + filenames, stdout=stdout, stderr=stderr, env=env).communicate() + Popen(['python', EMAR, action, output_filename] + filenames, stdout=stdout, stderr=stderr, env=env).communicate() if 'c' in action: assert os.path.exists(output_filename), 'emar could not create output file' |