forked from shaobin0604/faplayer
-
Notifications
You must be signed in to change notification settings - Fork 6
/
pre-build.rb
executable file
·54 lines (52 loc) · 1.64 KB
/
pre-build.rb
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env ruby
abi = `cat jni/Application.mk | grep ^APP_ABI | cut -d' ' -f3`.strip!
flag = `cat jni/Application.mk | grep "^OPT_CFLAGS +="`.split("\n")
no_neon = abi != 'armeabi-v7a'
if abi == 'armeabi-v7a'
flag = flag[0]
temp = flag.scan(/-mfpu=([^\s]+)/)
fpu = temp[0][0].to_s
no_neon = true if fpu != 'neon'
end
all = Array.new
list = `find . -name Android.mk`.split("\n")
list.each { |l|
next if ((l =~ /^\.\/jni\/vlc\/modules/) == nil)
temp = l.scan(/modules\/([^\/]+)\//)
next if temp == nil || temp.size == 0
File.open(l) { |f|
while !f.eof?
ln = f.readline
next if ((ln =~ /^LOCAL_MODULE/) == nil)
temp = ln.scan(/\s*LOCAL_MODULE\s*:=\s*([^\s]+)/)
next if temp == nil || temp.size == 0
name = temp[0][0].to_s
name = name[3..-1] if (name =~ /^lib/) != nil
next if no_neon && (name =~ /_neon_plugin$/) != nil
all.push(name)
end
}
}
all.sort!
f = File.open('jni/vlc/src/libvlcjni.h', 'w') { |f|
f.write("/* auto generated */\n")
all.each { |m|
a = m.sub(/_plugin$/, '')
f.write("vlc_declare_plugin(#{a});\n")
}
f.write("const void *vlc_builtins_modules[] = {\n");
all.each { |m|
a = m.sub(/_plugin$/, '')
f.write("\tvlc_plugin(#{a}),\n");
}
f.write("\tNULL\n");
f.write("};\n");
f.write("/* auto generated */\n")
}
n = `grep -n '# modules' jni/vlc/Android.mk | cut -d: -f1`
n = n.to_i + 1
old = `sed -n #{n}p jni/vlc/Android.mk`.strip!
new = 'LOCAL_STATIC_LIBRARIES += ' + all.join(' ')
if old != new
`sed -i "#{n} c\\#{new}" jni/vlc/Android.mk`
end