forked from electron/electron
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjs2c.py
More file actions
executable file
·39 lines (27 loc) · 792 Bytes
/
js2c.py
File metadata and controls
executable file
·39 lines (27 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python
import contextlib
import os
import subprocess
import sys
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
def main():
natives = os.path.abspath(sys.argv[1])
js_source_files = sys.argv[2:]
call_js2c(natives, js_source_files)
def call_js2c(natives, js_source_files):
js2c = os.path.join(SOURCE_ROOT, 'vendor', 'node', 'tools', 'js2c.py')
src_dir = os.path.dirname(js_source_files[0])
with scoped_cwd(src_dir):
subprocess.check_call(
[sys.executable, js2c, natives] +
[os.path.basename(source) for source in js_source_files])
@contextlib.contextmanager
def scoped_cwd(path):
cwd = os.getcwd()
os.chdir(path)
try:
yield
finally:
os.chdir(cwd)
if __name__ == '__main__':
sys.exit(main())