Skip to content

Commit 2d5ac35

Browse files
committed
Run dex2oat with rosetta on m1 remote machine
1 parent cbe8f87 commit 2d5ac35

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/main/java/org/moe/gradle/remote/Server.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ public URI getSdkDir() {
9999
return Require.nonNull(sdkDir);
100100
}
101101

102+
@Nullable
103+
private Boolean remoteAARCH64;
104+
105+
@NotNull
106+
public boolean isRemoteAARCH64() {
107+
return Require.nonNull(remoteAARCH64);
108+
}
109+
102110
@Nullable
103111
private Task moeRemoteServerSetupTask;
104112

@@ -202,13 +210,19 @@ public void connect() {
202210
throw new GradleException(e.getMessage(), e);
203211
}
204212

213+
fetchArchitecture();
205214
setupUserHome();
206215
setupBuildDir();
207216
prepareServerMOE();
208217
});
209218
});
210219
}
211220

221+
private void fetchArchitecture() {
222+
String arch = exec("get arch", "arch");
223+
remoteAARCH64 = arch.equals("arm64");
224+
}
225+
212226
private void prepareServerMOE() {
213227
final MoeSDK sdk = plugin.getSDK();
214228

src/main/java/org/moe/gradle/tasks/Dex2Oat.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,12 @@ protected void run() {
251251
"mkdir -p `dirname " + remoteDestArt + "` && " +
252252
"mkdir -p `dirname " + remoteDestOat + "`");
253253

254-
remoteServer.exec("dex2oat", dex2oatExec + " " +
254+
String optionalRosetta = "";
255+
if (remoteServer.isRemoteAARCH64() && !Arch.FAMILY_ARM64.equalsIgnoreCase(getArchFamily())) {
256+
optionalRosetta = "arch --x86_64 ";
257+
}
258+
259+
remoteServer.exec("dex2oat", optionalRosetta + dex2oatExec + " " +
255260
"--instruction-set=" + Arch.validateArchFamily(getArchFamily()) + " " +
256261
"--base=0x" + Long.toHexString(getBase()) + " " +
257262
"--compiler-backend=" + validateBackend(getCompilerBackend()) + " " +

0 commit comments

Comments
 (0)