Skip to content

Commit

Permalink
Optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
maoabc committed Jun 19, 2021
1 parent 17419a3 commit f035d0b
Showing 1 changed file with 28 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.nmmedit.apkprotect;

import com.nmmedit.apkprotect.data.Prefs;
import com.nmmedit.apkprotect.util.OsDetector;
import org.jetbrains.annotations.NotNull;

import java.io.*;
Expand Down Expand Up @@ -51,7 +50,7 @@ private static void execCmd(List<String> cmds) throws IOException {
try {
final int exitStatus = process.waitFor();
if (exitStatus != 0) {
throw new IOException(String.format("Cmd '%s' exec failed",cmds.toString()));
throw new IOException(String.format("Cmd '%s' exec failed", cmds.toString()));
}
} catch (InterruptedException e) {
e.printStackTrace();
Expand Down Expand Up @@ -141,17 +140,17 @@ public String getStripBinaryPath() {
final String abi = getAbi();
switch (abi) {
case "armeabi-v7a":
return new File(getNdkHome(), "/toolchains/arm-linux-androideabi-4.9/prebuilt/" +
Prefs.osName() + "/bin/arm-linux-androideabi-strip").getAbsolutePath();
return new File(getNdkHome(), "/toolchains/arm-linux-androideabi-4.9/prebuilt/" +
Prefs.osName() + "/bin/arm-linux-androideabi-strip").getAbsolutePath();
case "arm64-v8a":
return new File(getNdkHome(), "/toolchains/aarch64-linux-android-4.9/prebuilt/" +
Prefs.osName() + "/bin/aarch64-linux-android-strip").getAbsolutePath();
return new File(getNdkHome(), "/toolchains/aarch64-linux-android-4.9/prebuilt/" +
Prefs.osName() + "/bin/aarch64-linux-android-strip").getAbsolutePath();
case "x86":
return new File(getNdkHome(), "/toolchains/x86-4.9/prebuilt/" +
Prefs.osName() + "/bin/i686-linux-android-strip").getAbsolutePath();
return new File(getNdkHome(), "/toolchains/x86-4.9/prebuilt/" +
Prefs.osName() + "/bin/i686-linux-android-strip").getAbsolutePath();
case "x86_64":
return new File(getNdkHome(), "/toolchains/x86_64-4.9/prebuilt/" +
Prefs.osName() + "/bin/x86_64-linux-android-strip").getAbsolutePath();
return new File(getNdkHome(), "/toolchains/x86_64-4.9/prebuilt/" +
Prefs.osName() + "/bin/x86_64-linux-android-strip").getAbsolutePath();
}
//不支持arm和x86以外的abi
throw new RuntimeException("Unsupported abi " + abi);
Expand Down Expand Up @@ -187,18 +186,26 @@ public List<String> getCmakeArguments() {

//最后输出的so文件
public List<File> getSharedObjectFile() {
if(OsDetector.isWindows()){
return Arrays.asList(
new File(getBuildPath(), "vm/libnmmvm.so"),
new File(getBuildPath(), "libnmmp.so")
);

}else {
return Arrays.asList(
new File(getLibOutputDir(), "libnmmvm.so"),
new File(getLibOutputDir(), "libnmmp.so")
);
//linux,etc.
File vmSo = new File(getLibOutputDir(), "libnmmvm.so");
File mpSo = new File(getLibOutputDir(), "libnmmp.so");

if (!vmSo.exists()) {
//windows
vmSo = new File(getBuildPath(), "vm/libnmmvm.so");
}
if (!vmSo.exists()) {
throw new RuntimeException("Not Found so: " + vmSo.getAbsolutePath());
}

if (!mpSo.exists()) {
mpSo = new File(getBuildPath(), "libnmmp.so");
}
if (!mpSo.exists()) {
throw new RuntimeException("Not Found so: " + mpSo.getAbsolutePath());
}

return Arrays.asList(vmSo, mpSo);
}

public enum BuildType {
Expand Down

0 comments on commit f035d0b

Please sign in to comment.