|
1 | 1 | package com.nmmedit.apkprotect; |
2 | 2 |
|
3 | 3 | import com.nmmedit.apkprotect.data.Prefs; |
4 | | -import com.nmmedit.apkprotect.util.OsDetector; |
5 | 4 | import org.jetbrains.annotations.NotNull; |
6 | 5 |
|
7 | 6 | import java.io.*; |
@@ -51,7 +50,7 @@ private static void execCmd(List<String> cmds) throws IOException { |
51 | 50 | try { |
52 | 51 | final int exitStatus = process.waitFor(); |
53 | 52 | if (exitStatus != 0) { |
54 | | - throw new IOException(String.format("Cmd '%s' exec failed",cmds.toString())); |
| 53 | + throw new IOException(String.format("Cmd '%s' exec failed", cmds.toString())); |
55 | 54 | } |
56 | 55 | } catch (InterruptedException e) { |
57 | 56 | e.printStackTrace(); |
@@ -141,17 +140,17 @@ public String getStripBinaryPath() { |
141 | 140 | final String abi = getAbi(); |
142 | 141 | switch (abi) { |
143 | 142 | case "armeabi-v7a": |
144 | | - return new File(getNdkHome(), "/toolchains/arm-linux-androideabi-4.9/prebuilt/" + |
145 | | - Prefs.osName() + "/bin/arm-linux-androideabi-strip").getAbsolutePath(); |
| 143 | + return new File(getNdkHome(), "/toolchains/arm-linux-androideabi-4.9/prebuilt/" + |
| 144 | + Prefs.osName() + "/bin/arm-linux-androideabi-strip").getAbsolutePath(); |
146 | 145 | case "arm64-v8a": |
147 | | - return new File(getNdkHome(), "/toolchains/aarch64-linux-android-4.9/prebuilt/" + |
148 | | - Prefs.osName() + "/bin/aarch64-linux-android-strip").getAbsolutePath(); |
| 146 | + return new File(getNdkHome(), "/toolchains/aarch64-linux-android-4.9/prebuilt/" + |
| 147 | + Prefs.osName() + "/bin/aarch64-linux-android-strip").getAbsolutePath(); |
149 | 148 | case "x86": |
150 | | - return new File(getNdkHome(), "/toolchains/x86-4.9/prebuilt/" + |
151 | | - Prefs.osName() + "/bin/i686-linux-android-strip").getAbsolutePath(); |
| 149 | + return new File(getNdkHome(), "/toolchains/x86-4.9/prebuilt/" + |
| 150 | + Prefs.osName() + "/bin/i686-linux-android-strip").getAbsolutePath(); |
152 | 151 | case "x86_64": |
153 | | - return new File(getNdkHome(), "/toolchains/x86_64-4.9/prebuilt/" + |
154 | | - Prefs.osName() + "/bin/x86_64-linux-android-strip").getAbsolutePath(); |
| 152 | + return new File(getNdkHome(), "/toolchains/x86_64-4.9/prebuilt/" + |
| 153 | + Prefs.osName() + "/bin/x86_64-linux-android-strip").getAbsolutePath(); |
155 | 154 | } |
156 | 155 | //不支持arm和x86以外的abi |
157 | 156 | throw new RuntimeException("Unsupported abi " + abi); |
@@ -187,18 +186,26 @@ public List<String> getCmakeArguments() { |
187 | 186 |
|
188 | 187 | //最后输出的so文件 |
189 | 188 | public List<File> getSharedObjectFile() { |
190 | | - if(OsDetector.isWindows()){ |
191 | | - return Arrays.asList( |
192 | | - new File(getBuildPath(), "vm/libnmmvm.so"), |
193 | | - new File(getBuildPath(), "libnmmp.so") |
194 | | - ); |
195 | | - |
196 | | - }else { |
197 | | - return Arrays.asList( |
198 | | - new File(getLibOutputDir(), "libnmmvm.so"), |
199 | | - new File(getLibOutputDir(), "libnmmp.so") |
200 | | - ); |
| 189 | + //linux,etc. |
| 190 | + File vmSo = new File(getLibOutputDir(), "libnmmvm.so"); |
| 191 | + File mpSo = new File(getLibOutputDir(), "libnmmp.so"); |
| 192 | + |
| 193 | + if (!vmSo.exists()) { |
| 194 | + //windows |
| 195 | + vmSo = new File(getBuildPath(), "vm/libnmmvm.so"); |
| 196 | + } |
| 197 | + if (!vmSo.exists()) { |
| 198 | + throw new RuntimeException("Not Found so: " + vmSo.getAbsolutePath()); |
| 199 | + } |
| 200 | + |
| 201 | + if (!mpSo.exists()) { |
| 202 | + mpSo = new File(getBuildPath(), "libnmmp.so"); |
| 203 | + } |
| 204 | + if (!mpSo.exists()) { |
| 205 | + throw new RuntimeException("Not Found so: " + mpSo.getAbsolutePath()); |
201 | 206 | } |
| 207 | + |
| 208 | + return Arrays.asList(vmSo, mpSo); |
202 | 209 | } |
203 | 210 |
|
204 | 211 | public enum BuildType { |
|
0 commit comments