(header_path, namespace, package_name, includes, java_outdir, jni_outdir)
| 1233 | return out |
| 1234 | |
| 1235 | def generate(header_path, namespace, package_name, includes, java_outdir, jni_outdir): |
| 1236 | |
| 1237 | module_name = os.path.basename(header_path) |
| 1238 | module_name = os.path.splitext(module_name)[0].capitalize() |
| 1239 | |
| 1240 | package_name = 'com.dynamo.bob.pipeline' |
| 1241 | package_dir = make_package_dir(java_outdir, package_name) |
| 1242 | |
| 1243 | source_path = f'{jni_outdir}/{module_name}.empty.cpp' |
| 1244 | |
| 1245 | source_dir = os.path.dirname(source_path) |
| 1246 | if not os.path.exists(source_dir): |
| 1247 | os.makedirs(source_dir) |
| 1248 | |
| 1249 | with open(source_path, 'wb') as f: |
| 1250 | f.write(f"#include \"{header_path}\"".encode('utf-8')) |
| 1251 | |
| 1252 | print(f' {source_path} => {module_name}') |
| 1253 | reset_globals() |
| 1254 | ir = gen_ir.gen(source_path, includes, module_name, namespace, []) |
| 1255 | |
| 1256 | os.unlink(source_path) |
| 1257 | |
| 1258 | output_java_path = f"{package_dir}/{ir['module']}.java" |
| 1259 | output_jni_cpp_path = f"{jni_outdir}/{ir['module']}_jni.cpp" |
| 1260 | output_jni_h_path = f"{jni_outdir}/{ir['module']}_jni.h" |
| 1261 | |
| 1262 | gen_java_source(ir, module_name, package_name) |
| 1263 | |
| 1264 | write_generated(output_java_path, out_lines) |
| 1265 | print("Wrote", output_java_path) |
| 1266 | |
| 1267 | reset_lines() |
| 1268 | gen_jni_source(ir, module_name, os.path.basename(output_jni_h_path), package_name) |
| 1269 | |
| 1270 | write_generated(output_jni_cpp_path, out_lines) |
| 1271 | print("Wrote", output_jni_cpp_path) |
| 1272 | |
| 1273 | reset_lines() |
| 1274 | gen_jni_header(ir, module_name, package_name) |
| 1275 | write_generated(output_jni_h_path, out_lines) |
| 1276 | print("Wrote", output_jni_h_path) |
nothing calls this directly
no test coverage detected