Merge pull request #4956 from atom/default-app-asar

Store default_app in .asar archive
This commit is contained in:
Kevin Sawicki 2016-04-01 12:52:51 -07:00
commit b2ad0a05d7
4 changed files with 48 additions and 28 deletions

View file

@ -29,6 +29,7 @@
'type': 'executable', 'type': 'executable',
'dependencies': [ 'dependencies': [
'js2asar', 'js2asar',
'app2asar',
'<(project_name)_lib', '<(project_name)_lib',
], ],
'sources': [ 'sources': [
@ -66,12 +67,6 @@
'<(PRODUCT_DIR)/<(product_name) Framework.framework', '<(PRODUCT_DIR)/<(product_name) Framework.framework',
], ],
}, },
{
'destination': '<(PRODUCT_DIR)/<(product_name).app/Contents/Resources',
'files': [
'default_app',
],
},
], ],
'postbuilds': [ 'postbuilds': [
{ {
@ -167,12 +162,6 @@
'external_binaries/vccorlib120.dll', 'external_binaries/vccorlib120.dll',
], ],
}, },
{
'destination': '<(PRODUCT_DIR)/resources',
'files': [
'default_app',
]
},
], ],
}, { }, {
'dependencies': [ 'dependencies': [
@ -208,12 +197,6 @@
'<(libchromiumcontent_dir)/snapshot_blob.bin', '<(libchromiumcontent_dir)/snapshot_blob.bin',
], ],
}, },
{
'destination': '<(PRODUCT_DIR)/resources',
'files': [
'default_app',
]
},
], ],
}], # OS=="linux" }], # OS=="linux"
], ],
@ -376,11 +359,43 @@
'python', 'python',
'tools/js2asar.py', 'tools/js2asar.py',
'<@(_outputs)', '<@(_outputs)',
'lib',
'<@(_inputs)', '<@(_inputs)',
], ],
} }
], ],
}, # target js2asar }, # target js2asar
{
'target_name': 'app2asar',
'type': 'none',
'actions': [
{
'action_name': 'app2asar',
'variables': {
'conditions': [
['OS=="mac"', {
'resources_path': '<(PRODUCT_DIR)/<(product_name).app/Contents/Resources',
},{
'resources_path': '<(PRODUCT_DIR)/resources',
}],
],
},
'inputs': [
'<@(default_app_sources)',
],
'outputs': [
'<(resources_path)/default_app.asar',
],
'action': [
'python',
'tools/js2asar.py',
'<@(_outputs)',
'default_app',
'<@(_inputs)',
],
}
],
}, # target app2asar
{ {
'target_name': 'atom_js2c', 'target_name': 'atom_js2c',
'type': 'none', 'type': 'none',

View file

@ -67,6 +67,12 @@
'lib/common/asar.js', 'lib/common/asar.js',
'lib/common/asar_init.js', 'lib/common/asar_init.js',
], ],
'default_app_sources': [
'default_app/default_app.js',
'default_app/index.html',
'default_app/main.js',
'default_app/package.json',
],
'lib_sources': [ 'lib_sources': [
'atom/app/atom_content_client.cc', 'atom/app/atom_content_client.cc',
'atom/app/atom_content_client.h', 'atom/app/atom_content_client.h',

View file

@ -117,7 +117,7 @@ require('./guest-window-manager')
// Now we try to load app's package.json. // Now we try to load app's package.json.
var packageJson = null var packageJson = null
var searchPaths = ['app', 'app.asar', 'default_app'] var searchPaths = ['app', 'app.asar', 'default_app.asar']
var i, len, packagePath var i, len, packagePath
for (i = 0, len = searchPaths.length; i < len; i++) { for (i = 0, len = searchPaths.length; i < len; i++) {
packagePath = searchPaths[i] packagePath = searchPaths[i]

View file

@ -12,26 +12,25 @@ SOURCE_ROOT = os.path.dirname(os.path.dirname(__file__))
def main(): def main():
archive = sys.argv[1] archive = sys.argv[1]
js_source_files = sys.argv[2:] folder_name = sys.argv[2]
source_files = sys.argv[3:]
output_dir = tempfile.mkdtemp() output_dir = tempfile.mkdtemp()
copy_js(js_source_files, output_dir) copy_files(source_files, output_dir)
call_asar(archive, output_dir) call_asar(archive, os.path.join(output_dir, folder_name))
shutil.rmtree(output_dir) shutil.rmtree(output_dir)
def copy_js(js_source_files, output_dir): def copy_files(source_files, output_dir):
for source_file in js_source_files: for source_file in source_files:
output_filename = os.path.splitext(source_file)[0] + '.js' output_path = os.path.join(output_dir, source_file)
output_path = os.path.join(output_dir, output_filename)
safe_mkdir(os.path.dirname(output_path)) safe_mkdir(os.path.dirname(output_path))
shutil.copy2(source_file, output_path) shutil.copy2(source_file, output_path)
def call_asar(archive, output_dir): def call_asar(archive, output_dir):
js_dir = os.path.join(output_dir, 'lib')
asar = os.path.join(SOURCE_ROOT, 'node_modules', 'asar', 'bin', 'asar') asar = os.path.join(SOURCE_ROOT, 'node_modules', 'asar', 'bin', 'asar')
subprocess.check_call([find_node(), asar, 'pack', js_dir, archive]) subprocess.check_call([find_node(), asar, 'pack', output_dir, archive])
def find_node(): def find_node():