Skip to content

Commit f035d0b

Browse files
committed
Optimize
1 parent 17419a3 commit f035d0b

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

nmm-protect/apkprotect/src/main/java/com/nmmedit/apkprotect/BuildNativeLib.java

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.nmmedit.apkprotect;
22

33
import com.nmmedit.apkprotect.data.Prefs;
4-
import com.nmmedit.apkprotect.util.OsDetector;
54
import org.jetbrains.annotations.NotNull;
65

76
import java.io.*;
@@ -51,7 +50,7 @@ private static void execCmd(List<String> cmds) throws IOException {
5150
try {
5251
final int exitStatus = process.waitFor();
5352
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()));
5554
}
5655
} catch (InterruptedException e) {
5756
e.printStackTrace();
@@ -141,17 +140,17 @@ public String getStripBinaryPath() {
141140
final String abi = getAbi();
142141
switch (abi) {
143142
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();
146145
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();
149148
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();
152151
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();
155154
}
156155
//不支持arm和x86以外的abi
157156
throw new RuntimeException("Unsupported abi " + abi);
@@ -187,18 +186,26 @@ public List<String> getCmakeArguments() {
187186

188187
//最后输出的so文件
189188
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());
201206
}
207+
208+
return Arrays.asList(vmSo, mpSo);
202209
}
203210

204211
public enum BuildType {

0 commit comments

Comments
 (0)