Merge pull request #8899 from electron/dynamically-generate-browserify-dep-list

Dynamically generate dependencies of browserify build actions
This commit is contained in:
Kevin Sawicki 2017-03-15 09:12:31 -07:00 committed by GitHub
commit 019883f2fa
4 changed files with 33 additions and 17 deletions

View file

@ -437,11 +437,21 @@
# depend on this target to ensure the '<(js2c_input_dir)' is created
'atom_js2c_copy',
],
'variables': {
'sandbox_args': [
'./lib/sandboxed_renderer/init.js',
'-r',
'./lib/sandboxed_renderer/api/exports/electron.js:electron'
],
'isolated_args': [
'lib/isolated_renderer/init.js',
]
},
'actions': [
{
'action_name': 'atom_browserify_sandbox',
'inputs': [
'<@(browserify_entries)',
'<!@(python tools/list-browserify-deps.py <(sandbox_args))'
],
'outputs': [
'<(js2c_input_dir)/preload_bundle.js',
@ -452,9 +462,7 @@
'--silent',
'browserify',
'--',
'lib/sandboxed_renderer/init.js',
'-r',
'./lib/sandboxed_renderer/api/exports/electron.js:electron',
'<@(sandbox_args)',
'-o',
'<@(_outputs)',
],
@ -462,7 +470,7 @@
{
'action_name': 'atom_browserify_isolated_context',
'inputs': [
'<@(isolated_context_browserify_entries)',
'<!@(python tools/list-browserify-deps.py <(isolated_args))'
],
'outputs': [
'<(js2c_input_dir)/isolated_bundle.js',
@ -473,7 +481,7 @@
'--silent',
'browserify',
'--',
'lib/isolated_renderer/init.js',
'<@(isolated_args)',
'-o',
'<@(_outputs)',
],

View file

@ -77,14 +77,6 @@
'lib/renderer/extensions/storage.js',
'lib/renderer/extensions/web-navigation.js',
],
'browserify_entries': [
'lib/sandboxed_renderer/init.js',
'lib/sandboxed_renderer/api/exports/electron.js',
],
'isolated_context_browserify_entries': [
'lib/renderer/window-setup.js',
'lib/isolated_renderer/init.js',
],
'js2c_sources': [
'lib/common/asar.js',
'lib/common/asar_init.js',

View file

@ -1,6 +1,3 @@
// Any requires added here need to be added to the browserify_entries array
// in filenames.gypi so they get built into the preload_bundle.js bundle
/* eslint no-eval: "off" */
/* global binding, preloadPath, Buffer */
const events = require('events')

19
tools/list-browserify-deps.py Executable file
View file

@ -0,0 +1,19 @@
#!/usr/bin/env python
import os
import subprocess
import sys
SOURCE_ROOT = os.path.dirname(os.path.dirname(__file__))
BROWSERIFY = os.path.join(SOURCE_ROOT, 'node_modules', '.bin', 'browserify')
if sys.platform == 'win32':
BROWSERIFY += '.cmd'
deps = subprocess.check_output([BROWSERIFY, '--list'] + sys.argv[1:])
for dep in deps.split('\n'):
if dep:
dep = os.path.relpath(dep, SOURCE_ROOT)
if sys.platform == 'win32':
print('/'.join(dep.split('\\')))
else:
print(dep)