|
| 1 | +url = "jar:https://javacv.googlecode.com/files/javacv-0.5-bin.zip!/"; |
| 2 | +jarFile = new java.net.URL(url).openConnection().getJarFile(); |
| 3 | +cppUrl = "jar:https://javacv.googlecode.com/files/javacv-0.5-cppjars.zip!/"; |
| 4 | +cppjarFile = new java.net.URL(cppUrl).openConnection().getJarFile(); |
| 5 | + |
| 6 | +ijDir = System.getProperty("ij.dir"); |
| 7 | +libDir = new File(ijDir, "lib"); |
| 8 | + |
| 9 | +void copy(input, output) { |
| 10 | + buffer = new byte[16384]; |
| 11 | + for (;;) { |
| 12 | + int count = input.read(buffer, 0, buffer.length); |
| 13 | + if (count < 0) break; |
| 14 | + output.write(buffer, 0, count); |
| 15 | + } |
| 16 | + output.close(); |
| 17 | +} |
| 18 | + |
| 19 | +void extract(jarFile, String jarEntryPrefix, String javacvPlatform, String fijiPlatform) { |
| 20 | + javacvEntryName = jarEntryPrefix + javacvPlatform + ".jar"; |
| 21 | + jarStream = new java.util.jar.JarInputStream(jarFile.getInputStream(jarFile.getEntry(javacvEntryName))); |
| 22 | + outDir = new File(libDir, fijiPlatform); |
| 23 | + if (!outDir.isDirectory()) outDir.mkdirs(); |
| 24 | + prefix = "com/googlecode/javacv/cpp/" + javacvPlatform + "/"; |
| 25 | + for (;;) { |
| 26 | + entry = jarStream.getNextEntry(); |
| 27 | + if (entry == null) break; |
| 28 | + name = entry.getName(); |
| 29 | + if (!name.startsWith(prefix)) continue; |
| 30 | + outFile = new File(outDir, name.substring(prefix.length())); |
| 31 | + if (outFile.exists()) { |
| 32 | + print("Skipping " + outFile + "..."); |
| 33 | + continue; |
| 34 | + } |
| 35 | + print("Extracting " + outFile + "..."); |
| 36 | + copy(jarStream, new java.io.FileOutputStream(outFile)); |
| 37 | + } |
| 38 | + jarStream.close(); |
| 39 | +} |
| 40 | + |
| 41 | +void extract(String javacvPlatform, String fijiPlatform) { |
| 42 | + extract(jarFile, "javacv-bin/javacv-", javacvPlatform, fijiPlatform); |
| 43 | + extract(cppjarFile, "javacv-cppjars/opencv-2.4.5-", javacvPlatform, fijiPlatform); |
| 44 | + extract(cppjarFile, "javacv-cppjars/ffmpeg-1.2-", javacvPlatform, fijiPlatform); |
| 45 | +} |
| 46 | + |
| 47 | +extract("windows-x86_64", "win64"); |
| 48 | +extract("windows-x86", "win32"); |
| 49 | +extract("macosx-x86_64", "macosx"); |
| 50 | +extract("linux-x86_64", "linux64"); |
| 51 | +extract("linux-x86", "linux32"); |
0 commit comments