2022-04-12 05:21:55 -06:00
|
|
|
#!/usr/bin/env python3
|
2015-02-03 17:46:52 -07:00
|
|
|
|
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
2018-04-13 06:20:04 -06:00
|
|
|
TEMPLATE = """
|
2019-01-11 18:00:43 -07:00
|
|
|
#include "node_native_module.h"
|
|
|
|
#include "node_internals.h"
|
2018-04-13 06:20:04 -06:00
|
|
|
|
2022-06-29 13:55:47 -06:00
|
|
|
namespace node::native_module {{
|
2019-01-11 18:00:43 -07:00
|
|
|
|
2018-04-13 06:20:04 -06:00
|
|
|
{definitions}
|
|
|
|
|
2019-01-11 18:00:43 -07:00
|
|
|
void NativeModuleLoader::LoadEmbedderJavaScriptSource() {{
|
|
|
|
{initializers}
|
|
|
|
}}
|
2018-04-13 06:20:04 -06:00
|
|
|
|
2022-06-29 13:55:47 -06:00
|
|
|
}} // namespace node::native_module
|
2019-01-11 18:00:43 -07:00
|
|
|
"""
|
2015-02-03 17:46:52 -07:00
|
|
|
|
|
|
|
def main():
|
2018-05-01 17:22:39 -06:00
|
|
|
node_path = os.path.abspath(sys.argv[1])
|
|
|
|
natives = os.path.abspath(sys.argv[2])
|
2019-01-11 18:00:43 -07:00
|
|
|
js_source_files = sys.argv[3:]
|
2015-02-03 17:46:52 -07:00
|
|
|
|
2018-05-01 17:22:39 -06:00
|
|
|
js2c = os.path.join(node_path, 'tools', 'js2c.py')
|
2019-01-11 18:00:43 -07:00
|
|
|
subprocess.check_call(
|
2019-07-15 19:58:39 -06:00
|
|
|
[sys.executable, js2c] +
|
2019-01-11 18:00:43 -07:00
|
|
|
js_source_files +
|
2019-07-15 19:58:39 -06:00
|
|
|
['--only-js', '--target', natives])
|
2015-02-03 17:46:52 -07:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(main())
|