-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_jni_header.py
More file actions
33 lines (27 loc) · 882 Bytes
/
generate_jni_header.py
File metadata and controls
33 lines (27 loc) · 882 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
#!/usr/bin/env python
import os
java_src_path = "../src"
classes_path = "../bin/classes"
jni_src_path = "../jni"
list = []
def find_src():
arg = "-rl --include=*.java \"native\" " + java_src_path
pipe = os.popen("grep " + arg)
while True:
line = pipe.readline()
if line != '':
list.append(line)
else:
break
def process_jni():
for src in list:
file = os.path.basename(src)
package = src[len(java_src_path) + 1 : len(src) - len(file) - 1].replace('/', '.')
class_name = package + "." + file
class_name = class_name[:len(class_name) - 6]
print("Generate jni header:" + class_name)
command = "javah -classpath " + classes_path + " -d " + jni_src_path + " " + class_name
os.system(command)
if __name__ == '__main__':
find_src()
process_jni()