From: Cheng Zhao Date: Mon, 24 Jun 2013 08:24:19 +0000 (+0800) Subject: Rewrite compile-coffee script in python. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5c48f03dfead0826cfa0ef6bf1e2d72c52715603;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git Rewrite compile-coffee script in python. --- diff --git a/atom.gyp b/atom.gyp index 6205810..9430bb7 100644 --- a/atom.gyp +++ b/atom.gyp @@ -264,14 +264,14 @@ 'rule_name': 'coffee', 'extension': 'coffee', 'inputs': [ - 'script/compile-coffee', + 'script/compile-coffee.py', ], 'outputs': [ '<(PRODUCT_DIR)/<(product_name).app/Contents/Resources/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).js', ], 'action': [ - 'sh', - 'script/compile-coffee', + 'python', + 'script/compile-coffee.py', '<(RULE_INPUT_PATH)', '<(PRODUCT_DIR)/<(product_name).app/Contents/Resources/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).js', ], diff --git a/script/compile-coffee b/script/compile-coffee deleted file mode 100755 index 2c15358..0000000 --- a/script/compile-coffee +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -set -e - -# Because of the way xcodebuild invokes external scripts we need to load -# The Setup's environment ourselves. If this isn't done, things like the -# node shim won't be able to find the stuff they need. - -node --version > /dev/null 2>&1 || { - if [ -e /opt/github/env.sh ]; then - source /opt/github/env.sh - else - # Try Constructicon's PATH. - export PATH="/usr/local/Cellar/node/0.8.21/bin:${PATH}" - fi -} - -INPUT_FILE="${1}" -OUTPUT_DIR=`dirname "$2"` - -node_modules/.bin/coffee -c -o "$OUTPUT_DIR" "$INPUT_FILE" diff --git a/script/compile-coffee.py b/script/compile-coffee.py new file mode 100755 index 0000000..35642c9 --- /dev/null +++ b/script/compile-coffee.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +import os +import subprocess +import sys + +from lib.util import * + + +SOURCE_ROOT = os.path.dirname(os.path.dirname(__file__)) + + +def main(): + input_file = sys.argv[1] + output_dir = os.path.dirname(sys.argv[2]) + + node = get_node_path() + coffee = os.path.join(SOURCE_ROOT, 'node_modules', '.bin', 'coffee') + subprocess.check_call([node, coffee, '-c', '-o', output_dir, input_file]) + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/script/lib/util.py b/script/lib/util.py index ab33187..7060f1a 100644 --- a/script/lib/util.py +++ b/script/lib/util.py @@ -68,3 +68,10 @@ def safe_mkdir(path): except OSError as e: if e.errno != errno.EEXIST: raise + + +def get_node_path(): + node = os.path.join(os.path.dirname(__file__), '..', '..', 'node', 'node') + if sys.platform == 'win32' or sys.platform == 'cygwin': + node += '.exe' + return node