Refactor the atom_js2c target to include javascript from multiple dirs.

Before invoking js2c, copy all files that must be embedded into the shared
intermediate directory, and modify the js2c wrapper script to include all files
from that directory(which is passed as argument).

This allows the build system to embed files that don't share a common base
directory, such as javascript generated at build time.
This commit is contained in:
Thiago de Arruda 2016-08-20 12:19:14 -03:00
parent 6afe8aa7f2
commit 1713200084
2 changed files with 20 additions and 2 deletions

View file

@ -5,6 +5,7 @@
'company_name%': 'GitHub, Inc', 'company_name%': 'GitHub, Inc',
'company_abbr%': 'github', 'company_abbr%': 'github',
'version%': '1.4.1', 'version%': '1.4.1',
'js2c_input_dir': '<(SHARED_INTERMEDIATE_DIR)/js2c',
}, },
'includes': [ 'includes': [
'filenames.gypi', 'filenames.gypi',
@ -410,13 +411,29 @@
} }
], ],
}, # target app2asar }, # target app2asar
{
'target_name': 'atom_js2c_copy',
'type': 'none',
'copies': [
{
'destination': '<(js2c_input_dir)',
'files': [
'<@(js2c_sources)',
],
},
],
}, # target atom_js2c_copy
{ {
'target_name': 'atom_js2c', 'target_name': 'atom_js2c',
'type': 'none', 'type': 'none',
'dependencies': [
'atom_js2c_copy',
],
'actions': [ 'actions': [
{ {
'action_name': 'atom_js2c', 'action_name': 'atom_js2c',
'inputs': [ 'inputs': [
# List all input files that should trigger a rebuild with js2c
'<@(js2c_sources)', '<@(js2c_sources)',
], ],
'outputs': [ 'outputs': [
@ -426,7 +443,7 @@
'python', 'python',
'tools/js2c.py', 'tools/js2c.py',
'<@(_outputs)', '<@(_outputs)',
'<@(_inputs)', '<(js2c_input_dir)',
], ],
} }
], ],

View file

@ -1,6 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
import contextlib import contextlib
import glob
import os import os
import subprocess import subprocess
import sys import sys
@ -11,7 +12,7 @@ SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
def main(): def main():
natives = os.path.abspath(sys.argv[1]) natives = os.path.abspath(sys.argv[1])
js_source_files = sys.argv[2:] js_source_files = glob.glob('{0}/*.js'.format(sys.argv[2]))
call_js2c(natives, js_source_files) call_js2c(natives, js_source_files)