Put compiled coffee sources into asar archive
This commit is contained in:
parent
0b8efc434d
commit
0f15dd04af
3 changed files with 78 additions and 31 deletions
51
atom.gyp
51
atom.gyp
|
@ -625,40 +625,31 @@
|
||||||
{
|
{
|
||||||
'target_name': 'compile_coffee',
|
'target_name': 'compile_coffee',
|
||||||
'type': 'none',
|
'type': 'none',
|
||||||
'sources': [
|
'actions': [
|
||||||
'<@(coffee_sources)',
|
|
||||||
],
|
|
||||||
'rules': [
|
|
||||||
{
|
{
|
||||||
'rule_name': 'coffee',
|
'action_name': 'compile_coffee',
|
||||||
'extension': 'coffee',
|
'variables': {
|
||||||
|
'conditions': [
|
||||||
|
['OS=="mac"', {
|
||||||
|
'resources_path': '<(PRODUCT_DIR)/<(product_name).app/Contents/Resources',
|
||||||
|
},{
|
||||||
|
'resources_path': '<(PRODUCT_DIR)/resources',
|
||||||
|
}],
|
||||||
|
],
|
||||||
|
},
|
||||||
'inputs': [
|
'inputs': [
|
||||||
'tools/compile-coffee.py',
|
'<@(coffee_sources)',
|
||||||
],
|
],
|
||||||
'conditions': [
|
'outputs': [
|
||||||
['OS=="mac"', {
|
'<(resources_path)/atom.asar',
|
||||||
'outputs': [
|
|
||||||
'<(PRODUCT_DIR)/<(product_name).app/Contents/Resources/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).js',
|
|
||||||
],
|
|
||||||
'action': [
|
|
||||||
'python',
|
|
||||||
'tools/compile-coffee.py',
|
|
||||||
'<(RULE_INPUT_PATH)',
|
|
||||||
'<(PRODUCT_DIR)/<(product_name).app/Contents/Resources/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).js',
|
|
||||||
],
|
|
||||||
},{ # OS=="mac"
|
|
||||||
'outputs': [
|
|
||||||
'<(PRODUCT_DIR)/resources/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).js',
|
|
||||||
],
|
|
||||||
'action': [
|
|
||||||
'python',
|
|
||||||
'tools/compile-coffee.py',
|
|
||||||
'<(RULE_INPUT_PATH)',
|
|
||||||
'<(PRODUCT_DIR)/resources/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).js',
|
|
||||||
],
|
|
||||||
}], # OS=="win" or OS=="linux"
|
|
||||||
],
|
],
|
||||||
},
|
'action': [
|
||||||
|
'python',
|
||||||
|
'tools/coffee2asar.py',
|
||||||
|
'<@(_outputs)',
|
||||||
|
'<@(_inputs)',
|
||||||
|
],
|
||||||
|
}
|
||||||
],
|
],
|
||||||
}, # target compile_coffee
|
}, # target compile_coffee
|
||||||
{
|
{
|
||||||
|
|
|
@ -169,7 +169,7 @@ node::Environment* NodeBindings::CreateEnvironment(
|
||||||
exec_path.DirName().Append(FILE_PATH_LITERAL("resources"));
|
exec_path.DirName().Append(FILE_PATH_LITERAL("resources"));
|
||||||
#endif
|
#endif
|
||||||
base::FilePath script_path =
|
base::FilePath script_path =
|
||||||
resources_path.Append(FILE_PATH_LITERAL("atom"))
|
resources_path.Append(FILE_PATH_LITERAL("atom.asar"))
|
||||||
.Append(is_browser_ ? FILE_PATH_LITERAL("browser") :
|
.Append(is_browser_ ? FILE_PATH_LITERAL("browser") :
|
||||||
FILE_PATH_LITERAL("renderer"))
|
FILE_PATH_LITERAL("renderer"))
|
||||||
.Append(FILE_PATH_LITERAL("lib"))
|
.Append(FILE_PATH_LITERAL("lib"))
|
||||||
|
|
56
tools/coffee2asar.py
Executable file
56
tools/coffee2asar.py
Executable file
|
@ -0,0 +1,56 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
|
||||||
|
SOURCE_ROOT = os.path.dirname(os.path.dirname(__file__))
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
archive = sys.argv[1]
|
||||||
|
coffee_source_files = sys.argv[2:]
|
||||||
|
|
||||||
|
output_dir = tempfile.mkdtemp()
|
||||||
|
compile_coffee(coffee_source_files, output_dir)
|
||||||
|
call_asar(archive, output_dir)
|
||||||
|
shutil.rmtree(output_dir)
|
||||||
|
|
||||||
|
|
||||||
|
def compile_coffee(coffee_source_files, output_dir):
|
||||||
|
for source_file in coffee_source_files:
|
||||||
|
output_filename = os.path.splitext(source_file)[0] + '.js'
|
||||||
|
output_path = os.path.join(output_dir, output_filename)
|
||||||
|
call_compile_coffee(source_file, output_path)
|
||||||
|
|
||||||
|
|
||||||
|
def call_compile_coffee(source_file, output_filename):
|
||||||
|
compile_coffee = os.path.join(SOURCE_ROOT, 'tools', 'compile-coffee.py')
|
||||||
|
subprocess.check_call([sys.executable, compile_coffee, source_file,
|
||||||
|
output_filename])
|
||||||
|
|
||||||
|
|
||||||
|
def call_asar(archive, output_dir):
|
||||||
|
js_dir = os.path.join(output_dir, 'atom')
|
||||||
|
asar = os.path.join(SOURCE_ROOT, 'node_modules', 'asar', 'bin', 'asar')
|
||||||
|
subprocess.check_call([find_node(), asar, 'pack', js_dir, archive])
|
||||||
|
|
||||||
|
|
||||||
|
def find_node():
|
||||||
|
WINDOWS_NODE_PATHs = [
|
||||||
|
'C:/Program Files (x86)/nodejs',
|
||||||
|
'C:/Program Files/nodejs',
|
||||||
|
] + os.environ['PATH'].split(os.pathsep)
|
||||||
|
|
||||||
|
if sys.platform in ['win32', 'cygwin']:
|
||||||
|
for path in WINDOWS_NODE_PATHs:
|
||||||
|
full_path = os.path.join(path, 'node.exe')
|
||||||
|
if os.path.exists(full_path):
|
||||||
|
return full_path
|
||||||
|
return 'node'
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.exit(main())
|
Loading…
Add table
Add a link
Reference in a new issue