js2c.py 658 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env python3
  2. import os
  3. import subprocess
  4. import sys
  5. TEMPLATE = """
  6. #include "node_native_module.h"
  7. #include "node_internals.h"
  8. namespace node::native_module {{
  9. {definitions}
  10. void NativeModuleLoader::LoadEmbedderJavaScriptSource() {{
  11. {initializers}
  12. }}
  13. }} // namespace node::native_module
  14. """
  15. def main():
  16. node_path = os.path.abspath(sys.argv[1])
  17. natives = os.path.abspath(sys.argv[2])
  18. js_source_files = sys.argv[3:]
  19. js2c = os.path.join(node_path, 'tools', 'js2c.py')
  20. subprocess.check_call(
  21. [sys.executable, js2c] +
  22. js_source_files +
  23. ['--only-js', '--target', natives])
  24. if __name__ == '__main__':
  25. sys.exit(main())