2013-06-24 08:24:19 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
|
|
SOURCE_ROOT = os.path.dirname(os.path.dirname(__file__))
|
2015-05-20 21:37:26 +00:00
|
|
|
WINDOWS_NODE_PATHs = os.environ['PATH'].split(os.pathsep) + [
|
2014-11-25 21:46:09 +00:00
|
|
|
'C:/Program Files (x86)/nodejs',
|
2014-11-25 22:43:30 +00:00
|
|
|
'C:/Program Files/nodejs',
|
2015-05-20 21:37:26 +00:00
|
|
|
]
|
|
|
|
NIX_NODE_PATHs = os.environ['PATH'].split(os.pathsep) + [
|
2015-04-17 16:33:00 +00:00
|
|
|
'/usr/local/bin',
|
|
|
|
'/usr/bin',
|
|
|
|
'/bin',
|
2015-05-20 21:37:26 +00:00
|
|
|
]
|
2014-11-25 21:54:02 +00:00
|
|
|
|
2013-06-24 08:24:19 +00:00
|
|
|
def main():
|
|
|
|
input_file = sys.argv[1]
|
|
|
|
output_dir = os.path.dirname(sys.argv[2])
|
|
|
|
|
2013-07-01 10:04:15 +00:00
|
|
|
coffee = os.path.join(SOURCE_ROOT, 'node_modules', 'coffee-script', 'bin',
|
|
|
|
'coffee')
|
2015-04-17 16:33:00 +00:00
|
|
|
|
|
|
|
node = 'node'
|
2013-08-16 08:28:45 +00:00
|
|
|
if sys.platform in ['win32', 'cygwin']:
|
2015-04-17 16:33:00 +00:00
|
|
|
node = find_node(WINDOWS_NODE_PATHs, 'node.exe')
|
2013-08-16 08:28:45 +00:00
|
|
|
else:
|
2015-04-17 16:33:00 +00:00
|
|
|
node = find_node(NIX_NODE_PATHs, 'node')
|
|
|
|
|
|
|
|
if not node:
|
|
|
|
print 'Node.js not found in PATH for building electron'
|
|
|
|
return 1
|
|
|
|
|
|
|
|
subprocess.check_call(['node', coffee, '-c', '-o', output_dir, input_file],
|
|
|
|
executable=node)
|
2013-06-24 08:24:19 +00:00
|
|
|
|
2013-09-27 02:21:27 +00:00
|
|
|
|
2015-04-17 16:33:00 +00:00
|
|
|
def find_node(paths, target):
|
|
|
|
for path in paths:
|
|
|
|
full_path = os.path.join(path, target)
|
2014-11-25 19:41:11 +00:00
|
|
|
if os.path.exists(full_path):
|
|
|
|
return full_path
|
2013-12-17 05:14:54 +00:00
|
|
|
return None
|
|
|
|
|
|
|
|
|
2013-06-24 08:24:19 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(main())
|