js2c.py 688 B

123456789101112131415161718192021222324252627282930313233343536373839
  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 {{
  9. namespace native_module {{
  10. {definitions}
  11. void NativeModuleLoader::LoadEmbedderJavaScriptSource() {{
  12. {initializers}
  13. }}
  14. }} // namespace native_module
  15. }} // namespace node
  16. """
  17. def main():
  18. node_path = os.path.abspath(sys.argv[1])
  19. natives = os.path.abspath(sys.argv[2])
  20. js_source_files = sys.argv[3:]
  21. js2c = os.path.join(node_path, 'tools', 'js2c.py')
  22. subprocess.check_call(
  23. [sys.executable, js2c] +
  24. js_source_files +
  25. ['--only-js', '--target', natives])
  26. if __name__ == '__main__':
  27. sys.exit(main())